예제 #1
0
        Path AddEdgeToCanvas(PositionedEdge edge)
        {
            var          edgeSplineFigure = CreateEdgeSpline(edge);
            PathGeometry geometryVisible  = new PathGeometry();

            geometryVisible.Figures.Add(edgeSplineFigure);
            geometryVisible.Figures.Add(CreateEdgeArrow(edge));

            Path pathVisible = new Path();

            pathVisible.Stroke          = Brushes.Black;
            pathVisible.Fill            = Brushes.Black;
            pathVisible.StrokeThickness = 1;
            pathVisible.Data            = geometryVisible;

            // remember this spline Path at PositionedEdge to be able to highlight edge from PositionedNodeProperty
            edge.Spline = pathVisible;
            // and remember the the edge for the spline, so that we can get edge name on spline mouse-over
            pathVisible.Tag = edge;

            PathGeometry geometryInVisible = new PathGeometry();

            geometryInVisible.Figures.Add(edgeSplineFigure);

            Path pathInVisible = new Path();

            pathInVisible.Stroke          = Brushes.Transparent;
            pathInVisible.Fill            = Brushes.Transparent;
            pathInVisible.StrokeThickness = 16;
            pathInVisible.Data            = geometryInVisible;

            pathInVisible.MouseEnter += delegate(object sender, MouseEventArgs e)
            {
                pathVisible.StrokeThickness = 2;
                this.edgeTooltip.Text       = ((PositionedEdge)pathVisible.Tag).Name;
                Point mousePos = e.GetPosition(this.canvas);
                Canvas.SetLeft(this.edgeTooltip, mousePos.X - 5);
                Canvas.SetTop(this.edgeTooltip, mousePos.Y - 20);
                this.edgeTooltip.Visibility = Visibility.Visible;
            };
            pathInVisible.MouseLeave += delegate(object sender, MouseEventArgs e)
            {
                pathVisible.StrokeThickness = 1;
                this.edgeTooltip.Visibility = Visibility.Hidden;
            };
            pathInVisible.MouseMove += delegate(object sender, MouseEventArgs e)
            {
                Point mousePos = e.GetPosition(this.canvas);
                Canvas.SetLeft(this.edgeTooltip, mousePos.X - 5);
                Canvas.SetTop(this.edgeTooltip, mousePos.Y - 20);
            };

            canvas.Children.Add(pathVisible);
            canvas.Children.Add(pathInVisible);

            return(pathVisible);
        }
예제 #2
0
        PathFigure CreateEdgeSpline(PositionedEdge edge)
        {
            PathFigure figure = new PathFigure();

            figure.IsClosed = false;
            figure.IsFilled = false;

            figure.StartPoint = edge.SplinePoints[0];
            for (int i = 1; i < edge.SplinePoints.Count; i += 3)
            {
                figure.Segments.Add(new BezierSegment(edge.SplinePoints[i], edge.SplinePoints[i + 1], edge.SplinePoints[i + 2], true));
            }

            return(figure);
        }
예제 #3
0
        PathFigure CreateEdgeArrow(PositionedEdge edge)
        {
            Point splineEndPoint       = edge.SplinePoints[edge.SplinePoints.Count - 1];
            Point splineEndHandlePoint = edge.SplinePoints[edge.SplinePoints.Count - 2];

            Vector tangent = splineEndPoint - splineEndHandlePoint;

            tangent.Normalize();
            tangent = tangent * 20;
            Point basePoint = splineEndPoint - 0.4 * tangent;

            PathFigure arrowFigure = new PathFigure();

            arrowFigure.IsClosed = true;
            arrowFigure.IsFilled = true;

            arrowFigure.StartPoint = splineEndPoint;                    // arrow tip
            Vector tangent2 = Rotate90(tangent);

            arrowFigure.Segments.Add(new LineSegment(basePoint + tangent2 * 0.15, true));
            arrowFigure.Segments.Add(new LineSegment(basePoint - tangent2 * 0.15, true));

            return(arrowFigure);
        }
예제 #4
0
		PathFigure CreateEdgeArrow(PositionedEdge edge)
		{
			Point splineEndPoint = edge.SplinePoints[edge.SplinePoints.Count - 1];
			Point splineEndHandlePoint = edge.SplinePoints[edge.SplinePoints.Count - 2];
			
			Vector tangent = splineEndPoint - splineEndHandlePoint;
			tangent.Normalize();
			tangent = tangent * 20;
			Point basePoint = splineEndPoint - 0.4 * tangent;
			
			PathFigure arrowFigure = new PathFigure();
			arrowFigure.IsClosed = true;
			arrowFigure.IsFilled = true;

			arrowFigure.StartPoint = splineEndPoint;	// arrow tip
			Vector tangent2 = Rotate90(tangent);
			arrowFigure.Segments.Add(new LineSegment(basePoint + tangent2 * 0.15, true));
			arrowFigure.Segments.Add(new LineSegment(basePoint - tangent2 * 0.15, true));
			
			return arrowFigure;
		}
예제 #5
0
		PathFigure CreateEdgeSpline(PositionedEdge edge)
		{
			PathFigure figure = new PathFigure();
			figure.IsClosed = false;
			figure.IsFilled = false;
			
			figure.StartPoint = edge.SplinePoints[0];
			for (int i = 1; i < edge.SplinePoints.Count; i += 3)
			{
				figure.Segments.Add(new BezierSegment(edge.SplinePoints[i], edge.SplinePoints[i + 1], edge.SplinePoints[i + 2], true));
			}
			
			return figure;
		}
예제 #6
0
		Path AddEdgeToCanvas(PositionedEdge edge)
		{
			var edgeSplineFigure = CreateEdgeSpline(edge);
			PathGeometry geometryVisible = new PathGeometry();
			geometryVisible.Figures.Add(edgeSplineFigure);
			geometryVisible.Figures.Add(CreateEdgeArrow(edge));
			
			Path pathVisible = new Path();
			pathVisible.Stroke = Brushes.Black;
			pathVisible.Fill = Brushes.Black;
			pathVisible.StrokeThickness = 1;
			pathVisible.Data = geometryVisible;
			
			// remember this spline Path at PositionedEdge to be able to highlight edge from PositionedNodeProperty
			edge.Spline = pathVisible;
			// and remember the the edge for the spline, so that we can get edge name on spline mouse-over
			pathVisible.Tag = edge;
			
			PathGeometry geometryInVisible = new PathGeometry();
			geometryInVisible.Figures.Add(edgeSplineFigure);
			
			Path pathInVisible = new Path();
			pathInVisible.Stroke = Brushes.Transparent;
			pathInVisible.Fill = Brushes.Transparent;
			pathInVisible.StrokeThickness = 16;
			pathInVisible.Data = geometryInVisible;
			
			pathInVisible.MouseEnter += delegate(object sender, MouseEventArgs e)
			{
				pathVisible.StrokeThickness = 2;
				this.edgeTooltip.Text = ((PositionedEdge)pathVisible.Tag).Name;
				Point mousePos = e.GetPosition(this.canvas);
				Canvas.SetLeft(this.edgeTooltip, mousePos.X - 5);
				Canvas.SetTop(this.edgeTooltip, mousePos.Y - 20);
				this.edgeTooltip.Visibility = Visibility.Visible;
			};
			pathInVisible.MouseLeave += delegate(object sender, MouseEventArgs e)
			{
				pathVisible.StrokeThickness = 1;
				this.edgeTooltip.Visibility = Visibility.Hidden;
			};
			pathInVisible.MouseMove += delegate(object sender, MouseEventArgs e)
			{
				Point mousePos = e.GetPosition(this.canvas);
				Canvas.SetLeft(this.edgeTooltip, mousePos.X - 5);
				Canvas.SetTop(this.edgeTooltip, mousePos.Y - 20);
			};
			
			canvas.Children.Add(pathVisible);
			canvas.Children.Add(pathInVisible);
			
			return pathVisible;
		}
예제 #7
0
		void SetEdgeSplinePoints(PositionedEdge edge, RoutedEdge routedEdge)
		{
			foreach (Point2D point in routedEdge.SplinePoints) {
				edge.SplinePoints.Add(new Point(point.X, point.Y));
			}
		}