public void HandleChildDeleted(IEditableUIControl childControl) { // if any of our children are deleted, we want to delete ourselves completely. // First, remove the child that was just deleted, and then delete all other controls and ourself foreach (IUIControl child in ChildControls) { if (child.Equals(childControl) == true) { ChildControls.Remove(child); break; } } HandleDelete(true); //// if we still have children //if( ChildControls.Count > 0 ) //{ // // update our layout // SetPosition( Frame.Left, Frame.Top ); //} //else //{ // // otherwise, delete ourselves and tell our parent // HandleDelete( true ); //} }
public void HandleDelete(bool notifyParent) { // first, delete all our child controls int i = 0; for (i = ChildControls.Count - 1; i >= 0; i--) { // since we DO support child controls that are containers, call HandleDelete on all our children IEditableUIControl editableControl = ChildControls[i] as IEditableUIControl; if (editableControl != null) { // let them know not to inform their parent, since that's us. editableControl.HandleDelete(false); } else { // if it's not editable, we need to remove it ourselves ChildControls[i].RemoveFromView(ParentEditingCanvas); } ChildControls.Remove(ChildControls[i]); } // clean ourselves up RemoveFromView(ParentEditingCanvas); // notify our parent if we need to if (notifyParent) { ParentNote.HandleChildDeleted(this); } }
public void HandleChildDeleted(IEditableUIControl childControl) { // this allows direct children of ours to notify us they were deleted // (example: a user deletes the last word of text in a paragraph - the paragraph deletes itself, but Note must remove it from its ChildControls list.) foreach (IUIControl child in ChildControls) { if (child.Equals(childControl) == true) { ChildControls.Remove(child); break; } } }