Beispiel #1
0
 public override void OnKeyUp(CanvasPanel canvasPanel, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Escape && _activePolygon!=null)
     {
         ShapeCancelledEvent.Invoke(this,new ShapeEventArgs(_activePolygon));
         this._activePolygon = null;
         canvasPanel.Refresh();
     }
 }
Beispiel #2
0
        public override void OnDeactivate(CanvasPanel canvasPanel)
        {
            if (this._activePolygon!=null)
            {
                if (!_activePolygon.Created)
                {
                    if (_activePolygon.Vertices.Count >= 3)
                        _activePolygon.Created = true;
                    else
                        canvasPanel.Shapes.Remove(_activePolygon);
                }

                _activePolygon = null;
                canvasPanel.Refresh();
            }
        }
Beispiel #3
0
        public override void OnMouseDown(CanvasPanel canvasPanel, MouseEventArgs e)
        {
            if (_activePolygon == null)
            {
                _activePolygon = new Polygon(canvasPanel.CurrentColor, canvasPanel.CurrentLineWidth);
                canvasPanel.Shapes.Insert(0,_activePolygon);
                _activePolygon.AddVertex(e.Location);
            }

            //Wierzchołek, którym będziemy poruszać
            _activePolygon.AddVertex(e.Location);

            if (_activePolygon.Created)
                ShapeCreatedEvent.Invoke(this,new ShapeEventArgs(_activePolygon));

            canvasPanel.Refresh();
        }