Exemplo n.º 1
0
        private void ActionOpen(object sender, EventArgs e)
        {
            if (this.CloseCurrentWorkspace())
            {
                if (this.openDocumentDialog.ShowDialog() == DialogResult.OK)
                {
                    this.workspace = Workspace.Open(
                        this.WorkspaceModified,
                        this.WorkspaceSaved,
                        this.openDocumentDialog.FileName);

                    this.LoadWorkspace(this.workspace);

                    this.ResetMenuToolStatus();
                    this.editor.Text          = null;
                    this.editor.Enabled       = false;
                    this.browser.DocumentText = null;

                    this.mnuClose.Enabled             = true;
                    this.mnuProperties.Enabled        = true;
                    this.mnuOpenWorkingFolder.Enabled = true;



                    if (!templateReader.Exists(this.workspace.Document.TemplateId))
                    {
                        if (MessageBox.Show(
                                Resources.TemplateDoesNotExistConfirmMessage,
                                Resources.Confirmation,
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            var frmDocumentPropertyEditor = new FrmDocumentPropertyEditor(this.workspace.Document);
                            if (frmDocumentPropertyEditor.ShowDialog() == DialogResult.OK)
                            {
                                var settings = frmDocumentPropertyEditor.WorkspaceSettings;
                                this.workspace.Document.Title      = settings.DocumentTitle;
                                this.workspace.Document.Author     = settings.DocumentAuthor;
                                this.workspace.Document.Version    = settings.Version;
                                this.workspace.Document.TemplateId = settings.TemplateId;
                                var documentTreeNode =
                                    tvWorkspace.Nodes.Find(this.workspace.Document.Id.ToString(), false).First();
                                documentTreeNode.Text = this.workspace.Document.Title;
                            }
                        }
                    }
                }
            }
        }