private void canvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (StackControl == null && e.ChangedButton == MouseButton.Left && e.LeftButton == MouseButtonState.Released)
            {
                isDrawing = false;

                SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                               new Thickness(data.PrevPoint.X, data.PrevPoint.Y,
                                                                                             e.GetPosition(canvas).X, e.GetPosition(canvas).Y),
                                                                               (XData)data.Clone(), cmd
                                                                               );

                ctrl.GainFocus   += this.OnGainFocus;
                ctrl.LostFocus   += this.OnLostFocus;
                ctrl.FigurePaste += this.OnFigurePaste;

                ctrl.ContextMenu_Color.Click     += new RoutedEventHandler(cmd.aColor.Action);
                ctrl.ContextMenu_PenWidth.Click  += new RoutedEventHandler(cmd.aWidth.Action);
                ctrl.ContextMenu_ShapeType.Click += new RoutedEventHandler(cmd.aType.Action);

                data.AddPosition(e.GetPosition(canvas));
                if (data.Type == ShapeType.MULTILINE)
                {
                    Line[] lines = this.canvas.Children.OfType <Line>().ToArray();
                    foreach (var item in lines)
                    {
                        this.canvas.Children.Remove(item);
                    }
                    data.Path = new List <Point>();
                }
            }
        }
Exemplo n.º 2
0
        private void Canvas_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                isDrawing = false;

                SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                               new Rectangle(data.PrevPoint, new Size(e.X - data.PrevPoint.X, e.Y - data.PrevPoint.Y)), (XData)data.Clone(), cmd);
                ctrl.GainFocus   += this.OnGainFocus;
                ctrl.LostFocus   += this.OnLostFocus;
                ctrl.FigurePaste += this.OnFigurePaste;
                this.Controls[Controls.Count - 1].BringToFront();

                ctrl.ContextMenu_Color.Click     += new EventHandler(cmd.aColor.Action);
                ctrl.ContextMenu_PenWidth.Click  += new EventHandler(cmd.aWidth.Action);
                ctrl.ContextMenu_ShapeType.Click += new EventHandler(cmd.aType.Action);
                ctrl.PropertyPanel = (this.Parent.Parent.Parent.Parent as MiniPaintV).propertyPanel;

                data.AddPosition(e.Location);
                if (data.Type == ShapeType.MULTILINE)
                {
                    g.Clear(this.BackColor);
                    data.Path = new List <PointF>();
                }
            }
        }
Exemplo n.º 3
0
 public CanvasVector()
 {
     InitializeComponent();
     data             = new XData();
     DrawArea         = new Bitmap(pictureBox.Size.Width, pictureBox.Size.Height);
     pictureBox.Image = DrawArea;
     g = Graphics.FromImage(DrawArea);
     DrawingVector2DTool.SetUp(g);
 }
Exemplo n.º 4
0
 private void Canvas_SizeChanged(object sender, EventArgs e)
 {
     try
     {
         DrawArea         = new Bitmap(pictureBox.Size.Width, pictureBox.Size.Height);
         pictureBox.Image = DrawArea;
         g = Graphics.FromImage(DrawArea);
         DrawingVector2DTool.SetUp(g);
     }
     catch { }
 }
        public void OnFigurePaste(object sender, EventArgs e)
        {
            Figure obj     = sender as Figure;
            XData  newData = new XData();

            newData.LineColor = Color.FromArgb(obj.Color[0], obj.Color[1], obj.Color[2], obj.Color[3]);
            newData.LineWidth = obj.PenWidth;
            newData.Type      = obj.ShapeType;
            newData.Path      = obj.Path.ToList();

            SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                           obj.Bounds, newData, cmd);

            ctrl.GainFocus   += this.OnGainFocus;
            ctrl.LostFocus   += this.OnLostFocus;
            ctrl.FigurePaste += this.OnFigurePaste;

            ctrl.ContextMenu_Color.Click     += new RoutedEventHandler(cmd.aColor.Action);
            ctrl.ContextMenu_PenWidth.Click  += new RoutedEventHandler(cmd.aWidth.Action);
            ctrl.ContextMenu_ShapeType.Click += new RoutedEventHandler(cmd.aType.Action);
        }
Exemplo n.º 6
0
        public void OnFigurePaste(object sender, EventArgs e)
        {
            Figure obj     = sender as Figure;
            XData  newData = new XData();

            newData.LineColor = Color.FromArgb(obj.Color);
            newData.LineWidth = obj.PenWidth;
            newData.Type      = obj.ShapeType;
            newData.Path      = obj.Path.ToList();

            SimpleFigures ctrl = (SimpleFigures)DrawingVector2DTool.Render(this,
                                                                           new Rectangle(new Point(obj.Bounds.X + 20, obj.Bounds.Y + 20), obj.Bounds.Size), newData, cmd);

            ctrl.GainFocus   += this.OnGainFocus;
            ctrl.LostFocus   += this.OnLostFocus;
            ctrl.FigurePaste += this.OnFigurePaste;
            this.Controls[Controls.Count - 1].BringToFront();

            ctrl.ContextMenu_Color.Click     += new EventHandler(cmd.aColor.Action);
            ctrl.ContextMenu_PenWidth.Click  += new EventHandler(cmd.aWidth.Action);
            ctrl.ContextMenu_ShapeType.Click += new EventHandler(cmd.aType.Action);
            ctrl.PropertyPanel = (this.Parent.Parent.Parent.Parent as MiniPaintV).propertyPanel;
        }
 private void CB_ShapeType_SelectedIndexChanged(object sender, EventArgs e)
 {
     DrawingVector2DTool.ShapeTypeSelector(Canvas, CB_ShapeType.SelectedIndex);
 }
 private void B_ColorSelector_Click(object sender, EventArgs e)
 {
     DrawingVector2DTool.ColorSelector(Canvas);
 }
 private void LoadButton_Click(object sender, EventArgs e)
 {
     DrawingVector2DTool.LoadSelector(Canvas);
 }
Exemplo n.º 10
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     DrawingVector2DTool.SaveSelector(Canvas);
 }
Exemplo n.º 11
0
 private void NUD_Width_ValueChanged(object sender, EventArgs e)
 {
     DrawingVector2DTool.PenWidthSelector(Canvas, Convert.ToSingle(NUD_Width.Value));
 }