Ejemplo n.º 1
0
        public RingColorPicker()
        {
            InitializeComponent();

            if (_colorMap == null)
            {
                _colorMap = MakeHueRountRect(CANVAS_WIDTH, CANVAS_HEIGHT);
            }

            Ring.Source = _colorMap;

            var pg = new PathGeometry();

            pg.AddGeometry(new EllipseGeometry(new Rect(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT)));
            double xCenter = CANVAS_WIDTH / 2.0;
            double yCenter = CANVAS_HEIGHT / 2.0;
            double xRadius = xCenter - RING_THICKNESS;
            double yRadius = yCenter - RING_THICKNESS;

            pg.AddGeometry(new EllipseGeometry(new Point(xCenter, yCenter), xRadius, yRadius));

            Ring.Clip = pg;
            SyncColor(null);

            MouseDown += RingColorPicker_MouseDown;
            MouseMove += RingColorPicker_MouseMove;
            MouseUp   += RingColorPicker_MouseUp;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Построение геометрической информации
        /// </summary>
        /// <param name="srcGraphic">исходный двумерный график</param>
        /// <param name="rect">область вывода на экране</param>
        /// <returns>геометрическиая информация</returns>
        public static PathGeometry ConstructGeometry(GeometryGraphic srcGraphic, Rect rect, TimeSpan leftTimeBorder, TimeSpan rightTimeBorder)
        {
            PathGeometry PtColl = new PathGeometry();

            if (srcGraphic.Points.Count == 0)
            {
                return(PtColl);
            }
            GeometryPoint prevPt = srcGraphic.Points[0];

            if ((prevPt.SourcePoint.Time.CompareTo(leftTimeBorder) >= 0) && (prevPt.SourcePoint.Time.CompareTo(rightTimeBorder) <= 0))
            {
                PtColl.AddGeometry(new EllipseGeometry(prevPt.Position, 1, 1));
            }
            foreach (GeometryPoint item in srcGraphic.Points)
            {
                if (prevPt.Y != item.Y)
                {
                    if ((prevPt.SourcePoint.Time.CompareTo(leftTimeBorder) >= 0) && (prevPt.SourcePoint.Time.CompareTo(rightTimeBorder) <= 0))
                    {
                        PtColl.AddGeometry(new EllipseGeometry(item.Position, 1, 1));
                    }
                    prevPt = item;
                }
            }
            return(PtColl);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Создание Фигуры
        /// </summary>
        /// <returns></returns>
        public Path MakeFigure()
        {
            //TODO

            //Реализовать рисовалку
            Tochka LeftTop     = this.LeftTop3D.To2D;
            Tochka LeftBottom  = this.LeftBot3D.To2D;
            Tochka RightBottom = this.RightBot3D.To2D;
            Tochka RightTop    = this.RightTop3D.To2D;
            //Создаем коллекцию для хранения геометрии
            PathGeometry myPathG = new PathGeometry();
            Path         mypath  = new Path();

            mypath.Stroke          = Brushes.White;
            mypath.StrokeThickness = 1;
            //Рисуем две опорные линии
            myPathG.AddGeometry(DrowLine(LeftTop, RightTop));
            myPathG.AddGeometry(DrowLine(LeftBottom, RightBottom));
            //Создаем списки точек на линиях
            List <Tochka> top = Grid(LeftTop, RightTop, 20);
            List <Tochka> bot = Grid(RightBottom, LeftBottom, 20);

            //Рисуем опорные линии
            for (int i = 0; i < top.Count; i++)
            {
                myPathG.AddGeometry(DrowLine(top[i], bot[i]));
            }

            mypath.Data = myPathG;
            return(mypath);
        }
Ejemplo n.º 4
0
        private void Referesh(spatial.Point[] points, Canvas canvas)
        {
            ClearCanvas(canvas, "data");

            PathGeometry    geo  = new PathGeometry();
            EllipseGeometry temp = new EllipseGeometry(new Point(points[0].X, points[0].Y), 3, 3);

            geo.AddGeometry(temp);

            for (int i = 1; i < points.Length; i++)
            {
                geo.AddGeometry(new EllipseGeometry(new Point(points[i].X, points[i].Y), 3, 3));

                Line line = new Line()
                {
                    X1 = points[i - 1].X, X2 = points[i].X, Y1 = points[i - 1].Y, Y2 = points[i].Y, Stroke = Brushes.Green, StrokeThickness = 1, Tag = "data"
                };

                canvas.Children.Add(line);
            }

            Path path = new Path()
            {
                Data = geo, Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 2, Tag = "data"
            };

            canvas.Children.Add(path);
        }
Ejemplo n.º 5
0
        static public bool edge_rendering_delegate(Edge edge, object edgeLine_path)
        {
            Path   path = edgeLine_path as Path;
            ICurve cv   = edge.EdgeCurve;

            var   t_middle = cv.GetParameterAtLength(cv.Length / 2);
            var   dva = cv.Derivative(t_middle); //求中点的导数
            var   midPoint = cv[t_middle];       // Common.WpfPoint( cv[t_middle]);
            float x = (float)midPoint.X, y = (float)midPoint.Y;

            var                   geo2    = DataDefine.get_svg2();
            MatrixTransform       mt      = new MatrixTransform();
            Func <double, double> rad2Deg = v => { return(v * 180 / Math.PI); };
            //mt.Matrix.
            var deg = rad2Deg(Math.Atan2(dva.Y, dva.X));
            var mat = Matrix.Identity;

            mat.TranslatePrepend(x, y);
            mat.RotatePrepend(deg);
            mat.ScalePrepend(-0.2f, 0.2f);
            mt.Matrix      = mat;
            geo2.Transform = mt;

            var          circle = new EllipseGeometry(new WpfPoint(x, y), 2, 2);
            PathGeometry pp     = new PathGeometry();

            pp.FillRule = FillRule.EvenOdd;

            pp.AddGeometry(Common.GetICurveWpfGeometry(cv));
            pp.AddGeometry(circle);
            pp.AddGeometry(geo2);
            path.Data = pp;

            return(true);
        }
        /// <summary>Raises the <see cref="E:System.Windows.FrameworkElement.SizeChanged" /> event, using the specified information as part of the eventual event data. </summary>
        /// <param name="sizeInfo">Details of the old and new size involved in the change.</param>
        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
        {
            base.OnRenderSizeChanged(sizeInfo);
            var pathGeometry = new PathGeometry();

            pathGeometry.AddGeometry(new LineGeometry()
            {
                StartPoint = new Point(0, 0),
                EndPoint   = new Point(RenderSize.Width, 0)
            });
            pathGeometry.AddGeometry(new LineGeometry()
            {
                StartPoint = new Point(RenderSize.Width, 0),
                EndPoint   = new Point(RenderSize.Width, RenderSize.Height)
            });
            pathGeometry.AddGeometry(new LineGeometry()
            {
                StartPoint = new Point(RenderSize.Width, RenderSize.Height),
                EndPoint   = new Point(0, RenderSize.Height)
            });
            pathGeometry.AddGeometry(new LineGeometry()
            {
                StartPoint = new Point(0, RenderSize.Height),
                EndPoint   = new Point(0, 0)
            });
            AnimationData = pathGeometry;
        }
Ejemplo n.º 7
0
        public static PathGeometry ArrowGeometry(Point start, Point end)
        {
            PathGeometry geometry = new PathGeometry();

            geometry.Figures.Add(Utils.ArrowPathFigure(start, end));
            geometry.AddGeometry(new EllipseGeometry(start, 1.5, 1.5));
            geometry.AddGeometry(new EllipseGeometry(end, 0.5, 0.5));
            return(geometry);
        }
Ejemplo n.º 8
0
        protected override void OnRender(DrawingContext drawingContext)
        {
            base.OnRender(drawingContext);
            if (hexBox.Selection == null || hexBox.VisibleBytesPerLine < 1)
            {
                return;
            }

            ulong selStart     = hexBox.Selection.Value.StartOffset;
            ulong selEnd       = hexBox.Selection.Value.EndOffset;
            int   lines        = hexBox.VisibleLinesPerPage;
            ulong bpl          = (ulong)hexBox.VisibleBytesPerLine;
            ulong visibleStart = hexBox.TopOffset;
            ulong visibleEnd   = NumberUtils.AddUInt64(NumberUtils.AddUInt64(visibleStart, NumberUtils.MulUInt64(bpl, NumberUtils.SubUInt64((ulong)lines, 1))), NumberUtils.SubUInt64(bpl, 1));

            if (selStart > visibleEnd || selEnd < visibleStart)
            {
                return;
            }

            ulong  offset    = Math.Max(selStart, visibleStart);
            ulong  endOffset = Math.Min(selEnd, visibleEnd);
            double x         = -hexBox.CharacterWidth * hexBox.LeftColumn;
            double y         = (offset - hexBox.TopOffset) / bpl * hexBox.CharacterHeight;
            var    path      = new PathGeometry();
            double hexByteX  = hexBox.GetHexByteColumnIndex() * hexBox.CharacterWidth;
            double asciiX    = hexBox.GetAsciiColumnIndex() * hexBox.CharacterWidth;

            while (offset <= endOffset)
            {
                ulong byteIndex = hexBox.GetLineByteIndex(offset);
                ulong count     = Math.Min(bpl - byteIndex, endOffset - offset + 1);

                double dx      = byteIndex * hexBox.CharacterWidth;
                var    rectGeo = new RectangleGeometry(new Rect(x + dx * 3 + hexByteX + hexBox.CharacterWidth, y, count * hexBox.CharacterWidth * 3 - hexBox.CharacterWidth, hexBox.CharacterHeight));
                rectGeo.Freeze();
                path.AddGeometry(rectGeo);

                if (hexBox.ShowAscii)
                {
                    rectGeo = new RectangleGeometry(new Rect(x + dx + asciiX, y, count * hexBox.CharacterWidth, hexBox.CharacterHeight));
                    rectGeo.Freeze();
                    path.AddGeometry(rectGeo);
                }

                if (offset + bpl - byteIndex < offset)
                {
                    break;
                }
                offset += bpl - byteIndex;
                y      += hexBox.CharacterHeight;
            }

            path.Freeze();
            drawingContext.DrawGeometry(Background, null, path);
        }
Ejemplo n.º 9
0
        //方向線表示用PathGeometry作成
        private PathGeometry MakeDirectionLinePathGeometry(Path bezier)
        {
            PointCollection segmentPoint = GetPolyBezierSegmentPoints(bezier);
            var             pg           = new PathGeometry();

            for (int i = 2; i < segmentPoint.Count - 1; i += 3)
            {
                pg.AddGeometry(new LineGeometry(segmentPoint[i], segmentPoint[i - 1]));
                pg.AddGeometry(new LineGeometry(segmentPoint[i], segmentPoint[i + 1]));
            }
            return(pg);
        }
Ejemplo n.º 10
0
        Geometry DoubleCircle()
        {
            double w            = Node.BoundingBox.Width;
            double h            = Node.BoundingBox.Height;
            var    pathGeometry = new PathGeometry();
            var    r            = new Rect(-w / 2, -h / 2, w, h);

            pathGeometry.AddGeometry(new EllipseGeometry(r));
            r.Inflate(-5, -5);
            pathGeometry.AddGeometry(new EllipseGeometry(r));
            return(pathGeometry);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Creates an image of a Subtractor
        /// </summary>
        /// <param name="bounds">The desired bounds of the image</param>
        /// <param name="fillBrush">The brush for the interior of the shape</param>
        /// <param name="pen">The pen for the borders of the shape</param>
        /// <returns>A GeometryDrawing of the gate</returns>
        private GeometryDrawing DrawSubtractor(Rect bounds, Brush fillBrush, Pen pen)
        {
            double radius = Math.Min(bounds.Height, bounds.Width) / 2;

            LineGeometry      line  = new LineGeometry(new Point(bounds.Left + bounds.Width / 2 - radius / 2, bounds.Top + bounds.Height / 2), new Point(bounds.Left + bounds.Width / 2 + radius / 2, bounds.Top + bounds.Height / 2));
            PathGeometry      shape = new PathGeometry();
            RectangleGeometry rect  = new RectangleGeometry(bounds);

            shape.AddGeometry(line);
            shape.AddGeometry(rect);

            return(new GeometryDrawing(fillBrush, pen, shape));
        }
Ejemplo n.º 12
0
        //確認用方向線表示
        private void InitializeLinePath()
        {
            PointCollection segmentPoint = GetPolyBezierSegmentPoints(MyBezierPath);
            var             pg           = new PathGeometry();

            for (int i = 2; i < segmentPoint.Count - 1; i += 3)
            {
                pg.AddGeometry(new LineGeometry(segmentPoint[i], segmentPoint[i - 1]));
                pg.AddGeometry(new LineGeometry(segmentPoint[i], segmentPoint[i + 1]));
            }
            ControlLinePath.Data   = pg;
            ControlLinePath.Stroke = Brushes.DeepPink;
        }
Ejemplo n.º 13
0
        Geometry DoubleCircle()
        {
            var    box          = Node.BoundingBox;
            double w            = box.Width;
            double h            = box.Height;
            var    pathGeometry = new PathGeometry();
            var    r            = new Rect(box.Left, box.Bottom, w, h);

            pathGeometry.AddGeometry(new EllipseGeometry(r));
            var inflation = Math.Min(5.0, Math.Min(w / 3, h / 3));

            r.Inflate(-inflation, -inflation);
            pathGeometry.AddGeometry(new EllipseGeometry(r));
            return(pathGeometry);
        }
Ejemplo n.º 14
0
        private static Geometry Music(PathFigureCollection pFc, PathGeometry pG)
        {
            AddVLine(new Point(30, 65), 65, pFc);
            AddVLine(new Point(100, 85), 65, pFc);
            AddLine(new Point(30, 0), new Point(100, 20), pFc);
            AddLine(new Point(30, 20), new Point(100, 40), pFc);

            pG.Figures = pFc;
            const int r = 15;

            pG.AddGeometry(new EllipseGeometry(new Point(15, 65), r, r));
            pG.AddGeometry(new EllipseGeometry(new Point(85, 85), r, r));

            return(pG);
        }
Ejemplo n.º 15
0
        public static VectorXaml GetVectorXaml(IEnumerable <string> pathCollection, Brush overrideFill)
        {
            var pathGeometryContainer   = new VectorContainer();
            var streamGeometryContainer = new VectorContainer();
            var pathGeometry            = new PathGeometry();

            foreach (var pathString in pathCollection)
            {
                var path = (Path)XamlReader.Parse(pathString);

                if (overrideFill != Brushes.Transparent && (path.Fill == null || path.Fill.Equals(Brushes.Transparent)))
                {
                    path.Fill = overrideFill;
                }

                pathGeometryContainer.AddToContainer(path);
                pathGeometry.AddGeometry(path.Data);
            }
            streamGeometryContainer.AddToContainer(new Path {
                Data = pathGeometry.Clone()
            });
            var pathData = pathGeometry.ToString();

            return(new VectorXaml
            {
                PathData = pathData,
                PathGeometryXaml = XamlWriter.Save(pathGeometryContainer.Container),
                StreamGeometryXaml = XamlWriter.Save(streamGeometryContainer.Container),
                XamlObject = pathGeometryContainer.Container
            });
        }
Ejemplo n.º 16
0
        protected override void EndEditingInternal(bool pathJustCreated)
        {
            PathGeometry pathGeometry1 = PathGeometryUtilities.Copy(this.PathGeometry, false);
            bool         isAnimated    = this.IsAnimated;

            if (!isAnimated && this.ViewModel.AnimationEditor.IsKeyFraming)
            {
                System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry) this.editingElement.GetComputedValueAsWpf(Base2DElement.ClipProperty);
                PathGeometry geometry2 = new PathGeometry();
                if (geometry1 != null)
                {
                    geometry2.AddGeometry(geometry1);
                }
                PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(geometry2);
                SceneNode sceneNode = this.editingElement.ViewModel.CreateSceneNode(this.editingElement.ViewModel.DefaultView.ConvertFromWpfValue((object)geometry2));
                sceneNode.SetLocalValueAsWpf(DesignTimeProperties.IsAnimatedProperty, (object)true);
                this.editingElement.SetValueAsSceneNode(Base2DElement.ClipProperty, sceneNode);
                this.editingElement.ViewModel.Document.OnUpdatedEditTransaction();
            }
            if (this.EditingElement.IsAttached && (this.ViewModel.AnimationEditor.IsKeyFraming || isAnimated))
            {
                new PathDiff(this.EditingElement, Base2DElement.ClipProperty, this.PathDiffChangeList).SetPathUsingMinimalDiff(pathGeometry1);
            }
            else
            {
                PathGeometry pathGeometry2 = PathGeometryUtilities.RemoveMapping(pathGeometry1, true);
                this.EditingElement.SetValueAsWpf(Base2DElement.ClipProperty, (object)pathGeometry2);
            }
        }
Ejemplo n.º 17
0
        public static Geometry GetMarkerGeometryFromRectangles(IList <Rect> rectangles)
        {
            Debug.Assert(rectangles != null);

            if (rectangles.Count == 0)
            {
                return(null);
            }

            // Set up the initial geometry
            PathGeometry geometry = new PathGeometry();

            geometry.FillRule = FillRule.Nonzero;

            foreach (var rectangle in rectangles)
            {
                geometry.AddGeometry(new RectangleGeometry(rectangle));
            }
            geometry.Freeze();

            if (rectangles.Count > 1)
            {
                geometry = geometry.GetOutlinedPathGeometry();
                geometry.Freeze();
            }
            return(geometry);
        }
Ejemplo n.º 18
0
        public override PathGeometry Build(SvgTextContentElement element, string text, double x, double y)
        {
            ComputeMeasurement(text, x, y);

            _textWidth = 0;

            if (_glyphRun == null)
            {
                return(new PathGeometry());
            }

            // Approximate the width of the text...
            Rect designRect = _glyphRun.ComputeAlignmentBox();

            designRect.Offset(_glyphRunOrigin.X, _glyphRunOrigin.Y);

            _textWidth = Math.Max(0, designRect.Right);

            PathGeometry pathGeometry = null;

            var geometry = _glyphRun.BuildGeometry();

            if (geometry is PathGeometry)
            {
                pathGeometry = (PathGeometry)geometry;
            }
            else
            {
                pathGeometry = new PathGeometry();
                pathGeometry.AddGeometry(geometry);
            }

            return(pathGeometry);
        }
Ejemplo n.º 19
0
        private static Drawing SimplifyGeometryDrawing(GeometryDrawing geometryDrawing)
        {
            bool flag = geometryDrawing.Pen == null || geometryDrawing.Pen.Thickness == 0.0;

            if (geometryDrawing.Geometry == null || geometryDrawing.Geometry.IsEmpty() || geometryDrawing.Brush == null && flag)
            {
                return((Drawing)null);
            }
            System.Windows.Media.Geometry geometry = geometryDrawing.Geometry;
            if (geometry is StreamGeometry && geometry.Transform != null && !geometry.Transform.Value.IsIdentity)
            {
                PathGeometry pathGeometry = new PathGeometry();
                pathGeometry.AddGeometry(geometry);
                geometryDrawing.Geometry = (System.Windows.Media.Geometry)pathGeometry;
            }
            if (geometryDrawing.Brush == null)
            {
                geometryDrawing.ClearValue(GeometryDrawing.BrushProperty);
            }
            if (flag)
            {
                geometryDrawing.ClearValue(GeometryDrawing.PenProperty);
            }
            return((Drawing)geometryDrawing);
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Constructor. Initializes all the class fields.
        /// </summary>
        public XYLineChart()
        {
            // This assumes that you are navigating to this scene.
            // If you will normally instantiate it via code and display it
            // manually, you either have to call InitializeComponent by hand or
            // uncomment the following line.

            InitializeComponent();

            primitiveList = new List <ChartPrimitive>();

            // Set the Chart Geometry Clip region
            chartClip = new PathGeometry();
            chartClip.AddGeometry(
                new RectangleGeometry(new Rect(0, 0, clippedPlotCanvas.ActualWidth, clippedPlotCanvas.ActualHeight)));
            shapeTransform = new MatrixTransform();
            adorner        = new AdornerCursorCoordinateDrawer(this, clippedPlotCanvas, shapeTransform);

            optimalGridLineSpacing = new Point(150, 75);

            panZoomCalculator =
                new PanZoomCalculator(new Rect(0, 0, clippedPlotCanvas.ActualWidth, clippedPlotCanvas.ActualHeight));
            panZoomCalculator.Window          = new Rect(0, 0, clippedPlotCanvas.ActualWidth, clippedPlotCanvas.ActualHeight);
            panZoomCalculator.PanZoomChanged += panZoomCalculator_PanZoomChanged;

            closestPointPicker = new ClosestPointPicker(new Size(13, 13));
            closestPointPicker.ClosestPointChanged += closestPointPicker_ClosestPointChanged;

            Cursor = Cursors.None;

            // Set up all the message handlers for the clipped plot canvas
            AttachEventsToCanvas(this);
            clippedPlotCanvas.IsVisibleChanged += clippedPlotCanvas_IsVisibleChanged;
            clippedPlotCanvas.SizeChanged      += clippedPlotCanvas_SizeChanged;
        }
Ejemplo n.º 21
0
        public static PathGeometry RemoveDegeneratePoints(System.Windows.Media.Geometry geometry)
        {
            if (geometry == null)
            {
                return((PathGeometry)null);
            }
            PathGeometry pathGeometry1 = new PathGeometry();

            pathGeometry1.AddGeometry(geometry);
            PathGeometry pathGeometry2 = geometry as PathGeometry;

            if (pathGeometry2 != null)
            {
                pathGeometry1.FillRule = pathGeometry2.FillRule;
            }
            for (int index = 0; index < pathGeometry1.Figures.Count; ++index)
            {
                PathFigure pathFigure = pathGeometry1.Figures[index];
                if (pathFigure.IsFrozen)
                {
                    pathFigure = pathFigure.Clone();
                    pathGeometry1.Figures[index] = pathFigure;
                }
                PathConversionHelper.ReplacePolySegments(pathFigure.Segments);
                bool removeInvisible = true;
                PathConversionHelper.RemoveDegenerateSegments(pathFigure, removeInvisible);
                if (pathFigure.Segments.Count == 0)
                {
                    pathGeometry1.Figures.RemoveAt(index--);
                }
            }
            return(pathGeometry1);
        }
Ejemplo n.º 22
0
        private static void AddRect(Rect box, PathGeometry geom)
        {
            var loota = new RectangleGeometry();

            loota.Rect = box;
            geom.AddGeometry(loota);
        }
Ejemplo n.º 23
0
        public MainWindow()
        {
            InitializeComponent();

            _squres = new Squre [3, 3];
            PathGeometry board = new PathGeometry();

            int id = 0;

            for (int i = 0; i < 90; i += 30)
            {
                for (int j = 0; j < 90; j += 30)
                {
                    Rect temp = new Rect(j, i, 30, 30);
                    _squres[i / 30, j / 30] = new Squre(temp, id);
                    board.AddGeometry(new RectangleGeometry(temp));
                    id++;
                }
            }

            Path path = new Path
            {
                Fill            = Brushes.AliceBlue,
                Stroke          = Brushes.Black,
                StrokeThickness = 1,
                Data            = board
            };

            chessBoard.Children.Add(path);
        }
Ejemplo n.º 24
0
        //色相範囲ごとに仕分けられたListから🍕pie形のPathGeometry作成
        private Geometry MakeClip(int[] hues)
        {
            double max = hues.Max();

            //無彩色画像はmaxが0になっているはず、なので全クリップを返して終わり
            if (max == 0)
            {
                return(new RectangleGeometry(new Rect(0, 0, 0, 0)));
            }

            Point  center    = new Point(MyRadius, MyRadius);
            double divDeg    = 360.0 / hues.Length; //  1分割あたりの角度
            double divdivDeg = divDeg / 2.0;        //その半分の角度
            //各分割角度を中心にして、そこから均等に左右に分けるために使う

            var clip = new PathGeometry();

            clip.FillRule = FillRule.Nonzero;
            for (int i = 0; i < hues.Length; i++)
            {
                var distance  = hues[i] / max * MyRadius; //最大値からの割合を距離にする
                var centerDeg = i * divDeg;               //範囲の中間角度、配列のIndexが色相(角度)の割合になっている
                var start     = centerDeg - divdivDeg;    //範囲の半分の角度マイナスが開始角度になる
                var stop      = start + divDeg;
                //🍕PathGeometry作成して追加
                clip.AddGeometry(PieGeometry(center, distance, start, stop, SweepDirection.Clockwise));
            }
            return(clip);
        }
Ejemplo n.º 25
0
        private Geometry CreateVisuals(SnapshotPoint opening, SnapshotPoint closing, SnapshotPoint caret)
        {
            var openLine  = this.view.TextViewLines.GetTextViewLineContainingBufferPosition(opening);
            var closeLine = this.view.TextViewLines.GetTextViewLineContainingBufferPosition(closing);

            IList <LinePoint> points = null;

            if (openLine != null && closeLine != null && openLine.Extent == closeLine.Extent)
            {
                points = SingleLineSpan(opening, closing);
            }
            else
            {
                points = MultiLineSpan(opening, closing);
            }
            if (points.Count == 0)
            {
                return(null);
            }
            PathGeometry geometry = new PathGeometry();
            LinePoint    p        = points[0];

            for (int i = 1; i < points.Count; i++)
            {
                var p1 = points[i];
                if (!p.SkipNext)
                {
                    geometry.AddGeometry(new LineGeometry(p, p1));
                }
                p = p1;
            }
            return(geometry);
        }
Ejemplo n.º 26
0
        //●のGeometryを1つのPathにまとめて表示
        private void AddEllipsePoints2()
        {
            if (MyListPolyline.Count == 0)
            {
                return;
            }
            ClearEllipsePoints();

            var pg   = new PathGeometry();
            var path = new Path();

            path.Fill   = Brushes.Orange;
            path.Stroke = Brushes.Yellow;
            MyCanvas.Children.Add(path);
            MyListEllipsePath.Add(path);
            path.Data   = pg;
            pg.FillRule = FillRule.Nonzero;

            PointCollection ps;

            for (int i = 0; i < MyListPolyline.Count; i++)
            {
                ps = MyListPolyline[i].Points;
                for (int j = 0; j < ps.Count; j++)
                {
                    pg.AddGeometry(new EllipseGeometry(ps[j], 2, 2));
                }
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Draws an image of a NOR gate
        /// </summary>
        /// <param name="bounds">The desired bounds of the image</param>
        /// <param name="fillBrush">The brush for the interior of the shape</param>
        /// <param name="pen">The pen for the borders of the shape</param>
        /// <returns>A GeometryDrawing of the gate</returns>
        private GeometryDrawing DrawNor(Rect bounds, Brush fillBrush, Pen pen)
        {
            double radius = bounds.Width / widthToRadius;

            ArcSegment arc1 = new ArcSegment(bounds.BottomLeft, new Size(bounds.Height * backCurveDepth, bounds.Height), 0, false, SweepDirection.Clockwise, true);
            ArcSegment arc2 = new ArcSegment(new Point(bounds.Right - radius * 2, bounds.Top + bounds.Height / 2), new Size(bounds.Width, bounds.Height / 2),
                                             360 - tilt, false, SweepDirection.Counterclockwise, true);
            ArcSegment arc3 = new ArcSegment(bounds.TopLeft, new Size(bounds.Width, bounds.Height / 2), tilt, false, SweepDirection.Counterclockwise, true);

            PathFigure path = new PathFigure();

            path.StartPoint = bounds.TopLeft;
            path.Segments.Add(arc1);
            path.Segments.Add(arc2);
            path.Segments.Add(arc3);

            PathGeometry shape = new PathGeometry();

            shape.Figures.Add(path);

            EllipseGeometry circle = new EllipseGeometry(new Point(bounds.Right - radius, bounds.Top + bounds.Height / 2), radius, radius);

            shape.AddGeometry(circle);

            return(new GeometryDrawing(fillBrush, pen, shape));
        }
Ejemplo n.º 28
0
        public override void Draw(Canvas canvas, double scale)
        {
            if (!IsVisible)
            {
                return;
            }
            var pg = new PathGeometry();
            var dy = M1.Point.Y - M2.Point.Y;
            var dx = M1.Point.X - M2.Point.X;
            var d  = Math.Sqrt(dx * dx + dy * dy);
            var p1 = M1.Point;

            p1.Offset(960 * dx / d, 960 * dy / d);
            var p2 = M2.Point;

            p2.Offset(-960 * dx / d, -960 * dy / d);
            pg.AddGeometry(new LineGeometry(p1, p2));
            pg.Transform = new MatrixTransform(scale, 0, 0, scale, 0, 0);
            canvas.Children.Add(
                new Path {
                Data   = pg,
                Stroke = Brush
            });
            var label = new TextBlock {
                Text = Id, Foreground = Brush, Background = Background, Padding = Padding
            };

            Canvas.SetTop(label, (M1.Point.Y + 48 * dy / d) * scale);
            Canvas.SetLeft(label, (M1.Point.X + 48 * dx / d) * scale);
            canvas.Children.Add(label);
        }
Ejemplo n.º 29
0
 public static void AdjustPathForAnimations(PathElement pathElement, SceneEditTransaction editTransaction)
 {
     using (pathElement.ViewModel.ForceBaseValue())
     {
         System.Windows.Media.Geometry geometry1 = (System.Windows.Media.Geometry)pathElement.GetLocalOrDefaultValueAsWpf(PathElement.DataProperty);
         PathGeometry pathGeometry = new PathGeometry();
         pathGeometry.AddGeometry(geometry1);
         Rect bounds = PathCommandHelper.InflateRectByStrokeWidth(pathGeometry.Bounds, pathElement, false);
         PropertyReference propertyReference = PathCommandHelper.GetPathDataPropertyReference(pathElement.Platform);
         Rect            maxAnimatedExtent   = PathCommandHelper.FindMaxAnimatedExtent((SceneElement)pathElement, bounds, propertyReference);
         double          num1             = Math.Min(0.0, maxAnimatedExtent.Left);
         double          num2             = Math.Min(0.0, maxAnimatedExtent.Top);
         Vector          vector           = new Vector(-num1, -num2);
         ILayoutDesigner designerForChild = pathElement.ViewModel.GetLayoutDesignerForChild((SceneElement)pathElement, true);
         editTransaction.Update();
         Rect childRect = designerForChild.GetChildRect((BaseFrameworkElement)pathElement);
         childRect.X     += num1;
         childRect.Y     += num2;
         childRect.Width  = Math.Max(maxAnimatedExtent.Width, childRect.Width);
         childRect.Height = Math.Max(maxAnimatedExtent.Height, childRect.Height);
         designerForChild.SetChildRect((BaseFrameworkElement)pathElement, childRect);
         Transform    transform = (Transform) new TranslateTransform(vector.X, vector.Y);
         PathGeometry geometry2 = PathGeometryUtilities.TransformGeometry((System.Windows.Media.Geometry)pathGeometry, transform);
         if (!pathElement.DesignerContext.ActiveDocument.ProjectContext.IsCapabilitySet(PlatformCapability.IsWpf))
         {
             PathGeometryUtilities.EnsureOnlySingleSegmentsInGeometry(geometry2);
         }
         pathElement.PathGeometry = geometry2;
         PathCommandHelper.TransformPointKeyframes((SceneElement)pathElement, propertyReference, transform);
         pathElement.SetValueAsWpf(ShapeElement.StretchProperty, (object)(Stretch)(pathElement.HasVertexAnimations ? 0 : 1));
     }
 }
        public string CreatePhase(int width = 400, int height = 200)
        {
            PathGeometry pg         = new PathGeometry();
            PathFigure   pathFigure = new PathFigure();

            pathFigure.StartPoint = new Point(0, 0);
            pathFigure.IsClosed   = true;

            LineSegment ls = new LineSegment();

            ls.Point = new Point(width, 0);
            pathFigure.Segments.Add(ls);

            LineSegment ls1 = new LineSegment();

            ls1.Point = new Point(width, height);
            pathFigure.Segments.Add(ls1);

            LineSegment ls2 = new LineSegment();

            ls2.Point = new Point(0, height);
            pathFigure.Segments.Add(ls2);
            pg.Figures.Add(pathFigure);

            LineGeometry myLineGeometry = new LineGeometry();

            myLineGeometry.StartPoint = new Point(0, height / 10);
            myLineGeometry.EndPoint   = new Point(width, height / 10);
            pg.AddGeometry(myLineGeometry);
            return(pg.ToString());
        }