diff --git a/Signal Generator/TaskViewConverter.cs b/Signal Generator/ArrayConverter.cs similarity index 100% rename from Signal Generator/TaskViewConverter.cs rename to Signal Generator/ArrayConverter.cs diff --git a/Signal Generator/DrawTask.cs b/Signal Generator/DrawTask.cs index 58da12f..efebd93 100644 --- a/Signal Generator/DrawTask.cs +++ b/Signal Generator/DrawTask.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Linq; @@ -7,6 +8,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using System.Timers; +using System.Windows; using System.Windows.Controls; using System.Windows.Media; using System.Windows.Shapes; @@ -16,9 +18,8 @@ namespace Signal_Generator public class DrawTask : Task, INotifyPropertyChanged { Canvas canvas; - System.Timers.Timer taskTimer; - Stopwatch stopwatch = new Stopwatch(); MultiSignal multiSignal; + ProcedureModel procedureModel; private State _state; public State state @@ -40,25 +41,15 @@ namespace Signal_Generator public DrawTask(Action a) : base(a) { } - public void buildTask(Canvas c) + public void buildTask(ProcedureModel pm, Canvas c) { canvas = c; + procedureModel = pm; multiSignal = MultiSignal.getInstance(); state = State.Running; - stopwatch.Start(); - taskTimer = new System.Timers.Timer(2000); - taskTimer.Elapsed += updateTextForms; - taskTimer.Enabled = true; - drawSignalAtCanvas(); } - - - private void updateTextForms(object sender, ElapsedEventArgs e) - { - var elapsed = stopwatch.ElapsedMilliseconds; - } private void drawSignalAtCanvas() { @@ -66,6 +57,8 @@ namespace Signal_Generator double w = canvas.ActualWidth; for (int i = 0; i != (int)w; i++) { + procedureModel.CurrentAmplitude = multiSignal.currentAmplitude(i / 5.0).ToString(); + procedureModel.CurrentTime = (i / 5.0).ToString(); double y = multiSignal.currentAmplitude(i / 5.0); drawLine(lastX, lastY, i, y); lastX = i; diff --git a/Signal Generator/ProcedureModel.cs b/Signal Generator/ProcedureModel.cs index 99a6e49..3a1a45d 100644 --- a/Signal Generator/ProcedureModel.cs +++ b/Signal Generator/ProcedureModel.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Linq; @@ -8,10 +9,11 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Shapes; namespace Signal_Generator { - public class ProcedureModel : ICommand + public class ProcedureModel : ICommand, INotifyPropertyChanged { public DrawTask currentTask; Canvas targetCanvas; @@ -43,7 +45,7 @@ namespace Signal_Generator var btn = parameters[0] as Button; var ms = MultiSignal.getInstance(); - if ((ms == null) && (ms.count() == 0)) + if ((ms == null) || (ms.count() == 0)) return false; switch (btn.Name) { @@ -95,7 +97,8 @@ namespace Signal_Generator var parameters = parameter as object[]; var btn = parameters[0] as Button; targetCanvas = parameters[1] as Canvas; - + + switch (btn.Name) { case "start_Button": @@ -123,7 +126,7 @@ namespace Signal_Generator Action newAction = () => { currentTask.PropertyChanged += RaiseCanExecuteChanged; - currentTask.buildTask(targetCanvas); + currentTask.buildTask(this, targetCanvas); }; currentTask = new DrawTask(newAction); currentTask.Start(); @@ -141,5 +144,28 @@ namespace Signal_Generator break; } } + + public event PropertyChangedEventHandler PropertyChanged; + private string currentAmplitude; + public string CurrentAmplitude + { + get { return currentAmplitude; } + set + { + currentAmplitude = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CurrentAmplitude")); + } + } + + private string currentTime; + public string CurrentTime + { + get { return currentTime; } + set + { + currentTime = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CurrentTime")); + } + } } } diff --git a/Signal Generator/Signal Generator.csproj b/Signal Generator/Signal Generator.csproj index c9bac2e..af53227 100644 --- a/Signal Generator/Signal Generator.csproj +++ b/Signal Generator/Signal Generator.csproj @@ -65,7 +65,7 @@ - + TaskWindow.xaml diff --git a/Signal Generator/TaskWindow.xaml b/Signal Generator/TaskWindow.xaml index 4db8b83..aad6f82 100644 --- a/Signal Generator/TaskWindow.xaml +++ b/Signal Generator/TaskWindow.xaml @@ -13,7 +13,7 @@ - + @@ -26,18 +26,22 @@ - - + + Время выполения: - + Текущий сигнал: - + @@ -47,6 +51,8 @@ + +