Beispiel #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);
        }
Beispiel #2
0
        private bool ProcessMessage(string message)
        {
            if (IsDisposed)
            {
                return(false);
            }

            bool result = SplitMessage(message, out ArgumentAction action, out string 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.OpenUntitled:
                Activate();

                if (!string.IsNullOrEmpty(actionParm) && IsCurrentModalForm && Enabled)
                {
                    result = this.appWorkspace.OpenFileInNewWorkspace(actionParm, false);

                    if (result)
                    {
                        this.appWorkspace.ActiveDocumentWorkspace.SetDocumentSaveOptions(null, null, null);
                        this.appWorkspace.ActiveDocumentWorkspace.Document.Dirty = true;
                    }
                }

                break;

            case ArgumentAction.Print:
                Activate();

                if (!string.IsNullOrEmpty(actionParm) && 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);
        }
Beispiel #3
0
        private bool ProcessMessage(string message)
        {
            ArgumentAction action;
            string         str;

            if (base.IsDisposed)
            {
                return(false);
            }
            bool flag = this.SplitMessage(message, out action, out str);

            if (!flag)
            {
                return(true);
            }
            switch (action)
            {
            case ArgumentAction.Open:
                if (!this.processingOpen)
                {
                    base.Activate();
                    bool isCurrentModalForm = base.IsCurrentModalForm;
                    bool enabled            = base.Enabled;
                    if (!(isCurrentModalForm & enabled))
                    {
                        return(flag);
                    }
                    this.processingOpen = true;
                    try
                    {
                        return(this.appWorkspace.OpenFileInNewWorkspace(str));
                    }
                    finally
                    {
                        this.processingOpen = false;
                    }
                    break;
                }
                Work.QueueWorkItem(delegate {
                    Thread.Sleep(150);
                    this.BeginInvoke(() => this.singleInstanceManager.SendInstanceMessage(message));
                });
                return(true);

            case ArgumentAction.OpenUntitled:
                break;

            case ArgumentAction.Print:
                base.Activate();
                if ((!string.IsNullOrEmpty(str) && base.IsCurrentModalForm) && base.Enabled)
                {
                    flag = this.appWorkspace.OpenFileInNewWorkspace(str);
                    if (!flag)
                    {
                        return(flag);
                    }
                    DocumentWorkspace activeDocumentWorkspace = this.appWorkspace.ActiveDocumentWorkspace;
                    PrintAction       action2 = new PrintAction();
                    activeDocumentWorkspace.PerformAction(action2);
                    CloseWorkspaceAction performMe = new CloseWorkspaceAction(activeDocumentWorkspace);
                    this.appWorkspace.PerformAction(performMe);
                    if (this.appWorkspace.DocumentWorkspaces.Length == 0)
                    {
                        Startup.CloseApplication();
                    }
                }
                return(flag);

            case ArgumentAction.NoOp:
                return(true);

            default:
                throw ExceptionUtil.InvalidEnumArgumentException <ArgumentAction>(action, "action");
            }
            base.Activate();
            if ((!string.IsNullOrEmpty(str) && base.IsCurrentModalForm) && base.Enabled)
            {
                DocumentWorkspace workspace;
                flag = this.appWorkspace.OpenFileInNewWorkspace(str, false, out workspace);
                if (flag)
                {
                    workspace.SetDocumentSaveOptions(null, null, null);
                    workspace.Document.Dirty = true;
                }
            }
            return(flag);
        }