/// <summary>
        /// Applies a label to a group of substrokes.
        /// </summary>
        public override bool Execute()
        {
            // Add the new stroke to the sketch
            inkSketch.AddStroke(newStroke);

            // Update connections
            Sketch.Substroke newSubstroke = inkSketch.GetSketchSubstrokeByInk(newStroke);
            changedShape.AddSubstroke(newSubstroke);
            oldLocation.ConnectedShape = changedShape;
            newSubstroke.Endpoints[0].ConnectedShape = changedShape;
            newSubstroke.Endpoints[1].ConnectedShape = shapeAtNewLoc;

            // Add the new wire to the old wire's shape
            inkSketch.Sketch.connectShapes(changedShape, changedShape); // wires connected to themselves indicates an internal connection
            inkSketch.Sketch.connectShapes(changedShape, shapeAtNewLoc);
            changedShape.AlreadyLabeled = true;

            // Pre-emptive merging! Helps us undo.
            if (newIsWire)
            {
                inkSketch.Sketch.mergeShapes(changedShape, shapeAtNewLoc);
            }

            // Regroup everything so highlighting/labels are correctly updated
            Handle(changedShape);
            Regroup(new List <Sketch.Shape> {
                changedShape
            });
            return(true);
        }
Пример #2
0
        /// <summary>
        /// Applies a label to a group of substrokes.
        /// </summary>
        public override bool Execute()
        {
            // Add the new stroke to the sketch
            inkSketch.AddStroke(newStroke);

            // Update connections
            Sketch.Substroke newSubstroke = inkSketch.GetSketchSubstrokeByInk(newStroke);

            // If we're using on-the-fly recognition, the new substroke may already have a parent shape.  Get rid of it!
            if (newSubstroke.ParentShape != null)
            {
                Sketch.Shape parent = newSubstroke.ParentShape;
                parent.RemoveSubstroke(newSubstroke);
                if (parent.SubstrokesL.Count == 0)
                {
                    inkSketch.Sketch.RemoveShape(parent);
                }
            }

            changedShape.AddSubstroke(newSubstroke);
            oldLocation.ConnectedShape = changedShape;
            newSubstroke.Endpoints[0].ConnectedShape = changedShape;
            newSubstroke.Endpoints[1].ConnectedShape = shapeAtNewLoc;

            // Add the new wire to the old wire's shape
            inkSketch.Sketch.connectShapes(changedShape, changedShape); // wires connected to themselves indicates an internal connection
            inkSketch.Sketch.connectShapes(changedShape, shapeAtNewLoc);
            changedShape.AlreadyLabeled = true;

            // Pre-emptive merging! Helps us undo.
            if (newIsWire)
            {
                inkSketch.Sketch.mergeShapes(changedShape, shapeAtNewLoc);
            }

            // Regroup everything so highlighting/labels are correctly updated
            Handle(changedShape);
            Regroup(new List <Sketch.Shape> {
                changedShape
            });
            return(true);
        }