Ejemplo n.º 1
0
        public void FireFeedbackMechanism(Sketch.Sketch sketch, InkPicture inkPicture, Hashtable ink2sketchIdTable, FeedbackContext context)
        {
            // Disable the Ink Picture if it is already enabled
            bool toggleInkPic = inkPicture.Enabled;

            if (toggleInkPic)
            {
                inkPicture.Enabled = false;
            }

            foreach (Microsoft.Ink.Stroke istroke in inkPicture.Ink.Strokes)
            {
                // If this ink stroke does not have a
                // corresponding sketch stroke, skip it
                if (!ink2sketchIdTable.Contains(istroke.Id))
                {
                    continue;
                }

                // Get the label of the corresponding substroke
                Guid      substrokeGuid = (Guid)ink2sketchIdTable[istroke.Id];
                Substroke substr        = sketch.GetSubstroke(substrokeGuid);
                if (substr != null)
                {
                    string label = substr.GetFirstLabel();

                    // Now color the stroke
                    if (label == UIConstants.WireLabel)
                    {
                        istroke.DrawingAttributes.Color = UIConstants.WireColor;
                    }
                    else if (label == UIConstants.ErrorLabel)
                    {
                        istroke.DrawingAttributes.Color = UIConstants.ErrorColor;
                    }
                }
                else
                {
                    // We should report an error here because
                    // there should be a substroke
                    // in the sketch if it's referenced in the
                    // hashtable
                    continue;
                }
            }

            // Re-enable the ink picture if it was enabled.
            if (toggleInkPic)
            {
                inkPicture.Enabled = true;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set Ink stroke colors based upon domain
        /// </summary>
        public override void FireFeedbackMechanism(Sketch.Sketch sketch,
                                                   InkPicture inkPicture, Hashtable ink2sketchIdTable, FeedbackContext context)
        {
            // Only fire feedback on recogition events
            if (context != FeedbackContext.OnRecognitionResult)
            {
                return;
            }


            // Disable the Ink Picture if it is already enabled
            bool toggleInkPic = inkPicture.Enabled;

            if (toggleInkPic)
            {
                inkPicture.Enabled = false;
            }

            // Set Ink stroke colors
            foreach (Microsoft.Ink.Stroke istroke in inkPicture.Ink.Strokes)
            {
                // If this ink stroke does not have a
                // corresponding sketch stroke, skip it
                if (!ink2sketchIdTable.Contains(istroke.Id))
                {
                    continue;
                }

                // Get the label of the corresponding substroke
                Guid      substrokeGuid = (Guid)ink2sketchIdTable[istroke.Id];
                Substroke substr        = sketch.GetSubstroke(substrokeGuid);
                if (substr != null)
                {
                    string label = substr.GetFirstLabel();

                    // Now color the stroke
                    istroke.DrawingAttributes.Color = domain.getColor(label);

                    // Store the label
                    if (this.ink2sketchLabelTable.Contains(istroke.Id))
                    {
                        this.ink2sketchLabelTable[istroke.Id] = label;
                    }
                    else
                    {
                        this.ink2sketchLabelTable.Add(istroke.Id, label);
                    }
                }
                else
                {
                    // We should report an error here because
                    // there should be a substroke
                    // in the sketch if it's referenced in the
                    // hashtable
                    continue;
                }
            }

            // Re-enable the ink picture if it was enabled.
            if (toggleInkPic)
            {
                inkPicture.Enabled = true;
            }
        }