|
|
@ -19,9 +19,47 @@ namespace Signal_Generator |
|
|
|
/// </summary>
|
|
|
|
public partial class TaskWindow : Window |
|
|
|
{ |
|
|
|
public TaskWindow() |
|
|
|
MultiSignal currentMultiSignal; |
|
|
|
public TaskWindow(MultiSignal s) |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
currentMultiSignal = s; |
|
|
|
} |
|
|
|
|
|
|
|
public void drawSignal(MultiSignal s) |
|
|
|
{ |
|
|
|
double lastX = 0, lastY = 0; |
|
|
|
double w = signalGraph_Canvas.ActualWidth; |
|
|
|
for (int i = 0; i != (int)w; i++) |
|
|
|
{ |
|
|
|
double y = s.currentAmplitude(i / 5.0); |
|
|
|
drawLine(lastX, lastY, i, y); |
|
|
|
lastX = i; |
|
|
|
lastY = y; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void drawLine (double x1, double y1, double x2, double y2) |
|
|
|
{ |
|
|
|
Line l = new Line(); |
|
|
|
l.StrokeThickness = 1; |
|
|
|
l.Stroke = Brushes.Red; |
|
|
|
l.X1 = x1; |
|
|
|
l.Y1 = remap(y1); |
|
|
|
l.X2 = x2; |
|
|
|
l.Y2 = remap(y2); |
|
|
|
signalGraph_Canvas.Children.Add(l); |
|
|
|
} |
|
|
|
|
|
|
|
public double remap (double x, double oldMin = -100.0, double oldMax = 100.0, double newMin = 100.0, double newMax = 0.0) |
|
|
|
{ |
|
|
|
newMin = signalGraph_Canvas.ActualHeight; |
|
|
|
return newMin + (x - oldMin) * (newMax - newMin) / (oldMax - oldMin); |
|
|
|
} |
|
|
|
|
|
|
|
private void start_Button_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
drawSignal(currentMultiSignal); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|