Inheritance: PathSegment, IBezierSegment
        private static PathGeometry CloneDeep(PathGeometry pathGeometry)
        {
            var newPathGeometry = new PathGeometry();
            foreach (var figure in pathGeometry.Figures)
            {
                var newFigure = new PathFigure();
                newFigure.StartPoint = figure.StartPoint;
                foreach (var segment in figure.Segments)
                {
                    var segmentAsPolyLineSegment = segment as PolyLineSegment;
                    if (segmentAsPolyLineSegment != null)
                    {
                        var newSegment = new PolyLineSegment();
                        foreach (var point in segmentAsPolyLineSegment.Points)
                        {
                            newSegment.Points.Add(point);
                        }
                        newFigure.Segments.Add(newSegment);
                    }

                    var segmentLineSegment = segment as LineSegment;
                    if (segmentLineSegment != null)
                    {
                        var newSegment = new LineSegment();
                        newSegment.Point = new Point(segmentLineSegment.Point.X, segmentLineSegment.Point.Y);
                        newFigure.Segments.Add(newSegment);
                    }

                    var segmentBezierSegment = segment as BezierSegment;
                    if (segmentBezierSegment != null)
                    {
                        var newSegment = new BezierSegment();
                        newSegment.Point1 = new Point(segmentBezierSegment.Point1.X, segmentBezierSegment.Point1.Y);
                        newSegment.Point2 = new Point(segmentBezierSegment.Point2.X, segmentBezierSegment.Point2.Y);
                        newSegment.Point3 = new Point(segmentBezierSegment.Point3.X, segmentBezierSegment.Point3.Y);
                        newFigure.Segments.Add(newSegment);
                    }
                }

                newPathGeometry.Figures.Add(newFigure);
            }
            return newPathGeometry;
        }
Exemple #2
0
        public CurvePanel()
        {
            _bgcanvas = new Canvas();
            _bgcanvas.VerticalAlignment = VerticalAlignment.Stretch;
            _bgcanvas.HorizontalAlignment = HorizontalAlignment.Stretch;
            _path = new Path();
            _path.Stroke = Stroke;
            _path.StrokeThickness = StrokeThickness;
            PathGeometry geo = new PathGeometry();
            _bfigure = new PathFigure();
            _bseg = new BezierSegment();
            _bfigure.Segments.Add(_bseg);
            geo.Figures.Add(_bfigure);
            _path.Data = geo;
            _bgcanvas.Children.Add(_path);
            this.Children.Add(_bgcanvas);

            this.SizeChanged += OnSizeChanged;
        }
        private void NodeLinked(NodeConnection from, NodeConnection to)
        {
            Debug.WriteLine("Linked {0} -> {1}", from.ConnectedNodeId, to.ConnectedNodeId);
            NodeBase nodeFrom = null;
            NodeBase nodeTo = null;

            foreach (var child in this.canvasDiagram.Children)
            {
                if (child is NodeBase)
                {
                    var node = child as NodeBase;
                    if (node.NodeId == from.ConnectedNodeId)
                    {
                        nodeFrom = node;
                    }
                    if (node.NodeId == to.ConnectedNodeId)
                    {
                        nodeTo = node;
                    }
                }
            }

            var fromPoint = nodeFrom.GetPosition();
            var toPoint = nodeTo.GetPosition();
            Point distance = new Point(toPoint.X - fromPoint.X, toPoint.Y - fromPoint.Y);

            BezierSegment segment = new BezierSegment();
            segment.Point1 = new Point(fromPoint.X + distance.X / 3, fromPoint.Y - 100);
            segment.Point2 = new Point(fromPoint.X + distance.X * 2 / 3, toPoint.Y + 100);
            segment.Point3 = nodeTo.GetPosition();

            PathFigure figure = new PathFigure();
            figure.StartPoint = nodeFrom.GetPosition();
            figure.Segments.Add(segment);

            PathGeometry geo = new PathGeometry();
            geo.Figures.Add(figure);

            Windows.UI.Xaml.Shapes.Path path = new Windows.UI.Xaml.Shapes.Path();
            path.StrokeThickness = 2;
            path.Stroke = new SolidColorBrush(Colors.Black);

            path.Data = geo;

            this.canvasDiagram.Children.Add(path);
        }
        protected override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _path = (Path)GetTemplateChild(pathName);
            _thumbGrid = (Grid)GetTemplateChild(thumbGridName);
            _readingBlock = (TextBlock)GetTemplateChild(readingName);

            PathGeometry geo = new PathGeometry();
            _bfigure = new PathFigure();
            _bseg = new BezierSegment();
            _bfigure.Segments.Add(_bseg);
            geo.Figures.Add(_bfigure);
            _path.Data = geo;

            this.SizeChanged += OnSizeChanged;
        }
Exemple #5
0
        private void drawRoundTriangle()
        {
            _roundAreaLength = ActualHeight < ActualWidth ? ActualHeight : ActualWidth; // choose min one ,align right top.
            _roundAreaControlLength = _roundAreaLength / 3;
            _roundAreaBaseY = _roundAreaLength / 8;
            if (_roundAreaLength == 0) return;
            PathGeometry geo = new PathGeometry();
            PathFigure fig = new PathFigure();
            BezierSegment seg1 = new BezierSegment();
            BezierSegment seg2 = new BezierSegment();
            BezierSegment seg3 = new BezierSegment();

            fig.StartPoint = new Point(ActualWidth, _roundAreaBaseY);
            seg1.Point1 = new Point(ActualWidth+Math.Sin(45*DEG2RAD)*_roundAreaControlLength, Math.Cos(45 * DEG2RAD) * _roundAreaControlLength + _roundAreaBaseY);
            seg1.Point2 = new Point(ActualWidth - _roundAreaLength * Math.Tan(15 * DEG2RAD)+Math.Cos(15*DEG2RAD)*_roundAreaControlLength, _roundAreaLength-Math.Sin(15*DEG2RAD)* _roundAreaControlLength + _roundAreaBaseY);
            seg1.Point3 = new Point(ActualWidth - _roundAreaLength * Math.Tan(15 * DEG2RAD), _roundAreaLength + _roundAreaBaseY);

            seg2.Point1 = new Point(ActualWidth - _roundAreaLength * Math.Tan(15 * DEG2RAD) - Math.Cos(15 * DEG2RAD) * _roundAreaControlLength, _roundAreaLength + Math.Sin(15 * DEG2RAD) * _roundAreaControlLength + _roundAreaBaseY);
            seg2.Point2 = new Point(ActualWidth - _roundAreaLength - Math.Sin(15 * DEG2RAD) * _roundAreaControlLength, _roundAreaLength * Math.Tan(15 * DEG2RAD) + Math.Cos(15 * DEG2RAD) * _roundAreaControlLength + _roundAreaBaseY);
            seg2.Point3 = new Point(ActualWidth - _roundAreaLength, _roundAreaLength * Math.Tan(15 * DEG2RAD) + _roundAreaBaseY);

            seg3.Point1 = new Point(ActualWidth - _roundAreaLength + Math.Sin(15 * DEG2RAD) * _roundAreaControlLength, _roundAreaLength * Math.Tan(15 * DEG2RAD) - Math.Cos(15 * DEG2RAD) * _roundAreaControlLength + _roundAreaBaseY);
            seg3.Point2 = new Point(ActualWidth - Math.Sin(45 * DEG2RAD) * _roundAreaControlLength, -Math.Cos(45 * DEG2RAD) * _roundAreaControlLength + _roundAreaBaseY);
            seg3.Point3 = fig.StartPoint;

            fig.Segments.Add(seg1);
            fig.Segments.Add(seg2);
            fig.Segments.Add(seg3);
            geo.Figures.Add(fig);
            _roundTriangle.Data = geo;

            _trackerBtn.Width = _roundAreaLength / 3;
            _trackerBtn.Height = _roundAreaLength / 3;
            _trackerBtn.Margin = new Thickness(ActualWidth - _trackerBtn.Width * 2 / 3, _roundAreaBaseY - _trackerBtn.Height / 3, 0, 0);
        }
Exemple #6
0
        public static WMedia.Geometry ToWindows(this Geometry geometry)
        {
            WMedia.Geometry wGeometry = null;

            if (geometry is LineGeometry)
            {
                LineGeometry lineGeometry = geometry as LineGeometry;
                wGeometry = new WMedia.LineGeometry
                {
                    StartPoint = lineGeometry.StartPoint.ToWindows(),
                    EndPoint   = lineGeometry.EndPoint.ToWindows()
                };
            }
            else if (geometry is RectangleGeometry)
            {
                var rect = (geometry as RectangleGeometry).Rect;
                wGeometry = new WMedia.RectangleGeometry
                {
                    Rect = new WFoundation.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }
            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry ellipseGeometry = geometry as EllipseGeometry;
                wGeometry = new WMedia.EllipseGeometry
                {
                    Center  = ellipseGeometry.Center.ToWindows(),
                    RadiusX = ellipseGeometry.RadiusX,
                    RadiusY = ellipseGeometry.RadiusY
                };
            }
            else if (geometry is GeometryGroup)
            {
                GeometryGroup geometryGroup = geometry as GeometryGroup;
                wGeometry = new WMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(geometryGroup.FillRule)
                };

                foreach (Geometry children in geometryGroup.Children)
                {
                    WMedia.Geometry winChild = children.ToWindows();
                    (wGeometry as WMedia.GeometryGroup).Children.Add(winChild);
                }
            }
            else if (geometry is PathGeometry)
            {
                PathGeometry pathGeometry = geometry as PathGeometry;

                WMedia.PathGeometry wPathGeometry = new WMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(pathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in pathGeometry.Figures)
                {
                    WMedia.PathFigure wPathFigure = new WMedia.PathFigure
                    {
                        StartPoint = xamPathFigure.StartPoint.ToWindows(),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    wPathGeometry.Figures.Add(wPathFigure);

                    foreach (PathSegment pathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (pathSegment is LineSegment)
                        {
                            LineSegment lineSegment = pathSegment as LineSegment;

                            WMedia.LineSegment winSegment = new WMedia.LineSegment
                            {
                                Point = lineSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (pathSegment is PolyLineSegment)
                        {
                            PolyLineSegment        polyLineSegment = pathSegment as PolyLineSegment;
                            WMedia.PolyLineSegment wSegment        = new WMedia.PolyLineSegment();

                            foreach (var point in polyLineSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // BezierSegment
                        if (pathSegment is BezierSegment)
                        {
                            BezierSegment bezierSegment = pathSegment as BezierSegment;

                            WMedia.BezierSegment wSegment = new WMedia.BezierSegment
                            {
                                Point1 = bezierSegment.Point1.ToWindows(),
                                Point2 = bezierSegment.Point2.ToWindows(),
                                Point3 = bezierSegment.Point3.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyBezierSegment
                        else if (pathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment        polyBezierSegment = pathSegment as PolyBezierSegment;
                            WMedia.PolyBezierSegment wSegment          = new WMedia.PolyBezierSegment();

                            foreach (var point in polyBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }

                        // QuadraticBezierSegment
                        if (pathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment quadraticBezierSegment = pathSegment as QuadraticBezierSegment;

                            WMedia.QuadraticBezierSegment wSegment = new WMedia.QuadraticBezierSegment
                            {
                                Point1 = quadraticBezierSegment.Point1.ToWindows(),
                                Point2 = quadraticBezierSegment.Point2.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // PolyQuadraticBezierSegment
                        else if (pathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment        polyQuadraticBezierSegment = pathSegment as PolyQuadraticBezierSegment;
                            WMedia.PolyQuadraticBezierSegment wSegment = new WMedia.PolyQuadraticBezierSegment();

                            foreach (var point in polyQuadraticBezierSegment.Points)
                            {
                                wSegment.Points.Add(point.ToWindows());
                            }

                            wPathFigure.Segments.Add(wSegment);
                        }
                        // ArcSegment
                        else if (pathSegment is ArcSegment)
                        {
                            ArcSegment arcSegment = pathSegment as ArcSegment;

                            WMedia.ArcSegment wSegment = new WMedia.ArcSegment
                            {
                                Size           = new WFoundation.Size(arcSegment.Size.Width, arcSegment.Size.Height),
                                RotationAngle  = arcSegment.RotationAngle,
                                IsLargeArc     = arcSegment.IsLargeArc,
                                SweepDirection = arcSegment.SweepDirection == SweepDirection.Clockwise ? WMedia.SweepDirection.Clockwise : WMedia.SweepDirection.Counterclockwise,
                                Point          = arcSegment.Point.ToWindows()
                            };

                            wPathFigure.Segments.Add(wSegment);
                        }
                    }
                }

                wGeometry = wPathGeometry;
            }

            return(wGeometry);
        }
Exemple #7
0
        public object ConvertToNative(Geometry geometry)
        {
            winMedia.Geometry winGeometry = null;

            // Determine what type of geometry we're dealing with.
            if (geometry is LineGeometry)
            {
                LineGeometry xamGeometry = geometry as LineGeometry;
                winGeometry = new winMedia.LineGeometry
                {
                    StartPoint = ConvertPoint(xamGeometry.StartPoint),
                    EndPoint   = ConvertPoint(xamGeometry.EndPoint)
                };
            }

            else if (geometry is RectangleGeometry)
            {
                Rect rect = (geometry as RectangleGeometry).Rect;
                winGeometry = new winMedia.RectangleGeometry
                {
                    Rect = new winFound.Rect(rect.X, rect.Y, rect.Width, rect.Height)
                };
            }

            else if (geometry is EllipseGeometry)
            {
                EllipseGeometry xamGeometry = geometry as EllipseGeometry;
                winGeometry = new winMedia.EllipseGeometry
                {
                    Center  = ConvertPoint(xamGeometry.Center),
                    RadiusX = xamGeometry.RadiusX,
                    RadiusY = xamGeometry.RadiusY
                };
            }

            else if (geometry is GeometryGroup)
            {
                GeometryGroup xamGeometry = geometry as GeometryGroup;
                winGeometry = new winMedia.GeometryGroup
                {
                    FillRule = ConvertFillRule(xamGeometry.FillRule)
                };

                foreach (Geometry xamChild in xamGeometry.Children)
                {
                    winMedia.Geometry winChild = ConvertToNative(xamChild) as winMedia.Geometry;
                    (winGeometry as winMedia.GeometryGroup).Children.Add(winChild);
                }
            }

            else if (geometry is PathGeometry)
            {
                PathGeometry xamPathGeometry = geometry as PathGeometry;

                winMedia.PathGeometry winPathGeometry = new winMedia.PathGeometry
                {
                    FillRule = ConvertFillRule(xamPathGeometry.FillRule)
                };

                foreach (PathFigure xamPathFigure in xamPathGeometry.Figures)
                {
                    winMedia.PathFigure winPathFigure = new winMedia.PathFigure
                    {
                        StartPoint = ConvertPoint(xamPathFigure.StartPoint),
                        IsFilled   = xamPathFigure.IsFilled,
                        IsClosed   = xamPathFigure.IsClosed
                    };
                    winPathGeometry.Figures.Add(winPathFigure);

                    foreach (PathSegment xamPathSegment in xamPathFigure.Segments)
                    {
                        // LineSegment
                        if (xamPathSegment is LineSegment)
                        {
                            LineSegment xamSegment = xamPathSegment as LineSegment;

                            winMedia.LineSegment winSegment = new winMedia.LineSegment
                            {
                                Point = ConvertPoint(xamSegment.Point)
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolylineSegment
                        if (xamPathSegment is PolyLineSegment)
                        {
                            PolyLineSegment          xamSegment = xamPathSegment as PolyLineSegment;
                            winMedia.PolyLineSegment winSegment = new winMedia.PolyLineSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // BezierSegment
                        if (xamPathSegment is BezierSegment)
                        {
                            BezierSegment xamSegment = xamPathSegment as BezierSegment;

                            winMedia.BezierSegment winSegment = new winMedia.BezierSegment
                            {
                                Point1 = ConvertPoint(xamSegment.Point1),
                                Point2 = ConvertPoint(xamSegment.Point2),
                                Point3 = ConvertPoint(xamSegment.Point3)
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolyBezierSegment
                        else if (xamPathSegment is PolyBezierSegment)
                        {
                            PolyBezierSegment          xamSegment = xamPathSegment as PolyBezierSegment;
                            winMedia.PolyBezierSegment winSegment = new winMedia.PolyBezierSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // QuadraticBezierSegment
                        if (xamPathSegment is QuadraticBezierSegment)
                        {
                            QuadraticBezierSegment xamSegment = xamPathSegment as QuadraticBezierSegment;

                            winMedia.QuadraticBezierSegment winSegment = new winMedia.QuadraticBezierSegment
                            {
                                Point1 = ConvertPoint(xamSegment.Point1),
                                Point2 = ConvertPoint(xamSegment.Point2),
                            };

                            winPathFigure.Segments.Add(winSegment);
                        }

                        // PolyQuadraticBezierSegment
                        else if (xamPathSegment is PolyQuadraticBezierSegment)
                        {
                            PolyQuadraticBezierSegment          xamSegment = xamPathSegment as PolyQuadraticBezierSegment;
                            winMedia.PolyQuadraticBezierSegment winSegment = new winMedia.PolyQuadraticBezierSegment();

                            foreach (Point point in xamSegment.Points)
                            {
                                winSegment.Points.Add(ConvertPoint(point));
                            }

                            winPathFigure.Segments.Add(winSegment);
                        }


                        // ArcSegment
                        else if (xamPathSegment is ArcSegment)
                        {
                            ArcSegment          xamSegment = xamPathSegment as ArcSegment;
                            winMedia.ArcSegment winSegment = new winMedia.ArcSegment();

                            winSegment.Size           = new winFound.Size(xamSegment.Size.Width, xamSegment.Size.Height);
                            winSegment.RotationAngle  = xamSegment.RotationAngle;
                            winSegment.IsLargeArc     = xamSegment.IsLargeArc;
                            winSegment.SweepDirection = xamSegment.SweepDirection == SweepDirection.Clockwise ? winMedia.SweepDirection.Clockwise : winMedia.SweepDirection.Counterclockwise;
                            winSegment.Point          = ConvertPoint(xamSegment.Point);

                            winPathFigure.Segments.Add(winSegment);
                        }
                    }
                }

                winGeometry = winPathGeometry;
            }

            // Set transform.
            if (geometry.Transform != null)
            {
                winGeometry.Transform = (winMedia.Transform)geometry.Transform.GetNativeObject();
            }

            return(winGeometry);
        }
        private static void RenderAllStrokes(InkCanvas canvas, Panel parent)
        {
            // Get the InkStroke objects.
            IReadOnlyList<InkStroke> inkStrokes = canvas.InkPresenter.StrokeContainer.GetStrokes();

            List<Windows.UI.Xaml.Shapes.Path> retVal = new List<Windows.UI.Xaml.Shapes.Path>();

            // Process each stroke.
            foreach (InkStroke inkStroke in inkStrokes)
            {
                PathGeometry pathGeometry = new PathGeometry();
                PathFigureCollection pathFigures = new PathFigureCollection();
                PathFigure pathFigure = new PathFigure();
                PathSegmentCollection pathSegments = new PathSegmentCollection();

                // Create a path and define its attributes.
                Windows.UI.Xaml.Shapes.Path path = new Windows.UI.Xaml.Shapes.Path();
                path.Stroke = new SolidColorBrush(inkStroke.DrawingAttributes.Color);
                path.StrokeThickness = inkStroke.DrawingAttributes.Size.Height;
                if (inkStroke.DrawingAttributes.DrawAsHighlighter)
                {
                    path.Opacity = .4d;
                }

                // Get the stroke segments.
                IReadOnlyList<InkStrokeRenderingSegment> segments;
                segments = inkStroke.GetRenderingSegments();

                // Process each stroke segment.
                bool first = true;
                foreach (InkStrokeRenderingSegment segment in segments)
                {
                    // The first segment is the starting point for the path.
                    if (first)
                    {
                        pathFigure.StartPoint = segment.BezierControlPoint1;
                        first = false;
                    }

                    // Copy each ink segment into a bezier segment.
                    BezierSegment bezSegment = new BezierSegment();
                    bezSegment.Point1 = segment.BezierControlPoint1;
                    bezSegment.Point2 = segment.BezierControlPoint2;
                    bezSegment.Point3 = segment.Position;

                    // Add the bezier segment to the path.
                    pathSegments.Add(bezSegment);
                }

                // Build the path geometerty object.
                pathFigure.Segments = pathSegments;
                pathFigures.Add(pathFigure);
                pathGeometry.Figures = pathFigures;

                // Assign the path geometry object as the path data.
                path.Data = pathGeometry;

                // Render the path by adding it as a child of the Canvas object.
                parent.Children.Add(path);
            }
        }
        /// <summary>
        /// Main parser routine, which loops over each char in received string, and performs actions according to command/parameter being passed
        /// </summary>
        /// <param name="path">String with path data definition</param>
        /// <returns>PathGeometry object created from string definition</returns>
        private PathGeometry Parse(string path)
        {
            PathGeometry pathGeometry = null;

            _formatProvider = CultureInfo.InvariantCulture;
            _pathString = path;
            _pathLength = path.Length;
            _curIndex = 0;

            _secondLastPoint = new Point(0, 0);
            _lastPoint = new Point(0, 0);
            _lastStart = new Point(0, 0);

            _figureStarted = false;

            var first = true;

            var lastCmd = ' ';

            while (ReadToken()) // Empty path is allowed in XAML
            {
                char cmd = _token;

                if (first)
                {
                    if ((cmd != 'M') && (cmd != 'm') && (cmd != 'f') && (cmd != 'F'))  // Path starts with M|m
                    {
                        ThrowBadToken();
                    }

                    first = false;
                }

                switch (cmd)
                {
                    case 'f':
                    case 'F':
                        pathGeometry = new PathGeometry();
                        var num = ReadNumber(!AllowComma);
                        // ReSharper disable once CompareOfFloatsByEqualityOperator
                        pathGeometry.FillRule = num == 0 ? FillRule.EvenOdd : FillRule.Nonzero;
                        break;

                    case 'm':
                    case 'M':
                        // XAML allows multiple points after M/m
                        _lastPoint = ReadPoint(cmd, !AllowComma);

                        _figure = new PathFigure
                        {
                            StartPoint = _lastPoint,
                            IsFilled = IsFilled,
                            IsClosed = !IsClosed
                        };
                        //context.BeginFigure(_lastPoint, IsFilled, !IsClosed);
                        _figureStarted = true;
                        _lastStart = _lastPoint;
                        lastCmd = 'M';

                        while (IsNumber(AllowComma))
                        {
                            _lastPoint = ReadPoint(cmd, !AllowComma);

                            var lineSegment = new LineSegment {Point = _lastPoint};
                            _figure.Segments.Add(lineSegment);
                            //context.LineTo(_lastPoint, IsStroked, !IsSmoothJoin);
                            lastCmd = 'L';
                        }
                        break;

                    case 'l':
                    case 'L':
                    case 'h':
                    case 'H':
                    case 'v':
                    case 'V':
                        EnsureFigure();

                        do
                        {
                            switch (cmd)
                            {
                                case 'l': _lastPoint = ReadPoint(cmd, !AllowComma); break;
                                case 'L': _lastPoint = ReadPoint(cmd, !AllowComma); break;
                                case 'h': _lastPoint.X += ReadNumber(!AllowComma); break;
                                case 'H': _lastPoint.X = ReadNumber(!AllowComma); break;
                                case 'v': _lastPoint.Y += ReadNumber(!AllowComma); break;
                                case 'V': _lastPoint.Y = ReadNumber(!AllowComma); break;
                            }

                            var lineSegment = new LineSegment {Point = _lastPoint};
                            _figure.Segments.Add(lineSegment);
                            //context.LineTo(_lastPoint, IsStroked, !IsSmoothJoin);
                        }
                        while (IsNumber(AllowComma));

                        lastCmd = 'L';
                        break;

                    case 'c':
                    case 'C': // cubic Bezier
                    case 's':
                    case 'S': // smooth cublic Bezier
                        EnsureFigure();

                        do
                        {
                            Point p;

                            if ((cmd == 's') || (cmd == 'S'))
                            {
                                p = lastCmd == 'C' ? Reflect() : _lastPoint;

                                _secondLastPoint = ReadPoint(cmd, !AllowComma);
                            }
                            else
                            {
                                p = ReadPoint(cmd, !AllowComma);

                                _secondLastPoint = ReadPoint(cmd, AllowComma);
                            }

                            _lastPoint = ReadPoint(cmd, AllowComma);

                            var bizierSegment = new BezierSegment
                            {
                                Point1 = p,
                                Point2 = _secondLastPoint,
                                Point3 = _lastPoint
                            };
                            _figure.Segments.Add(bizierSegment);
                            //context.BezierTo(p, _secondLastPoint, _lastPoint, IsStroked, !IsSmoothJoin);

                            lastCmd = 'C';
                        }
                        while (IsNumber(AllowComma));

                        break;

                    case 'q':
                    case 'Q': // quadratic Bezier
                    case 't':
                    case 'T': // smooth quadratic Bezier
                        EnsureFigure();

                        do
                        {
                            if ((cmd == 't') || (cmd == 'T'))
                            {
                                _secondLastPoint = lastCmd == 'Q' ? Reflect() : _lastPoint;

                                _lastPoint = ReadPoint(cmd, !AllowComma);
                            }
                            else
                            {
                                _secondLastPoint = ReadPoint(cmd, !AllowComma);
                                _lastPoint = ReadPoint(cmd, AllowComma);
                            }

                            var quadraticBezierSegment = new QuadraticBezierSegment
                            {
                                Point1 = _secondLastPoint,
                                Point2 = _lastPoint
                            };
                            _figure.Segments.Add(quadraticBezierSegment);
                            //context.QuadraticBezierTo(_secondLastPoint, _lastPoint, IsStroked, !IsSmoothJoin);

                            lastCmd = 'Q';
                        }
                        while (IsNumber(AllowComma));

                        break;

                    case 'a':
                    case 'A':
                        EnsureFigure();

                        do
                        {
                            // A 3,4 5, 0, 0, 6,7
                            var w = ReadNumber(!AllowComma);
                            var h = ReadNumber(AllowComma);
                            var rotation = ReadNumber(AllowComma);
                            var large = ReadBool();
                            var sweep = ReadBool();

                            _lastPoint = ReadPoint(cmd, AllowComma);

                            var arcSegment = new ArcSegment
                            {
                                Point = _lastPoint,
                                Size = new Size(w, h),
                                RotationAngle = rotation,
                                IsLargeArc = large,
                                SweepDirection = sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise
                            };
                            _figure.Segments.Add(arcSegment);
                            //context.ArcTo(
                            //    _lastPoint,
                            //    new Size(w, h),
                            //    rotation,
                            //    large,
                            //    sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
                            //    IsStroked,
                            //    !IsSmoothJoin
                            //    );
                        }
                        while (IsNumber(AllowComma));

                        lastCmd = 'A';
                        break;

                    case 'z':
                    case 'Z':
                        EnsureFigure();
                        _figure.IsClosed = IsClosed;
                        //context.SetClosedState(IsClosed);

                        _figureStarted = false;
                        lastCmd = 'Z';

                        _lastPoint = _lastStart; // Set reference point to be first point of current figure
                        break;

                    default:
                        ThrowBadToken();
                        break;
                }

                if (null != _figure)
                {
                    if (_figure.IsClosed)
                    {
                        if (null == pathGeometry)
                            pathGeometry = new PathGeometry();

                        pathGeometry.Figures.Add(_figure);

                        _figure = null;
                        first = true;
                    }
                }

            }

            if (null != _figure)
            {
                if (null == pathGeometry)
                    pathGeometry = new PathGeometry();

                if (!pathGeometry.Figures.Contains(_figure))
                    pathGeometry.Figures.Add(_figure);

            }
            return pathGeometry;
        }
		public Windows.UI.Xaml.Shapes.Path CreateBezierPath(Point p1, Point p2, Point p3, Point org, float pressure)
		{
			var figure = new PathFigure();
			figure.StartPoint = org;
			
			var bezier = new BezierSegment();
			bezier.Point1 = p1;
			bezier.Point2 = p2;
			bezier.Point3 = p3;
			figure.Segments.Add(bezier);

			var geometry = new PathGeometry();
			geometry.Figures.Add(figure);

			var path = new Windows.UI.Xaml.Shapes.Path();
			path.Stroke = new SolidColorBrush(inkAttr.Color);
			path.StrokeThickness = pressure * inkAttr.Size.Width * 2;
			path.StrokeStartLineCap = PenLineCap.Round;
			path.StrokeEndLineCap = PenLineCap.Round;
			path.StrokeLineJoin = PenLineJoin.Round;
			path.Data = geometry;

			return path;
		}
        /// <summary>
        /// Main parser routine, which loops over each char in received string, and performs actions according to command/parameter being passed
        /// </summary>
        /// <param name="path">String with path data definition</param>
        /// <returns>PathGeometry object created from string definition</returns>
        private PathGeometry parse(string path)
        {
            PathGeometry _pathGeometry = null;
            

            _formatProvider = CultureInfo.InvariantCulture;
            _pathString = path;
            _pathLength = path.Length;
            _curIndex = 0;

            _secondLastPoint = new Point(0, 0);
            _lastPoint = new Point(0, 0);
            _lastStart = new Point(0, 0);

            _figureStarted = false;

            bool first = true;

            char last_cmd = ' ';

            while (ReadToken()) // Empty path is allowed in XAML
            {
                char cmd = _token;

                if (first)
                {
                    if ((cmd != 'M') && (cmd != 'm'))  // Path starts with M|m 
                    {
                        ThrowBadToken();
                    }

                    first = false;
                }

                switch (cmd)
                {
                    case 'm':
                    case 'M':
                        // XAML allows multiple points after M/m
                        _lastPoint = ReadPoint(cmd, !AllowComma);

                        _figure = new PathFigure();
                        _figure.StartPoint = _lastPoint;
                        _figure.IsFilled = IsFilled;
                        _figure.IsClosed = !IsClosed;
                        //context.BeginFigure(_lastPoint, IsFilled, !IsClosed);
                        _figureStarted = true;
                        _lastStart = _lastPoint;
                        last_cmd = 'M';

                        while (IsNumber(AllowComma))
                        {
                            _lastPoint = ReadPoint(cmd, !AllowComma);

                            LineSegment _lineSegment = new LineSegment();
                            _lineSegment.Point = _lastPoint;
                            _figure.Segments.Add(_lineSegment);
                            //context.LineTo(_lastPoint, IsStroked, !IsSmoothJoin);
                            last_cmd = 'L';
                        }
                        break;

                    case 'l':
                    case 'L':
                    case 'h':
                    case 'H':
                    case 'v':
                    case 'V':
                        EnsureFigure();

                        do
                        {
                            switch (cmd)
                            {
                                case 'l': _lastPoint = ReadPoint(cmd, !AllowComma); break;
                                case 'L': _lastPoint = ReadPoint(cmd, !AllowComma); break;
                                case 'h': _lastPoint.X += ReadNumber(!AllowComma); break;
                                case 'H': _lastPoint.X = ReadNumber(!AllowComma); break;
                                case 'v': _lastPoint.Y += ReadNumber(!AllowComma); break;
                                case 'V': _lastPoint.Y = ReadNumber(!AllowComma); break;
                            }

                            LineSegment _lineSegment = new LineSegment();
                            _lineSegment.Point = _lastPoint;
                            _figure.Segments.Add(_lineSegment);
                            //context.LineTo(_lastPoint, IsStroked, !IsSmoothJoin);
                        }
                        while (IsNumber(AllowComma));

                        last_cmd = 'L';
                        break;

                    case 'c':
                    case 'C': // cubic Bezier 
                    case 's':
                    case 'S': // smooth cublic Bezier
                        EnsureFigure();

                        do
                        {
                            Point p;

                            if ((cmd == 's') || (cmd == 'S'))
                            {
                                if (last_cmd == 'C')
                                {
                                    p = Reflect();
                                }
                                else
                                {
                                    p = _lastPoint;
                                }

                                _secondLastPoint = ReadPoint(cmd, !AllowComma);
                            }
                            else
                            {
                                p = ReadPoint(cmd, !AllowComma);

                                _secondLastPoint = ReadPoint(cmd, AllowComma);
                            }

                            _lastPoint = ReadPoint(cmd, AllowComma);

                            BezierSegment _bizierSegment = new BezierSegment();
                            _bizierSegment.Point1 = p;
                            _bizierSegment.Point2 = _secondLastPoint;
                            _bizierSegment.Point3 = _lastPoint;
                            _figure.Segments.Add(_bizierSegment);
                            //context.BezierTo(p, _secondLastPoint, _lastPoint, IsStroked, !IsSmoothJoin);

                            last_cmd = 'C';
                        }
                        while (IsNumber(AllowComma));

                        break;

                    case 'q':
                    case 'Q': // quadratic Bezier 
                    case 't':
                    case 'T': // smooth quadratic Bezier
                        EnsureFigure();

                        do
                        {
                            if ((cmd == 't') || (cmd == 'T'))
                            {
                                if (last_cmd == 'Q')
                                {
                                    _secondLastPoint = Reflect();
                                }
                                else
                                {
                                    _secondLastPoint = _lastPoint;
                                }

                                _lastPoint = ReadPoint(cmd, !AllowComma);
                            }
                            else
                            {
                                _secondLastPoint = ReadPoint(cmd, !AllowComma);
                                _lastPoint = ReadPoint(cmd, AllowComma);
                            }

                            QuadraticBezierSegment _quadraticBezierSegment = new QuadraticBezierSegment();
                            _quadraticBezierSegment.Point1 = _secondLastPoint;
                            _quadraticBezierSegment.Point2 = _lastPoint;
                            _figure.Segments.Add(_quadraticBezierSegment);
                            //context.QuadraticBezierTo(_secondLastPoint, _lastPoint, IsStroked, !IsSmoothJoin);

                            last_cmd = 'Q';
                        }
                        while (IsNumber(AllowComma));

                        break;

                    case 'a':
                    case 'A':
                        EnsureFigure();

                        do
                        {
                            // A 3,4 5, 0, 0, 6,7
                            double w = ReadNumber(!AllowComma);
                            double h = ReadNumber(AllowComma);
                            double rotation = ReadNumber(AllowComma);
                            bool large = ReadBool();
                            bool sweep = ReadBool();

                            _lastPoint = ReadPoint(cmd, AllowComma);

                            ArcSegment _arcSegment = new ArcSegment();
                            _arcSegment.Point = _lastPoint;
                            _arcSegment.Size = new Size(w, h);
                            _arcSegment.RotationAngle = rotation;
                            _arcSegment.IsLargeArc = large;
                            _arcSegment.SweepDirection = sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise;
                            _figure.Segments.Add(_arcSegment);
                            //context.ArcTo(
                            //    _lastPoint,
                            //    new Size(w, h),
                            //    rotation,
                            //    large,
                            //    sweep ? SweepDirection.Clockwise : SweepDirection.Counterclockwise,
                            //    IsStroked,
                            //    !IsSmoothJoin
                            //    );
                        }
                        while (IsNumber(AllowComma));

                        last_cmd = 'A';
                        break;

                    case 'z':
                    case 'Z':
                        EnsureFigure();
                        _figure.IsClosed = IsClosed;
                        //context.SetClosedState(IsClosed);

                        _figureStarted = false;
                        last_cmd = 'Z';

                        _lastPoint = _lastStart; // Set reference point to be first point of current figure
                        break;

                    default:
                        ThrowBadToken();
                        break;
                }
            }

            if (null != _figure)
            {
                _pathGeometry = new PathGeometry();
                _pathGeometry.Figures.Add(_figure);
                
            }
            return _pathGeometry;
        }
Exemple #12
0
        private void drawCurve(String name, int channel, double amp)
        {
            if (-1 == channel) //don't draw networks that are not on the band
                return;

            double channelWidth = this.width / channelSpaces;
            double curveWidth = channelWidth * 4;

            double y = this.y + this.height;
            double x = this.x;

            x += (channel -1) * channelWidth;

            System.Diagnostics.Debug.WriteLine("drawingCurve with CHannel:" + channel + " on x: " + x);
            System.Diagnostics.Debug.WriteLine("With Amplitude: " + amp);

            Path path = new Path();
            PathFigure figure = new PathFigure();
            BezierSegment myBs = new BezierSegment();

            double channelAmplitude = 1.12* ( ((amp + 100) / 80) * this.height );
            myBs.Point1 = new Point(x, y);
            Point curveTop = new Point(x + curveWidth / 2, y - channelAmplitude);
            //calculation of line heights on amplitude scale
            //                double lineY = y + this.height - ((amplitude + 100.0) / 80.0) * this.height;
            //P(t) = P0*t^2 + P1*2*t*(1-t) + P2*(1-t)^2 //http://stackoverflow.com/questions/6711707/draw-a-quadratic-b%C3%A9zier-curve-through-three-given-points
            double controlX = 2 * (x + curveWidth / 2) - x / 2 - (x + curveWidth) / 2;
            double controlY = 2 * (curveTop.Y) - y / 2 - y / 2;
            myBs.Point2 = new Point(controlX, controlY);
            myBs.Point3 = new Point(x + curveWidth, y);

            figure.Segments.Add(myBs);
            figure.StartPoint = new Point(x, y); //WUT?!

            PathGeometry myPath = new PathGeometry();
            myPath.Figures.Add(figure);
            path.Data = myPath;
            Color color = getColor();
            path.Stroke = new SolidColorBrush(color);
            path.StrokeThickness = 2;

            this.activeCanvas.Children.Add(path);

            TextBlock textBlock = new TextBlock();
            textBlock.Foreground = new SolidColorBrush(color);
            if (null != name)
            {
                textBlock.Text = name;
                    }
            else
            {
                textBlock.Text = "NULL";
                    }

            if (curveTop.Y < this.x)
            {
                curveTop.Y = this.x;
                curveTop.X += 15;
            }

            Canvas.SetLeft(textBlock, curveTop.X);
            Canvas.SetTop(textBlock, curveTop.Y);

            this.activeCanvas.Children.Add(textBlock);
        }
Exemple #13
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Path Demonstration
            LineSegment lineSeg1 = new LineSegment();
            lineSeg1.Point = new Point(500, 500);
            LineSegment lineSeg2 = new LineSegment();
            lineSeg2.Point = new Point(0, 500);
            ArcSegment arcSeg = new ArcSegment();
            arcSeg.Point = new Point(0, 0);
            arcSeg.Size = new Size(250, 250);
            arcSeg.IsLargeArc = true;
            BezierSegment bzSeg = new BezierSegment();
            bzSeg.Point1 = new Point(125, 125);
            bzSeg.Point2 = new Point(375, 375);
            bzSeg.Point3 = new Point(500, 250);

            // Add Segment to PathSegmentCollention
            PathSegmentCollection myPathSegCol1 = new PathSegmentCollection();
            myPathSegCol1.Add(lineSeg1);
            PathSegmentCollection myPathSegCol2 = new PathSegmentCollection();
            myPathSegCol2.Add(lineSeg2);
            PathSegmentCollection myPathSegCol3 = new PathSegmentCollection();
            myPathSegCol3.Add(arcSeg);
            PathSegmentCollection myPathSegCol4 = new PathSegmentCollection();
            myPathSegCol4.Add(bzSeg);

            // Add Segment Collection to Figure
            PathFigure myPathFig1 = new PathFigure
            {
                StartPoint = new Point(0, 0),
                Segments = myPathSegCol1
            };
            PathFigure myPathFig2 = new PathFigure
            {
                StartPoint = new Point(500, 0),
                Segments = myPathSegCol2
            };
            PathFigure myPathFig3 = new PathFigure
            {
                StartPoint = new Point(0, -0.1),
                Segments = myPathSegCol3
            };
            PathFigure myPathFig4 = new PathFigure
            {
                StartPoint = new Point(0, 250),
                Segments = myPathSegCol4
            };

            // Add Figures to Geometry
            PathGeometry myPathGeo1 = new PathGeometry();
            myPathGeo1.Figures.Add(myPathFig1);
            myPathGeo1.Figures.Add(myPathFig2);
            PathGeometry myPathGeo2 = new PathGeometry();
            myPathGeo2.Figures.Add(myPathFig3);
            PathGeometry myPathGeo3 = new PathGeometry();
            myPathGeo3.Figures.Add(myPathFig4);

            // Add Geometry to Path
            Path myPath1 = new Path
            {
                Stroke = new SolidColorBrush(Colors.Cyan),
                StrokeThickness = 12,
                StrokeLineJoin = PenLineJoin.Round,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Data = myPathGeo1,
                Stretch = Stretch.Uniform
            };
            Path myPath2 = new Path
            {
                Stroke = new SolidColorBrush(Colors.Crimson),
                StrokeThickness = 12,
                StrokeLineJoin = PenLineJoin.Round,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Data = myPathGeo2,
                Stretch = Stretch.Uniform
            };
            Path myPath3 = new Path
            {
                Stroke = new SolidColorBrush(Colors.Crimson),
                StrokeThickness = 12,
                StrokeLineJoin = PenLineJoin.Round,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Data = myPathGeo3,
                Stretch = Stretch.Uniform
            };
            // Another way, read from XAML.
            Path tempPath = XamlReader.Load("<Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Stroke='Blue' Data='M 0 0 Q 10 10 20 0'/>") as Path;
            Geometry geo = tempPath.Data;
            tempPath.Data = null;           // YOu can NOT use the data for another path before the original one is empty!!
            Path myPath4 = new Path
            {
                Stroke = new SolidColorBrush(Colors.Coral),
                StrokeThickness = 12,
                StrokeLineJoin = PenLineJoin.Round,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Stretch = Stretch.Uniform,
                Data = geo
            };

            ThirdPgGrid.Children.Add(myPath1);
            ThirdPgGrid.Children.Add(myPath2);
            ThirdPgGrid.Children.Add(myPath3);
            ThirdPgGrid.Children.Add(myPath4);
        }
        private void drawRoundTriangleButtons()
        {
            //button large
            _roundAreaLength1 = ActualHeight < ActualWidth ? ActualHeight : ActualWidth; // choose min one ,align right top.
            _roundAreaControlLength1 = _roundAreaLength1 / 3;
            _roundAreaBaseY1 = _roundAreaLength1 / 8;
            if (_roundAreaLength1 == 0) return;
            PathGeometry geo = new PathGeometry();
            PathFigure fig = new PathFigure();
            BezierSegment seg1 = new BezierSegment();
            BezierSegment seg2 = new BezierSegment();
            BezierSegment seg3 = new BezierSegment();

            fig.StartPoint = new Point(0, _roundAreaBaseY1);
            seg1.Point1 = new Point(-Math.Sin(45 * DEG2RAD) * _roundAreaControlLength1, Math.Cos(45 * DEG2RAD) * _roundAreaControlLength1 + _roundAreaBaseY1);
            seg1.Point2 = new Point(_roundAreaLength1 * Math.Tan(15 * DEG2RAD) - Math.Cos(15 * DEG2RAD) * _roundAreaControlLength1, _roundAreaLength1 - Math.Sin(15 * DEG2RAD) * _roundAreaControlLength1 + _roundAreaBaseY1);
            seg1.Point3 = new Point(_roundAreaLength1 * Math.Tan(15 * DEG2RAD), _roundAreaLength1 + _roundAreaBaseY1);

            seg2.Point1 = new Point(_roundAreaLength1 * Math.Tan(15 * DEG2RAD) + Math.Cos(15 * DEG2RAD) * _roundAreaControlLength1, _roundAreaLength1 + Math.Sin(15 * DEG2RAD) * _roundAreaControlLength1 + _roundAreaBaseY1);
            seg2.Point2 = new Point(_roundAreaLength1 + Math.Sin(15 * DEG2RAD) * _roundAreaControlLength1, _roundAreaLength1 * Math.Tan(15 * DEG2RAD) + Math.Cos(15 * DEG2RAD) * _roundAreaControlLength1 + _roundAreaBaseY1);
            seg2.Point3 = new Point(_roundAreaLength1, _roundAreaLength1 * Math.Tan(15 * DEG2RAD) + _roundAreaBaseY1);

            seg3.Point1 = new Point(_roundAreaLength1 - Math.Sin(15 * DEG2RAD) * _roundAreaControlLength1, _roundAreaLength1 * Math.Tan(15 * DEG2RAD) - Math.Cos(15 * DEG2RAD) * _roundAreaControlLength1 + _roundAreaBaseY1);
            seg3.Point2 = new Point(Math.Sin(45 * DEG2RAD) * _roundAreaControlLength1, -Math.Cos(45 * DEG2RAD) * _roundAreaControlLength1 + _roundAreaBaseY1);
            seg3.Point3 = fig.StartPoint;

            fig.Segments.Add(seg1);
            fig.Segments.Add(seg2);
            fig.Segments.Add(seg3);
            geo.Figures.Add(fig);
            _roundButton1.Data = geo;
            viewboxs[0].Width = _roundAreaLength1*9/10;
            viewboxs[0].Height = _roundAreaLength1;
            viewboxs[1].Margin = new Thickness(0, _roundAreaBaseY1 / 2, 0, 0);
            btnTexts[0].FontSize = _roundAreaLength1 / 10;

            //button small
            _roundAreaLength2 = _roundAreaLength1 / 3; // choose min one ,align right top.
            _roundAreaControlLength2 = _roundAreaLength2 / 3;
            _roundAreaBaseY2 = _roundAreaLength2 / 8;
            if (_roundAreaLength1 == 0) return;
            PathGeometry geo2 = new PathGeometry();
            PathFigure fig2 = new PathFigure();
            BezierSegment seg21 = new BezierSegment();
            BezierSegment seg22 = new BezierSegment();
            BezierSegment seg23 = new BezierSegment();

            fig2.StartPoint = new Point(ActualWidth, _roundAreaBaseY2);
            seg21.Point1 = new Point(ActualWidth + Math.Sin(45 * DEG2RAD) * _roundAreaControlLength2, Math.Cos(45 * DEG2RAD) * _roundAreaControlLength2 + _roundAreaBaseY2);
            seg21.Point2 = new Point(ActualWidth - _roundAreaLength2 * Math.Tan(15 * DEG2RAD) + Math.Cos(15 * DEG2RAD) * _roundAreaControlLength2, _roundAreaLength2 - Math.Sin(15 * DEG2RAD) * _roundAreaControlLength2 + _roundAreaBaseY2);
            seg21.Point3 = new Point(ActualWidth - _roundAreaLength2 * Math.Tan(15 * DEG2RAD), _roundAreaLength2 + _roundAreaBaseY2);

            seg22.Point1 = new Point(ActualWidth - _roundAreaLength2 * Math.Tan(15 * DEG2RAD) - Math.Cos(15 * DEG2RAD) * _roundAreaControlLength2, _roundAreaLength2 + Math.Sin(15 * DEG2RAD) * _roundAreaControlLength2 + _roundAreaBaseY2);
            seg22.Point2 = new Point(ActualWidth - _roundAreaLength2 - Math.Sin(15 * DEG2RAD) * _roundAreaControlLength2, _roundAreaLength2 * Math.Tan(15 * DEG2RAD) + Math.Cos(15 * DEG2RAD) * _roundAreaControlLength2 + _roundAreaBaseY2);
            seg22.Point3 = new Point(ActualWidth - _roundAreaLength2, _roundAreaLength2 * Math.Tan(15 * DEG2RAD) + _roundAreaBaseY2);

            seg23.Point1 = new Point(ActualWidth - _roundAreaLength2 + Math.Sin(15 * DEG2RAD) * _roundAreaControlLength2, _roundAreaLength2 * Math.Tan(15 * DEG2RAD) - Math.Cos(15 * DEG2RAD) * _roundAreaControlLength2 + _roundAreaBaseY2);
            seg23.Point2 = new Point(ActualWidth - Math.Sin(45 * DEG2RAD) * _roundAreaControlLength2, -Math.Cos(45 * DEG2RAD) * _roundAreaControlLength2 + _roundAreaBaseY2);
            seg23.Point3 = fig2.StartPoint;

            fig2.Segments.Add(seg21);
            fig2.Segments.Add(seg22);
            fig2.Segments.Add(seg23);
            geo2.Figures.Add(fig2);
            _roundButton2.Data = geo2;
            viewboxs[1].Width = _roundAreaLength2;
            viewboxs[1].Height = _roundAreaLength2;
            viewboxs[1].Margin = new Thickness(ActualWidth-_roundAreaLength2*8/9,_roundAreaBaseY2/2,0,0);
            btnTexts[1].FontSize = _roundAreaLength2 / 4;

            _trackerBtn.Width = _roundAreaLength1 / 3;
            _trackerBtn.Height = _roundAreaLength1 / 3;
            _trackerBtn.Margin = new Thickness(-_trackerBtn.Width * 1 / 3, _roundAreaBaseY1 - _trackerBtn.Height / 3, 0, 0);
        }