Beispiel #1
0
        /// <summary>
        /// Pulled directly from Reflector disassembly
        /// </summary>
        private LineSegment[] CalculateSegments(IGeometryHost geometryHost, DiagramHitTestInfo hitTestInfo)
        {
            IBinaryLinkGeometryData data1       = geometryHost as IBinaryLinkGeometryData;
            EdgePointCollection     collection1 = data1.GeometryEdgePointsNoJumps;

            LineSegment[] segmentArray1 = new LineSegment[collection1.Count - 1];
            Pen           pen1          = geometryHost.GeometryStyleSet.GetPen(this.GetOutlinePenId(geometryHost));

            if (pen1 != null)
            {
                for (int num1 = 0; num1 < (collection1.Count - 1); num1++)
                {
                    RectangleD ed1 = GeometryHelpers.RectangleDFrom2Pts(collection1[num1].Point, collection1[num1 + 1].Point);
                    // In DSL Tools v8.2, GetHitTestTolerance is an instance method, but in DSL Tools v9.0, it is a static method.
                    // We call it without a qualifier here so that it will compile against both versions.
                    SizeD ed2 = GetHitTestTolerance(hitTestInfo);
                    if (ed1.Height < ed2.Height)
                    {
                        ed1.Inflate(0, (pen1.Width / 2f) + ed2.Height);
                    }
                    else if (ed1.Width < ed2.Width)
                    {
                        ed1.Inflate((pen1.Width / 2f) + ed2.Width, 0);
                    }
                    segmentArray1[num1] = new LineSegment(collection1[num1].Point, collection1[num1 + 1].Point, num1, num1 + 1, num1 == 0, (num1 + 1) == (collection1.Count - 1), ed1);
                }
            }
            return(segmentArray1);
        }
        /// <summary>
        /// Convert from logic.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string s1 = value as string;
            if (s1 != null)
            {
                s1 = s1.Trim();

                if (culture == null)
                    culture = System.Globalization.CultureInfo.InvariantCulture;

                if (s1.StartsWith("[", false, culture) && s1.EndsWith("]", false, culture))
                {
                    s1 = s1.Substring(1, s1.Length - 2);

                    char[] chArr = new char[] { ';' };
                    string[] sArr1 = s1.Split(chArr, System.StringSplitOptions.None);
                    
                    EdgePointCollection edgePointCollection = new EdgePointCollection();
                    for (int i = 0; i < sArr1.Length; i++)
                    {
                        string s2 = sArr1[i];
                        edgePointCollection.Add(EdgePointConverter.ConvertFromString(culture, s2));
                    }
                    return edgePointCollection;
                }
            }
            return base.ConvertFrom(context, culture, value);
        }
Beispiel #3
0
        /// <summary>
        /// Convert from logic.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string s1 = value as string;

            if (s1 != null)
            {
                s1 = s1.Trim();

                if (culture == null)
                {
                    culture = System.Globalization.CultureInfo.InvariantCulture;
                }

                if (s1.StartsWith("[", false, culture) && s1.EndsWith("]", false, culture))
                {
                    s1 = s1.Substring(1, s1.Length - 2);

                    char[]   chArr = new char[] { ';' };
                    string[] sArr1 = s1.Split(chArr, System.StringSplitOptions.None);

                    EdgePointCollection edgePointCollection = new EdgePointCollection();
                    for (int i = 0; i < sArr1.Length; i++)
                    {
                        string s2 = sArr1[i];
                        edgePointCollection.Add(EdgePointConverter.ConvertFromString(culture, s2));
                    }
                    return(edgePointCollection);
                }
            }
            return(base.ConvertFrom(context, culture, value));
        }
Beispiel #4
0
        /// <summary>
        /// Convert to logic.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <param name="destinationType"></param>
        /// <returns></returns>
        public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType)
        {
            EdgePointCollection edgePointCollection = value as EdgePointCollection;

            if (edgePointCollection != null)
            {
                System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
                stringBuilder.Append("[");

                for (int i = 0; i < edgePointCollection.Count; i++)
                {
                    EdgePoint edgePoint = edgePointCollection[i];
                    stringBuilder.Append(EdgePointConverter.ConvertToString(culture, edgePoint));

                    if (i < edgePointCollection.Count - 1)
                    {
                        stringBuilder.Append("; ");
                    }
                }

                stringBuilder.Append("]");
                return(stringBuilder.ToString());
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
Beispiel #5
0
        /// <summary>
        /// Override of BinaryLinkShape.ExcludeFromClipRegion to support moving the link
        /// decorator and properly rotating it.
        /// </summary>
        public override void ExcludeFromClipRegion(Graphics g, Matrix matrix, GraphicsPath perimeter)
        {
            ObliqueBinaryLinkShapeGeometry geometry = this.ShapeGeometry as ObliqueBinaryLinkShapeGeometry;
            Pen linePen = this.StyleSet.GetPen(DiagramPens.ConnectionLine);
            EdgePointCollection edgePoints = this.EdgePoints;
            int edgePointCount             = edgePoints.Count;

            if ((geometry != null) && (linePen != null))
            {
                for (int i = 1; i < edgePointCount; ++i)
                {
                    if (edgePoints[i].Flag == VGPointType.JumpEnd)
                    {
                        GraphicsPath excludePath = this.ExcludePath;
                        geometry.AddLineArcPath(excludePath, edgePoints[i - 1].Point, edgePoints[i].Point);
                        g.SetClip(excludePath, CombineMode.Exclude);
                    }
                    else
                    {
                        RectangleD excludeRect = GeometryHelpers.RectangleDFrom2Pts(edgePoints[i - 1].Point, edgePoints[i].Point);
                        double     inflateBy   = linePen.Width / 2f;
                        excludeRect.Inflate(inflateBy, inflateBy);
                        g.SetClip(RectangleD.ToRectangleF(excludeRect), CombineMode.Exclude);
                    }
                }
                if (edgePointCount > 1)
                {
                    LinkDecorator decorator;
#if VISUALSTUDIO_10_0
                    IBinaryLinkGeometryData geometryData = (IBinaryLinkGeometryData)this;
#endif
                    if (null != (decorator = DecoratorFrom))
                    {
                        ExcludeDecorator(g, geometry, decorator, edgePoints[0].Point, edgePoints[1].Point
#if VISUALSTUDIO_10_0
                                         , geometryData.GeometryDecoratorFromSize
#endif
                                         );
                    }
                    if (null != (decorator = DecoratorTo))
                    {
                        ExcludeDecorator(g, geometry, decorator, edgePoints[edgePointCount - 1].Point, edgePoints[edgePointCount - 2].Point
#if VISUALSTUDIO_10_0
                                         , geometryData.GeometryDecoratorToSize
#endif
                                         );
                    }
                }
            }
        }
Beispiel #6
0
        /// <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);
        }
Beispiel #7
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);
        }