コード例 #1
0
 internal static Boolean ConstructFromString(string p, Shape displayShape, out AbstractController Controller)
 {
     try
     {
         var ctrlData    = p.Split(new[] { ',' }, 2);
         var ctrlName    = ctrlData[0];
         var ctrlParams  = DoubleCollectionConverter.Convert(ctrlData[1]).ToArray();
         var ctrlType    = Type.GetType("GraphSynth.GraphDisplay." + ctrlName, true);
         var constructor = ctrlType.GetConstructor(new[] { typeof(Shape), typeof(double[]) });
         Controller = (AbstractController)constructor.Invoke(new object[] { displayShape, ctrlParams });
         return(true);
     }
     catch { Controller = null; return(false); }
 }
コード例 #2
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));
        }
コード例 #3
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));
        }
コード例 #4
0
 public void copyValueTo(AbstractController victim)
 {
     victim.parameters = this.parameters;
 }