Beispiel #1
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.CircleGrid = ((System.Windows.Controls.Grid)(target));
                return;

            case 2:
                this.pathFigureCollection = ((System.Windows.Media.PathFigureCollection)(target));
                return;

            case 3:
                this.selectedPathFigureCollection = ((System.Windows.Media.PathFigureCollection)(target));
                return;

            case 4:
                this.btnCircle = ((System.Windows.Controls.Button)(target));

            #line 61 "..\..\OptionCircle.xaml"
                this.btnCircle.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.btnCircle_MouseDown);

            #line default
            #line hidden

            #line 61 "..\..\OptionCircle.xaml"
                this.btnCircle.PreviewMouseLeftButtonUp += new System.Windows.Input.MouseButtonEventHandler(this.btnCircle_MouseUp);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
Beispiel #2
0
        /// <summary>
        /// Returns a Windows Media Path Geometry from a Rhinocommon Arc
        /// </summary>
        /// <param name="input">Rhinocommon Arc</param>
        /// <returns>System Windows Media Path Geometry</returns>
        public static Sm.PathGeometry ToGeometry(this Rg.Arc input)
        {
            Sm.ArcSegment            arc               = new Sm.ArcSegment();
            Sm.PathFigure            figure            = new Sm.PathFigure();
            Sm.PathGeometry          geometry          = new Sm.PathGeometry();
            Sm.PathFigureCollection  figureCollection  = new Sm.PathFigureCollection();
            Sm.PathSegmentCollection segmentCollection = new Sm.PathSegmentCollection();

            figure.StartPoint = input.StartPoint.ToWindowsPoint();

            arc.Point = input.EndPoint.ToWindowsPoint();
            arc.Size  = new Sw.Size(input.Radius, input.Radius);
            if (Rg.Vector3d.VectorAngle(input.Plane.Normal, Rg.Vector3d.ZAxis) > 0)
            {
                arc.SweepDirection = Sm.SweepDirection.Counterclockwise;
            }
            else
            {
                arc.SweepDirection = Sm.SweepDirection.Clockwise;
            }
            arc.IsLargeArc = (input.Angle > Math.PI);

            segmentCollection.Add(arc);
            figure.Segments = segmentCollection;
            figureCollection.Add(figure);
            geometry.Figures = figureCollection;

            return(geometry);
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.sceneCanvas = ((System.Windows.Controls.Canvas)(target));

            #line 5 "..\..\MainWindow.xaml"
                this.sceneCanvas.Loaded += new System.Windows.RoutedEventHandler(this.InitScene);

            #line default
            #line hidden

            #line 5 "..\..\MainWindow.xaml"
                this.sceneCanvas.MouseMove += new System.Windows.Input.MouseEventHandler(this.HandleMouseMove);

            #line default
            #line hidden
                return;

            case 2:
                this.ballEllipse = ((System.Windows.Shapes.Ellipse)(target));
                return;

            case 3:
                this.path = ((System.Windows.Shapes.Path)(target));
                return;

            case 4:
                this.PFC = ((System.Windows.Media.PathFigureCollection)(target));
                return;
            }
            this._contentLoaded = true;
        }
Beispiel #4
0
        /// <summary>
        /// 直接根据视图位置,绘制WPF封闭区域;
        /// </summary>
        /// <param name="screenPoints"></param>
        /// <param name="brush"></param>
        /// <param name="pen"></param>
        private void NativeDrawFill(IEnumerable <Point> screenPoints, SystemMedia.Brush brush, SystemMedia.Pen pen)
        {
            if (screenPoints == null)
            {
                throw new ArgumentNullException(nameof(screenPoints));
            }
            if (pen == null)
            {
                throw new ArgumentNullException(nameof(pen));
            }

            ValidateDrawingContext();

            pen.Freeze();



            //操作SystemMedia.PathGeometry中的Figures以绘制(封闭)区域
            var paths = new SystemMedia.PathGeometry();

            var pfc = new SystemMedia.PathFigureCollection();
            var pf  = new SystemMedia.PathFigure();

            pfc.Add(pf);

            //存储一个点表示当前的PathFigure的StartPoint是否被指定;
            var startPointSet = false;

            foreach (var p in screenPoints)
            {
                //若StartPoint未被设定(第一个节点),设定后继续下一次循环;
                if (!startPointSet)
                {
                    pf.StartPoint = p;
                    startPointSet = true;
                    continue;
                }

                //若若StartPoint被设定,则加入线段;
                var ps = new SystemMedia.LineSegment();
                ps.Point = p;
                pf.Segments.Add(ps);
            }


            pf.IsClosed   = true;
            paths.Figures = pfc;
            DrawingContext.DrawGeometry(brush, pen, paths);
        }
Beispiel #5
0
        /// <summary>
        /// Returns a Windows Media Path Geometry from a Rhinocommon Polyline
        /// </summary>
        /// <param name="input">Rhinocommon Polyline</param>
        /// <returns>System Windows Media Path Geometry</returns>
        public static Sm.PathGeometry ToGeometry(this Rg.Polyline input)
        {
            Sm.PathFigure            figure            = new Sm.PathFigure();
            Sm.PathGeometry          geometry          = new Sm.PathGeometry();
            Sm.PathFigureCollection  figureCollection  = new Sm.PathFigureCollection();
            Sm.PathSegmentCollection segmentCollection = new Sm.PathSegmentCollection();

            figure.StartPoint = input[0].ToWindowsPoint();
            for (int i = 1; i < input.Count; i++)
            {
                Sm.LineSegment line = new Sm.LineSegment(input[i].ToWindowsPoint(), true);
                segmentCollection.Add(line);
            }

            figure.Segments = segmentCollection;
            figureCollection.Add(figure);
            geometry.Figures = figureCollection;

            return(geometry);
        }
        /// <summary>
        /// Returns true if this type converter can convert to the given type.
        /// </summary>
        /// <returns>
        /// bool - True if this converter can convert to the provided type, false if not.
        /// </returns>
        /// <param name="context"> The ITypeDescriptorContext for this call. </param>
        /// <param name="destinationType"> The Type being queried for support. </param>
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                // When invoked by the serialization engine we can convert to string only for some instances
                if (context != null && context.Instance != null)
                {
                    if (!(context.Instance is PathFigureCollection))
                    {
                        throw new ArgumentException(SR.Get(SRID.General_Expected_Type, "PathFigureCollection"), "context");
                    }

                    PathFigureCollection value = (PathFigureCollection)context.Instance;

                    #pragma warning suppress 6506 // value is obviously not null
                    return(value.CanSerializeToString());
                }

                return(true);
            }

            return(base.CanConvertTo(context, destinationType));
        }
Beispiel #7
0
        /// <summary>
        /// Equilateral triangle of side 'sideLength', centered on the same point as if a circle of diameter 'sideLength' was there
        /// </summary>
        private static XamlMedia.PathGeometry CreateTriangle(double sideLength)
        {
            var altitude     = Math.Sqrt(3) / 2.0 * sideLength;
            var inradius     = altitude / 3.0;
            var circumradius = 2.0 * inradius;

            var top   = new XamlPoint(0, -circumradius);
            var left  = new XamlPoint(sideLength * -0.5, inradius);
            var right = new XamlPoint(sideLength * 0.5, inradius);

            var segments = new XamlMedia.PathSegmentCollection();

            segments.Add(new XamlMedia.LineSegment(left, true));
            segments.Add(new XamlMedia.LineSegment(right, true));
            var figure  = new XamlMedia.PathFigure(top, segments, true);
            var figures = new XamlMedia.PathFigureCollection();

            figures.Add(figure);

            return(new XamlMedia.PathGeometry
            {
                Figures = figures
            });
        }
Beispiel #8
0
        /// <summary>
        /// Returns a Windows Media Bezier Spline Path Geometry from a Rhinocommon Curve
        /// </summary>
        /// <param name="input">Rhinocommon Curve</param>
        /// <returns>System Windows Media Bezier Curve Path Geometry </returns>
        public static Sm.PathGeometry ToGeometry(this Rg.Curve input)
        {
            Rg.NurbsCurve nurbsCurve = input.ToNurbsCurve();
            nurbsCurve.MakePiecewiseBezier(true);
            Rg.BezierCurve[] bezier = Rg.BezierCurve.CreateCubicBeziers(nurbsCurve, 0, 0);

            Sm.PathFigure            figure            = new Sm.PathFigure();
            Sm.PathGeometry          geometry          = new Sm.PathGeometry();
            Sm.PathFigureCollection  figureCollection  = new Sm.PathFigureCollection();
            Sm.PathSegmentCollection segmentCollection = new Sm.PathSegmentCollection();

            figure.StartPoint = bezier[0].GetControlVertex3d(0).ToWindowsPoint();
            for (int i = 0; i < bezier.Count(); i++)
            {
                Sm.BezierSegment segment = new Sm.BezierSegment(bezier[i].GetControlVertex3d(1).ToWindowsPoint(), bezier[i].GetControlVertex3d(2).ToWindowsPoint(), bezier[i].GetControlVertex3d(3).ToWindowsPoint(), true);
                segmentCollection.Add(segment);
            }

            figure.Segments = segmentCollection;
            figureCollection.Add(figure);
            geometry.Figures = figureCollection;

            return(geometry);
        }
Beispiel #9
0
        /// <summary>
        /// Returns true if this geometry is empty
        /// </summary>
        public override bool IsEmpty()
        {
            PathFigureCollection figures = Figures;

            return((figures == null) || (figures.Count <= 0));
        }
Beispiel #10
0
 ///<summary>
 /// Constructor
 ///</summary>
 internal FigureList()
 {
     _figures = new PathFigureCollection();
 }
Beispiel #11
0
        internal override PathFigureCollection GetTransformedFigureCollection(Transform transform)
        {
            if (IsEmpty())
            {
                return(null);
            }

            // Combine the transform argument with the internal transform
            Matrix matrix = GetCombinedMatrix(transform);

            double radiusX = RadiusX;
            double radiusY = RadiusY;
            Rect   rect    = Rect;

            if (IsRounded(radiusX, radiusY))
            {
                Point[] points = GetPointList(rect, radiusX, radiusY);

                // Transform if applicable.
                if (!matrix.IsIdentity)
                {
                    for (int i = 0; i < points.Length; i++)
                    {
                        points[i] *= matrix;
                    }
                }

                PathFigureCollection collection = new PathFigureCollection();
                collection.Add(
                    new PathFigure(
                        points[0],
                        new PathSegment[] {
                    new BezierSegment(points[1], points[2], points[3], true, true),
                    new LineSegment(points[4], true, true),
                    new BezierSegment(points[5], points[6], points[7], true, true),
                    new LineSegment(points[8], true, true),
                    new BezierSegment(points[9], points[10], points[11], true, true),
                    new LineSegment(points[12], true, true),
                    new BezierSegment(points[13], points[14], points[15], true, true)
                },
                        true    // closed
                        )
                    );

                return(collection);
            }
            else
            {
                PathFigureCollection collection = new PathFigureCollection();
                collection.Add(
                    new PathFigure(
                        rect.TopLeft * matrix,
                        new PathSegment[] {
                    new PolyLineSegment(
                        new Point[]
                    {
                        rect.TopRight *matrix,
                        rect.BottomRight *matrix,
                        rect.BottomLeft *matrix
                    },
                        true)
                },
                        true    // closed
                        )
                    );

                return(collection);
            }
        }
Beispiel #12
0
 public PathGeometry(IEnumerable <PathFigure> figures, FillRule fillRule, Transform transform)
 {
     Figures   = new PathFigureCollection(figures);
     FillRule  = fillRule;
     Transform = transform;
 }
Beispiel #13
0
 public PathGeometry(IEnumerable <PathFigure> figures)
 {
     Figures = new PathFigureCollection(figures);
 }