private DrawableItem CreateItem(Point begin, Point end) { DrawableItem item = null; if (DrawingMode == Mode.Rectange) { item = new Rectangle(begin.X, begin.Y, end.X - begin.X, end.Y - begin.Y); } else { item = new Ellipse(begin.X, begin.Y, end.X - begin.X, end.Y - begin.Y); } return item; }
public void CreateOrChangeItem(Point begin, Point end) { if (end != begin) { if (_selectedItem == null) { _items.Add(CreateItem(begin, end)); } else { ChangeItem(_selectedItem, begin, end); } _isCreatingItem = null; Controller.Instance.InvalidateCanvas(); } }
public void SelectItem(Point location) { _selectedItem?.Deselect(); _selectedItem = null; foreach (var item in _items) { if (item.IsOnLocation(location)) { item.Select(); _selectedItem = item; break; } } Controller.Instance.InvalidateCanvas(); }
public void IsCreating(Point begin, Point end) { if(_selectedItem != null) { _isCreatingItem = _selectedItem; } if(_isCreatingItem == null) { _isCreatingItem = CreateItem(begin, end); _isCreatingItem.Color = Color.Gray; } else { ChangeItem(_isCreatingItem, begin, end); } Controller.Instance.InvalidateCanvas(); }
private void ChangeItem(DrawableItem item, Point begin, Point end) { item.Move(begin.X, begin.Y, end.X - begin.X, end.Y - begin.Y); }