コード例 #1
0
 private void UserControlEditServer_Load(object sender, EventArgs e)
 {
     try
     {
         XmlDocument xmlDoc = new XmlDocument();
         xmlDoc.Load(Properties.Settings.Default.XMLServersListFile);
         foreach (XmlNode node in xmlDoc.SelectNodes("/Servers/Server"))
         {
             if (node.Attributes["name"].InnerText == Properties.Settings.Default.SelectedServer)
             {
                 TxbServerName.Text = node.Attributes["name"].InnerText;
                 TxbRealmlist.Text  = node["Realmlist"].InnerText;
                 TxbAccount.Text    = node["Account"].InnerText;
                 TxbWoWPath.Text    = node["WoWPath"].InnerText;
                 CbCache.Checked    = Convert.ToBoolean(node.Attributes["cache"].InnerText);
                 CbFill.Checked     = Convert.ToBoolean(node.Attributes["fill"].InnerText);
             }
         }
     }
     catch (Exception ex)
     {
         CMessageBox myAlertBox = new CMessageBox();
         myAlertBox.Show("Alertbox", ex.Message, Color.Red, Color.IndianRed, true);
         myAlertBox.Dispose();
     }
 }
コード例 #2
0
        private void BtnAddNew_Click(object sender, EventArgs e)
        {
            CMessageBox  myCMessageBox = new CMessageBox();
            DialogResult result        = myCMessageBox.Show("New Server", "Add new server to list?\n\n" + TxbServerName.Text);

            if (result == DialogResult.Yes)
            {
                bool IsDuplicate = false;

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Properties.Settings.Default.XMLServersListFile);
                XmlNodeList nodes = xmlDoc.SelectNodes("/Servers/Server");

                foreach (XmlNode node in nodes)
                {
                    if (node.Attributes["name"].InnerText == TxbServerName.Text)
                    {
                        IsDuplicate = true;
                    }
                }

                if (IsDuplicate)
                {
                    CMessageBox myAlertBox = new CMessageBox();
                    myAlertBox.Show("Alertbox", "That server name already exists, please chose another name!", Color.Red, Color.IndianRed, true);
                    myAlertBox.Dispose();
                }
                else
                {
                    XDocument xdoc = XDocument.Load(Properties.Settings.Default.XMLServersListFile);
                    XElement  root = xdoc.Element("Servers");
                    root.Add(new XElement("Server",
                                          new XAttribute("name", TxbServerName.Text),
                                          new XAttribute("cache", CbCache.Checked.ToString()),
                                          new XAttribute("fill", CbFill.Checked.ToString()),

                                          new XElement("Realmlist", TxbRealmlist.Text),
                                          new XElement("Account", TxbAccount.Text),
                                          new XElement("WoWPath", TxbWoWPath.Text)
                                          )
                             );

                    xdoc.Save(Properties.Settings.Default.XMLServersListFile);

                    WoWRealmListChanger MWL = (WoWRealmListChanger)FindForm();
                    MWL.ClearDisplayPanel();
                    MWL.PanelDisplay.Controls.Add(new UserControlServersList());
                }
            }
            myCMessageBox.Dispose();
        }
コード例 #3
0
        private void UserControlServersList_Load(object sender, EventArgs e)
        {
            try
            {
                // load data into servers list
                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(Properties.Settings.Default.XMLServersListFile);

                // Begin Servers List Update
                LbServersList.BeginUpdate();

                // Clear Servers List
                LbServersList.Items.Clear();

                foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
                {
                    LbServersList.Items.Add(node.Attributes["name"].InnerText);
                }

                // set a selected index if none
                if (LbServersList.SelectedIndex == -1)
                {
                    LbServersList.SelectedIndex = 0;
                }

                // End Servers List Update
                LbServersList.EndUpdate();

                // set current selected server id
                LbServersList.SelectedItem = Properties.Settings.Default.SelectedServer;
                Properties.Settings.Default.SelectedServer = LbServersList.SelectedItem.ToString();
                Properties.Settings.Default.Save();
            }
            catch (Exception ex)
            {
                CMessageBox myAlertBox = new CMessageBox();
                myAlertBox.Show("Alertbox", ex.Message, Color.Red, Color.IndianRed, true);
                myAlertBox.Dispose();
            }
        }
コード例 #4
0
        private void UpdateWoWConfigAndStart(string WoWPath, string realmlist, string account, bool cache)
        {
            using (var outputFile = new StreamWriter(WoWPath + @"\WTF\Config.wtf", true))
                outputFile.WriteLine("SET realmList " + realmlist);

            using (var outputFile = new StreamWriter(WoWPath + @"\WTF\Config.wtf", true))
                outputFile.WriteLine("SET accountName " + account);

            if (cache && Directory.Exists(WoWPath + @"\Cache"))
            {
                var dir = new DirectoryInfo(WoWPath + @"\Cache");
                dir.Delete(true); // true => recursive delete
            }

            try
            {
                if (!File.Exists(WoWPath + @"\Wow.exe"))
                {
                    CMessageBox myAlertBox = new CMessageBox();
                    myAlertBox.Show("Alertbox", "The WoW.exe file could not be located!", Color.Red, Color.IndianRed, true);
                    myAlertBox.Dispose();
                    return;
                }
                else
                {
                    Process proc = new Process();
                    proc.StartInfo.FileName = WoWPath + @"\Wow.exe";
                    proc.Start();
                }
            }
            catch (Exception ex)
            {
                CMessageBox myAlertBox = new CMessageBox();
                myAlertBox.Show("Alertbox", ex.Message, Color.Red, Color.IndianRed, true);
                myAlertBox.Dispose();
            }
        }
コード例 #5
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                CMessageBox  myCMessageBox = new CMessageBox();
                DialogResult result        = myCMessageBox.Show("Confirm Removal", "Do you really want to remove that server?");
                if (result == DialogResult.Yes)
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.Load(Properties.Settings.Default.XMLServersListFile);
                    XmlNodeList nodes  = xmlDoc.SelectNodes("/Servers/Server");
                    XmlNode     parent = xmlDoc.SelectSingleNode("/Servers");

                    foreach (XmlNode node in nodes)
                    {
                        if (node.Attributes["name"].InnerText == Properties.Settings.Default.SelectedServer)
                        {
                            parent.RemoveChild(node);
                        }
                    }

                    xmlDoc.Save(Properties.Settings.Default.XMLServersListFile);

                    WoWRealmListChanger MWL = (WoWRealmListChanger)FindForm();
                    MWL.ClearDisplayPanel();
                    MWL.PanelDisplay.Controls.Add(new UserControlServersList());
                }
                myCMessageBox.Dispose();
            }
            catch (Exception ex)
            {
                CMessageBox myAlertBox = new CMessageBox();
                myAlertBox.Show("Alertbox", ex.Message, Color.Red, Color.IndianRed, true);
                myAlertBox.Dispose();
            }
        }