private void SetupBezierLink() { bfigureG.StartPoint = new Point(A.X() - LineMargin, A.Y()); bfigureA.StartPoint = new Point(A.X(), A.Y()); bfigureB.StartPoint = new Point(A.X() + LineMargin, A.Y()); polyBezierG.Points = UpdatePoints(-LineMargin, -LineMargin); polyBezierA.Points = UpdatePoints(0, LineMargin); polyBezierB.Points = UpdatePoints(LineMargin, 0); }
public ConnectorCanvas(ConnectClickPoint A, ConnectClickPoint B, Canvas rootcvs) { this.A = A; this.B = B; this.rootcvs = rootcvs; //画一条线 从A到B /* * line.X1 = A.X(); * line.Y1 = A.Y(); * line.X2 = B.X(); * line.Y2 = B.Y(); * line.Stroke = Brushes.LightSteelBlue; * line.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; * line.VerticalAlignment = System.Windows.VerticalAlignment.Top; * rootcvs.Children.Add(line); */ bpath = new Path() { Stroke = Brushes.Red, StrokeThickness = 1, Data = new PathGeometry() { Figures = new PathFigureCollection(new PathFigure[] { bfigureA = new PathFigure() { StartPoint = new Point(A.X(), A.Y()), Segments = new PathSegmentCollection(new PathSegment[] { polyBezierA }) }, bfigureB = new PathFigure() { StartPoint = new Point(A.X(), A.Y()), Segments = new PathSegmentCollection(new PathSegment[] { polyBezierB }) }, bfigureG = new PathFigure() { StartPoint = new Point(A.X(), A.Y()), Segments = new PathSegmentCollection(new PathSegment[] { polyBezierG }) } }) } }; SetupBezierLink(); rootcvs.Children.Add(bpath); timer.Tick += Update; timer.Interval = TimeSpan.FromMilliseconds(100); timer.Start(); bpath.MouseDown += MouseDown; bpath.Cursor = Cursors.No; }