private static void removeForm(INamedComponent component) { if (component is NamedComponent) { NamedComponent nc = component as NamedComponent; nc.RemoveForm(); return; } if (component is IShowForm) { IShowForm sf = component as IShowForm; sf.RemoveForm(); return; } IChildObjectLabel l = ContainerPerformer.GetPanel(component as IObjectLabel) as IChildObjectLabel; l.RemoveForm(); }
/// <summary> /// Removes itself /// </summary> /// <param name="removeForm">The "remove form" sign</param> public void Remove(bool removeForm) { Control cp = Parent; if (cp != null) { if (cp.Controls.Contains(rbox)) { cp.Controls.Remove(rbox); } } if (removeForm) { if (label is IShowForm) { IShowForm sf = label as IShowForm; Form form = sf.Form as Form; if (form is IRemovableObject) { IRemovableObject r = form as IRemovableObject; r.RemoveObject(); } sf.RemoveForm(); sf = null; } } if (isRemoved) { return; } isRemoved = true; if (label is IRemovableObject) { IRemovableObject r = label as IRemovableObject; r.RemoveObject(); } Control cont = label as Control; Control c = Parent; if (c != null) { PanelDesktop d = pDesktop; if (c.Controls.Contains(cont)) { d.Remove(label); if (c.Controls.Contains(cont)) { c.Controls.Remove(cont); } } } if (label.Object is IRemovableObject) { IRemovableObject obj = label.Object as IRemovableObject; obj.RemoveObject(); obj = null; } cont.Dispose(); label = null; cont = null; GC.Collect(); }