Esempio n. 1
0
        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();
        }
Esempio n. 2
0
 private void Background_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (curAction != null && curAction.GetGraphic() != null)
     {
         AddNewAction(curAction);
         undoActionList.Clear();
         isChange = true;
     }
     DrawStuff();
 }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
        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;
                }
            }
        }