Beispiel #1
0
        private void SelectProfileProc(string selectedProfile, bool cancelEnabled)
        {
            try {
                lock (Config.SyncRoot) {
                    using (SelectProfileDialog dlg = new SelectProfileDialog()) {
                        dlg.AddExistingProfiles(Config.Profile.EnumerateProfiles());
                        dlg.SelectedProfile = selectedProfile;
                        dlg.CancelEnabled   = cancelEnabled;

ShowDialog:
                        if (dlg.ShowDialog() == DialogResult.OK)
                        {
                            if (dlg.CreateProfile && Config.Profile.ProfileExists(dlg.SelectedProfile))
                            {
                                if (MessageBox.Show("Profile of same name already exists. Overwrite?", "Profile exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    Config.Profile.CreateProfile(dlg.SelectedProfile);
                                }
                                else
                                {
                                    goto ShowDialog;
                                }
                            }
                            else
                            {
                                Config.Profile.ChangeProfile(dlg.SelectedProfile);
                            }

                            Config.PlayerProfile = Config.Profile.ProfileName;
                            Config.Save();
                        }
                    }
                }
            }
            catch (Exception e) {
                Trace.WriteLine("Error changing profile. Exception:\n" + e.ToString(), "Phoenix");
                MessageBox.Show("Error changing profile.\nMessage: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void SelectProfileProc(string selectedProfile, bool cancelEnabled)
        {
            try {
                lock (Config.SyncRoot) {
                    using (SelectProfileDialog dlg = new SelectProfileDialog()) {
                        dlg.AddExistingProfiles(Config.Profile.EnumerateProfiles());
                        dlg.SelectedProfile = selectedProfile;
                        dlg.CancelEnabled = cancelEnabled;

                    ShowDialog:
                        if (dlg.ShowDialog() == DialogResult.OK) {

                            if (dlg.CreateProfile && Config.Profile.ProfileExists(dlg.SelectedProfile)) {
                                if (MessageBox.Show("Profile of same name already exists. Overwrite?", "Profile exists", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) {
                                    Config.Profile.CreateProfile(dlg.SelectedProfile);
                                }
                                else {
                                    goto ShowDialog;
                                }
                            }
                            else {
                                Config.Profile.ChangeProfile(dlg.SelectedProfile);
                            }

                            Config.PlayerProfile = Config.Profile.ProfileName;
                            Config.Save();
                        }
                    }
                }
            }
            catch (Exception e) {
                Trace.WriteLine("Error changing profile. Exception:\n" + e.ToString(), "Phoenix");
                MessageBox.Show("Error changing profile.\nMessage: " + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }