Exemple #1
0
        /// <summary>
        /// Controls the Config file and makes sure it is in correct format.
        /// </summary>
        /// <param name="masterForm">Master form for accessing controls.</param>
        public XMLController(Form masterForm)
        {
            m_masterForm = masterForm;
            XMLValidator validator = new XMLValidator("Config.xml");

            validator.ValidateXMLFile();
        }
Exemple #2
0
        /// <summary>
        /// Scan the WoW Folders Directory for any folder plugins, validate them, and add them to the program.
        /// </summary>
        public void ScanDirectories()
        {
            if (!Directory.Exists("./ClientPlugins/"))
                Directory.CreateDirectory("./ClientPlugins/");

            String[] files = Directory.GetFiles("./ClientPlugins/", "*.xml");
            foreach (String file in files)
            {
                XMLValidator validator = new XMLValidator(file, iswowfolder: true);
                if (validator.ValidateXMLFile())
                {
                    MessageBox.Show(String.Format("Plugin {0} is in an invalid format! Possibly out of date?", file));
                    continue;
                }
                XmlTextReader reader = new XmlTextReader(file);
                String element = "";
                String locale = "", client = "", fileLocation = "";
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            {
                                element = reader.Name;
                                if (String.Compare(element, "WoWDirectory") == 0)
                                {
                                    client = "0.0.0";
                                    fileLocation = "";
                                    locale = "";
                                }
                                break;
                            }
                        case XmlNodeType.Text:
                            {
                                switch (element)
                                {
                                    case "Client":
                                        client = reader.Value;
                                        break;
                                    case "FileLocation":
                                        fileLocation = reader.Value;
                                        break;
                                    case "Locale":
                                        locale = reader.Value;
                                        break;
                                }
                                break;
                            }
                    }
                }

                if (Config.wowDirectories.ContainsX(client))
                    throw new Exception(String.Format("You cannot have multiple WoW.exe files for the same client {0}!", client));
                if (Config.ValidateClient(client) && Config.ValidateLocale(locale) && fileLocation != "")
                    Config.wowDirectories.Add(client, locale, fileLocation);
            }
        }
Exemple #3
0
        /// <summary>
        /// Scan the Plugins Directory for any plugins, validate them, and add them to the program.
        /// </summary>
        public void ScanPlugins()
        {
            if (!Directory.Exists("./Plugins/"))
            {
                Directory.CreateDirectory("./Plugins/");
            }
            String[] files = Directory.GetFiles("./Plugins/", "*.xml");
            foreach (String sFile in files)
            {
                XMLValidator validator = new XMLValidator(sFile, isplugin: true);
                if (validator.ValidateXMLFile())
                {
                    MessageBox.Show(String.Format("Plugin {0} is in an invalid format! Possibly out of date?", sFile));
                    continue;
                }
                XmlTextReader reader = new XmlTextReader(sFile);
                String        element = "";
                String        name = "", client = "", realmlist = "";
                SArray3       realmOptions = new SArray3();
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        element = reader.Name;
                        if (String.Compare(element, "Realm") == 0)
                        {
                            if (realmOptions.ContainsX(name))
                            {
                                continue;
                            }
                            if (name != "" && Config.ValidateClient(client))
                            {
                                realmOptions.Add(name, realmlist, client);
                            }
                            client    = "0.0.0";
                            name      = "";
                            realmlist = "";
                        }
                        break;
                    }

                    case XmlNodeType.Text:
                    {
                        switch (element)
                        {
                        case "RealmName":
                            name = reader.Value;
                            break;

                        case "RealmList":
                            realmlist = reader.Value;
                            break;

                        case "RealmClient":
                            client = reader.Value;
                            break;
                        }
                        break;
                    }
                    }
                }

                if (realmOptions.ContainsX(name))
                {
                    throw new Exception(String.Format("Realm id {0} used more than once!", name));
                }
                if (Config.ValidateClient(client))
                {
                    realmOptions.Add(name, realmlist, client);
                }

                foreach (Vector3 <String> vector in realmOptions)
                {
                    Config.realmOptions.Add(vector);
                }

                ListView box = (ListView)m_masterForm.Controls["chosenRealm"];
                foreach (Vector3 <String> kvp in realmOptions)
                {
                    ListViewItem itemToAdd = new ListViewItem(kvp.X);
                    itemToAdd.Name = kvp.X;
                    box.Items.Add(itemToAdd);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Scan the WoW Folders Directory for any folder plugins, validate them, and add them to the program.
        /// </summary>
        public void ScanDirectories()
        {
            if (!Directory.Exists("./ClientPlugins/"))
            {
                Directory.CreateDirectory("./ClientPlugins/");
            }

            String[] files = Directory.GetFiles("./ClientPlugins/", "*.xml");
            foreach (String file in files)
            {
                XMLValidator validator = new XMLValidator(file, iswowfolder: true);
                if (validator.ValidateXMLFile())
                {
                    MessageBox.Show(String.Format("Plugin {0} is in an invalid format! Possibly out of date?", file));
                    continue;
                }
                XmlTextReader reader = new XmlTextReader(file);
                String        element = "";
                String        locale = "", client = "", fileLocation = "";
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                    case XmlNodeType.Element:
                    {
                        element = reader.Name;
                        if (String.Compare(element, "WoWDirectory") == 0)
                        {
                            client       = "0.0.0";
                            fileLocation = "";
                            locale       = "";
                        }
                        break;
                    }

                    case XmlNodeType.Text:
                    {
                        switch (element)
                        {
                        case "Client":
                            client = reader.Value;
                            break;

                        case "FileLocation":
                            fileLocation = reader.Value;
                            break;

                        case "Locale":
                            locale = reader.Value;
                            break;
                        }
                        break;
                    }
                    }
                }

                if (Config.wowDirectories.ContainsX(client))
                {
                    throw new Exception(String.Format("You cannot have multiple WoW.exe files for the same client {0}!", client));
                }
                if (Config.ValidateClient(client) && Config.ValidateLocale(locale) && fileLocation != "")
                {
                    Config.wowDirectories.Add(client, locale, fileLocation);
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// Controls the Config file and makes sure it is in correct format.
 /// </summary>
 /// <param name="masterForm">Master form for accessing controls.</param>
 public XMLController(Form masterForm)
 {
     m_masterForm = masterForm;
     XMLValidator validator = new XMLValidator("Config.xml");
     validator.ValidateXMLFile();
 }
Exemple #6
0
        /// <summary>
        /// Scan the Plugins Directory for any plugins, validate them, and add them to the program.
        /// </summary>
        public void ScanPlugins()
        {
            if (!Directory.Exists("./Plugins/"))
                Directory.CreateDirectory("./Plugins/");
            String[] files = Directory.GetFiles("./Plugins/", "*.xml");
            foreach (String sFile in files)
            {
                XMLValidator validator = new XMLValidator(sFile, isplugin: true);
                if (validator.ValidateXMLFile())
                {
                    MessageBox.Show(String.Format("Plugin {0} is in an invalid format! Possibly out of date?", sFile));
                    continue;
                }
                XmlTextReader reader = new XmlTextReader(sFile);
                String element = "";
                String name = "", client = "", realmlist = "";
                SArray3 realmOptions = new SArray3();
                while (reader.Read())
                {
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            {
                                element = reader.Name;
                                if (String.Compare(element, "Realm") == 0)
                                {
                                    if (realmOptions.ContainsX(name))
                                        continue;
                                    if (name != "" && Config.ValidateClient(client))
                                        realmOptions.Add(name, realmlist, client);
                                    client = "0.0.0";
                                    name = "";
                                    realmlist = "";
                                }
                                break;
                            }
                        case XmlNodeType.Text:
                            {
                                switch (element)
                                {
                                    case "RealmName":
                                        name = reader.Value;
                                        break;
                                    case "RealmList":
                                        realmlist = reader.Value;
                                        break;
                                    case "RealmClient":
                                        client = reader.Value;
                                        break;
                                }
                                break;
                            }
                    }
                }

                if (realmOptions.ContainsX(name))
                    throw new Exception(String.Format("Realm id {0} used more than once!", name));
                if (Config.ValidateClient(client))
                    realmOptions.Add(name, realmlist, client);

                foreach (Vector3<String> vector in realmOptions)
                    Config.realmOptions.Add(vector);

                ListView box = (ListView)m_masterForm.Controls["chosenRealm"];
                foreach (Vector3<String> kvp in realmOptions)
                {
                    ListViewItem itemToAdd = new ListViewItem(kvp.X);
                    itemToAdd.Name = kvp.X;
                    box.Items.Add(itemToAdd);
                }
            }
        }