Esempio n. 1
0
        private bool ProcessMessage(string message)
        {
            ArgumentAction action;
            string actionParm;
            bool result;

            result = SplitMessage(message, out action, out actionParm);

            if (!result)
            {
                return true;
            }

            switch (action)
            {
                case ArgumentAction.NoOp:
                    result = true;
                    break;

                case ArgumentAction.Open:
                    Activate();

                    if (IsCurrentModalForm && Enabled)
                    {
                        result = this.appWorkspace.OpenFileInNewWorkspace(actionParm);
                    }
                    break;

                case ArgumentAction.Print:
                    Activate();

                    if (IsCurrentModalForm && Enabled)
                    {
                        result = this.appWorkspace.OpenFileInNewWorkspace(actionParm);

                        if (result)
                        {
                            DocumentWorkspace dw = this.appWorkspace.ActiveDocumentWorkspace;
                            PrintAction pa = new PrintAction();
                            dw.PerformAction(pa);
                            CloseWorkspaceAction cwa = new CloseWorkspaceAction(dw);
                            this.appWorkspace.PerformAction(cwa);

                            if (this.appWorkspace.DocumentWorkspaces.Length == 0)
                            {
                                Startup.CloseApplication();
                            }
                        }
                    }
                    break;

                default:
                    throw new InvalidEnumArgumentException();
            }

            return result;
        }
Esempio n. 2
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();
            }
        }