public override void OnKeyUp(CanvasPanel canvasPanel, KeyEventArgs e) { if (e.KeyCode==Keys.Delete && SelectedShape!=null) { DeleteSelectedShape(canvasPanel); canvasPanel.Refresh(); } }
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(); } }
public override void OnMouseDoubleClick(CanvasPanel canvasPanel, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (SelectedShape != null) { using (var editShapeDialog = new EditShapeDialog(SelectedShape)) { editShapeDialog.ShowDialog(); canvasPanel.Refresh(); } } } }
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(); }
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(); } }
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(); }
private void Init() { _canvasPanel = new CanvasPanel(); mainWindowSplitContainer.Panel2.Controls.Add(_canvasPanel); mainWindowSplitContainer.FixedPanel = FixedPanel.Panel1; _canvasPanel.Location = new Point(3, 3); _canvasPanel.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top | AnchorStyles.Right; _canvasPanel.Size = new Size(_canvasPanel.Parent.Width - 8, _canvasPanel.Parent.Height - 5); _canvasPanel.MouseMove += canvasPanel_MouseMove; _canvasPanel.ToolChangedEvent += canvasPanel_ToolChangedEvent; this.Resize += MainForm_Resize; _canvasPanel.Paint += canvasPanel_Paint; pixelCountLabel.Text = string.Format("Liczba pixeli: " + GraphicsExtensions.PixelCount); canvasSizeLabel.Text = string.Format("Rozmiar: " + _canvasPanel.Width + " x " + _canvasPanel.Height); }
public virtual void OnKeyUp(CanvasPanel canvasPanel,KeyEventArgs e) { }
public override void OnDeactivate(CanvasPanel canvasPanel) { this.SelectedShape = null; }
public override void OnActivate(CanvasPanel canvasPanel) { base.OnActivate(canvasPanel); }
private void DeleteSelectedShape(CanvasPanel canvasPanel) { canvasPanel.Shapes.Remove(SelectedShape); SelectedShape = null; }
private Shape GetClickedShape(CanvasPanel canvasPanel, MouseEventArgs e) { foreach (var shape in canvasPanel.Shapes) { if (shape.GetHandlerAt(e.Location) > -1) return shape; if (shape.Contains(e.Location)) return shape; } return null; }
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(); } } }
public virtual void OnMouseUp(CanvasPanel canvasPanel, MouseEventArgs e) { }
public override void OnMouseUp(CanvasPanel canvasPanel, MouseEventArgs e) { }
public override void OnMouseMove(CanvasPanel canvasPanel, MouseEventArgs e) { if (_activePolygon != null) { _activePolygon.Vertices[_activePolygon.Vertices.Count - 1] = e.Location; } canvasPanel.Refresh(); }
public virtual void OnDeactivate(CanvasPanel canvasPanel) { }
public override void OnMouseMove(CanvasPanel canvasPanel, MouseEventArgs e) { if (_selectedShape != null && _dragInfo != null) { _dragInfo.CurrentPosition = e.Location; if (_dragInfo.Button == MouseButtons.Left) { if (_dragInfo.DraggedHandlerNumber>-1) { _selectedShape.MoveHandler(_dragInfo.DraggedHandlerNumber,_dragInfo.DragDelta.X,_dragInfo.DragDelta.Y); } else { _selectedShape.Move(_dragInfo.DragDelta.X, _dragInfo.DragDelta.Y); } } canvasPanel.Refresh(); } else if (_selectedShape!=null && _dragInfo==null && _selectedShape.GetHandlerAt(e.Location)>-1) { canvasPanel.Cursor = Cursors.Hand; } else { canvasPanel.Cursor = this.Cursor; } }
public virtual void OnMouseDoubleClick(CanvasPanel canvasPanel, MouseEventArgs e) { }