示例#1
0
        /// <summary>
        /// Attempts to load a Glider Profile.
        /// </summary>
        /// <param name="path">Absolute Path to Glider Profile.</param>
        /// <returns>A Stab Face Profile.</returns>
        public static Profile LoadGliderProfile(String path)
        {
            Profile p = new Profile();

            using (FileStream reader = new FileStream(path,
                                                      FileMode.Open, FileAccess.Read))
            {
                XmlReader xreader        = XmlReader.Create(reader);
                String    currentElement = "";
                while (xreader.Read())
                {
                    switch (xreader.NodeType)
                    {
                    case XmlNodeType.Element:
                        currentElement = xreader.Name;
                        break;

                    case XmlNodeType.Text:
                        switch (currentElement.ToUpper())
                        {
                        case "MINLEVEL":
                            //TODO
                            Debug.WriteLine("MinLevel: " + xreader.Value);
                            break;

                        case "MAXLEVEL":
                            //TODO
                            Debug.WriteLine("MaxLevel: " + xreader.Value);
                            break;

                        case "FACTIONS":
                            String[] facs = xreader.Value.Split(' ');
                            foreach (string fac in facs)
                            {
                                p.addFaction(Convert.ToUInt16(fac));
                            }
                            break;

                        case "LUREMINUTES":
                            //TODO
                            Debug.WriteLine("LureMinutes: " + xreader.Value);
                            break;

                        case "SKIPWAYPOINTS":
                            //TODO
                            Debug.WriteLine("SkipWaypoints: " + xreader.Value);
                            break;

                        case "NATURALRUN":
                            //TODO
                            Debug.WriteLine("NaturalRun: " + xreader.Value);
                            break;

                        case "WAYPOINT":
                            String[] wps = xreader.Value.Split(' ');
                            p.AddWaypoint(new Waypoint(
                                              Convert.ToSingle(wps[0]),
                                              Convert.ToSingle(wps[1]),
                                              0.0f));
                            break;

                        case "GHOSTWAYPOINT":
                            String[] gwps = xreader.Value.Split(' ');
                            p.AddGhostWaypoint(new Waypoint(
                                                   Convert.ToSingle(gwps[0]),
                                                   Convert.ToSingle(gwps[1]),
                                                   0.0f));
                            break;

                        default:
                            break;
                        }
                        break;
                    }
                }
            }

            return(p);
        }