Ejemplo n.º 1
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sketch">SketchPanel to add a label to</param>
        /// <param name="inkStrokes">InkOverlay strokes</param>
        /// <param name="inkStrokes">A StrokeCollection strokes</param>
        /// <param name="label">Label to apply</param>
        public ApplyLabelCmd(SketchPanel sketch, StrokeCollection inkStrokes,
                             string label, bool userSpecifiedGroup = true, bool userSpecifiedLabel = true)
        {
            isUndoable = false;

            this.sketchPanel        = sketch;
            this.label              = label;
            this.inkStrokes         = inkStrokes;
            this.userSpecifiedGroup = userSpecifiedGroup;
            this.userSpecifiedLabel = userSpecifiedLabel;
            labelColor              = LogicDomain.getType(label).Color;

            // Save the original labels of the substrokes
            origLabels       = new Dictionary <string, Data.Pair <ShapeType, StrokeCollection> >();
            unlabeledStrokes = new StrokeCollection();

            foreach (Stroke stroke in inkStrokes)
            {
                Sketch.Substroke sub = sketchPanel.InkSketch.GetSketchSubstrokeByInk(stroke);

                if (sub.ParentShape != null)
                {
                    if (!origLabels.ContainsKey(sub.ParentShape.Name))
                    {
                        origLabels[sub.ParentShape.Name] = new Data.Pair <ShapeType, StrokeCollection>(sub.ParentShape.Type, new StrokeCollection());
                    }
                    origLabels[sub.ParentShape.Name].B.Add(stroke);
                }
                else
                {
                    unlabeledStrokes.Add(stroke);
                }
            }
        }
 public EndPointHighlightFeedback(ref SketchPanel parentPanel, EndPointMovedHandler endPointMovedFunction)
     : base(ref parentPanel)
 {
     init();
     Clear();
     endPointMoved = endPointMovedFunction;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sketch">SketchPanel to add a label to</param>
        /// <param name="inkStrokes">InkOverlay strokes</param>
        /// <param name="inkStrokes">A StrokeCollection strokes</param>
        /// <param name="label">Label to apply</param>

        public ApplyLabelCmd(SketchPanel sketch, StrokeCollection inkStrokes,
                             ShapeType labelType, bool userSpecifiedGroup = true, bool userSpecifiedLabel = true, int tagNumber = int.MinValue)
        {
            isUndoable = true;

            this.sketchPanel        = sketch;
            this.inkStrokes         = inkStrokes;
            this.userSpecifiedGroup = userSpecifiedGroup;
            this.userSpecifiedLabel = userSpecifiedLabel;
            this.tagNumber          = tagNumber;
            this.labelType          = labelType;

            // Save the original labels of the substrokes
            originalLabels   = new Dictionary <Sketch.Shape, Tuple <ShapeType, StrokeCollection> >();
            unlabeledStrokes = new StrokeCollection();

            foreach (Stroke stroke in inkStrokes)
            {
                // If the stroke is classified, save its original shape.
                Sketch.Substroke sub = sketchPanel.InkSketch.GetSketchSubstrokeByInk(stroke);
                if (sub.ParentShape != null)
                {
                    if (!originalLabels.ContainsKey(sub.ParentShape))
                    {
                        originalLabels[sub.ParentShape] = new Tuple <ShapeType, StrokeCollection>(sub.ParentShape.Type, new StrokeCollection());
                    }
                    originalLabels[sub.ParentShape].Item2.Add(stroke);
                }
                else // Record that it wasn't labeled.
                {
                    unlabeledStrokes.Add(stroke);
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// <see cref="SketchPanelSubscriber.SubscribeToPanel"/>
        /// </summary>
        public override void SubscribeToPanel(SketchPanel parentPanel)
        {
            base.SubscribeToPanel(parentPanel);

            sketchPanel.ResultReceived   += new RecognitionResultReceivedHandler(sketchPanel_ResultReceived);
            sketchPanel.SketchFileLoaded += new SketchFileLoadedHandler(sketchPanel_SketchFileLoaded);
            //sketchPanel.InkPicture.Resize += new EventHandler(InkPicture_Resize);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RedrawCmd(SketchPanel panel, StrokeCollection oldStrokes, StrokeCollection newStrokes)
        {
            sketchPanel = panel;
            OldStrokes  = new StrokeCollection();
            NewStrokes  = new StrokeCollection();

            NewStrokes.Add(newStrokes);
            OldStrokes.Add(oldStrokes);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// <see cref="FeedbackMechanism.SubscribeToPanel"/>
        /// </summary>
        public override void SubscribeToPanel(SketchPanel parentPanel)
        {
            sketchPanel = parentPanel;

            sketchPanel.ResultReceived          += new RecognitionResultReceivedHandler(sketchPanel_ResultReceived);
            sketchPanel.SketchFileLoaded        += new SketchFileLoadedHandler(sketchPanel_SketchFileLoaded);
            sketchPanel.InkCanvas.StrokeErasing += new InkCanvasStrokeErasingEventHandler(InkPicture_StrokesDeleting);
            sketchPanel.InkTransformed          += new InkTransformedEventHandler(sketchPanel_InkTransformed);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor for the simulation manager.
        /// </summary>
        /// <param name="panel">The panel that this manager controls</param>
        public SimulationManager(ref SketchPanel panel)
        {
            sketchPanel = panel;
            directory   = AppDomain.CurrentDomain.BaseDirectory;

            // Circuit related initializations
            inputMapping           = new Dictionary <string, ListSet <String> >();
            outputMapping          = new Dictionary <string, ListSet <String> >();
            wireToInputGateMapping = new Dictionary <string, Dictionary <int, ListSet <string> > >();
        }
        public SelectionManager(ref CommandManagement.CommandManager commandManager, ref SketchPanel SP)
        {
            // Set the CommandManager, DomainInfo and SketchPanel
            this.commandManager = commandManager;
            this.sketchPanel    = SP;

            // Widget helpers
            this.selector = new DragBoxSelect(ref sketchPanel);
            this.editMenu = new EditMenu.EditMenu(ref this.sketchPanel, this.commandManager);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// <see cref="FeedbackMechanism.SubscribeToPanel"/>
        /// </summary>
        public override void SubscribeToPanel(SketchPanel parentPanel)
        {
            base.SubscribeToPanel(parentPanel);

            labels = new List <Label>();

            sketchPanel.ResultReceived          += new RecognitionResultReceivedHandler(sketchPanel_ResultReceived);
            sketchPanel.SketchFileLoaded        += new SketchFileLoadedHandler(sketchPanel_SketchFileLoaded);
            sketchPanel.InkCanvas.StrokeErasing += new System.Windows.Controls.InkCanvasStrokeErasingEventHandler(InkCanvas_StrokesDeleting);
        }
Ejemplo n.º 10
0
        public override void SubscribeToPanel(SketchPanel parentPanel)
        {
            base.SubscribeToPanel(parentPanel);

            toolTip = new ToolTip();
            toolTip.InitialDelay              = 100;
            sketchPanel.InkPicture.MouseMove += new MouseEventHandler(InkPicture_MouseMove);
            sketchPanel.SketchFileLoaded     += new SketchFileLoadedHandler(enableMe);
            sketchPanel.ResultReceived       += new RecognitionResultReceivedHandler(sketchPanel_ResultReceived);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Constructor for the simulation manager.
        /// </summary>
        /// <param name="panel">The panel that this manager controls</param>
        public SimulationManager(ref SketchPanel panel)
        {
            sketchPanel = panel;

            // Circuit related initializations
            inputMapping             = new Dictionary <Shape, ListSet <String> >();
            outputMapping            = new Dictionary <Shape, ListSet <String> >();
            wireToInputGateMapping   = new Dictionary <Shape, Dictionary <int, ListSet <string> > >();
            subCircuitShapetoElement = new Dictionary <Shape, CircuitElement>();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// <see cref="SketchPanelSubscriber.SubscribeToPanel"/>
        /// </summary>
        public override void SubscribeToPanel(ref SketchPanel parentPanel)
        {
            if (subscribed)
            {
                return;
            }
            base.SubscribeToPanel(ref parentPanel);

            sketchPanel.SketchFileLoaded += new SketchFileLoadedHandler(sketchPanel_SketchFileLoaded);
            subscribed = true;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="originalSketch"></param>
        public DisplayHelpTool(ref SketchPanel SP)
            : base()
        {
            // Set the sketch panel info and tooltips
            this.toolTips    = new Dictionary <Shape, Popup>();
            this.sketchPanel = SP;

            // Timer
            this.hoverTimer          = new System.Windows.Forms.Timer();
            this.hoverTimer.Interval = INTERVAL;
        }
        private HoverCrossSelect selector;      // Handles adding and removing strokes from selection

        #endregion

        #region Constructor

        public HoverCrossManager(ref CommandManager commandManager, ref SketchPanel SP)
            : base(ref commandManager, ref SP)
        {
            // Set the CommandManager, DomainInfo and SketchPanel
            this.commandManager = commandManager;

            this.sketchPanel = SP;

            this.selector = new HoverCrossSelect(ref sketchPanel);

            this.editMenu = new EditMenu.EditMenu(ref this.sketchPanel, this.commandManager);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Subscribes to SketchPanel.  Subscibe only when tool is selected.
        /// <see cref="SketchPanelLib.SketchPanelListener.SubscribeToPanel()"/>
        /// </summary>
        public override void SubscribeToPanel(SketchPanel parentPanel)
        {
            base.SubscribeToPanel(parentPanel);

            // Hook into SketchPanel Events
            sketchPanel.InkPicture.SelectionChanged += new InkOverlaySelectionChangedEventHandler(InkPicture_SelectionChanged);

            //init();

            // Put panel in Select Mode
            sketchPanel.EditingMode = InkOverlayEditingMode.Select;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// <see cref="SketchPanelSubscriber.SubscribeToPanel"/>
        /// </summary>
        public override void SubscribeToPanel(ref SketchPanel parentPanel)
        {
            if (subscribed)
            {
                return;
            }
            base.SubscribeToPanel(ref parentPanel);

            sketchPanel.ResultReceived   += new RecognitionResultReceivedHandler(sketchPanel_ResultReceived);
            sketchPanel.SketchFileLoaded += new SketchFileLoadedHandler(sketchPanel_SketchFileLoaded);
            //sketchPanel.InkPicture.Resize += new EventHandler(InkPicture_Resize);
            subscribed = true;
        }
        /// <summary>
        /// Constructor.  Makes gate drawer, initializes lists, subscribes to supplied panel
        /// </summary>
        /// <param name="parent"></param>
        public GhostGateFeedback(ref SketchPanel parent)
            : base(ref parent)
        {
            // Set up gate drawer
            gateDrawer                  = new GateDrawing.GateDrawing();
            gateDrawer.RotateGates      = true;
            gateDrawer.SnapRotation     = true;
            gateDrawer.LockDrawingRatio = true;

            // Initialize our list of ghosts
            this.currGhosts = new List <GhostGate>();

            SubscribeToPanel();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// <see cref="FeedbackMechanism.SubscribeToPanel"/>
        /// </summary>
        public override void SubscribeToPanel(SketchPanel parentPanel)
        {
            sketchPanel = parentPanel;

            sketchPanel.ResultReceived += new SketchPanelLib.RecognitionResultReceivedHandler(sketchPanel_ResultReceived);

            /*sketchPanel.ResultReceived += new RecognitionResultReceivedHandler(sketchPanel_ResultReceived);
             * sketchPanel.InkPicture.MouseMove += new System.Windows.Forms.MouseEventHandler(InkPicture_MouseMove);
             * sketchPanel.InkPicture.CursorInRange += new Microsoft.Ink.InkCollectorCursorInRangeEventHandler(InkPicture_CursorInRange);
             * sketchPanel.InkPicture.Painted += new InkOverlayPaintedEventHandler(InkPicture_Painted);
             * sketchPanel.InkPicture.StrokesDeleting += new InkOverlayStrokesDeletingEventHandler(InkPicture_StrokesDeleting);
             * sketchPanel.ZoomEvent += new ZoomEventHandler(sketchPanel_ZoomEvent);
             * sketchPanel.SketchFileLoaded += new SketchFileLoadedHandler(sketchPanel_SketchFileLoaded);
             * */
        }
        /// <summary>
        /// HACK need this constructor to get this class to compile.
        /// This Constructor simply creates a new LabelerPanel. Do not use it.
        /// <see cref="http://blogs.msdn.com/jmanning/archive/2005/09/21/472456.aspx"/>
        /// </summary>

        /*public LabelerPanelAdatper(CommandManager CM, DomainInfo domainInfo)
         *  : base(CM, domainInfo)
         * {
         * }*/

        /// <summary>
        /// Constructor.  Wraps the given SketchPanel
        /// </summary>
        /// <param name="panel">The panel to wrap</param>
        public LabelerPanelAdatper(SketchPanel panel)
        {
            sketchPanel = panel;

            // Build Ink 2 Sketch map
            base.mIdToSubstroke = new Dictionary <int, Substroke>();
            foreach (Substroke sub in sketchPanel.InkSketch.Sketch.Substrokes)
            {
                Microsoft.Ink.Stroke iStroke = sketchPanel.InkSketch.GetInkStrokeBySubstrokeId(sub.XmlAttrs.Id);
                base.mIdToSubstroke.Add(iStroke.Id, sub);
            }

            base.sketch    = sketchPanel.InkSketch.Sketch;
            base.sketchInk = sketchPanel.InkPicture as Labeler.mInkPicture;
        }
Ejemplo n.º 20
0
        public EditMenu(ref SketchPanel sp, CommandManagement.CommandManager commandManager)
        {
            sketchPanel         = sp;
            activeButtonList    = new List <Popup>();
            this.commandManager = commandManager;
            visible             = false;
            labelFuncSet        = false;
            overButton          = false;
            drawPoint           = new Point();

            #region Initialize the images for undo/redo, brush effects

            undoImage = new System.Windows.Controls.Image();
            System.Windows.Media.Imaging.BitmapImage undoBitmap = new System.Windows.Media.Imaging.BitmapImage(new Uri(
                                                                                                                   (AppDomain.CurrentDomain.BaseDirectory + @"EditIcons\UndoIcon.bmp")));
            undoImage.Source = undoBitmap;

            redoImage = new System.Windows.Controls.Image();
            System.Windows.Media.Imaging.BitmapImage redoBitmap = new System.Windows.Media.Imaging.BitmapImage(new Uri(
                                                                                                                   (AppDomain.CurrentDomain.BaseDirectory + @"EditIcons\RedoIcon.bmp")));
            redoImage.Source = redoBitmap;

            undoImageGray = new System.Windows.Controls.Image();
            System.Windows.Media.Imaging.BitmapImage undoGrayBitmap = new System.Windows.Media.Imaging.BitmapImage(new Uri(
                                                                                                                       (AppDomain.CurrentDomain.BaseDirectory + @"EditIcons\UndoIconGray.bmp")));
            undoImageGray.Source = undoGrayBitmap;

            redoImageGray = new System.Windows.Controls.Image();
            System.Windows.Media.Imaging.BitmapImage redoGrayBitmap = new System.Windows.Media.Imaging.BitmapImage(new Uri(
                                                                                                                       (AppDomain.CurrentDomain.BaseDirectory + @"EditIcons\RedoIconGray.bmp")));
            redoImageGray.Source = redoGrayBitmap;

            // Initialize Button Effects and Brushes
            highlightBrush = new System.Windows.Media.LinearGradientBrush(System.Windows.Media.Colors.White, System.Windows.Media.Colors.SkyBlue,
                                                                          new System.Windows.Point(0, 0), new System.Windows.Point(0, 1));
            normalBrush = new System.Windows.Media.LinearGradientBrush(System.Windows.Media.Colors.White, System.Windows.Media.Colors.Silver,
                                                                       new System.Windows.Point(0, 0), new System.Windows.Point(0, 1));

            highlightEffect             = new System.Windows.Media.Effects.DropShadowEffect();
            highlightEffect.ShadowDepth = 1.0;
            highlightEffect.Color       = System.Windows.Media.Colors.Silver;

            #endregion

            InitializeLabelMenu();
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Subscribes to SketchPanel.
        /// <see cref="SketchPanelLib.SketchPanelListener.SubscribeToPanel()"/>
        /// </summary>
        public void SubscribeToPanel(SketchPanel parentPanel, List <ErrorBoxHelp> errors)
        {
            // Update tooltips
            MakeHelpBlocks(errors);

            if (subscribed)
            {
                return;
            }
            subscribed = true;

            // Hook into SketchPanel stylus and stroke events
            sketchPanel.InkCanvas.StylusInAirMove  += new StylusEventHandler(InkCanvas_StylusMove);
            sketchPanel.InkCanvas.StylusDown       += new StylusDownEventHandler(InkCanvas_StylusDown);
            sketchPanel.InkCanvas.StylusOutOfRange += new StylusEventHandler(InkCanvas_StylusOutOfRange);

            hoverTimer.Tick += new EventHandler(hoverTimer_Tick);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Subscribes to SketchPanel.  Subscibe only when tool is selected.
        /// <see cref="SketchPanelLib.SketchPanelListener.SubscribeToPanel()"/>
        /// </summary>
        public void SubscribeToPanel(SketchPanel parentPanel)
        {
            if (subscribed)
            {
                return;
            }
            subscribed = true;

            // Update tooltips
            MakeTextBlocks();

            // Hook into SketchPanel stylus and stroke events (not displayed regularly right now)
            sketchPanel.InkCanvas.StylusDown             += new StylusDownEventHandler(InkCanvas_StylusDown);
            sketchPanel.InkCanvas.StylusOutOfRange       += new StylusEventHandler(InkCanvas_StylusOutOfRange);
            sketchPanel.InkCanvas.Strokes.StrokesChanged += new StrokeCollectionChangedEventHandler(InkCanvas_StrokesChanged);

            hoverTimer.Tick += new EventHandler(hoverTimer_Tick);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RemoveLabelCmd(SketchPanel sketch, StrokeCollection inkStrokes, string label)
        {
            isUndoable = true;

            sketchPanel     = sketch;
            this.inkStrokes = inkStrokes;
            this.label      = Domain.LogicDomain.getType(label);

            labelColor = LogicDomain.getType(label).Color;

            labeledStrokes = new StrokeCollection();
            foreach (Stroke stroke in inkStrokes)
            {
                if (stroke.DrawingAttributes.Color == labelColor)
                {
                    labeledStrokes.Add(stroke);
                }
            }
        }
        /// <summary>
        /// Subscribes to SketchPanel.  Subscibe only when tool is selected.
        /// <see cref="SketchPanelLib.SketchPanelListener.SubscribeToPanel()"/>
        /// </summary>
        public override void SubscribeToPanel(SketchPanel parentPanel)
        {
            base.SubscribeToPanel(parentPanel);

            // Hook into SketchPanel Events
            sketchPanel.InkPicture.SelectionChanged += new InkOverlaySelectionChangedEventHandler(InkPicture_SelectionChanged);

            // Create LabelMenu and Button
            init();

            // Put panel in Select Mode
            sketchPanel.EditingMode = InkOverlayEditingMode.Select;

            // Add button and menu
            sketchPanel.Controls.Add(this.labelButton);
            sketchPanel.Controls.Add(this.labelMenu);

            // Initially hide the controls
            this.labelButton.Hide();
            this.labelMenu.Hide();
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Constructor.  Makes gate drawer, initializes lists, subscribes to supplied panel
        /// </summary>
        /// <param name="parent"></param>
        public GhostGateFeedback(ref SketchPanel parent, GateRotatedHandler gateRotated)
            : base(ref parent)
        {
            // Set up gate drawer
            gateDrawer                  = new GateDrawing.GateDrawing();
            gateDrawer.RotateGates      = true;
            gateDrawer.SnapRotation     = false;
            gateDrawer.LockDrawingRatio = true;
            this.gateRotated            = gateRotated;


            // Initialize our list of ghosts
            this.currGhosts = new List <GhostGate>();

            ShapeToIO   = new Dictionary <Sketch.Shape, KeyValuePair <List <string>, List <string> > >();
            ShapeToGate = new Dictionary <Shape, GhostGate>();

            displayHelpTool = new DisplayHelpTool(ref sketchPanel);

            SubscribeToPanel();
        }
Ejemplo n.º 26
0
 public HoverCrossSelect(ref SketchPanel sketchPanel)
 {
     this.sketchPanel    = sketchPanel;
     this.allowSelection = false;
 }
        /// <summary>
        /// Updates endpoint's connection type based on location of end point painter
        /// </summary>
        /// <returns>True if the endpoint was properly reconnected</returns>
        public System.Windows.Ink.Stroke closestInkStroke(System.Windows.Point searchPoint, SketchPanel sketchPanel)
        {
            // Get the parent shape (a wire)
            Shape wire = endPoint.ParentSub.ParentShape;

            // Find the shape that we're closest to
            StrokeCollection closeStrokes = sketchPanel.InkCanvas.Strokes.HitTest(searchPoint, CONNECT_DIAMETER);

            if (closeStrokes.Count == 0)
            {
                if (debug)
                {
                    Console.WriteLine("Endpoint moved: No Strokes in range");
                }
                return(null);
            }

            // If we're trying to connect the wire to itself, it shouldn't work.
            Shape closestShape = sketchPanel.InkSketch.GetSketchSubstrokeByInk(closeStrokes[0]).ParentShape;

            //if (endPoint.ParentSub.ParentShapes[0] == closestShape)
            //return null;

            return(closeStrokes[0]);
        }
        /// <summary>
        /// <see cref="FeedbackMechanism.SubscribeToPanel"/>
        /// </summary>
        public override void SubscribeToPanel(ref SketchPanel parentPanel)
        {
            base.SubscribeToPanel(ref parentPanel);

            UnpauseEvents();
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Constructor.  Subscribes to the given
 /// SketchPanel and initializes this recognizer
 /// </summary>
 /// <param name="panel">The SketchPanel to which we want to subscribe.</param>
 public TruthTableRecognizer(SketchPanel panel)
 {
     SubscribeToPanel(panel);
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Constructor.  Subscribes to the given
 /// SketchPanel.
 /// </summary>
 /// <param name="panel">The SketchPanel to which we want to subscribe.</param>
 public FlowRecognizer(SketchPanel panel)
     : base(panel)
 {
 }