Beispiel #1
0
        private bool CloseTab(DocumentView documentView)
        {
            if (documentView.Modified)
            {
                this.ctlTabControl.SelectedTab = documentView.TabPage;

                string question;
                if (string.IsNullOrEmpty(documentView.Filename))
                {
                    question = "Save this file?";
                }
                else
                {
                    question = "Save changes to this file?\r\n\r\n" + documentView.Filename;
                }

                switch (MessageBox.Show(question, "Save Changes",
                                        MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                {
                case DialogResult.Cancel:
                    return(false);

                case DialogResult.Yes:
                    documentView.SaveFile();
                    break;
                }
            }

            this.ctlTabControl.TabPages.Remove(documentView.TabPage);
            documentView.NotifyRemoved();
            this.UpdateUI();
            return(true);
        }
Beispiel #2
0
        private void mnuFileSaveAs_Click(object sender, EventArgs e)
        {
            DocumentView documentView = this.SelectedDocumentView;

            if (documentView == null)
            {
                return;
            }

            try
            {
                this.ctlSaveFileDialog.FileName         = Path.GetFileName(documentView.Filename);
                this.ctlSaveFileDialog.InitialDirectory = Path.GetDirectoryName(documentView.Filename);
            }
            catch {  }

            if (this.ctlSaveFileDialog.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            documentView.SaveFile(this.ctlSaveFileDialog.FileName);
        }