/// <summary> /// Removes a label from the Substroke /// </summary> /// <param name="label">Label to remove</param> /// <returns>The shape that was removed</returns> public Shape RemoveLabel(ShapeType label) { if (_parentShape.Type == label) { _parentShape.RemoveSubstroke(this); return(_parentShape); } return(null); }
/// <summary> /// Removes a Substroke from the Sketch. Removes parent stroke if /// this substroke is the only substroke in the stroke. /// </summary> /// <param name="substroke">Substroke to remove</param> /// <returns>True iff Substroke is removed</returns> public bool RemoveSubstroke(Substroke substroke) { Stroke parentStroke = substroke.ParentStroke; // Remove this substrokes from parent shapes // and remove all parent shapes that contain // only this substroke object[] parentShapes = substroke.ParentShapes.ToArray(); for (int i = 0; i < parentShapes.Length; ++i) { if (parentShapes[i] != null) { Shape currentShape = (Shape)parentShapes[i]; if (currentShape.Substrokes.Length == 1) { RemoveShape(currentShape); } else { currentShape.RemoveSubstroke(substroke); } } } // Remove the substroke from the parent stroke, // or, if the substroke is its parent stroke's only // child, remove the parent stroke. if (parentStroke.Substrokes.Length == 1) { return(RemoveStroke(parentStroke)); } else { return(parentStroke.RemoveSubstroke(substroke)); } }