/// <summary> /// <see cref="RendererBase"/> /// </summary> protected override void OnControlPointMouseMove(object sender, MouseEventArgs e) { Rectangle source = sender as Rectangle; if (source.Equals(Mouse.Captured)) { double x = e.GetPosition(Main.Paint2D).X; double y = e.GetPosition(Main.Paint2D).Y; this._lastX += x - this.LastPoint.X; Canvas.SetLeft(source, this._lastX); this._lastY += y - this.LastPoint.Y; Canvas.SetTop(source, this._lastY); this.LastPoint = new Point(x, y); ShapeDegree shapeDegree = source.Tag as ShapeDegree; if (shapeDegree.Out != null) { shapeDegree.Out.ForEach(line => { line.X1 = this._lastX; line.Y1 = this._lastY; }); } if (shapeDegree.In != null) { shapeDegree.In.ForEach(line => { line.X2 = this._lastX; line.Y2 = this._lastY; }); } this.FixLastXY(); } }
/// <summary> /// <see cref="SplineRenderer2D"/> /// </summary> protected override void DrawControlShapesOverride() { Matrix <Rectangle> rectMatrix = new Matrix <Rectangle>(); Matrix <Line> lineMatrix = new Matrix <Line>(); for (int i = 0; i < this.AlgInfoResult.KMatrix.Columns; i++) { for (int j = 0; j < this.AlgInfoResult.KMatrix.Rows; j++) { Rectangle rect = new Rectangle { Stroke = Brushes.Black, Fill = Brushes.Black, Height = MARKER_SIZE, Width = MARKER_SIZE, Tag = new ShapeDegree { In = new List <Line>(), Out = new List <Line>() } }; rect.MouseMove += PointMouseMove; rect.MouseLeftButtonDown += PointMouseLeftButtonDown; rect.MouseLeftButtonUp += PointMouseLeftButtonUp; Canvas.SetLeft(rect, this.AlgInfoResult.KMatrix[j, i].X - MARKER_SIZE / 2); Canvas.SetTop(rect, this.AlgInfoResult.KMatrix[j, i].Y - MARKER_SIZE / 2); rectMatrix[j].Add(rect); } } for (int j = 0; j < this.AlgInfoResult.KMatrix.Rows - 1; j++) { for (int i = 0; i < this.AlgInfoResult.KMatrix.Columns - 1; i++) { Line line = new Line { X1 = this.AlgInfoResult.KMatrix[j, i].X, X2 = this.AlgInfoResult.KMatrix[j, i + 1].X, Y1 = this.AlgInfoResult.KMatrix[j, i].Y, Y2 = this.AlgInfoResult.KMatrix[j, i + 1].Y, Stroke = Brushes.Black, StrokeThickness = this.ShowTypicalPolygon ? 0.5 : 0 }; Line line2 = new Line { X1 = this.AlgInfoResult.KMatrix[j, i].X, X2 = this.AlgInfoResult.KMatrix[j + 1, i].X, Y1 = this.AlgInfoResult.KMatrix[j, i].Y, Y2 = this.AlgInfoResult.KMatrix[j + 1, i].Y, Stroke = Brushes.Black, StrokeThickness = this.ShowTypicalPolygon ? 0.5 : 0 }; ShapeDegree degree = rectMatrix[j, i].Tag as ShapeDegree; degree.Out.Add(line); degree.Out.Add(line2); degree = rectMatrix[j, i + 1].Tag as ShapeDegree; degree.In.Add(line); degree = rectMatrix[j + 1, i].Tag as ShapeDegree; degree.In.Add(line2); this.Main.Paint2D.Children.Add(line); this.Main.Paint2D.Children.Add(line2); } } for (int i = 0; i < this.AlgInfoResult.KMatrix.Rows - 1; i++) { Line line = new Line { X1 = this.AlgInfoResult.KMatrix[i, this.AlgInfoResult.KMatrix.Columns - 1].X, X2 = this.AlgInfoResult.KMatrix[i + 1, this.AlgInfoResult.KMatrix.Columns - 1].X, Y1 = this.AlgInfoResult.KMatrix[i, this.AlgInfoResult.KMatrix.Columns - 1].Y, Y2 = this.AlgInfoResult.KMatrix[i + 1, this.AlgInfoResult.KMatrix.Columns - 1].Y, Stroke = Brushes.Black, StrokeThickness = this.ShowTypicalPolygon ? 0.5 : 0 }; this.Main.Paint2D.Children.Add(line); ShapeDegree degree = rectMatrix[i, this.AlgInfoResult.KMatrix.Columns - 1].Tag as ShapeDegree; degree.Out.Add(line); degree = rectMatrix[i + 1, this.AlgInfoResult.KMatrix.Columns - 1].Tag as ShapeDegree; degree.In.Add(line); } for (int i = 0; i < this.AlgInfoResult.KMatrix.Columns - 1; i++) { Line line = new Line { X1 = this.AlgInfoResult.KMatrix[this.AlgInfoResult.KMatrix.Rows - 1, i].X, X2 = this.AlgInfoResult.KMatrix[this.AlgInfoResult.KMatrix.Rows - 1, i + 1].X, Y1 = this.AlgInfoResult.KMatrix[this.AlgInfoResult.KMatrix.Rows - 1, i].Y, Y2 = this.AlgInfoResult.KMatrix[this.AlgInfoResult.KMatrix.Rows - 1, i + 1].Y, Stroke = Brushes.Black, StrokeThickness = this.ShowTypicalPolygon ? 0.5 : 0 }; this.Main.Paint2D.Children.Add(line); ShapeDegree degree = rectMatrix[this.AlgInfoResult.KMatrix.Rows - 1, i].Tag as ShapeDegree; degree.Out.Add(line); degree = rectMatrix[this.AlgInfoResult.KMatrix.Rows - 1, i + 1].Tag as ShapeDegree; degree.In.Add(line); } foreach (Rectangle rectangle in rectMatrix.SelectMany(pair => pair.Value)) { this.Main.Paint2D.Children.Add(rectangle); } }