Beispiel #1
0
        void DockContent_FormClosing(object sender, FormClosingEventArgs e)
        {
            DockContent      dc = sender as DockContent;
            DockableDocument dd = dc.Tag as DockableDocument;

            if (dd.Editor.Modified)
            {
                switch (MessageBox.Show(this, string.Format("Do you want to save '{0}'?", dc.TabText), "Saving?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1))
                {
                case DialogResult.Cancel:
                    e.Cancel = true;
                    break;

                case DialogResult.Yes:
                    if (dd.Save() == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                    break;

                case DialogResult.No:
                    break;
                }
            }
        }
Beispiel #2
0
        void DockContent_FormClosing(object sender, FormClosingEventArgs e)
        {
            DockContent      dc = sender as DockContent;
            DockableDocument dd = dc.Tag as DockableDocument;

            if (dd.Editor.Modified)
            {
                switch (MessageBox.Show(this, string.Format("Do you want to save '{0}'?", dc.TabText), "Saving?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1))
                {
                case DialogResult.Cancel:
                    e.Cancel = true;
                    break;

                case DialogResult.Yes:
                    if (dd.Save() == DialogResult.Cancel)
                    {
                        e.Cancel = true;
                    }
                    break;

                case DialogResult.No:
                    break;
                }
                //MessageBoxEx msgBox = MessageBoxExManager.CreateMessageBox("ask for saving");
                //msgBox.Caption = "Saving?";
                //msgBox.Text = string.Format("Do you want to save '{0}'?", dd.FileName);
                //msgBox.Icon = MessageBoxExIcon.Exclamation;

                //msgBox.AddButton("Yes", "Y");
                //msgBox.AddButton("No", "N");
                //msgBox.AddButton("Cancel", "C");
                //switch (msgBox.Show(this))
                //{
                //    case "C":
                //        e.Cancel = true;
                //        break;
                //    case "Y":
                //        if (dd.Save() == DialogResult.Cancel)
                //        {
                //            e.Cancel = true;
                //        }
                //        break;
                //    case "N":
                //        break;
                //}
            }
        }