コード例 #1
0
ファイル: SaveToXML.cs プロジェクト: logisketchUCSD/Code
 /// <summary>
 /// Write the XML to the given XmlTextWriter
 /// </summary>
 /// <param name="textWriter">the target XmlTextWriter, which could be a file or string</param>
 private void WriteXML(XmlTextWriter textWriter)
 {
     textWriter.Formatting = System.Xml.Formatting.Indented;
     textWriter.WriteStartDocument();
     SaveToXML.WriteSketch(this.project, textWriter);
     textWriter.WriteEndDocument();
 }
コード例 #2
0
ファイル: SaveToXML.cs プロジェクト: logisketchUCSD/Code
        private static void WriteStroke(Sketch.Stroke stroke, XmlTextWriter xmlDocument)
        {
            string[] strokeAttributeNames  = stroke.XmlAttrs.getAttributeNames();
            object[] strokeAttributeValues = stroke.XmlAttrs.getAttributeValues();

            Sketch.Substroke[] substrokes = stroke.Substrokes;
            int length;
            int i;

            xmlDocument.WriteStartElement("shape");

            // Write all the attributes
            length = strokeAttributeNames.Length;
            for (i = 0; i < length; ++i)
            {
                if (strokeAttributeValues[i] != null)
                {
                    xmlDocument.WriteAttributeString(strokeAttributeNames[i], strokeAttributeValues[i].ToString());
                }
            }
            // Write the substroke references
            length = substrokes.Length;
            for (i = 0; i < length; ++i)
            {
                SaveToXML.WriteSubstrokeReference(substrokes[i], xmlDocument);
            }

            xmlDocument.WriteEndElement();
        }
コード例 #3
0
ファイル: SaveToXML.cs プロジェクト: logisketchUCSD/Code
        /// <summary>
        /// precondition: circuit is not null
        /// </summary>
        /// <param name="circuit"></param>
        /// <param name="xmlDocument"></param>
        private static void WriteCircuit(Sketch.Project project, XmlTextWriter xmlDocument)
        {
            xmlDocument.WriteStartElement("circuit");

            SaveToXML.WriteInputOutput(project.inputs, project.outputs, xmlDocument);
            SaveToXML.WriteBehavior(project.behavior, xmlDocument);
            SaveToXML.WriteLogisim(project.saveToCircDoc, xmlDocument);
            xmlDocument.WriteEndElement();
        }
コード例 #4
0
        /// <summary>
        /// precondition: circuit is not null
        /// </summary>
        /// <param name="circuit"></param>
        /// <param name="xmlDocument"></param>
        private static void WriteCircuit(CircuitSimLib.Circuit circuit, XmlTextWriter xmlDocument)
        {
            CircuitSimLib.TruthTable truthTable = new CircuitSimLib.TruthTable(circuit);
            xmlDocument.WriteStartElement("circuit");
            List <CircuitSimLib.INPUT>  inputs   = circuit.GlobalInputs;
            List <CircuitSimLib.OUTPUT> outputs  = circuit.GlobalOutputs;
            Dictionary <int, int>       behavior = new Dictionary <int, int>();

            SaveToXML.WriteInputOutput(truthTable, xmlDocument);
            SaveToXML.WriteBehavior(truthTable, xmlDocument);
            xmlDocument.WriteEndElement();
        }
コード例 #5
0
ファイル: SaveToXML.cs プロジェクト: logisketchUCSD/Code
        private static void WriteShape(Sketch.Shape shape, XmlTextWriter xmlDocument)
        {
            string[] shapeAttributeNames  = shape.XmlAttrs.getAttributeNames();
            object[] shapeAttributeValues = shape.XmlAttrs.getAttributeValues();

            Sketch.Substroke[] substrokes = shape.Substrokes;
            int length;
            int i;

            xmlDocument.WriteStartElement("shape");

            // Write all the attributes
            length = shapeAttributeNames.Length;
            for (i = 0; i < length; ++i)
            {
                if (shapeAttributeValues[i] != null)
                {
                    xmlDocument.WriteAttributeString(shapeAttributeNames[i], shapeAttributeValues[i].ToString());
                }
            }
            // Write all the substrokes args
            length = substrokes.Length;
            for (i = 0; i < length; ++i)
            {
                SaveToXML.WriteSubstrokeReference(substrokes[i], xmlDocument);
            }

            // Write all of the neighbor args
            foreach (Sketch.Shape neighbor in shape.ConnectedShapes)
            {
                SaveToXML.WriteNeighborReference(neighbor, xmlDocument);
            }
            if (shape.Type == Domain.LogicDomain.SUBCIRCUIT)
            {
                xmlDocument.WriteStartElement("SubCircuit");
                xmlDocument.WriteAttributeString("tagNumber", shape.SubCircuitNumber.ToString());
                xmlDocument.WriteEndElement();
            }


            xmlDocument.WriteEndElement();
        }
コード例 #6
0
ファイル: SaveToXML.cs プロジェクト: logisketchUCSD/Code
        /// <summary>
        /// writes the sketch and its points, substrokes and shapes to the given xml document.
        /// also writes its circuit.
        /// </summary>
        /// <param name="sketch"></param>
        /// <param name="circuit"></param>
        /// <param name="xmlDocument"></param>
        private static void WriteSketch(Sketch.Project project, XmlTextWriter xmlDocument)

        {
            xmlDocument.WriteStartElement("sketch");

            string[] sketchAttributeNames  = project.sketch.XmlAttrs.getAttributeNames();
            object[] sketchAttributeValues = project.sketch.XmlAttrs.getAttributeValues();

            Sketch.Point[]     points     = project.sketch.Points;
            Sketch.Shape[]     shapes     = project.sketch.Shapes;
            Sketch.Stroke[]    strokes    = project.sketch.Strokes;
            Sketch.Substroke[] substrokes = project.sketch.Substrokes;


            int length;
            int i;


            // Write all the attributes
            length = sketchAttributeNames.Length;
            for (i = 0; i < length; ++i)
            {
                if (sketchAttributeValues[i] != null)
                {
                    xmlDocument.WriteAttributeString(sketchAttributeNames[i], sketchAttributeValues[i].ToString());
                }
            }

            // Write all the points
            length = points.Length;
            for (i = 0; i < length; ++i)
            {
                SaveToXML.WritePoint(points[i], xmlDocument);
            }

            // Write all the substrokes
            length = substrokes.Length;
            for (i = 0; i < length; ++i)
            {
                SaveToXML.WriteSubstroke(substrokes[i], xmlDocument);
            }

            // Write all the strokes
            length = strokes.Length;
            for (i = 0; i < length; ++i)
            {
                SaveToXML.WriteStroke(strokes[i], xmlDocument);
            }

            // Write all the shapes
            length = shapes.Length;
            for (i = 0; i < length; ++i)
            {
                SaveToXML.WriteShape(shapes[i], xmlDocument);
            }

            WriteCircuit(project, xmlDocument);

            WriteSubCircuitInfo(xmlDocument, project);
            xmlDocument.WriteEndElement();
        }