private void undoButton_Click(object sender, RoutedEventArgs e) { Action lastAction = actionList[actionList.Count - 1]; actionList.Remove(lastAction); undoActionList.Add(lastAction); lastAction.Undo(); if (actionList.Count == 0) { undoButton.IsEnabled = false; curGraphic = null; selectRibbonButton_Unchecked(sender, e); } else { Action prevLastAction = actionList[actionList.Count - 1]; curGraphic = prevLastAction.GetGraphic(); } DrawStuff(); redoButton.IsEnabled = true; isChange = true; UpdateLayerImage(); }
private void AddNewAction(Action newAction) { actionList.Add(newAction); UpdateLayerImage(); undoButton.IsEnabled = true; redoButton.IsEnabled = false; }
private void selectRibbonButton_Checked(object sender, RoutedEventArgs e) { if (ButtonRotate.IsChecked == true) { curActionType = ActionType.Rotating; } else { curActionType = ActionType.Selecting; } curAction = null; curGraphic = null; DisableMenuItem(); CbBox_Shapes.IsEnabled = false; ButtonRotate.IsEnabled = true; DrawStuff(); }
private void New() { layerSystem = new LayerManager(); actionList = new List <Action>(); undoActionList = new List <Action>(); grdLayer.Children.Clear(); curLayerIndex = 0; redoButton.IsEnabled = false; selectRibbonButton.IsChecked = false; ButtonRotate.IsChecked = false; curGraphic = null; RadioBtn_Solid.IsChecked = true; RadioBtn_SolidPenIcon.IsChecked = true; curAction = null; filePath = null; isChange = false; curOutLineColor = Colors.Black; ClearStuff(); undoButton.IsEnabled = false; CbBox_Shapes.SelectedItem = ShapeType.None; curActionType = ActionType.None; }
private void redoButton_Click(object sender, RoutedEventArgs e) { Action lastUndoAction = undoActionList[undoActionList.Count - 1]; undoActionList.Remove(lastUndoAction); actionList.Add(lastUndoAction); lastUndoAction.Redo(); curGraphic = lastUndoAction.GetGraphic(); DrawStuff(); undoButton.IsEnabled = true; if (undoActionList.Count == 0) { redoButton.IsEnabled = false; } isChange = true; UpdateLayerImage(); }
private void Background_MouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { switch (curActionType) { case ActionType.Drawing: curAction = new Actions.Drawing(layerSystem.GetLayer(curLayerIndex), (ShapeType)CbBox_Shapes.SelectedItem, CurrentBrush.Brush, curOutLineColor, curOutlineWidth, curDashStyle, e.GetPosition(Background)); curGraphic = curAction.GetGraphic(); break; case ActionType.Selecting: curAction = new Selecting(layerSystem.GetLayer(curLayerIndex), e.GetPosition(Background)); curGraphic = curAction.GetGraphic(); curAction = null; if (curGraphic != null) { curActionType = ActionType.Selected; EnableMenuItem(); } break; case ActionType.Selected: if (curGraphic.Intersect(e.GetPosition(Background))) { curAction = new Moving(curGraphic, e.GetPosition(Background)); } else if (curGraphic.IntersectWithAnchor(e.GetPosition(Background)) != AnchorType.None) { curAction = new Resizing(curGraphic, e.GetPosition(Background)); } else { curActionType = ActionType.Selecting; selectRibbonButton_Checked(sender, e); } break; case ActionType.Rotating: if (curGraphic != null) { curAction = new Rotating(curGraphic, e.GetPosition(Background)); } break; case ActionType.DrawingText: cTextbox = new CustomTextbox.CustomTextbox(e.GetPosition(Background)); cTextbox.showTextbox(mainGrid, e.GetPosition(mainGrid)); cTextbox.changeFont(cbFonts.SelectedItem.ToString()); cTextbox.changeFontSize(cbFontSize.SelectedItem.ToString()); using (DrawingContext drawingContext = drawingVisual.RenderOpen()) { cTextbox.DrawRect(drawingContext); } buffer.Render(drawingVisual); curActionType = ActionType.Editting; break; case ActionType.Editting: btnConfirm_Click(sender, e); break; } } }