예제 #1
0
		/// <summary>
		/// Check if the Main profile exists. If it does not and there are no other profiles, create it.
		/// </summary>
		private void CheckForMainProfile(string path) {
			try {
				using(SqlCeConnection conn = new SqlCeConnection(Properties.Settings.Default.switchexConnectionString)) {
					using(SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM Profiles", conn)) {
						using(DataSet ds = new DataSet()) {
							using(SqlCeDataAdapter adapter = new SqlCeDataAdapter(cmd)) {
								adapter.SelectCommand = cmd;

								adapter.Fill(ds);

								if(ds.Tables[0].Rows.Count == 0) {
									cmd.CommandText = "INSERT INTO Profiles (ProfileName, ProfilePath, ProfileDescription, ProfileType, ProfileDefault) " +
										"VALUES ('Main', @path, 'Main profile.', 32, 1)";
									cmd.Parameters.AddWithValue("@path", path);

									conn.Open();
									cmd.ExecuteNonQuery();

									Properties.Settings.Default.currentProfile = "Main";
								}
							}
						}
					}
				}

				Globals.GetProfiles();
			}
			catch(Exception ex) {
				Globals.frmError.ShowDialog(ex);
			}
		}
예제 #2
0
        private void btnDone_Click(object sender, EventArgs e)
        {
            if (WasChanged)
            {
                if (MessageBox.Show("You have unsaved changes. Would you like to save?", "Save", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    EditSelectedProfile();
                }
            }

            Globals.GetProfiles();
            Close();
        }
예제 #3
0
        /// <summary>
        /// Load all the profiles from the database.
        /// </summary>
        private void LoadAllProfiles()
        {
            cmbProfiles.Items.Clear();
            Globals.GetProfiles();

            foreach (Profile profile in Globals.profiles)
            {
                cmbProfiles.Items.Add(profile.ProfileName);
            }

            if (cmbProfiles.Items.Count > 0)
            {
                cmbProfiles.SelectedIndex = 0;
            }

            profileCount = Globals.profiles.Count;
        }
예제 #4
0
		private void frmMain_Load(object sender, EventArgs e) {
			string wowInstall = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);

			if(Properties.Settings.Default.firstRun) {
				using(RegistryKey key = Registry.LocalMachine.OpenSubKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Blizzard Entertainment\World of Warcraft")) {
					// if the registry key does not exist or InstallPath is blank
					if(key == null || key.GetValue("InstallPath").ToString() == "") {
						CheckForMainProfile(wowInstall);
					}
					// if the registry key exists
					else if(key != null) {
						wowInstall = key.GetValue("InstallPath").ToString();

						CheckForMainProfile(wowInstall);

						if(!File.Exists(wowInstall + "\\Data\\enUS\\realmlist.wtf") && !File.Exists(wowInstall + "\\Data\\enGB\\realmlist.wtf")) {
							frmCreateRealmlist.ShowDialog();
						}
					}
				}

				Properties.Settings.Default.firstRun = false;
				Properties.Settings.Default.Save();
			}

			if(!Directory.Exists(Application.StartupPath + "\\Backups")) {
				Directory.CreateDirectory(Application.StartupPath + "\\Backups");
			}

			CheckForMainProfile(wowInstall);

			Globals.GetProfiles();

			AddProfilesToDropDown();

			dgvServers.DefaultCellStyle.SelectionBackColor = Color.Gainsboro;
			dgvServers.DefaultCellStyle.SelectionForeColor = Color.Black;

			LoadColumnWidths();
			LoadWindowSize();
			RefreshList();
		}