コード例 #1
0
    AnnotationInk CreateAnnotationInk(XmlNode xmlAnnotation)
    {
        AnnotationInk annotationInk = new AnnotationInk ();

        XmlNode xmlElements = null;
        XmlNodeList annotationChildNodeList = xmlAnnotation.ChildNodes;
        for (int w = 0; w < annotationChildNodeList.Count; w++) {
            xmlElements = annotationChildNodeList.Item (w);
            switch (xmlElements.Name) {

            case "formatting":
                //Debug.Log ("formatting: " + xmlElements.InnerText);
                XmlNodeList formattingChildNodes = xmlElements.ChildNodes;
                XmlNode xmlColor = formattingChildNodes.Item (0);

                FormattingInk formattingInk = new FormattingInk ();
                int red = Int32.Parse (formattingChildNodes.Item (0).ChildNodes.Item (0).InnerText);
                int green = Int32.Parse (formattingChildNodes.Item (0).ChildNodes.Item (1).InnerText);
                int blue = Int32.Parse (formattingChildNodes.Item (0).ChildNodes.Item (2).InnerText);
                formattingInk.Color = new Color32 ((byte)red, (byte)green, (byte)blue, 0);

                XmlNode xmlThickness = formattingChildNodes.Item (1);
                formattingInk.Thickness = Int32.Parse(xmlThickness.InnerText);
                annotationInk.FormattingInk = formattingInk;

                break;

            case "path":
                XmlNodeList pathXmlList = xmlElements.ChildNodes;
                List<Vector2> pathList = new List<Vector2>();
                int x = 0;
                for (int j = 0; j < pathXmlList.Count; j++) {
                    if(pathXmlList.Item (j).Name.Equals("x")) {
                        x = Int32.Parse(pathXmlList.Item (j).InnerText);
                    }
                    if(pathXmlList.Item (j).Name.Equals("y")) {
                        Vector2 position = new Vector2();
                        position.x = x;
                        position.y = Int32.Parse(pathXmlList.Item (j).InnerText);

                        pathList.Add(position);
                    }
                }
                annotationInk.Paths = pathList;

                break;

            default:
                break;
            }
        }

        annotationInk = (AnnotationInk) AddAnnotationCommonFields (xmlAnnotation, annotationInk);

        return annotationInk;
    }
コード例 #2
0
    AnnotationInk CreateAnnotationInk(XmlNode xmlAnnotation)
    {
        AnnotationInk annotationInk = new AnnotationInk();

        XmlNode     xmlElements             = null;
        XmlNodeList annotationChildNodeList = xmlAnnotation.ChildNodes;

        for (int w = 0; w < annotationChildNodeList.Count; w++)
        {
            xmlElements = annotationChildNodeList.Item(w);
            switch (xmlElements.Name)
            {
            case "formatting":
                //Debug.Log ("formatting: " + xmlElements.InnerText);
                XmlNodeList formattingChildNodes = xmlElements.ChildNodes;
                XmlNode     xmlColor             = formattingChildNodes.Item(0);

                FormattingInk formattingInk = new FormattingInk();
                int           red           = Int32.Parse(formattingChildNodes.Item(0).ChildNodes.Item(0).InnerText);
                int           green         = Int32.Parse(formattingChildNodes.Item(0).ChildNodes.Item(1).InnerText);
                int           blue          = Int32.Parse(formattingChildNodes.Item(0).ChildNodes.Item(2).InnerText);
                formattingInk.Color = new Color32((byte)red, (byte)green, (byte)blue, 0);


                XmlNode xmlThickness = formattingChildNodes.Item(1);
                formattingInk.Thickness     = Int32.Parse(xmlThickness.InnerText);
                annotationInk.FormattingInk = formattingInk;

                break;

            case "path":
                XmlNodeList    pathXmlList = xmlElements.ChildNodes;
                List <Vector2> pathList    = new List <Vector2>();
                int            x           = 0;
                for (int j = 0; j < pathXmlList.Count; j++)
                {
                    if (pathXmlList.Item(j).Name.Equals("x"))
                    {
                        x = Int32.Parse(pathXmlList.Item(j).InnerText);
                    }
                    if (pathXmlList.Item(j).Name.Equals("y"))
                    {
                        Vector2 position = new Vector2();
                        position.x = x;
                        position.y = Int32.Parse(pathXmlList.Item(j).InnerText);

                        pathList.Add(position);
                    }
                }
                annotationInk.Paths = pathList;

                break;

            default:
                break;
            }
        }

        annotationInk = (AnnotationInk)AddAnnotationCommonFields(xmlAnnotation, annotationInk);

        return(annotationInk);
    }