コード例 #1
0
ファイル: PolygonTool.cs プロジェクト: Bajena/PolygonEditor
 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();
     }
 }
コード例 #2
0
ファイル: PolygonTool.cs プロジェクト: Bajena/PolygonEditor
        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();
            }
        }
コード例 #3
0
ファイル: PolygonTool.cs プロジェクト: Bajena/PolygonEditor
        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();
        }