public void DrawingPanelRightMouseButtonPressed(int mouseX, int mouseY) { RightClickPopUp = null; var clickedOnSelectedShape = SelectedShapes.Where(s => s.Contains(mouseX, mouseY)).ToList().Count > 0; if (SelectedShapes.Count > 1 && clickedOnSelectedShape) { var tmpSelectedShapes = new GroupShapes(); foreach (var shape in SelectedShapes) { tmpSelectedShapes.Add(shape); } RightClickPopUp = tmpSelectedShapes.CreateRightClickPopUp(); } else { var shape = DrawnShapes.LastOrDefault(s => s.Contains(mouseX, mouseY)); if (shape != null) { RightClickPopUp = shape.CreateRightClickPopUp(); } } if (RightClickPopUp != null) { _g.OpenRightClickPopUp(); } }
public void ClearDrawingPanel() { DrawnShapes.Clear(); SelectedShapes.Clear(); CreateMemento(); _g.RefreshView(); }
public void DeleteSelectedShapes() { DrawnShapes.RemoveAll(s => SelectedShapes.Contains(s)); SelectedShapes.Clear(); _g.RefreshView(); ClickedOnSelectedShape = false; CreateMemento(); }
private void Undo_Clicked(object sender, RoutedEventArgs e) { if (DrawnShapes.Count > 0) { DrawnShapes.RemoveAt(DrawnShapes.Count - 1); ClearShapesComboSelection(); canvasControl.Invalidate(); } }
public void SetState(List <IShape> drawnShapes, ToolBar toolbar) { DrawnShapes.Clear(); foreach (var shape in drawnShapes) { DrawnShapes.Add((IShape)shape.Clone()); } ToolBar = (ToolBar)toolbar.Clone(); }
public void DrawCurrentShape(int x, int y) { if (_currentShape != null) { _currentShape.Accept(new CenterShapeOnDrawing(x, y)); DrawnShapes.Add(_currentShape); _g.RefreshView(); _currentShape = null; CreateMemento(); } }
public void CreateGroup(GroupShapes gr) { foreach (var shape in gr.Children) { DrawnShapes.Remove(shape); SelectedShapes.Remove(shape); } DrawnShapes.Add(gr); SelectedShapes.Add(gr); CreateMemento(); }
public void RestoreState(Memento newState) { DrawnShapes.Clear(); SelectedShapes.Clear(); foreach (var shape in newState.DrawnShapes) { DrawnShapes.Add((IShape)shape.Clone()); } ToolBar = (ToolBar)newState.ToolBar.Clone(); _g.RefreshView(); _g.RefreshToolBar(); }
public void DeleteGroup(GroupShapes gr) { if (DrawnShapes.Contains(gr)) { DrawnShapes.Remove(gr); foreach (var shape in gr.Children) { DrawnShapes.Add(shape); } SelectedShapes.Clear(); _g.RefreshView(); } CreateMemento(); }
private void Clear_Clicked(object sender, RoutedEventArgs e) { DrawnShapes.Clear(); HideEditPanel(); DrawnShapesCombo.ItemsSource = null; DrawnShapesCombo.ItemsSource = DrawnShapes; if (ShapeToEdit != null) { ShapeToEdit.Mode = ShapeModes.Drawn; ShapeToEdit = null; } canvasControl.Invalidate(); }
private void AddShape() { if (PendingShape != null) { PendingShape.Mode = ShapeModes.Drawn; DrawnShapes.Add(PendingShape); int idx = DrawnShapesCombo.SelectedIndex; DrawnShapesCombo.ItemsSource = null; DrawnShapesCombo.ItemsSource = DrawnShapes; DrawnShapesCombo.SelectedIndex = idx; PendingShape = null; } canvasControl.Invalidate(); }
public void EraseShape(IShape shape) { if (DrawnShapes.Contains(shape)) { DrawnShapes.Remove(shape); } else { foreach (var child in ((GroupShapes)shape).Children) { DrawnShapes.Remove(child); } } _g.RefreshView(); CreateMemento(); }
public void AddRemoveSelectedShape(int x, int y) { var shape = DrawnShapes.LastOrDefault(s => s.Contains(x, y)); if (shape == null) { SelectedShapes.Clear(); } else { if (!SelectedShapes.Contains(shape)) { SelectedShapes.Add(shape); } else { SelectedShapes.Remove(shape); } } _g.RefreshView(); }
private async void ShapeAdd_Clicked(object sender, RoutedEventArgs e) { double sx, sy, ex, ey; try { sx = double.Parse(AddStartLocationX.Text); sy = double.Parse(AddStartLocationY.Text); ex = double.Parse(AddEndLocationX.Text); ey = double.Parse(AddEndLocationY.Text); } catch (Exception) { await InvalidValuesFormatDialog(); return; } Point start = new Point(sx, sy); Point end = new Point(ex, ey); if (CurrentShapeType == ShapeType.Rectangle) { DrawnShapes.Add(new MRectangle(start, end)); } else if (CurrentShapeType == ShapeType.Circle) { start = new Point((ex - sx) / 2, (ey - sy) / 2); DrawnShapes.Add(new MCircle(start, end)); } else if (CurrentShapeType == ShapeType.Line) { DrawnShapes.Add(new MLine(start, end)); } canvasControl.Invalidate(); }