internal void RemovePageFromWizard(WizardPage page) { IDesignerHost h = this.DesignerHost; IComponentChangeService c = this.ComponentChangeService; if (h == null || c == null) { throw new ArgumentNullException("Both IDesignerHost and IComponentChangeService arguments cannot be null."); } if (WizardControl == null || !WizardControl.Pages.Contains(page)) { return; } DesignerTransaction dt = null; try { dt = h.CreateTransaction("Remove Wizard Page"); MemberDescriptor member = TypeDescriptor.GetProperties(this.WizardControl)["Pages"]; base.RaiseComponentChanging(member); if (page.Owner != null) { //c.OnComponentChanging(page.Owner, null); page.Owner.Pages.Remove(page); //c.OnComponentChanged(page.Owner, null, null, null); h.DestroyComponent(page); } else { //c.OnComponentChanging(page, null); page.Dispose(); //c.OnComponentChanged(page, null, null, null); } base.RaiseComponentChanged(member, null, null); } finally { if (dt != null) { dt.Commit(); } } RefreshDesigner(); }
internal void RemovePageFromWizard(WizardPage page) { var h = DesignerHost; var c = ComponentChangeService; if (h == null || c == null) { throw new ArgumentException("Both IDesignerHost and IComponentChangeService arguments cannot be null."); } if (Control == null || !Control.Pages.Contains(page)) { return; } DesignerTransaction dt = null; try { dt = h.CreateTransaction("Remove Wizard Page"); MemberDescriptor member = TypeDescriptor.GetProperties(Control)["Pages"]; RaiseComponentChanging(member); if (page.Owner != null) { page.Owner.Pages.Remove(page); h.DestroyComponent(page); } else { page.Dispose(); } RaiseComponentChanged(member, null, null); } finally { dt?.Commit(); } RefreshDesigner(); }