Exemple #1
0
        public bool PerformAction()
        {
            bool flag2;

            try
            {
                if (this.documentWorkspace.ApplyFunction(new AddNewBlankLayerFunction()) == HistoryFunctionResult.Success)
                {
                    PasteAction action = new PasteAction(this.documentWorkspace, this.clipData, this.maskedSurface);
                    if (!action.PerformAction())
                    {
                        using (new WaitCursorChanger(this.documentWorkspace))
                        {
                            this.documentWorkspace.History.StepBackward(this.documentWorkspace.AppWorkspace);
                            goto Label_006E;
                        }
                    }
                    return(true);
                }
Label_006E:
                flag2 = false;
            }
            finally
            {
                this.clipData      = null;
                this.maskedSurface = null;
            }
            return(flag2);
        }
        public bool PerformAction()
        {
            HistoryFunctionResult hfr = this.documentWorkspace.ExecuteFunction(new AddNewBlankLayerFunction());

            if (hfr == HistoryFunctionResult.Success)
            {
                PasteAction pa = new PasteAction(this.documentWorkspace);
                bool result = pa.PerformAction();

                if (!result)
                {
                    using (new WaitCursorChanger(this.documentWorkspace))
                    {
                        this.documentWorkspace.History.StepBackward();
                    }
                }
                else
                {
                    return true;
                }
            }

            return false;
        }
        public bool PerformAction()
        {
            HistoryFunctionResult hfr = this.documentWorkspace.ExecuteFunction(new AddNewBlankLayerFunction());

            if (hfr == HistoryFunctionResult.Success)
            {
                PasteAction pa     = new PasteAction(this.documentWorkspace);
                bool        result = pa.PerformAction();

                if (!result)
                {
                    using (new WaitCursorChanger(this.documentWorkspace))
                    {
                        this.documentWorkspace.History.StepBackward();
                    }
                }
                else
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #4
0
        private void CommonActionsStrip_ButtonClick(object sender, EventArgs<CommonAction> e)
        {
            CommonAction ca = e.Data;

            switch (ca)
            {
                case CommonAction.New:
                    PerformAction(new NewImageAction());
                    break;

                case CommonAction.Open:
                    PerformAction(new OpenFileAction());
                    break;

                case CommonAction.Save:
                    if (ActiveDocumentWorkspace != null)
                    {
                        ActiveDocumentWorkspace.DoSave();
                    }
                    break;

                case CommonAction.Print:
                    if (ActiveDocumentWorkspace != null)
                    {
                        PrintAction pa = new PrintAction();
                        ActiveDocumentWorkspace.PerformAction(pa);
                    }
                    break;

                case CommonAction.Cut:
                    if (ActiveDocumentWorkspace != null)
                    {
                        CutAction cutAction = new CutAction();
                        cutAction.PerformAction(ActiveDocumentWorkspace);
                    }

                    break;

                case CommonAction.Copy:
                    if (ActiveDocumentWorkspace != null)
                    {
                        CopyToClipboardAction ctca = new CopyToClipboardAction(ActiveDocumentWorkspace);
                        ctca.PerformAction();
                    }
                    break;

                case CommonAction.Paste:
                    if (ActiveDocumentWorkspace != null)
                    {
                        PasteAction pa = new PasteAction(ActiveDocumentWorkspace);
                        pa.PerformAction();
                    }

                    break;

                case CommonAction.CropToSelection:
                    if (ActiveDocumentWorkspace != null)
                    {
                        using (new PushNullToolMode(ActiveDocumentWorkspace))
                        {
                            ActiveDocumentWorkspace.ExecuteFunction(new CropToSelectionFunction());
                        }
                    }

                    break;

                case CommonAction.Deselect:
                    if (ActiveDocumentWorkspace != null)
                    {
                        ActiveDocumentWorkspace.ExecuteFunction(new DeselectFunction());
                    }
                    break;

                case CommonAction.Undo:
                    if (ActiveDocumentWorkspace != null)
                    {
                        ActiveDocumentWorkspace.PerformAction(new HistoryUndoAction());
                    }
                    break;

                case CommonAction.Redo:
                    if (ActiveDocumentWorkspace != null)
                    {
                        ActiveDocumentWorkspace.PerformAction(new HistoryRedoAction());
                    }
                    break;

                default:
                    throw new InvalidEnumArgumentException("e.Data");
            }

            if (ActiveDocumentWorkspace != null)
            {
                ActiveDocumentWorkspace.Focus();
            }
        }