Esempio n. 1
0
        /// <summary>
        /// Regroups and recognizes the shape
        /// </summary>
        /// <param name="shape"></param>
        private void regroupShape(Sketch.Shape shape)
        {
            if (shape.Type == new ShapeType())
            {
                //shape.Classification = (new ShapeType()).Classification;
                // If any strokes do not have classifications, we need to reclassify
                foreach (Sketch.Substroke substroke in shape.Substrokes)
                {
                    _strokeClassifier.classify(substroke, _featuresketch);
                }
            }

            if (shape.Substrokes.Length > 0)
            {
                // Give all the substrokes the same classification since they are in the same group
                string Classification = shape.Substrokes[0].Classification;
                shape.Classification = Classification;

                _sketchRecognizer.recognize(shape, _featuresketch);
            }

            else
            {
                Console.WriteLine("WARNING No substrokes available");
            }

            MakeShapeNames();
        }
Esempio n. 2
0
        /// <summary>
        /// Removes a labeled shape from a sketch.
        /// Postcondition: Original shapes are restored.
        /// </summary>
        public override bool UnExecute()
        {
            // Go through original shapes and restore them.
            foreach (var originalLabel in originalLabels)
            {
                Sketch.Shape oldShape = originalLabel.Key;

                List <Sketch.Substroke> originalSubstrokes = new List <Stroke>(originalLabel.Value.Item2).
                                                             ConvertAll(sketchPanel.InkSketch.GetSketchSubstrokeByInk);

                // Free our substrokes from their new shape.
                sketchPanel.InkSketch.Sketch.FreeSubstrokes(originalSubstrokes);

                // Put our substrokes back into the old shape.
                foreach (Sketch.Substroke substroke in originalSubstrokes)
                {
                    oldShape.AddSubstroke(substroke);
                }

                // Put the shape back into the sketch.
                if (!sketchPanel.InkSketch.Sketch.containsShape(oldShape))
                {
                    sketchPanel.InkSketch.Sketch.AddShape(oldShape);
                }
            }

            // Unlabel everything that was not labeled before.
            List <Sketch.Substroke> unknownSubstrokes = new List <Stroke>(unlabeledStrokes).
                                                        ConvertAll(sketchPanel.InkSketch.GetSketchSubstrokeByInk);

            sketchPanel.InkSketch.Sketch.FreeSubstrokes(unknownSubstrokes);

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Find all subgroups within a shape, where subgroups
        /// are sets of adjacent substrokes.
        /// </summary>
        /// <param name="shape"></param>
        /// <returns>A list containing lists of connected substrokes</returns>
        private List <List <Sketch.Substroke> > findShapeSubgroups(Sketch.Shape shape, Dictionary <Guid, Dictionary <Guid, int> > adjacency)
        {
            List <List <Sketch.Substroke> > shapeSubgroups = new List <List <Sketch.Substroke> >();

            // For every stroke in the shape
            foreach (Sketch.Substroke substroke in shape.Substrokes)
            {
                // Calculate whether this substroke is in a new subgroup
                bool belongsToNewSubgroup = true;
                foreach (List <Sketch.Substroke> subList in shapeSubgroups)
                {
                    if (subList.Contains(substroke))
                    {
                        belongsToNewSubgroup = false;
                    }
                }

                // If it does belong to a new subgroup, find and add
                // this entire subgroup to the list
                if (belongsToNewSubgroup)
                {
                    List <Sketch.Substroke> subgroup = new List <Sketch.Substroke>();
                    oneShapeSubgroup(substroke, shape, subgroup, adjacency);
                    shapeSubgroups.Add(subgroup);
                }
            }

            return(shapeSubgroups);
        }
Esempio n. 4
0
        /// <summary>
        /// Break any shapes which are only partially in this selection
        /// </summary>
        private void BreakShapes()
        {
            foreach (Stroke stroke in resizedStrokes)
            {
                Sketch.Substroke substroke = inkSketch.GetSketchSubstrokeByInk(stroke);
                Sketch.Shape     parent    = substroke.ParentShape;

                if (parent != null && !oldShapesToNewShapes.ContainsKey(parent))
                {
                    bool breakShape = false;
                    List <Sketch.Substroke> substrokes = new List <Sketch.Substroke>();

                    foreach (Sketch.Substroke sub in parent.Substrokes)
                    {
                        if (!resizedStrokes.Contains(inkSketch.GetInkStrokeBySubstroke(sub)))
                        {
                            breakShape = true;
                        }
                        else
                        {
                            substrokes.Add(sub);
                        }
                    }

                    if (breakShape)
                    {
                        Sketch.Shape newShape = inkSketch.Sketch.BreakOffShape(parent, substrokes);
                        oldShapesToNewShapes[newShape] = parent;
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// The ghost gate to be drawn and added to the Sketch. The ghost gates are tracked in
        /// Edit Menu in currGhosts. It delegates when to draw and undraw these. The Ghosts have
        /// the shape that is associated with it so that it can update Orientation.
        ///
        /// Also the name Ghost gate is super cool
        /// </summary>
        /// <param name="shape"></param>
        /// <param name="SketchPanel"></param>
        public GhostGate(Sketch.Shape shape, ref SketchPanelLib.SketchPanel SketchPanel, ref GateDrawing.GateDrawing gateDrawer)
        {
            //initialize everything
            startPoint = new System.Windows.Point();
            endPoint   = new System.Windows.Point();

            subscribed = false;

            if (!Domain.LogicDomain.IsGate(shape.Type))
            {
                return;
            }

            myShape = shape;

            // Make the desired image
            GeometryDrawing ghostGate = gateDrawer.DrawGate(myShape.Type, myShape.Bounds, false, true, myShape.Orientation);

            System.Windows.Media.DrawingImage drawingImage = new System.Windows.Media.DrawingImage(ghostGate);
            relabelImage        = new System.Windows.Controls.Image();
            relabelImage.Source = drawingImage;

            sketchPanel = SketchPanel;

            drawingAdvice = createDrawingAdvice(ref gateDrawer);

            //Actual adding of the image
            InkCanvas.SetLeft(relabelImage, myShape.Bounds.Left);
            InkCanvas.SetTop(relabelImage, myShape.Bounds.Top);

            sketchPanel.InkCanvas.Children.Add(relabelImage);
            sketchPanel.InkCanvas.Children.Add(drawingAdvice);
        }
Esempio n. 6
0
        public void FeatureSketchCreationBehavior()
        {
            /*
             * Problem description:
             * When a sketch contains duplicated points, the creation of a FeatureSketch
             * may delete those points.
             */

            Sketch.Sketch sketch = Sketches.newValidSketch();

            // Duplicate a point in the sketch
            Sketch.Shape shape = sketch.Shapes[0];

            List <Sketch.Point> points = new List <Sketch.Point>(shape.Substrokes[0].Points);

            points.Add(points[points.Count - 1]);

            Sketch.Substroke substroke = new Sketch.Substroke(points);
            sketch.AddStroke(new Sketch.Stroke(substroke));
            shape.AddSubstroke(substroke);

            Sketch.Sketch clone = sketch.Clone();

            Assert.IsTrue(sketch.Equals(clone), "Sketch is not equal to its clone");

            Featurefy.FeatureSketch featureSketch = newValidFeatureSketch(new Sketch.Project(sketch));

            Assert.IsTrue(sketch.Equals(clone), "FeatureSketch creation modified original sketch");
        }
Esempio n. 7
0
        public void TestParseTwoInputsAndWire()
        {
            List <Sketch.Shape> modifiedShapes;

            // Add a wire
            Sketch.Substroke wireSub = AddNewStroke(new Tuple <double, double>(0.2, 0.2), new Tuple <double, double>(0.8, 0.8));
            Sketch.Shape     wire    = sketch.MakeNewShapeFromSubstroke(out modifiedShapes, wireSub, Domain.LogicDomain.WIRE, 1);
            wire.Name = "wire_0";

            // Add the left input and connect it to the wire
            Sketch.Substroke firstSub   = AddNewStroke(new Tuple <double, double>(0.0, 0.0), new Tuple <double, double>(0.1, 0.1));
            Sketch.Shape     firstLabel = sketch.MakeNewShapeFromSubstroke(out modifiedShapes, firstSub, Domain.LogicDomain.TEXT, 1);
            firstLabel.Name = "A";
            wire.Endpoints[0].ConnectedShape = firstLabel;
            sketch.connectShapes(firstLabel, wire);

            // Add the right input and connect it to the wire
            Sketch.Substroke secondSub   = AddNewStroke(new Tuple <double, double>(0.9, 0.9), new Tuple <double, double>(1.0, 1.0));
            Sketch.Shape     secondLabel = sketch.MakeNewShapeFromSubstroke(out modifiedShapes, secondSub, Domain.LogicDomain.TEXT, 1);
            secondLabel.Name = "B";
            wire.Endpoints[1].ConnectedShape = secondLabel;
            sketch.connectShapes(secondLabel, wire);

            Assert.IsTrue(parser.SuccessfullyParse(sketch), "parser should be able to parse sketch with a wire connecting two labels");
        }
Esempio n. 8
0
        /// <summary>
        /// Take a substroke and add it to a given shape.
        /// </summary>
        /// <param name="shape">The shape that steals</param>
        /// <param name="substroke">The substroke to steal</param>
        private void stealStroke(Sketch.Shape strokeThief, Sketch.Substroke strokeToSteal, Featurefy.FeatureSketch featureSketch)
        {
            if (strokeToSteal != null)
            {
                // Move the substroke we're trying to steal
                Sketch.Shape strokeLoser = strokeToSteal.ParentShape;
                strokeLoser.RemoveSubstroke(strokeToSteal);
                strokeThief.AddSubstroke(strokeToSteal);

                // Update what these recombinant shapes and their
                // connected shapes are connected to
                List <Sketch.Shape> changedShapes = new List <Sketch.Shape>();
                changedShapes.Add(strokeThief);
                changedShapes.Add(strokeLoser);
                _connector.recomputeConnectedShapes(changedShapes, featureSketch.Sketch);

                // Also update the substroke to match its new shape
                strokeToSteal.Classification = "Gate";

                // See if the stroke thief is a valid shape
                _sketchRecognizer.recognize(strokeThief, featureSketch);

                // See if the stroke loser is a valid shape
                if (strokeLoser.SubstrokesL.Count > 0)
                {
                    _sketchRecognizer.recognize(strokeLoser, featureSketch);
                }
            }
        }
Esempio n. 9
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            Sketch.Shape shape = MakeShape();
            m_Recognizer.addExample(textBox1.Text, shape);

            ClearInk();
        }
Esempio n. 10
0
        /// <summary>
        /// Recognizes a given shape and updates the shape accordingly.
        /// </summary>
        /// <param name="shape">The shape to recogize</param>
        /// <param name="featureSketch">A featuresketch</param>
        public override void recognize(Sketch.Shape shape, Featurefy.FeatureSketch featureSketch)
        {
            // Make sure we do nothing if the user specified the label
            if (shape.AlreadyLabeled)
            {
                return;
            }

            // Use a particular recognizer based on how the shape was
            // classified.

            if (shape.Classification == LogicDomain.WIRE_CLASS)
            {
                _wireRecognizer.recognize(shape, featureSketch);
            }
            else if (shape.Classification == LogicDomain.TEXT_CLASS)
            {
                _textRecognizer.recognize(shape, featureSketch);
            }
            else if (shape.Classification == LogicDomain.GATE_CLASS)
            {
                _gateRecognizer.recognize(shape, featureSketch);
            }
            else
            {
                Console.WriteLine(
                    "Error in shape recognition: cannot recognize" +
                    " a shape with the classification \"" +
                    shape.Classification + "\"");
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Updates the Truth Table headers and also alerts the dictionaries in
        /// SimulationManager
        /// </summary>
        /// <param name="newNameDict">Dictionary of old name keys to new name values</param>
        private void replaceNamesDialog_ReplaceNames(Dictionary <Sketch.Shape, string> newNameDict)
        {
            int index = 0;

            foreach (TableColumn col in TruthTable.Columns)
            {
                Sketch.Shape shape = columnsToShapes[col];
                // If the name has been changed, update the paragraph and column name
                if (newNameDict.ContainsKey(shape))
                {
                    //I guess the names have to be letters, so we have to change it back if it fails
                    string oldname = col.Name;
                    try
                    {
                        col.Name = newNameDict[shape];
                        Block newBlock = new Paragraph(new Run(newNameDict[shape]));
                        TruthTable.RowGroups[0].Rows[0].Cells[index].Blocks.Clear();
                        TruthTable.RowGroups[0].Rows[0].Cells[index].Blocks.Add(newBlock);
                    }
                    catch
                    {
                        MessageBox.Show("That's not a valid name, try using letters", "invalid name");
                        col.Name = oldname;
                        return;
                    }
                }
                index++;
            }

            RelabelStrokes(newNameDict);
        }
Esempio n. 12
0
 /// <summary>
 /// Handles learning from error correction event.
 /// </summary>
 /// <param name="shape"></param>
 public void labelMenu_errorCorrected(Sketch.Shape shape)
 {
     if (LearnFromCorrection != null)
     {
         LearnFromCorrection(shape);
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Reclassify a shape.
        /// If a shape is determined to be incorrectly classified,
        /// this function assigns it the next most likely label.
        /// </summary>
        /// <param name="shape">the shape to reclassify</param>
        private void nextBestLabel(Sketch.Shape shape)
        {
            ShapeType bestlabel = new ShapeType();
            double    bestscore = 0;
            double    total     = 0F;

            foreach (KeyValuePair <ShapeType, double> pair in shape.AlternateTypes)
            {
                total += pair.Value;
                if (pair.Value > bestscore)
                {
                    bestlabel = pair.Key;
                    bestscore = pair.Value;
                }
            }

            shape.AlternateTypes.Remove(bestlabel);
            shape.Type = bestlabel;
            // Currently, the probabilities all add up to 1.
            // This means if we remove a label possibility,
            // the next probability will be unreasonably low.
            // To get around this, we update the new probability by
            // dividing it by the sum of all remaining probabilities.
            shape.Probability = (float)(bestscore / total);
            //shape.Name = bestlabel; // ?????
        }
Esempio n. 14
0
        /// <summary>
        /// Event for when the stylus is lifted from a toggle. Updates input values.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toggle_StylusUp(object sender, StylusEventArgs e)
        {
            TextBlock textBoxClicked = (TextBlock)e.Source;

            // Set the content of the popup
            if (textBoxClicked.Text == OFF)
            {
                textBoxClicked.Text       = ON;
                textBoxClicked.Foreground = ON_COLOR;
            }
            else
            {
                textBoxClicked.Text       = OFF;
                textBoxClicked.Foreground = OFF_COLOR;
            }

            // Find associated parent popup
            Popup toggleClicked = null;

            foreach (Popup popup in inputPopups)
            {
                if (popup.Child == textBoxClicked)
                {
                    toggleClicked = popup;
                    break;
                }
            }

            // Raise the event to alert SimulationManager
            if (SetInputEvent != null && toggleClicked != null)
            {
                Sketch.Shape shape = MovingShapes[toggleClicked];
                SetInputEvent(shape, Convert.ToInt32(textBoxClicked.Text));
            }
        }
Esempio n. 15
0
        private static void WriteNeighborReference(Sketch.Shape shape, XmlTextWriter xmlDocument)
        {
            xmlDocument.WriteStartElement("neighbor");
            xmlDocument.WriteString(shape.Id.ToString());

            xmlDocument.WriteEndElement();
        }
Esempio n. 16
0
        /// <summary>
        /// Updates our meshes drawn and our meshDictionary
        /// </summary>
        /// <param name="mesh"></param>
        /// <param name="child"></param>
        private void UpdateMeshes(List <GeometryDrawing> mesh, CircuitElement elem)
        {
            Sketch.Shape theShape = getShapeByElement(elem);

            // ID number of this mesh
            int index = meshesDrawn.Keys.Count;

            // Update our parent meshes
            foreach (var outputs in elem.Outputs.Values)
            {
                foreach (CircuitElement output in outputs.Keys)
                {
                    Sketch.Shape parentShape = getShapeByElement(output);

                    if (!meshDict.ContainsKey(parentShape))
                    {
                        meshDict[parentShape] = new List <int>();
                    }
                    meshDict[parentShape].Add(index);
                }
            }

            if (!meshDict.ContainsKey(theShape))
            {
                meshDict[theShape] = new List <int>();
            }
            meshDict[theShape].Add(index);

            // Add to meshes drawn
            meshesDrawn[index] = mesh;
        }
Esempio n. 17
0
        /// <summary>
        /// Find all the substrokes that compose one subgroup
        /// within a given shape, starting with a given
        /// seed substroke, and store these substrokes in a
        /// given list.
        ///
        /// A subgroup is defined as a set of adjacent substrokes.
        /// This function uses a depth first search.
        ///
        /// NOTE: the shape must contain the given substroke
        /// </summary>
        /// <param name="seedSubstroke">A substroke in the desired subgroup</param>
        /// <param name="shape">The shape to investigate</param>
        /// <param name="adjacentSubstrokes">The list to store the desired substrokes</param>
        /// <param name="adjacency">The adjacency matrix for strokes</param>
        private void oneShapeSubgroup(Sketch.Substroke seedSubstroke,
                                      Sketch.Shape shape, List <Sketch.Substroke> adjacentSubstrokes, Dictionary <Guid, Dictionary <Guid, int> > adjacency)
        {
            Debug.Assert(shape.SubstrokesL.Contains(seedSubstroke), "Shape does not contain given substroke");

            // Make a list of adjacent substrokes not yet accounted for
            List <Sketch.Substroke> additionalSubstrokes = new List <Sketch.Substroke>();

            foreach (Sketch.Substroke substroke in shape.Substrokes)
            {
                if ((!adjacentSubstrokes.Contains(substroke)) &&
                    ((seedSubstroke.Id == substroke.Id) || (adjacency[seedSubstroke.Id][substroke.Id] > 0)))
                {
                    additionalSubstrokes.Add(substroke);
                }
            }

            // Recurse on each of the found adjacent substrokes
            if (additionalSubstrokes.Count > 0)
            {
                foreach (Sketch.Substroke substroke in additionalSubstrokes)
                {
                    adjacentSubstrokes.Add(substroke);
                }
                foreach (Sketch.Substroke substroke in additionalSubstrokes)
                {
                    oneShapeSubgroup(substroke, shape, adjacentSubstrokes, adjacency);
                }
            }
        }
Esempio n. 18
0
 public void removeIO(Sketch.Shape shape)
 {
     if (ghostGateFeedback.ShapeToIO.ContainsKey(shape))
     {
         ghostGateFeedback.ShapeToIO.Remove(shape);
     }
 }
Esempio n. 19
0
 /// <summary>
 /// Default constructor for making a new,
 /// unconnected wire-mesh associated with a
 /// given shape.
 /// </summary>
 /// <param name="shape">The shape associated
 /// with the new wire</param>
 public WireMesh(Sketch.Shape shape)
     : base(shape)
 {
     _sourceComponent     = null;
     _dependentComponents = new List <CircuitComponent>();
     loadEndpoints();
 }
Esempio n. 20
0
        public void testWriteXML()
        {
            Sketch.Sketch sketch = new Sketch.Sketch();
            sketch.XmlAttrs.Id = System.Guid.NewGuid();

            Sketch.Shape shape = new Sketch.Shape();
            shape.XmlAttrs.Id   = System.Guid.NewGuid();
            shape.XmlAttrs.Name = "shapeName";
            shape.XmlAttrs.Type = "shape";
            shape.XmlAttrs.Time = "111";

            Sketch.Stroke    stroke;
            Sketch.Substroke substroke;
            Sketch.Point     point;

            ulong h;
            ulong i;
            ulong j;

            for (h = 0; h < 3; ++h)
            {
                stroke               = new Sketch.Stroke();
                stroke.XmlAttrs.Id   = System.Guid.NewGuid();
                stroke.XmlAttrs.Name = "strokeName";
                stroke.XmlAttrs.Type = "stroke";
                stroke.XmlAttrs.Time = h;

                for (i = 0; i < 5; ++i)
                {
                    substroke               = new Sketch.Substroke();
                    substroke.XmlAttrs.Id   = System.Guid.NewGuid();
                    substroke.XmlAttrs.Name = "substrokeName";
                    substroke.XmlAttrs.Type = "substroke";
                    substroke.XmlAttrs.Time = i;

                    for (j = 0; j < 10; ++j)
                    {
                        point                   = new Sketch.Point();
                        point.XmlAttrs.X        = (float)random.NextDouble();
                        point.XmlAttrs.Y        = (float)random.NextDouble();
                        point.XmlAttrs.Id       = System.Guid.NewGuid();
                        point.XmlAttrs.Pressure = (ushort)(random.NextDouble() * 256);
                        point.XmlAttrs.Name     = "point" + j.ToString();
                        point.XmlAttrs.Time     = j;

                        substroke.AddPoint(point);
                    }
                    stroke.AddSubstroke(substroke);
                    shape.AddSubstroke(substroke);
                }
                sketch.AddStroke(stroke);
            }
            sketch.AddShape(shape);

            sketch.Strokes[0].SplitStrokeAt(new int[] { 7, 14, 16, 21 });

            ConverterXML.MakeXML xml = new ConverterXML.MakeXML(sketch);
            xml.WriteXML("test.xml");
        }
Esempio n. 21
0
 /// <summary>
 /// Makes all strokes in the specified shape black
 /// </summary>
 /// <param name="shape"></param>
 public void ClearColors(Sketch.Shape shape)
 {
     foreach (Sketch.Substroke sub in shape.Substrokes)
     {
         System.Windows.Ink.Stroke stroke = panel.InkSketch.GetInkStrokeBySubstroke(sub);
         stroke.DrawingAttributes.Color = Colors.Black;
     }
 }
Esempio n. 22
0
        /// <summary>
        /// Sets the location of a single given popup to the location stored in popupLocations
        /// </summary>
        /// <param name="popup"></param>
        /// <param name="newPoint"></param>
        private void ResetPopupLoc(Popup popup)
        {
            Sketch.Shape shape  = MovingShapes[popup];
            Point        newLoc = popupLocations[shape];

            popup.VerticalOffset   = newLoc.Y;
            popup.HorizontalOffset = newLoc.X;
        }
Esempio n. 23
0
        /// <summary>
        /// Recognizes a shape as a wire and updates the shape
        /// accordingly.
        /// </summary>
        /// <param name="shape">The shape to recognize</param>
        /// <param name="featureSketch">The sketch describing features of the shape</param>
        /// <returns>the most probable type of the shape</returns>
        public override RecognitionInterfaces.RecognitionResult recognize(Sketch.Shape shape, Featurefy.FeatureSketch featureSketch)
        {
            // Let's assume we're 100% sure it's a wire, for now...
            double confidence  = 1;
            double orientation = 0;

            return(new RecognitionInterfaces.RecognitionResult(LogicDomain.WIRE, confidence, orientation));
        }
Esempio n. 24
0
        private void buttonRecognize_Click(object sender, EventArgs e)
        {
            Sketch.Shape shape = MakeShape();
            double       score;
            string       result = m_Recognizer.classify(shape, out score);

            labelResult.Text = result + ": " + score.ToString("#0.000");
        }
Esempio n. 25
0
        /// <summary>
        /// finds the midpoint of a shape
        /// </summary>
        /// <param name="sh"></param>
        /// <returns></returns>
        public Sketch.Point shapeMidPoint(Sketch.Shape sh)
        {
            Sketch.Point p = new Sketch.Point();
            p.XmlAttrs.X = (double)sh.XmlAttrs.X + (double)sh.XmlAttrs.Width / 2;
            p.XmlAttrs.Y = (double)sh.XmlAttrs.Y + (double)sh.XmlAttrs.Height / 2;

            return(p);
        }
Esempio n. 26
0
        private static void WriteShapeReference(Sketch.Shape shape, XmlTextWriter xmlDocument)
        {
            xmlDocument.WriteStartElement("arg");
            xmlDocument.WriteAttributeString("type", "shape");
            xmlDocument.WriteString(shape.XmlAttrs.Id.ToString());

            xmlDocument.WriteEndElement();
        }
Esempio n. 27
0
 /// <summary>
 /// Constructs a new, unconnected logic gate
 /// associated with a given shape.
 /// </summary>
 /// <param name="shape">The shape associated
 /// with the new logic gate</param>
 public CircuitComponent(Sketch.Shape shape)
 {
     _associatedShape  = shape;
     _inputWires       = new List <WireMesh>();
     _outputWires      = new List <WireMesh>();
     _inputComponents  = new Dictionary <CircuitComponent, int>();
     _outputComponents = new List <List <CircuitComponent> >();
 }
Esempio n. 28
0
        /// <summary>
        /// Default constructor for making a new,
        /// unconnected wire-mesh associated with a
        /// given shape.
        /// </summary>
        /// <param name="shape">The shape associated
        /// with the new wire</param>
        public WireMesh(Sketch.Shape shape)
        {
            _associatedShape     = shape;
            _sourceComponent     = null;
            _dependentComponents = new List <CircuitComponent>();

            loadEndpoints();
        }
Esempio n. 29
0
 public ShapeRotateCmd(Sketch.Shape shape, double newOrientation)
 {
     this.shape          = shape;
     this.oldOrientation = shape.Orientation;
     this.oldOrientationWasUserSpecified = shape.AlreadyOriented;
     this.newOrientation = newOrientation;
     this.isUndoable     = true;
 }
Esempio n. 30
0
 /// <summary>
 /// Make a mapping from ink strokes to parent shapes
 /// </summary>
 private void MakeDictionary()
 {
     strokesToShapes = new Dictionary <Stroke, Sketch.Shape>();
     foreach (Stroke stroke in removedStrokes)
     {
         Sketch.Shape parent = inkSketch.GetSketchSubstrokeByInk(stroke).ParentShape;
         strokesToShapes[stroke] = parent;
     }
 }