private async void Button_Click(object sender, RoutedEventArgs e) { var ctrl = sender as UIElement; while (ctrl != null && !(ctrl is Border)) { ctrl = VisualTreeHelper.GetParent(ctrl) as UIElement; } var ctr = ctrl as Border; if (ctr != null) { ctr.Background = new SolidColorBrush(Colors.DarkOliveGreen); await Task.Delay(100); } if (!isCalibrated) { await plotter.Calibrate(); plotter.Stop(); isCalibrated = true; } try { this.isPainting = true; if (sender == btnSquares) { await painter.Squares(); } else if (sender == btnHilbert) { await painter.Hilbert(); } else if (sender == btnLines) { await painter.Sun(); } else if (sender == btnStar) { await painter.Star(); } else if (sender == btnDemoXY) { await painter.DemoXY(); } else if (sender == btnPenDemo) { await painter.PenDemo(); } else if (sender == btnText) { await textPainter.DrawText("HELLO", 25, 160); await textPainter.DrawText("WORLD!", 5, 20); plotter.GoToXY(5, 290); } else if (sender == btnTextRu) { await textPainter.DrawText("ПРИВЕТ", 5, 160); await textPainter.DrawText("ХАБР!", 25, 20); plotter.GoToXY(5, 290); } else if (sender == btnHashtag) { await textPainterSmall.DrawText("#WINBUILDER", 5, 130); await painter.DrawCursor(150, 110); plotter.GoToXY(5, 290); } else if (sender == btnPcb) { await painter.PCB(); } } finally { plotter.Stop(); this.isPainting = false; if (ctr != null) { ctr.Background = null; } } return; }
public async Task Squares() { await this.plotter.PenUp(); for (var x = 0; x < 140; x += 10) { plotter.GoToXY(x, x); await this.plotter.PenDown(); plotter.GoToXY(310 - x, x); plotter.GoToXY(310 - x, 310 - x); plotter.GoToXY(x, 310 - x); plotter.GoToXY(x, x); await this.plotter.PenUp(); } this.plotter.Stop(); }