Exemplo n.º 1
0
        /// <summary>
        /// Removes a labeled shape from a sketch.
        /// </summary>
        public override bool UnExecute()
        {
            // Go through original labels, apply them
            foreach (string shape in origLabels.Keys)
            {
                ApplyLabelCmd unLabel = new ApplyLabelCmd(sketchPanel, origLabels[shape].B, origLabels[shape].A.Name, false, false);
                unLabel.Regroup = Regroup;
                unLabel.Execute();
            }

            // Unlabel everything that was not labeled before (note: will make these Unknown, but all the same shape)
            if (unlabeledStrokes.Count > 0)
            {
                ApplyLabelCmd unLabel2 = new ApplyLabelCmd(sketchPanel, unlabeledStrokes, (new ShapeType()).Name, false, false);
                unLabel2.Regroup = Regroup;
                unLabel2.Execute();
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add the stroke
        /// </summary>
        public override bool Execute()
        {
            //Make the stroke on the screen
            if (storedStroke == null)
            {
                storedStroke = addSubCircuitBox(addPoint);
            }
            else
            {
                sketchPanel.InkSketch.AddStroke(storedStroke);
            }
            Sketch.Substroke associatedSub = sketchPanel.InkSketch.GetSketchSubstrokeByInk(storedStroke);

            //Label the stroke as a subcircuit and give it the tag number for project lookup
            // We dont want this on the command stack because the undo of this will handle everything we want
            ApplyLabelCmd applyLabel = new ApplyLabelCmd(sketchPanel, new StrokeCollection(new Stroke[] { storedStroke }),
                                                         Domain.LogicDomain.SUBCIRCUIT, true, true, tagNumber);

            applyLabel.Execute();
            Sketch.Shape associatedShape = associatedSub.ParentShape;
            associatedShape.SubCircuitNumber = tagNumber;

            //color and select the stroke
            storedStroke.DrawingAttributes.Color = associatedShape.Type.Color;
            sketchPanel.InkCanvas.Select(new StrokeCollection(new Stroke[] { storedStroke }));

            //Add to the embed list if you need to, only if you embed with the widget and it's not already in the list
            if (embedCallback != null)
            {
                embedCallback(associatedShape, addToList);
                //make sure we don't add it to the list again
                embedCallback = null;
                addToList     = false;
            }

            return(true);
        }