예제 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete " + lbAddons.SelectedItem + " from your addons folder?", "Delete", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                try {
                    string   name = lbAddons.SelectedItem.ToString();
                    string[] args = { addonFolder + name };

                    if (Globals.RunActionsExecutable(Globals.FileAction.DeleteFolder, args) == 0)
                    {
                        RefreshAddons();
                        MessageBox.Show("Deletion of " + name + " successful.", "Success");
                    }
                    else
                    {
                        MessageBox.Show("Could not delete folder.", "Error");
                    }
                }
                catch (Exception ex) {
                    Globals.frmError.ShowDialog(ex);
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Restores the file.
        /// </summary>
        /// <param name="file">The file path</param>
        private void RestoreFile(string file)
        {
            try {
                string backupFile = file.Replace(file.Substring(0, file.LastIndexOf("\\") + 1),
                                                 Application.StartupPath + "\\Backups\\").Replace(file.Substring(file.IndexOf('.')), ".bak");

                string[] args       = { "true", backupFile, file };
                int      fileAction = 0;

                fileAction = Globals.RunActionsExecutable(Globals.FileAction.CopyFile, args);

                if (fileAction == 0)
                {
                    MessageBox.Show("Restore successful.", "Success");
                }
                else if (fileAction == 2)
                {
                    MessageBox.Show("A backup does not exist.", "Error");
                }
                else
                {
                    MessageBox.Show("A backup could not be restored.", "Error");
                }
            }
            catch (Exception ex) {
                Globals.frmError.ShowDialog(ex);
            }
        }
예제 #3
0
        private void btnEU_Click(object sender, EventArgs e)
        {
            Profile profile = Globals.profiles.SingleOrDefault(item => item.ProfileName == Globals.currentProfile);

            string[] args =
            {
                profile.ProfilePath + "\\Data\\enGB",
                profile.ProfilePath + "\\Data\\enGB\\realmlist.wtf",
                "set realmlist eu.logon.worldofwarcraft.com\n" + Environment.NewLine +
                "set patchlist enGB.patch.battle.net:1119/patch\n" + Environment.NewLine +
                "set realmlistbn \"\"\n" + Environment.NewLine +
                "set portal eu"
            };
            Globals.RunActionsExecutable(Globals.FileAction.CreateBoth, args);

            Close();
        }
예제 #4
0
        private void frmAddons_Load(object sender, EventArgs e)
        {
            Profile profile = Globals.profiles.SingleOrDefault(item => item.ProfileName == Globals.currentProfile);

            // if the profile exists
            if (profile != null)
            {
                addonFolder = profile.ProfilePath + "\\Interface\\AddOns\\";

                // if the addons folder exists in the profile
                if (Directory.Exists(addonFolder))
                {
                    RefreshAddons();
                }
                // if the addons folder does not exist in the profile
                else
                {
                    DialogResult result = MessageBox.Show("You do not have an addons folder. Would you like to create it?", "Addons", MessageBoxButtons.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        string[] args = { addonFolder };
                        Globals.RunActionsExecutable(Globals.FileAction.CreateFolder, args);

                        HasAddons = false;
                        lbAddons.Items.Add("No addons installed.");
                    }
                    else
                    {
                        HasAddons = false;
                        lbAddons.Items.Add("No addons folder detected.");
                    }
                }
            }
            // if the profile does not exist or there is a problem
            else
            {
                HasAddons = false;
                lbAddons.Items.Add("Cannot find a WoW installation in your current profile.");
            }
        }
예제 #5
0
        /// <summary>
        /// Backs up a file.
        /// </summary>
        /// <param name="file">The file path</param>
        /// <param name="confirm">Display an overwrite confirmation or not</param>
        private void BackupFile(string file, bool confirm)
        {
            try {
                string backupFile = file.Replace(file.Substring(0, file.LastIndexOf("\\") + 1),
                                                 Application.StartupPath + "\\Backups\\").Replace(file.Substring(file.IndexOf('.')), ".bak");
                string[] args       = { "false", file, backupFile };
                int      fileAction = 0;

                if (File.Exists(backupFile) && confirm)
                {
                    DialogResult result = MessageBox.Show("A backup already exists. Would you like to overwrite it?", "Confirm Overwrite", MessageBoxButtons.YesNo);

                    if (result != DialogResult.Yes)
                    {
                        return;
                    }
                }

                fileAction = Globals.RunActionsExecutable(Globals.FileAction.CopyFile, args);

                if (confirm)
                {
                    if (fileAction == 0)
                    {
                        MessageBox.Show("Backup successful.", "Success");
                    }
                    else if (fileAction == 2)
                    {
                        MessageBox.Show("File does not exist. Cannot back up.", "Error");
                    }
                }
            }
            catch (Exception ex) {
                Globals.frmError.ShowDialog(ex);
            }
        }
예제 #6
0
		private void btnSet_Click(object sender, EventArgs e) {
			if(dgvServers.SelectedRows.Count > 0) {
				try {
					Profile profile = Globals.profiles.SingleOrDefault(item => item.ProfileName == cmbProfiles.Text);

					if(profile != null) {
						string fileUS = profile.ProfilePath + "\\Data\\enUS\\realmlist.wtf",
							fileGB = profile.ProfilePath + "\\Data\\enGB\\realmlist.wtf",
							exec32 = profile.ProfilePath + "\\Wow.exe",
							exec64 = profile.ProfilePath + "\\Wow-64.exe",
							file = "",
							text = "";

						// If realmlist.wtf does not exist
						if(!File.Exists(fileUS) && !File.Exists(fileGB)) {
							frmCreateRealmlist.ShowDialog();
						}
						// If realmlist.wtf and WoW executables exist
						else {
							// If realmlist.wtf is in the US folder
							if(File.Exists(fileUS)) {
								file = fileUS;
							}
							// If realmlist.wtf is in the GB folder
							else if(File.Exists(fileGB)) {
								file = fileGB;
							}

							// Read from the file and replace text
							text = File.ReadAllText(file);
							text = text.Remove(14, text.Substring(14, text.IndexOf(Environment.NewLine) - 14).Length);
							text = text.Insert(14, dgvServers.SelectedRows[0].Cells[2].Value.ToString());

							// Write the replaced text to a local file
							File.WriteAllText(Application.StartupPath + "\\realmlist.wtf", text);

							// And move it to the correct directory
							string[] args = { "true", Application.StartupPath + "\\realmlist.wtf", file };
							int fileAction = Globals.RunActionsExecutable(Globals.FileAction.CopyFile, args);

							if(fileAction == 0) {
								// If they want to open WoW after setting a server
								if(Properties.Settings.Default.openWow) {
									OpenWow();
								}
								else {
									MessageBox.Show("Server changed successfully.", "Success");
								}

								ToolstripInfo(false);
							}
							else if(fileAction != 5) {
								MessageBox.Show("Could not set server.", "Error");
							}
						}
					}
					else {
						MessageBox.Show("Cannot find a World of Warcraft installation with your current profile.", "Error");
					}
				}
				catch(Exception ex) {
					if(!ex.Message.Contains("canceled by the user")) {
						Globals.frmError.ShowDialog(ex);
					}
				}
			}
			else {
				MessageBox.Show("There is no row selected.", "Error");
			}
		}