/// <summary>
        /// Groups the given StrokeCollection with the given label.
        /// </summary>
        public void Group(string label, System.Windows.Ink.StrokeCollection selectedStrokes)
        {
            // Apply the label
            if (selectedStrokes.Count > 0)
            {
                CommandList.ApplyLabelCmd applyLabel = new CommandList.ApplyLabelCmd(sketchPanel,
                                                                                     selectedStrokes, label);

                applyLabel.Regroup += new CommandList.RegroupEventHandler(applyLabel_Regroup);

                commandManager.ExecuteCommand(applyLabel);
            }
        }
Beispiel #2
0
        public void ApplyLabelToSelection(ShapeType label)
        {
            if (this.sketchPanel.InkCanvas.GetSelectedStrokes().Count > 0)
            {
                // Apply the label
                CommandList.ApplyLabelCmd applyLabelCmd = new CommandList.ApplyLabelCmd(sketchPanel,
                                                                                        sketchPanel.InkCanvas.GetSelectedStrokes(), label);
                applyLabelCmd.Regroup        += new CommandList.RegroupEventHandler(applyLabel);
                applyLabelCmd.ErrorCorrected += new CommandList.ErrorCorrectedEventHandler(errorCorrected);
                CM.ExecuteCommand(applyLabelCmd);
            }

            if (LabelMenuFinished != null)
            {
                LabelMenuFinished();
            }
        }
        /// <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);
        }
        public void ApplyLabelToSelection(string label)
        {
            if (this.sketchPanel.InkCanvas.GetSelectedStrokes().Count > 0)
            {
                // Apply the label
                CommandList.ApplyLabelCmd applyLabelCmd = new CommandList.ApplyLabelCmd(sketchPanel,
                                                                                        sketchPanel.InkCanvas.GetSelectedStrokes(), label);
                applyLabelCmd.Regroup        += new CommandList.RegroupEventHandler(applyLabel);
                applyLabelCmd.ErrorCorrected += new CommandList.ErrorCorrectedEventHandler(errorCorrected);
                CM.ExecuteCommand(applyLabelCmd);
            }
            else
            {
                // Otherwise change back the cursor
                sketchPanel.InkCanvas.Cursor          = Cursors.Pen;
                sketchPanel.InkCanvas.UseCustomCursor = false;
            }

            this.Visibility = System.Windows.Visibility.Hidden;
            sketchPanel.InkCanvas.InvalidateArrange();
        }
Beispiel #5
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);
        }