void editorForm_FormClosing(object sender, FormClosingEventArgs e) { FormStyleEditorControl editor = (FormStyleEditorControl)editorForm.Controls[0]; if (editor.IsDirty) { DialogResult result = MessageBox.Show(editorForm, "Current style contains unsaved changed. Do you want to close anyway?", editorForm.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question); e.Cancel = (result == DialogResult.No); } }
public void ShowFormEditor(CustomBorderForm owningForm) { FormStyleEditorControl editor; if (editorForm == null || editorForm.IsDisposed) { editorForm = new Form(); components.Add(editorForm); editorForm.Text = "Form Style Editor"; // editorForm.FormBorderStyle = FormBorderStyle.SizableToolWindow; editorForm.Size = new System.Drawing.Size(600, 400); editor = new FormStyleEditorControl(); editor.Dock = DockStyle.Fill; editorForm.Controls.Add(editor); editorForm.FormClosing += new FormClosingEventHandler(editorForm_FormClosing); editorForm.FormClosed += new FormClosedEventHandler(editorForm_FormClosed); } else { editor = (FormStyleEditorControl)editorForm.Controls[0]; } editor.OwningForm = owningForm; editorForm.Show(); }