diff --git a/Signal Generator/DrawTask.cs b/Signal Generator/DrawTask.cs
index efebd93..933742e 100644
--- a/Signal Generator/DrawTask.cs
+++ b/Signal Generator/DrawTask.cs
@@ -57,8 +57,7 @@ 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();
+ updateTextBoxProps(multiSignal.currentAmplitude(i / 5.0), i / 5.0);
double y = multiSignal.currentAmplitude(i / 5.0);
drawLine(lastX, lastY, i, y);
lastX = i;
@@ -76,6 +75,12 @@ namespace Signal_Generator
state = State.Finished;
}
+ private void updateTextBoxProps(double amp, double time)
+ {
+ procedureModel.CurrentAmplitude = amp.ToString();
+ procedureModel.CurrentTime = time.ToString();
+ }
+
private void drawLine(double x1, double y1, double x2, double y2)
{
Action a = () => {
@@ -83,18 +88,17 @@ namespace Signal_Generator
l.StrokeThickness = 1;
l.Stroke = Brushes.Red;
l.X1 = x1;
- l.Y1 = remap(y1);
+ l.Y1 = remapOY(y1, 100, canvas.ActualHeight);
l.X2 = x2;
- l.Y2 = remap(y2);
+ l.Y2 = remapOY(y2, 100, canvas.ActualHeight);
canvas.Children.Add(l);
};
canvas.Dispatcher.Invoke(a);
}
- private double remap(double x, double oldMin = -100.0, double oldMax = 100.0, double newMin = 100.0, double newMax = 0.0)
+ private double remapOY(double x, double amp = 100.0, double height = 100.0)
{
- newMin = canvas.ActualHeight;
- return newMin + (x - oldMin) * (newMax - newMin) / (oldMax - oldMin);
+ return height + (x + amp) * (-height) / (2 * amp);
}
}
}
diff --git a/Signal Generator/ProcedureModel.cs b/Signal Generator/ProcedureModel.cs
index 2b3fcf2..ea6367f 100644
--- a/Signal Generator/ProcedureModel.cs
+++ b/Signal Generator/ProcedureModel.cs
@@ -167,5 +167,16 @@ namespace Signal_Generator
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CurrentTime"));
}
}
+
+ private double duration;
+ public double Duration
+ {
+ get { return duration; }
+ set
+ {
+ duration = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CurrentTime"));
+ }
+ }
}
}
diff --git a/Signal Generator/Signal Generator.csproj b/Signal Generator/Signal Generator.csproj
index af53227..df770ba 100644
--- a/Signal Generator/Signal Generator.csproj
+++ b/Signal Generator/Signal Generator.csproj
@@ -66,6 +66,7 @@
+
TaskWindow.xaml
diff --git a/Signal Generator/StringDoubleConverter.cs b/Signal Generator/StringDoubleConverter.cs
new file mode 100644
index 0000000..53eb9fa
--- /dev/null
+++ b/Signal Generator/StringDoubleConverter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Data;
+
+namespace Signal_Generator
+{
+ class StringDoubleConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return ((double)value).ToString();
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return double.Parse((string)value);
+ }
+ }
+}
diff --git a/Signal Generator/TaskWindow.xaml b/Signal Generator/TaskWindow.xaml
index aad6f82..fa1aef6 100644
--- a/Signal Generator/TaskWindow.xaml
+++ b/Signal Generator/TaskWindow.xaml
@@ -11,6 +11,7 @@
+
@@ -19,6 +20,7 @@
+
@@ -34,7 +36,10 @@
Текущий сигнал:
-