private void inkCanvas_PointerMoved(object sender, PointerRoutedEventArgs e) { //check penId if (e.Pointer.PointerId == penId) { //same input //for eg. a mouse and pen may interact at same time , but they will be given different pointer id //you can differentiate different key strokes of different at the same time using this var pt = e.GetCurrentPoint(inkCanvas); var currentPoint = pt.Position; Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line(); line.X1 = startPoint.X; line.Y1 = startPoint.Y; line.X2 = currentPoint.X; line.Y2 = currentPoint.Y; line.StrokeThickness = 10; line.Stroke = new SolidColorBrush(Colors.Red); startPoint = currentPoint; inkCanvas.Children.Add(line); inkManager.ProcessPointerUpdate(pt); } else { //handle touch } e.Handled = true; }
// specific Draw related public void Drawchessboard(int i, bool horizontal) { var deltax = Convert.ToDouble(chessboard_background.ActualWidth) / 16; var deltay = Convert.ToDouble(chessboard_background.ActualHeight) / 16; Windows.UI.Xaml.Shapes.Line line; line = new Windows.UI.Xaml.Shapes.Line(); if (horizontal == true) { line.X1 = deltax; line.X2 = 15 * deltax; line.Y1 = deltay * i; line.Y2 = deltay * i; } else { line.Y1 = deltay; line.Y2 = 15 * deltay; line.X1 = deltax * i; line.X2 = deltax * i; } line.X1 += 10; line.X2 += 10; line.Y1 += 10; line.Y2 += 10; line.IsHitTestVisible = false; line.Stroke = new SolidColorBrush(Colors.Black); line.StrokeThickness = 2.5; chessboard_father.Children.Add(line); chessboard_line.Add(new Chessboard_line_class(line, i, horizontal)); }
/// <summary> /// Draws the specified line. /// </summary> public void Draw(DualViewsDrawingModel.Shapes.Line line) { Windows.UI.Xaml.Shapes.Line drawingPageCanvasLine = new Windows.UI.Xaml.Shapes.Line(); drawingPageCanvasLine.X1 = line.X1; drawingPageCanvasLine.Y1 = line.Y1; drawingPageCanvasLine.X2 = line.X2; drawingPageCanvasLine.Y2 = line.Y2; drawingPageCanvasLine.Stroke = new SolidColorBrush(Colors.Black); _canvas.Children.Add(drawingPageCanvasLine); }
/// <summary> Draw line. </summary> /// /// <param name="point1.X"> The first x value. </param> /// <param name="point1.Y"> The first y value. </param> /// <param name="point2.X"> The second x value. </param> /// <param name="point2.Y"> The second y value. </param> /// <param name="isRedLine"> True if is red line, false if not. </param> /// /// ### <remarks> Chen-Tai,Peng, 12/12/2018. </remarks> public void DrawLine(DrawingModel.Point point1, DrawingModel.Point point2, bool isRedLine) { Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line(); line.X1 = point1.X; line.Y1 = point1.Y; line.X2 = point2.X; line.Y2 = point2.Y; line.Stroke = new SolidColorBrush(isRedLine ? Colors.Red : Colors.Black); _canvas.Children.Add(line); }
//draw a line public void DrawLine(double x1, double y1, double x2, double y2) { Windows.UI.Xaml.Shapes.Line line = new Windows.UI.Xaml.Shapes.Line(); line.X1 = x1; line.Y1 = y1; line.X2 = x2; line.Y2 = y2; line.Stroke = new SolidColorBrush(Colors.Black); _canvas.Children.Add(line); }
// Create ImageCanvas_PointerMoved to handle moving a mouse pointer across an opened image. private void ImageCanvas_PointerMoved(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e) { Windows.Foundation.Point positionOfPointer = e.GetCurrentPoint(this.ImageCanvas).Position; double positionOfPointerRelativeToLeftEdgeOfImageCanvas = positionOfPointer.X; double positionOfPointerRelativeToTopEdgeOfImageCanvas = positionOfPointer.Y; // If the image has not been clicked to draw a bounding box, or if a bounding box has been drawn and clickState reset... if (this.ClickState == 0) { // Remove any horizontal and vertical lines through the mouse pointer. this.ImageCanvas.Children.Remove((Windows.UI.Xaml.UIElement) this.ImageCanvas.FindName("horizontalPointerLine")); this.ImageCanvas.Children.Remove((Windows.UI.Xaml.UIElement) this.ImageCanvas.FindName("verticalPointerLine")); // Draw a new horizontal pointer line. Windows.UI.Xaml.Shapes.Line horizontalPointerLine = new Windows.UI.Xaml.Shapes.Line(); horizontalPointerLine.Name = "horizontalPointerLine"; horizontalPointerLine.X1 = this.PositionOfLeftEdgeOfImageRelativeToLeftEdgeOfImageCanvas; horizontalPointerLine.X2 = this.PositionOfRightEdgeOfImageRelativeToLeftEdgeOfImageCanvas; horizontalPointerLine.Y1 = positionOfPointerRelativeToTopEdgeOfImageCanvas; horizontalPointerLine.Y2 = positionOfPointerRelativeToTopEdgeOfImageCanvas; horizontalPointerLine.Stroke = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Black); horizontalPointerLine.StrokeThickness = 1; this.ImageCanvas.Children.Add(horizontalPointerLine); // Draw a new vertical pointer line. Windows.UI.Xaml.Shapes.Line verticalPointerLine = new Windows.UI.Xaml.Shapes.Line(); verticalPointerLine.Name = "verticalPointerLine"; verticalPointerLine.X1 = positionOfPointerRelativeToLeftEdgeOfImageCanvas; verticalPointerLine.X2 = positionOfPointerRelativeToLeftEdgeOfImageCanvas; verticalPointerLine.Y1 = this.PositionOfTopEdgeOfImageRelativeToTopEdgeOfImageCanvas; verticalPointerLine.Y2 = this.PositionOfBottomEdgeOfImageRelativeToTopEdgeOfImageCanvas; verticalPointerLine.Stroke = new Windows.UI.Xaml.Media.SolidColorBrush(Windows.UI.Colors.Black); verticalPointerLine.StrokeThickness = 1; this.ImageCanvas.Children.Add(verticalPointerLine); } // if // If the image has been clicked once, or if a bounding box has been drawn, clickState reset, and the image clicked again... if (this.ClickState == 1) { // Remove any rectangle from the imageCanvas. this.ImageCanvas.Children.Remove((Windows.UI.Xaml.UIElement) this.ImageCanvas.FindName("rectangle")); // Add a new rectangle named rectangle between the first click point and the present location of a mouse pointer. Windows.UI.Xaml.Shapes.Rectangle rectangle = new Windows.UI.Xaml.Shapes.Rectangle(); rectangle.Name = "rectangle"; rectangle.Fill = this.GetColor(this.TextBoxForClassIndex.Text); rectangle.Opacity = 0.1; rectangle.Width = System.Math.Abs(positionOfPointerRelativeToLeftEdgeOfImageCanvas - this.PositionOfFirstClickRelativeToLeftEdgeOfImageCanvas); rectangle.Height = System.Math.Abs(positionOfPointerRelativeToTopEdgeOfImageCanvas - this.PositionOfFirstClickRelativeToTopEdgeOfImageCanvas); Windows.UI.Xaml.Controls.Canvas.SetLeft(rectangle, System.Math.Min(positionOfPointerRelativeToLeftEdgeOfImageCanvas, this.PositionOfFirstClickRelativeToLeftEdgeOfImageCanvas)); Windows.UI.Xaml.Controls.Canvas.SetTop(rectangle, System.Math.Min(positionOfPointerRelativeToTopEdgeOfImageCanvas, this.PositionOfFirstClickRelativeToTopEdgeOfImageCanvas)); this.ImageCanvas.Children.Add(rectangle); } // if } // private void ImageCanvas_PointerMoved
/// <summary> /// Draws the selection border. /// </summary> public void DrawSelectionBorder(DualViewsDrawingModel.Shapes.Line line) { Windows.UI.Xaml.Shapes.Line drawingPageCanvasLine = new Windows.UI.Xaml.Shapes.Line(); drawingPageCanvasLine.X1 = line.X1; drawingPageCanvasLine.Y1 = line.Y1; drawingPageCanvasLine.X2 = line.X2; drawingPageCanvasLine.Y2 = line.Y2; drawingPageCanvasLine.Stroke = new SolidColorBrush(Colors.Red); drawingPageCanvasLine.StrokeDashArray = GetStrokeDashArray(); _canvas.Children.Add(drawingPageCanvasLine); }
private void DrawPixel(int fromX, int fromY, int color) { var _line = new Windows.UI.Xaml.Shapes.Line(); _line.Stroke = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 255, 0, 0)); _line.StrokeThickness = 5; _line.StrokeStartLineCap = PenLineCap.Round; _line.StrokeEndLineCap = PenLineCap.Round; _line.StrokeDashCap = PenLineCap.Round; _line.X1 = fromX; _line.Y1 = fromY; _line.X2 = fromX + 5; _line.Y2 = fromY + 5; canvas.Children.Add(_line); }
public void DrawNoticeLine(int row, int col, bool black) { var deltax = Convert.ToDouble(chessboard_background.ActualWidth) / 16; var deltay = Convert.ToDouble(chessboard_background.ActualHeight) / 16; Windows.UI.Xaml.Shapes.Line line; line = new Windows.UI.Xaml.Shapes.Line() { X1 = 10 + (row + 0.875) * deltax, X2 = 10 + (row + 0.875) * deltax + 0.25 * deltax, Y1 = 10 + (col + 1) * deltay, Y2 = 10 + (col + 1) * deltay }; if (black) { line.Stroke = new SolidColorBrush(Colors.White); } else { line.Stroke = new SolidColorBrush(Colors.Black); } line.StrokeThickness = 3; chessboard_father.Children.Add(line); chessboard_noticeline.Add(new Chessboard_notice_line_class(line, row, col, true)); line = new Windows.UI.Xaml.Shapes.Line() { Y1 = 10 + (col + 0.875) * deltay, Y2 = 10 + (col + 0.875) * deltay + 0.25 * deltay, X1 = 10 + (row + 1) * deltax, X2 = 10 + (row + 1) * deltax }; if (black) { line.Stroke = new SolidColorBrush(Colors.White); } else { line.Stroke = new SolidColorBrush(Colors.Black); } line.StrokeThickness = 3; chessboard_father.Children.Add(line); chessboard_noticeline.Add(new Chessboard_notice_line_class(line, row, col, false)); }
private void BuildChart(Shared.Dto.Wave waveFile) { this.PageGrid.Children.Clear(); Windows.UI.Xaml.Shapes.Line line = Utilities.SetLine(10, 10, 92, 208, Colors.Black); this.PageGrid.Children.Add(line); line = Utilities.SetLine(10, waveFile.PlotLines.Count, 150, 150, Colors.Black); this.PageGrid.Children.Add(line); this.tbAudioFileCount.Text = waveFile.Samples.Count.ToString() + " audio files"; int ctr = 0; foreach (Shared.Dto.Line lne in waveFile.PlotLines) { Windows.UI.Xaml.Shapes.Line xamlLine = Utilities.SetLine(lne.lineX1, lne.lineX2, lne.lineY1, lne.lineY2, Colors.Blue); this.PageGrid.Children.Add(xamlLine); ctr++; } }
internal void drawLine(Windows.Foundation.Point?startPoint, Windows.Foundation.Point?endPoint, ref Windows.UI.Xaml.Shapes.Line line) { if (startPoint != null && endPoint != null && _drawLine) { line.X1 = startPoint.Value.X; line.Y1 = startPoint.Value.Y; line.X2 = endPoint.Value.X; line.Y2 = endPoint.Value.Y; line.Visibility = Windows.UI.Xaml.Visibility.Visible; } else { line.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } }
private void ShowGridLine(int number) { var rect = new Windows.UI.Xaml.Shapes.Line() { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch, StrokeThickness = 1, Stroke = new SolidColorBrush(Colors.White), StrokeDashCap = PenLineCap.Round, StrokeStartLineCap = PenLineCap.Round, StrokeDashOffset = 40, StrokeLineJoin = PenLineJoin.Round, StrokeDashArray = new DoubleCollection() { 8 } }; var txt = new TextBlock(); var txt2 = new TextBlock(); if (number == 1) { txt.Text = "1"; txt2.Text = "2"; rect.Y1 = 0; rect.Y2 = this.ActualHeight; rect.HorizontalAlignment = HorizontalAlignment.Right; rect.VerticalAlignment = VerticalAlignment.Stretch; Grid.SetRowSpan(rect, 3); } if (number == 2) { rect.Y1 = 0; rect.Y2 = this.ActualHeight; rect.HorizontalAlignment = HorizontalAlignment.Right; rect.VerticalAlignment = VerticalAlignment.Stretch; Grid.SetRowSpan(rect, 3); Grid.SetColumn(rect, 1); } if (number == 3) { rect.X1 = 0; rect.X2 = this.ActualWidth; rect.HorizontalAlignment = HorizontalAlignment.Stretch; rect.VerticalAlignment = VerticalAlignment.Bottom; Grid.SetColumnSpan(rect, 3); } if (number == 4) { rect.X1 = 0; rect.X2 = this.ActualWidth; rect.HorizontalAlignment = HorizontalAlignment.Stretch; rect.VerticalAlignment = VerticalAlignment.Bottom; Grid.SetColumnSpan(rect, 3); Grid.SetRow(rect, 1); } WidgetZone.Children.Add(rect); }