Ejemplo n.º 1
0
 /// <summary>
 /// Constructor for removing multiple strokes
 /// </summary>
 /// <param name="sketch"></param>
 /// <param name="strokes"></param>
 public StrokeRemoveCmd(ref InkToSketchWPF.InkCanvasSketch sketch, StrokeCollection strokes)
 {
     isUndoable     = true;
     inkSketch      = sketch;
     removedStrokes = strokes;
     MakeDictionary();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        public CopyCmd(InkToSketchWPF.InkCanvasSketch sketch)
        {
            isUndoable = false;
            inkSketch  = sketch;

            StoredStrokes = inkSketch.InkCanvas.GetSelectedStrokes();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Main constructor of the subcircuit window. Takes in a project that it will wrap into an inkcanvas sketch
        /// in order to display.
        /// </summary>
        /// <param name="subSketch"></param>
        public MainWindow(ref Sketch.Project subSketch)
        {
            try
            {
                InitializeComponent();
            }
            catch (Exception ex)
            {
                // Log error
                System.Console.WriteLine(ex.InnerException.Message);
                //System.Console.WriteLine(ex.ListTrace);
            }

            // Set up notes panel
            this.subSketch        = subSketch;
            WrapperSketch         = new InkToSketchWPF.InkCanvasSketch(new InkCanvas());
            WrapperSketch.project = subSketch;
            this.WrapperSketch.ClearButNotSketch();
            // Makes the ink to display
            WrapperSketch.CreateInkStrokesFromSketch();

            //Set up the ink holder
            this.inkCanvas        = WrapperSketch.InkCanvas;
            this.inkCanvas.Height = dockPanel.Height;
            this.inkCanvas.Width  = dockPanel.Width;

            //The dockPanel is in a view box, which means that it will scale (and scale its children)
            //to fit the screen.
            TextBlock helpText = new TextBlock();

            helpText.Text     = "You can click a sub-circuit if one exists to view it";
            helpText.FontSize = 16;

            dockPanel.Children.Clear();
            dockPanel.Children.Add(this.inkCanvas);
            this.inkCanvas.Children.Add(helpText);

            //Actually color the strokes on the inkcanvas according to the recognition
            //This is valid because only simulatable circuits can be viewed here
            foreach (System.Windows.Ink.Stroke inkStroke in this.inkCanvas.Strokes)
            {
                Sketch.Substroke substroke = (Sketch.Substroke)WrapperSketch.GetSketchSubstrokeByInk(inkStroke);
                Domain.ShapeType label     = substroke.Type;

                Color color = label.Color;

                inkStroke.DrawingAttributes.Color = color;
            }

            //Draws the inkcanvas with the new colors
            this.WrapperSketch.InkCanvas.InvalidateVisual();
            this.inkCanvas.UpdateLayout();



            // Set Editing Modes
            inkCanvas.EditingMode         = InkCanvasEditingMode.None;
            inkCanvas.EditingModeInverted = InkCanvasEditingMode.None;
            inkCanvas.StylusDown         += new StylusDownEventHandler(inkCanvas_StylusDown);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor
        /// </summary>
        public MoveResizeCmd(ref InkToSketchWPF.InkCanvasSketch sketch, Rect oldBounds, Rect newBounds)
        {
            isUndoable  = true;
            inkSketch   = sketch;
            OldBounds   = oldBounds;
            NewBounds   = newBounds;
            SplitShapes = new Dictionary <Sketch.Shape, Sketch.Shape>();

            StoredStrokes = inkSketch.InkCanvas.GetSelectedStrokes();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Constructor
        /// </summary>
        public PasteCmd(InkCanvas canvas, InkToSketchWPF.InkCanvasSketch sketch, Point pastePoint)
        {
            isUndoable = true;
            PastedOnce = false;
            inkCanvas  = canvas;
            inkSketch  = sketch;
            PastePoint = pastePoint;

            ReplacedStrokes = inkCanvas.GetSelectedStrokes();
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor
 /// </summary>
 public MoveResizeCmd(ref InkToSketchWPF.InkCanvasSketch sketch, StrokeCollection resizedStrokes,
                      Rect oldBounds, Rect newBounds)
 {
     isUndoable           = true;
     inkSketch            = sketch;
     this.oldBounds       = oldBounds;
     this.newBounds       = newBounds;
     this.resizedStrokes  = resizedStrokes;
     oldShapesToNewShapes = new Dictionary <Sketch.Shape, Sketch.Shape>();
 }
Ejemplo n.º 7
0
        public MainWindow(ref InkToSketchWPF.InkCanvasSketch sketch, ref RecognitionInterfaces.Recognizer recog)
        {
            try
            {
                InitializeComponent();
            }
            catch (Exception ex)
            {
                // Log error
                System.Console.WriteLine(ex.InnerException.Message);
            }

            // Set up inkSketch
            this.inkSketch = sketch;

            // Set up practice panel
            this.inkCanvas        = inkSketch.InkCanvas;
            this.inkCanvas.Height = practiceDock.ActualHeight;
            this.inkCanvas.Width  = practiceDock.ActualWidth;
            if (!practiceDock.Children.Contains(this.inkCanvas))
            {
                practiceDock.Children.Add(this.inkCanvas);
            }

            inkCanvas.Strokes.StrokesChanged += new System.Windows.Ink.StrokeCollectionChangedEventHandler(Strokes_StrokesChanged);
            inkCanvas.StrokeCollected        += new InkCanvasStrokeCollectedEventHandler(Strokes_StrokesCollected);
            inkCanvas.StrokeErasing          += new InkCanvasStrokeErasingEventHandler(Strokes_StrokesErasing);

            // Set up gate drawing
            gateDrawer = new GateDrawing.GateDrawing();
            gateDrawer.LockDrawingRatio = false;

            recognizer = recog;

            // Set up the list of gates
            defaultChoice         = new ComboBoxItem();
            defaultChoice.Content = "Choose a gate";
            gateChooser.Items.Add(defaultChoice);
            gateChooser.SelectedItem = defaultChoice;

            foreach (ShapeType gate in LogicDomain.Gates)
            {
                if (gate == LogicDomain.SUBCIRCUIT)
                {
                    continue;
                }
                ComboBoxItem item = new ComboBoxItem();
                item.Content = gate.Name;
                gateChooser.Items.Add(item);
            }
            ComboBoxItem free = new ComboBoxItem();

            free.Content = freehandString;
            gateChooser.Items.Add(free);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes the panel using the given InkCanvasSketch.
        /// </summary>
        public virtual void InitPanel(InkToSketchWPF.InkCanvasSketch inkCanvasSketch)
        {
            // Add the inkCanvas to the panel
            this.Children.Clear();
            inkSketch = inkCanvasSketch;
            inkCanvas = inkCanvasSketch.InkCanvas;
            setDefaultInkPicProps();
            this.Children.Add(inkSketch.InkCanvas);

            // Hook into ink events
            subscribeToEvents();
            Recognized = false;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes the panel using the given InkCanvasSketch.
        /// </summary>
        public virtual void InitPanel(InkToSketchWPF.InkCanvasSketch inkCanvasSketch)
        {
            // Add the inkCanvas to the panel
            this.Children.Clear();
            inkSketch = inkCanvasSketch;
            inkCanvas = inkCanvasSketch.InkCanvas;
            inkSketch.InkCanvas.VerticalAlignment   = System.Windows.VerticalAlignment.Stretch;
            inkSketch.InkCanvas.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            this.Children.Add(inkSketch.InkCanvas);
            setDefaultInkPicProps();

            // Hook into ink events
            subscribeToEvents();
            Recognized = false;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor for removing a single stroke
 /// </summary>
 /// <param name="sketch"></param>
 /// <param name="stroke"></param>
 public StrokeRemoveCmd(ref InkToSketchWPF.InkCanvasSketch sketch, Stroke stroke)
     : this(ref sketch, new StrokeCollection(Data.Utils.singleEntryList(stroke)))
 {
 }
Ejemplo n.º 11
0
 public void Initialize()
 {
     inkCanvasSketch = newInkCanvasSketch();
 }
Ejemplo n.º 12
0
 public void Initialize()
 {
     SketchPanelLib.SketchPanel panel = SketchPanelTest.newSketchPanel();
     inkCanvasSketch   = panel.InkSketch;
     simulationManager = new SimulationManager.SimulationManager(ref panel);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// The constructor
 /// </summary>
 /// <param name="canvas"></param>
 /// <param name="sketch"></param>
 /// <param name="stroke"></param>
 public StrokeAddCmd(ref InkToSketchWPF.InkCanvasSketch sketch, Stroke stroke)
 {
     isUndoable = true;
     inkSketch  = sketch;
     thisStroke = stroke;
 }
Ejemplo n.º 14
0
 public void Cleanup()
 {
     inkCanvasSketch = null;
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Constructor.  Creates a sketchPanel using the given commandManager and inkCanvasSketch.
 /// </summary>
 public SketchPanel(CommandManagement.CommandManager commandManager, InkToSketchWPF.InkCanvasSketch inkCanvasSketch)
     : base()
 {
     CM = commandManager;
     this.InitPanel(inkCanvasSketch);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CutCmd(InkToSketchWPF.InkCanvasSketch sketch) : base(sketch)
 {
     isUndoable = true;
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Constructor
 /// </summary>
 public CutCmd(InkToSketchWPF.InkCanvasSketch sketch) : base(sketch)
 {
 }