public void cmd_prepareLine(UIMouseEventArgs e)
        {
            MyPoint CurrPosition = new MyPoint(e.ClientX - LocalData.SVGPosition.x, e.ClientY - LocalData.SVGPosition.y);

            BPaintLine new_BPaintLine = new BPaintLine();


            if (ObjectsList.Any())
            {
                new_BPaintLine.ObjectID = ObjectsList.Max(x => x.ObjectID) + 1;


                cmd_Clear_Selection();
                cmd_Clear_Editing();
            }
            else
            {
                new_BPaintLine.ObjectID = 1;
            }


            new_BPaintLine.ObjectType    = BPaintOpbjectType.Line;
            new_BPaintLine.Selected      = true;
            new_BPaintLine.EditMode      = true;
            new_BPaintLine.Color         = Color1;
            new_BPaintLine.width         = LineWidth1;
            new_BPaintLine.StartPosition = new MyPoint(CurrPosition.x, CurrPosition.y);
            new_BPaintLine.end           = new_BPaintLine.StartPosition;
            ObjectsList.Add(new_BPaintLine);
        }
        public void cmd_Line(UIMouseEventArgs e)
        {
            if (ObjectsList.Any(x => x.EditMode))
            {
                MyPoint CurrPosition = new MyPoint(e.ClientX - LocalData.SVGPosition.x, e.ClientY - LocalData.SVGPosition.y);


                BPaintLine Curr_Object = (BPaintLine)ObjectsList.Single(x => x.EditMode);


                if (Curr_Object.end.x != CurrPosition.x || Curr_Object.end.y != CurrPosition.y)
                {
                    Curr_Object.end = CurrPosition;
                    cmd_RefreshSVG();
                }
            }
        }
Exemple #3
0
        private line drawLine(BPaintLine Par_Object)
        {
            line l = new line()
            {
                x1 = Par_Object.StartPosition.x + Par_Object.PositionChange.x,
                y1 = Par_Object.StartPosition.y + Par_Object.PositionChange.y,
                x2 = Par_Object.end.x + Par_Object.PositionChange.x,
                y2 = Par_Object.end.y + Par_Object.PositionChange.y,
                // opacity = 1,
                stroke       = Par_Object.Color,
                stroke_width = Par_Object.width,
                // stroke_linecap = strokeLinecap.round,
            };


            if (Par_Object.Scale.x != 0 || Par_Object.Scale.y != 0)
            {
                l.transform = "scale(" + Par_Object.Scale.x + "," + Par_Object.Scale.y + ")";
            }

            return(l);
        }
Exemple #4
0
        public static RectD Get_Border_Points(BPaintLine Par_obj, bool padding = true)
        {
            RectD result = new RectD();


            List <PointD> data = new List <PointD>();

            data.Add(Par_obj.Position.PtD);
            data.Add(Par_obj.end.PtD);

            result.x      = data.Min(j => j.X);
            result.y      = data.Min(j => j.Y);
            result.width  = data.Max(j => j.X) - result.x;
            result.height = data.Max(j => j.Y) - result.y;

            if (padding)
            {
                Set_Padding(result);
            }

            return(result);
        }
Exemple #5
0
        public static MyPointRect Get_Border_Points(BPaintLine Par_obj)
        {
            MyPointRect result = new MyPointRect();


            List <MyPoint> data = new List <MyPoint>();

            data.Add(Par_obj.StartPosition);
            data.Add(Par_obj.end);

            result.x      = data.Min(j => j.x);
            result.y      = data.Min(j => j.y);
            result.width  = data.Max(j => j.x) - result.x;
            result.height = data.Max(j => j.y) - result.y;

            result.x += Par_obj.PositionChange.x;
            result.y += Par_obj.PositionChange.y;

            Set_Padding(result);

            return(result);
        }
        public void startLine(MouseEventArgs e)
        {
            PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y);

            BPaintLine new_BPaintLine = new BPaintLine();


            if (ObjectsList.Any())
            {
                new_BPaintLine.ObjectID = ObjectsList.Max(x => x.ObjectID) + 1;
                cmd_Clear_Selection();
                cmd_Clear_Editing();
            }
            else
            {
                new_BPaintLine.ObjectID = 1;
            }

            BPaintVertex startVertex = new BPaintVertex(CurrPosition, Color1);

            VerticesList.Add(startVertex);

            new_BPaintLine.Selected  = true;
            new_BPaintLine.EditMode  = true;
            new_BPaintLine.Color     = Color1;
            new_BPaintLine.LineWidth = LineWidth1;
            new_BPaintLine.Position  = startVertex;
            BPaintVertex endVertex = new BPaintVertex(CurrPosition, Color1);

            new_BPaintLine.end = endVertex;
            VerticesList.Add(endVertex);
            ObjectsList.Add(new_BPaintLine);

            CurrPaintMode             = BPaintMode.movingAnElement;
            bpVertexUnderMousePointer = endVertex;
        }
Exemple #7
0
        public void Generate_SVG()
        {
            _Svg = new svg
            {
                id     = "svgPaint",
                width  = par_width,
                height = par_height,
                xmlns  = "http://www.w3.org/2000/svg",
            };

            _Svg.Children.Add(new rect
            {
                width        = par_width,
                height       = par_height,
                fill         = "wheat",
                stroke       = "red",
                stroke_width = 1,
            });



            foreach (var item in (parent as CompBlazorPaint).ObjectsList.OrderBy(x => x.SequenceNumber))
            {
                switch (item.ObjectType)
                {
                case BPaintOpbjectType.HandDraw:
                    _Svg.Children.Add(drawPath(item as BPaintHandDraw));


                    if (item.Selected)
                    {
                        MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintHandDraw);

                        _Svg.Children.Add(new rect
                        {
                            x            = p_rect.x,
                            y            = p_rect.y,
                            width        = p_rect.width,
                            height       = p_rect.height,
                            fill         = "none",
                            stroke       = "red",
                            stroke_width = 1,
                            style        = "opacity:0.2",
                        });
                    }

                    break;

                case BPaintOpbjectType.Line:
                    BPaintLine currLine = item as BPaintLine;
                    _Svg.Children.Add(drawLine(currLine));
                    if (item.Selected)
                    {
                        circle c1 = new circle()
                        {
                            cx           = currLine.StartPosition.x + currLine.PositionChange.x,
                            cy           = currLine.StartPosition.y + currLine.PositionChange.y,
                            r            = currLine.width * 1.5,
                            fill         = "wheat",
                            stroke       = currLine.Color,
                            stroke_width = 2,
                        };

                        if (currLine.Scale.x != 0 || currLine.Scale.y != 0)
                        {
                            c1.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")";
                        }
                        _Svg.Children.Add(c1);

                        circle c2 = new circle()
                        {
                            cx           = currLine.end.x + currLine.PositionChange.x,
                            cy           = currLine.end.y + currLine.PositionChange.y,
                            r            = currLine.width * 1.5,
                            fill         = "wheat",
                            stroke       = currLine.Color,
                            stroke_width = 2,
                        };

                        if (currLine.Scale.x != 0 || currLine.Scale.y != 0)
                        {
                            c2.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")";
                        }
                        _Svg.Children.Add(c2);


                        MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintLine);

                        _Svg.Children.Add(new rect
                        {
                            x            = p_rect.x,
                            y            = p_rect.y,
                            width        = p_rect.width,
                            height       = p_rect.height,
                            fill         = "none",
                            stroke       = "red",
                            stroke_width = 1,
                            style        = "opacity:0.2",
                        });
                    }


                    break;

                default:
                    break;
                }
            }
        }