Exemplo n.º 1
0
        public override void OnMouseDown(CanvasPanel canvasPanel, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                SelectedShape = GetClickedShape(canvasPanel, e);
                if (this.SelectedShape != null)
                {
                    canvasPanel.Cursor = Cursors.SizeAll;
                    _dragInfo = new DragInfo(e, SelectedShape.GetHandlerAt(e.Location));
                }

            }

            canvasPanel.Refresh();
        }
Exemplo n.º 2
0
        public override void OnMouseUp(CanvasPanel canvasPanel, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                canvasPanel.Cursor = this.Cursor;
                _dragInfo = null;
            }
            else if (e.Button==MouseButtons.Right)
            {
                if (_selectedShape!=null)
                {
                    if (_selectedShape.GetType() == typeof(Polygon))
                    {
                        var poly = (Polygon) SelectedShape;
                        int clickedHandler = _selectedShape.GetHandlerAt(e.Location);
                        if (clickedHandler > -1)
                        {
                            poly.RemoveVertex(clickedHandler);
                        }
                        else
                        {
                            poly.AddVertex(e.Location);
                        }

                    }

                    canvasPanel.Refresh();
                }
            }
        }