예제 #1
0
        private void UpdateLinkAnchorAndShape(DragItem item, PointD locationFrom, PointD locationTo)
        {
            if (item == null)
            {
                return;
            }

            if (this.EdgePointType == EdgePointVMType.Start)
            {
                item.Thumb.Margin = new System.Windows.Thickness(locationFrom.X, locationFrom.Y, 0, 0);
            }
            else if (this.EdgePointType == EdgePointVMType.End)
            {
                item.Thumb.Margin = new System.Windows.Thickness(locationTo.X, locationTo.Y, 0, 0);
            }
            else
            {
                //...
            }

            FixedGeometryPoints fixedPoints = FixedGeometryPoints.Source;

            if (this.EdgePointType == EdgePointVMType.End)
            {
                fixedPoints = FixedGeometryPoints.Target;
            }
            else if (this.EdgePointType == EdgePointVMType.Normal)
            {
                fixedPoints = FixedGeometryPoints.None;
            }
            item.Path.Data = selectedItemVM.CalcPathGeometry(locationFrom, locationTo, fixedPoints, selectedItemVM.RoutingMode);
        }
예제 #2
0
        /// <summary>
        /// Layouts this link shape. Called from AnchorAbsoluteLocationChanged.
        /// </summary>
        /// <param name="fixedPoints">Fixed points.</param>
        internal virtual void InternalLayout(FixedGeometryPoints fixedPoints)
        {
            if (this.IsDeleted || this.IsDeleting)
            {
                return;
            }

            if (fixedPoints == FixedGeometryPoints.None)
            {
                SetStartPoint(CalculateStartPoint());
                SetEndPoint(CalculateEndPoint());
                UpdateLinkPlacement();
            }
            else if (fixedPoints == FixedGeometryPoints.Source && this.EndPoint == PointD.Empty)
            {
                SetEndPoint(CalculateEndPoint());
                UpdateLinkPlacementTarget();
            }
            else if (fixedPoints == FixedGeometryPoints.Target && this.StartPoint == PointD.Empty)
            {
                SetStartPoint(CalculateStartPoint());
                UpdateLinkPlacementStart();
            }

            Layout(this.StartPoint, this.EndPoint, fixedPoints);
        }
예제 #3
0
        /// <summary>
        /// Layouts this link shape.
        /// </summary>
        /// <param name="startPoint">Start point.</param>
        /// <param name="endPoint">End point.</param>
        /// <param name="fixedPoints">Fixed points.</param>
        public virtual void Layout(PointD startPoint, PointD endPoint, FixedGeometryPoints fixedPoints)
        {
            if (this.IsDeleted || this.IsDeleting)
            {
                return;
            }

            IsLayoutInProgress = true;

            EdgePointCollection colNew = new EdgePointCollection();

            colNew.AddRange(LayoutEdge(startPoint, endPoint));
            this.EdgePoints = colNew;

            if (colNew.Count > 0)
            {
                if (this.SourceAnchor != null)
                {
                    if (this.StartPoint != this.EdgePoints[0].Point)
                    {
                        if (!this.Store.InSerializationTransaction)
                        {
                            this.SourceAnchor.DiscardLocationChange = true;
                        }
                        SetStartPoint(this.EdgePoints[0].Point);
                    }
                }

                if (this.TargetAnchor != null)
                {
                    if (this.EndPoint != this.EdgePoints[this.EdgePoints.Count - 1].Point)
                    {
                        if (!this.Store.InSerializationTransaction)
                        {
                            this.TargetAnchor.DiscardLocationChange = true;
                        }
                        SetEndPoint(this.EdgePoints[this.EdgePoints.Count - 1].Point);
                    }
                }
            }

            UpdateLinkPlacement();
            IsLayoutInProgress = false;
        }
예제 #4
0
        private void AddLinkAnchorAndShape(PointD locationFrom, PointD locationTo)
        {
            DragItem dragItem = new DragItem();

            Rectangle r = new Rectangle();

            r.Stroke          = new SolidColorBrush(Colors.Black);
            r.StrokeThickness = 1.0;
            r.Width           = this.ActualWidth;
            r.Height          = this.ActualHeight;
            if (this.EdgePointType == EdgePointVMType.Start)
            {
                r.Margin = new System.Windows.Thickness(locationFrom.X, locationFrom.Y, 0, 0);
            }
            else if (this.EdgePointType == EdgePointVMType.End)
            {
                r.Margin = new System.Windows.Thickness(locationTo.X, locationTo.Y, 0, 0);
            }
            else
            {
                //...
            }
            dragItem.Thumb = r;

            FixedGeometryPoints fixedPoints = FixedGeometryPoints.Source;

            if (this.EdgePointType == EdgePointVMType.End)
            {
                fixedPoints = FixedGeometryPoints.Target;
            }
            else if (this.EdgePointType == EdgePointVMType.Normal)
            {
                fixedPoints = FixedGeometryPoints.None;
            }

            Path path = new Path();

            path.Data            = selectedItemVM.CalcPathGeometry(locationFrom, locationTo, fixedPoints, selectedItemVM.RoutingMode);
            path.Stroke          = new SolidColorBrush(Colors.Black);
            path.StrokeThickness = 1.0;
            dragItem.Path        = path;

            dragCanvas.Children.Add(dragItem);
        }
예제 #5
0
        /// <summary>
        /// Calculates a path geometry between the source and the target point.
        /// </summary>
        /// <param name="proposedSourcePoint">Source point (Absolute location).</param>
        /// <param name="targetShape">Target shape.</param>
        /// <param name="proposedTargetPoint">Target point (Absolute location).</param>
        /// <param name="fixedPoints">Fixed points.</param>
        /// <returns>Calculated path geometry.</returns>
        public virtual List <PointD> CalcPath(PointD proposedSourcePoint, NodeShape targetShape, PointD proposedTargetPoint, FixedGeometryPoints fixedPoints)
        {
            PointD sourcePoint = proposedSourcePoint;
            PointD targetPoint = proposedTargetPoint;

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Source)
            {
                // calculate allowed source position
                // TODO
            }

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Target)
            {
                // calculate allowed target position
                targetPoint = CalculateAllowedPosition(targetShape, proposedTargetPoint);
            }

            List <PointD> edgePoints = CalculatePath(sourcePoint, targetPoint);

            return(edgePoints);
        }
예제 #6
0
        /// <summary>
        /// Calculates a path between the source and the target point.
        /// </summary>
        /// <param name="proposedSourcePoint">Source point (Absolute location).</param>
        /// <param name="proposedTargetPoint">Target point (Absolute location).</param>
        /// <param name="fixedPoints">Fixed points.</param>
        /// <returns>Calculated path geometry.</returns>
        public virtual List <PointD> CalcPath(PointD proposedSourcePoint, PointD proposedTargetPoint, FixedGeometryPoints fixedPoints)
        {
            PointD sourcePoint = proposedSourcePoint;
            PointD targetPoint = proposedTargetPoint;

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Source)
            {
                // calculate allowed source position
                // TODO: not required yet
            }

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Target)
            {
                // calculate allowed target position
                // TODO: not required yet
            }

            List <PointD> edgePoints = new List <PointD>();

            edgePoints.Add(sourcePoint);
            edgePoints.Add(targetPoint);

            return(edgePoints);
        }
예제 #7
0
        /// <summary>
        /// Calculates a path geometry between the source and the target point. 
        /// </summary>
        /// <param name="proposedSourcePoint">Source point (Absolute location).</param>
        /// <param name="targetShape">Target shape.</param>
        /// <param name="proposedTargetPoint">Target point (Absolute location).</param>
        /// <param name="fixedPoints">Fixed points.</param>
        /// <returns>Calculated path geometry.</returns>
        public virtual List<PointD> CalcPath(PointD proposedSourcePoint, NodeShape targetShape, PointD proposedTargetPoint, FixedGeometryPoints fixedPoints)
        {
            PointD sourcePoint = proposedSourcePoint;
            PointD targetPoint = proposedTargetPoint;

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Source)
            {
                // calculate allowed source position
                // TODO
            }

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Target)
            {
                // calculate allowed target position
                targetPoint = CalculateAllowedPosition(targetShape, proposedTargetPoint);
            }

            List<PointD> edgePoints = CalculatePath(sourcePoint, targetPoint);
            return edgePoints;
        }
예제 #8
0
        /// <summary>
        /// Calculates a path between the source and the target point.
        /// </summary>
        /// <param name="proposedSourcePoint">Source point (Absolute location).</param>
        /// <param name="proposedTargetPoint">Target point (Absolute location).</param>
        /// <param name="fixedPoints">Fixed points.</param>
        /// <returns>Calculated path geometry.</returns>
        public virtual List<PointD> CalcPath(PointD proposedSourcePoint, PointD proposedTargetPoint, FixedGeometryPoints fixedPoints)
        {
            PointD sourcePoint = proposedSourcePoint;
            PointD targetPoint = proposedTargetPoint;

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Source)
            {
                // calculate allowed source position
                // TODO: not required yet
            }

            if (fixedPoints != FixedGeometryPoints.SourceAndTarget &&
                fixedPoints != FixedGeometryPoints.Target)
            {
                // calculate allowed target position
                // TODO: not required yet
            }

            List<PointD> edgePoints = new List<PointD>();
            edgePoints.Add(sourcePoint);
            edgePoints.Add(targetPoint);

            return edgePoints;
        }
        /// <summary>
        /// Calculates a path geometry between the source and the target points.
        /// </summary>
        /// <param name="sourcePoint">Source point (Absolute location).</param>
        /// <param name="targetPoint">Target point (Absolute location).</param>
        /// <param name="fixedPoints">Fixed points.</param>
        /// <param name="routingMode">Routing mode.</param>
        /// <returns>Calculated path geometry.</returns>
        public virtual PathGeometry CalcPathGeometry(PointD sourcePoint, PointD targetPoint, FixedGeometryPoints fixedPoints, RoutingMode routingMode)
        {
            // fixedPoints: not required yet...
            EdgePointCollection col = this.ShapeElement.CalcLayoutEdge(sourcePoint, targetPoint, routingMode);

            PathGeometry geometry = new PathGeometry();

            PathFigure figure = new PathFigure();
            figure.StartPoint = new System.Windows.Point(col[0].X, col[0].Y);

            List<System.Windows.Point> points = new List<System.Windows.Point>();
            for (int i = 1; i < col.Count; i++)
            {
                points.Add(new System.Windows.Point(col[i].X, col[i].Y));
            }
            figure.Segments.Add(new PolyLineSegment(points, true));
            geometry.Figures.Add(figure);

            return geometry;
        }
예제 #10
0
        /// <summary>
        /// Layouts this link shape.
        /// </summary>
        /// <param name="startPoint">Start point.</param>
        /// <param name="endPoint">End point.</param>
        /// <param name="fixedPoints">Fixed points.</param>
        public virtual void Layout(PointD startPoint, PointD endPoint, FixedGeometryPoints fixedPoints)
        {
            if (this.IsDeleted || this.IsDeleting)
                return;

            IsLayoutInProgress = true;

            EdgePointCollection colNew = new EdgePointCollection();
            colNew.AddRange(LayoutEdge(startPoint, endPoint));
            this.EdgePoints = colNew;

            if (colNew.Count > 0)
            {
                if (this.SourceAnchor != null)
                    if (this.StartPoint != this.EdgePoints[0].Point)
                    {
                        if (!this.Store.InSerializationTransaction)
                            this.SourceAnchor.DiscardLocationChange = true;
                        SetStartPoint(this.EdgePoints[0].Point);
                    }

                if (this.TargetAnchor != null)
                    if (this.EndPoint != this.EdgePoints[this.EdgePoints.Count - 1].Point)
                    {
                        if (!this.Store.InSerializationTransaction)
                            this.TargetAnchor.DiscardLocationChange = true;
                        SetEndPoint(this.EdgePoints[this.EdgePoints.Count - 1].Point);
                    }
            }
 
            UpdateLinkPlacement();
            IsLayoutInProgress = false;
        }
예제 #11
0
        /// <summary>
        /// Layouts this link shape. Called from AnchorAbsoluteLocationChanged.
        /// </summary>
        /// <param name="fixedPoints">Fixed points.</param>
        internal virtual void InternalLayout(FixedGeometryPoints fixedPoints)
        {
            if (this.IsDeleted || this.IsDeleting)
                return;

            if (fixedPoints == FixedGeometryPoints.None)
            {
                SetStartPoint(CalculateStartPoint());
                SetEndPoint(CalculateEndPoint());
                UpdateLinkPlacement();
            }
            else if (fixedPoints == FixedGeometryPoints.Source && this.EndPoint == PointD.Empty)
            {
                SetEndPoint(CalculateEndPoint());
                UpdateLinkPlacementTarget();
            }
            else if (fixedPoints == FixedGeometryPoints.Target && this.StartPoint == PointD.Empty)
            {
                SetStartPoint(CalculateStartPoint());
                UpdateLinkPlacementStart();
            }

            Layout(this.StartPoint, this.EndPoint, fixedPoints);
        }
예제 #12
0
        /// <summary>
        /// Calculates a path geometry between the source and the target points.
        /// </summary>
        /// <param name="sourcePoint">Source point (Absolute location).</param>
        /// <param name="targetPoint">Target point (Absolute location).</param>
        /// <param name="fixedPoints">Fixed points.</param>
        /// <param name="routingMode">Routing mode.</param>
        /// <returns>Calculated path geometry.</returns>
        public virtual PathGeometry CalcPathGeometry(PointD sourcePoint, PointD targetPoint, FixedGeometryPoints fixedPoints, RoutingMode routingMode)
        {
            // fixedPoints: not required yet...
            EdgePointCollection col = this.ShapeElement.CalcLayoutEdge(sourcePoint, targetPoint, routingMode);

            PathGeometry geometry = new PathGeometry();

            PathFigure figure = new PathFigure();

            figure.StartPoint = new System.Windows.Point(col[0].X, col[0].Y);

            List <System.Windows.Point> points = new List <System.Windows.Point>();

            for (int i = 1; i < col.Count; i++)
            {
                points.Add(new System.Windows.Point(col[i].X, col[i].Y));
            }
            figure.Segments.Add(new PolyLineSegment(points, true));
            geometry.Figures.Add(figure);

            return(geometry);
        }