コード例 #1
0
        public SvgPathData.SvgPathIndex GetPathIndex(int partIndex)
        {
            var pathIndex = new SvgPathData.SvgPathIndex();

            pathIndex.BlockIndex = blockIndex;
            pathIndex.ItemIndex  = currentIndex;
            pathIndex.PartIndex  = partIndex;

            return(pathIndex);
        }
コード例 #2
0
        private void DrawAnchorSub(CanvasDrawingSession win2d, ViewInfo viewInfo, SvgPathData.SvgPathIndex myIndex, int partIndex, float x, float y)
        {
            myIndex.PartIndex = partIndex;
            bool ellipse = true;

            switch (Command)
            {
            case 'c':
            case 'C':
                if (partIndex == 2)
                {
                    ellipse = false;
                }
                break;

            default:
                break;
            }

            //            bool hover = viewInfo.HoverIndex == myIndex;
            bool select = viewInfo.TargetPathData.GetCurrentIndex() == myIndex;

            Color color = Colors.Blue;
            bool  fill  = false;

            if (viewInfo.HoverIndex == myIndex)
            {
                fill = true;
            }
            else if (select)
            {
                color = GetColor();
                fill  = true;
            }
            else
            {
                color = GetColor();
            }
            int size = 4;

            if (ellipse)
            {
                if (fill)
                {
                    win2d.FillEllipse(x, y, size, size, color);
                }
                else
                {
                    win2d.DrawEllipse(x, y, size, size, color);
                }
            }
            else
            {
                Rect r = new Rect(x - size, y - size, size * 2, size * 2);
                if (fill)
                {
                    win2d.FillRectangle(r, color);
                }
                else
                {
                    win2d.DrawRectangle(r, color);
                }
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="win2d"></param>
        /// <param name="scale"></param>
        internal void DrawAnchor(CanvasDrawingSession win2d, ViewInfo viewInfo, SvgPathData.SvgPathIndex myIndex)
        {
            float scale = viewInfo.Scale;

            switch (Command)
            {
            case 'M':
            case 'h':
            case 'H':
            case 'v':
            case 'V':
            case 'l':
            case 'L':
                int partindex = 0;
                foreach (Vector2 point in points)
                {
                    float x = (float)point.X * scale;
                    float y = (float)point.Y * scale;
                    DrawAnchorSub(win2d, viewInfo, myIndex, partindex, x, y);
                    partindex++;
                }
                break;

            case 'c':
            case 'C':
                if (points.Count == 3)
                {
                    Color   color = GetColor();
                    Vector2 point = points[2];
                    float   x     = (float)point.X * scale;
                    float   y     = (float)point.Y * scale;

                    DrawAnchorSub(win2d, viewInfo, myIndex, 2, x, y);

                    Vector2 p0 = befor.GetPoint();
                    float   x0 = (float)p0.X * scale;
                    float   y0 = (float)p0.Y * scale;

                    Vector2 p1 = points[0];
                    float   x1 = (float)p1.X * scale;
                    float   y1 = (float)p1.Y * scale;
                    win2d.DrawLine(x0, y0, x1, y1, color);
                    DrawAnchorSub(win2d, viewInfo, myIndex, 0, x1, y1);


                    Vector2 p2 = points[1];
                    float   x2 = (float)p2.X * scale;
                    float   y2 = (float)p2.Y * scale;
                    win2d.DrawLine(x, y, x2, y2, color);
                    DrawAnchorSub(win2d, viewInfo, myIndex, 1, x2, y2);
                }
                break;

            case 'a':
            case 'A':
                foreach (Vector2 point in points)
                {
                    float x = (float)point.X * scale;
                    float y = (float)point.Y * scale;
                    DrawAnchorSub(win2d, viewInfo, myIndex, 0, x, y);
                }
                break;

            default:
                break;
            }
        }