コード例 #1
0
        private AbstractController defineController(Geometry initGeometry, Shape p)
        {
            /* first try to find the new easy way, from data stored in the Tag */
            AbstractController ctrl;
            int colonPosition = p.Tag.ToString().IndexOf(':');

            if ((colonPosition >= 0) &&
                AbstractController.ConstructFromString(p.Tag.ToString().Substring(colonPosition + 1),
                                                       this, out ctrl))
            {
                return(ctrl);
            }
            if (initGeometry is EllipseGeometry)
            {
                return(new CircleHyperArcController(this, initGeometry));
            }
            if (initGeometry is RectangleGeometry)
            {
                return(new RectangleHyperArcController(this, initGeometry));
            }
            return(new StarHyperArcController(this, initGeometry));
        }
コード例 #2
0
ファイル: ArcShape.cs プロジェクト: mdecourse/GraphSynth
        private AbstractController defineController(Path p)
        {
            /* first try to find the new easy way, from data stored in the Tag */
            AbstractController ctrl;
            int colonPosition = p.Tag.ToString().IndexOf(':');

            if ((colonPosition >= 0) &&
                AbstractController.ConstructFromString(p.Tag.ToString().Substring(colonPosition + 1),
                                                       this, out ctrl))
            {
                return(ctrl);
            }
            /* that didn't work? the old way is to try to parse the shape to get at the right parameters for each controller. */
            if ((p.Data is PathGeometry) &&
                (((PathGeometry)p.Data).Figures.Count > 0) &&
                (((PathGeometry)p.Data).Figures[0].Segments.Count > 0))
            // here we are assuming that the first figure, Figures[0], is the arcBody
            // if others exist, then they are the arrowHeads
            {
                var startPt = ((PathGeometry)p.Data).Figures[0].StartPoint;
                var segment = ((PathGeometry)p.Data).Figures[0].Segments[0];
                if (segment is BezierSegment)
                {
                    return(new BezierArcController(this, segment, startPt));
                }
                if (segment is PolyLineSegment)
                {
                    return(new RectilinearArcController(this, segment, startPt));
                }
                if (segment is ArcSegment)
                {
                    return(new CircleArcController(this, segment, startPt));
                }
            }
            return(new StraightArcController(this));
        }