Example #1
0
        void LoadFile()
        {
            string path = Path.Combine(Application.StartupPath, "savegame.xml");

            FDocument.Load(path);

            XmlNode      host;
            XmlAttribute attr;

            string[] nodename;
            char[]   separator = { '|' };
            host = FDocument.SelectSingleNode(@"//HOST");

            if (host != null)
            {
                //restore window
                attr = host.Attributes.GetNamedItem("windowleft") as XmlAttribute;
                if (attr != null)
                {
                    this.Left = Convert.ToInt32(attr.Value);
                }
                attr = host.Attributes.GetNamedItem("windowtop") as XmlAttribute;
                if (attr != null)
                {
                    this.Top = Convert.ToInt32(attr.Value);
                }
                attr = host.Attributes.GetNamedItem("windowwidth") as XmlAttribute;
                if (attr != null)
                {
                    this.Width = Convert.ToInt32(attr.Value);
                }
                attr = host.Attributes.GetNamedItem("windowheight") as XmlAttribute;
                if (attr != null)
                {
                    this.Height = Convert.ToInt32(attr.Value);
                }

                foreach (XmlNode plugin in host.ChildNodes)
                {
                    attr     = plugin.LastChild.Attributes.GetNamedItem("nodename") as XmlAttribute;
                    nodename = attr.Value.Split(separator);

                    if (System.IO.File.Exists(nodename[0]))
                    {
                        PluginPage pp = AddPlugin(nodename[0], nodename[1]);
                        System.Diagnostics.Debug.WriteLine("Loading From XML");
                        pp.LoadFromXML(plugin);
                    }
                }

                //select saved tabindex
                attr = host.Attributes.GetNamedItem("selectedtab") as XmlAttribute;
                if ((attr != null) && (PluginTabs != null))
                {
                    PluginTabs.SelectedIndex = Convert.ToInt32(attr.Value);
                }
            }
        }