示例#1
0
        private void ReadXml(XmlReader r)
        {
            try
            {
                r.MoveToContent();

                if (!(r.Name == "KinoveaPostureTool"))
                {
                    return;
                }

                r.ReadStartElement();
                string formatVersion = r.ReadElementContentAsString("FormatVersion", "");
                CheckFormatVersion(formatVersion);

                while (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                    // Header section
                    case "Id":
                        Id = new Guid(r.ReadElementContentAsString());
                        break;

                    case "Name":
                        Name = r.ReadElementContentAsString();
                        break;

                    case "DisplayName":
                        DisplayName = r.ReadElementContentAsString();
                        break;

                    case "Icon":
                        r.ReadOuterXml();
                        break;

                    // Data section

                    // Deprecated (1.0)
                    case "PointCount":
                        // Ignored.
                        r.ReadElementContentAsInt();
                        break;

                    case "InitialConfiguration":
                        ParseInitialConfiguration(r);
                        break;

                    case "Points":
                        ParsePoints(r);
                        break;

                    case "Segments":
                        ParseSegments(r);
                        break;

                    case "Ellipses":
                    case "Circles":
                        ParseCircles(r);
                        break;

                    case "Angles":
                        ParseAngles(r);
                        break;

                    // Interaction section
                    case "Handles":
                        ParseHandles(r);
                        break;

                    case "HitZone":
                        ParseHitZone(r);
                        break;

                    // Variables section
                    case "Distances":
                        ParseDistances(r);
                        break;

                    case "Positions":
                        ParsePositions(r);
                        break;

                    case "ComputedPoints":
                        ParseComputedPoints(r);
                        break;

                    // Menus
                    case "Options":
                        ParseOptions(r);
                        break;

                    case "Capabilities":
                        ParseCapabilities(r);
                        break;

                    // Extra
                    case "TrackingProfile":
                        CustomTrackingProfile.ReadXml(r);
                        break;

                    default:
                        string unparsed = r.ReadOuterXml();
                        log.DebugFormat("Unparsed content in XML: {0}", unparsed);
                        break;
                    }
                }

                r.ReadEndElement();

                ConsolidateOptions();
            }
            catch (Exception e)
            {
                log.ErrorFormat("An error occurred during the parsing of a custom tool.");
                log.ErrorFormat(e.ToString());
            }
        }
示例#2
0
        private void ReadXml(XmlReader r)
        {
            try
            {
                r.MoveToContent();

                if (!(r.Name == "KinoveaPostureTool"))
                {
                    return;
                }

                r.ReadStartElement();
                r.ReadElementContentAsString("FormatVersion", "");

                while (r.NodeType == XmlNodeType.Element)
                {
                    switch (r.Name)
                    {
                    case "Icon":
                        r.ReadOuterXml();
                        break;

                    case "Id":
                        Id = new Guid(r.ReadElementContentAsString());
                        break;

                    case "Name":
                        Name = r.ReadElementContentAsString();
                        break;

                    case "DisplayName":
                        DisplayName = r.ReadElementContentAsString();
                        break;

                    case "PointCount":
                        ParsePointCount(r);
                        break;

                    case "Segments":
                        ParseSegments(r);
                        break;

                    case "Ellipses":
                        ParseEllipses(r);
                        break;

                    case "Angles":
                        ParseAngles(r);
                        break;

                    case "Distances":
                        ParseDistances(r);
                        break;

                    case "Positions":
                        ParsePositions(r);
                        break;

                    case "Handles":
                        ParseHandles(r);
                        break;

                    case "ComputedPoints":
                        ParseComputedPoints(r);
                        break;

                    case "HitZone":
                        ParseHitZone(r);
                        break;

                    case "TrackingProfile":
                        CustomTrackingProfile.ReadXml(r);
                        break;

                    case "DefaultOptions":
                        ParseDefaultOptions(r);
                        break;

                    case "Capabilities":
                        ParseCapabilities(r);
                        break;

                    case "InitialConfiguration":
                        ParseInitialConfiguration(r);
                        break;

                    default:
                        string unparsed = r.ReadOuterXml();
                        log.DebugFormat("Unparsed content in XML: {0}", unparsed);
                        break;
                    }
                }

                r.ReadEndElement();

                ImportOptionGroups();
            }
            catch (Exception e)
            {
                log.ErrorFormat("An error occurred during the parsing of a custom tool.");
                log.ErrorFormat(e.ToString());
            }
        }