Esempio n. 1
0
        /// <summary>
        /// Layouts the edge betweend the given points.
        /// </summary>
        /// <param name="startPoint"></param>
        /// <param name="endPoint"></param>
        /// <param name="rMode">Routing mode.</param>
        /// <returns></returns>
        public virtual EdgePointCollection LayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode)
        {
            EdgePointCollection points = new EdgePointCollection();

            if (rMode == RoutingMode.Orthogonal)
            {
                try
                {
                    // calculate points between start and end
                    List <PointD> calcPoints = OrthogonalEdgeRouter.GetConnectionLine(this, this.FromShape, startPoint, this.ToShape, endPoint);

                    foreach (PointD p in calcPoints)
                    {
                        points.Add(new EdgePoint(p.X, p.Y));
                    }
                }
                catch
                {
                    points.Add(new EdgePoint(startPoint));
                    points.Add(new EdgePoint(endPoint));
                }
            }
            else
            {
                points.Add(new EdgePoint(startPoint));
                points.Add(new EdgePoint(endPoint));
            }
            return(points);
        }
Esempio n. 2
0
        /// <summary>
        /// Layouts the edge betweend the given points. This method is used to calculate a path that is displayed
        /// when any of the anchors is changed (via drag&drop).
        /// </summary>
        /// <param name="startPoint"></param>
        /// <param name="endPoint"></param>
        /// <param name="rMode">Routing mode. TODO: Not yet supported.</param>
        /// <returns></returns>
        public virtual EdgePointCollection CalcLayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode)
        {
            EdgePointCollection points = new EdgePointCollection();

            /*if (rMode == RoutingMode.Orthogonal)
             * {
             *  try
             *  {
             *      // calculate points between start and end
             *      List<PointD> calcPoints = OrthogonalEdgeRouter.GetConnectionLineSimple(this, this.FromShape, startPoint, this.ToShape, endPoint, GetLinkPlacement(this.ToShape.AbsoluteBounds, endPoint));
             *
             *      foreach (PointD p in calcPoints)
             *          points.Add(new EdgePoint(p.X, p.Y));
             *  }
             *  catch
             *  {
             *      points.Add(new EdgePoint(startPoint));
             *      points.Add(new EdgePoint(endPoint));
             *  }
             * }
             * else
             * {*/
            points.Add(new EdgePoint(startPoint));
            points.Add(new EdgePoint(endPoint));
            //}
            return(points);
        }
        /// <summary>
        /// Layouts an edge between the given points.
        /// </summary>
        /// <param name="startPoint">Start point.</param>
        /// <param name="endPoint">End point.</param>
        /// <param name="rMode">Routing mode.</param>
        /// <returns>Edge point collection.</returns>
        public override EdgePointCollection LayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode)
        {
            double middle = startPoint.X + (endPoint.X - startPoint.X) / 2.0;

            EdgePointCollection points = new EdgePointCollection();
            points.Add(new EdgePoint(startPoint));
            points.Add(new EdgePoint(middle, startPoint.Y));
            points.Add(new EdgePoint(middle, endPoint.Y));
            points.Add(new EdgePoint(endPoint));
            
            return points;
        }
Esempio n. 4
0
        /// <summary>
        /// Layouts an edge between the given points.
        /// </summary>
        /// <param name="startPoint">Start point.</param>
        /// <param name="endPoint">End point.</param>
        /// <param name="rMode">Routing mode.</param>
        /// <returns>Edge point collection.</returns>
        public override EdgePointCollection LayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode)
        {
            double middle = startPoint.X + (endPoint.X - startPoint.X) / 2.0;

            EdgePointCollection points = new EdgePointCollection();

            points.Add(new EdgePoint(startPoint));
            points.Add(new EdgePoint(middle, startPoint.Y));
            points.Add(new EdgePoint(middle, endPoint.Y));
            points.Add(new EdgePoint(endPoint));

            return(points);
        }
Esempio n. 5
0
        public static EdgePointCollection ConvertFromRelativeEdgePoints(EdgePointCollection col, PointD relativeTo)
        {
            EdgePointCollection retCol = new EdgePointCollection();

            foreach (EdgePoint p in col)
            {
                PointD ret = new PointD();
                ret.X = p.X + relativeTo.X;
                ret.Y = p.Y + relativeTo.Y;

                EdgePoint point = new EdgePoint(ret, p.PointType);
                retCol.Add(point);
            }

            return(retCol);
        }
Esempio n. 6
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;
        }
        public static EdgePointCollection ConvertFromRelativeEdgePoints(EdgePointCollection col, PointD relativeTo)
        {
            EdgePointCollection retCol = new EdgePointCollection();

            foreach (EdgePoint p in col)
            {
                PointD ret = new PointD();
                ret.X = p.X + relativeTo.X;
                ret.Y = p.Y + relativeTo.Y;

                EdgePoint point = new EdgePoint(ret, p.PointType);
                retCol.Add(point);
            }

            return retCol;
        }
        /// <summary>
        /// Converts a collection of edge points to the corresponding path geometry.
        /// </summary>
        /// <param name="edgePoints">Collection of edge points.</param>
        /// <returns>Path geometry.</returns>
        protected virtual PathGeometry ConvertEdgePointsToGeometry(EdgePointCollection edgePoints)
        {
            PathGeometry geometry = new PathGeometry();

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

            return geometry;
        }
        /// <summary>
        /// Layouts the edge betweend the given points. This method is used to calculate a path that is displayed
        /// when any of the anchors is changed (via drag&drop).
        /// </summary>
        /// <param name="startPoint"></param>
        /// <param name="endPoint"></param>
        /// <param name="rMode">Routing mode. TODO: Not yet supported.</param>
        /// <returns></returns>
        public virtual EdgePointCollection CalcLayoutEdge(PointD startPoint, PointD endPoint, RoutingMode rMode)
        {
            EdgePointCollection points = new EdgePointCollection();
            /*if (rMode == RoutingMode.Orthogonal)
            {
                try
                {
                    // calculate points between start and end
                    List<PointD> calcPoints = OrthogonalEdgeRouter.GetConnectionLineSimple(this, this.FromShape, startPoint, this.ToShape, endPoint, GetLinkPlacement(this.ToShape.AbsoluteBounds, endPoint));

                    foreach (PointD p in calcPoints)
                        points.Add(new EdgePoint(p.X, p.Y));
                }
                catch
                {
                    points.Add(new EdgePoint(startPoint));
                    points.Add(new EdgePoint(endPoint));
                }
            }
            else
            {*/
                points.Add(new EdgePoint(startPoint));
                points.Add(new EdgePoint(endPoint));
            //}
            return points;
        }
Esempio n. 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;
        }