private void menuEditColors_Click(object sender, EventArgs e) { GuiSettings current = this.Settings; PropertyDlg dlg = new PropertyDlg(); dlg.EditObject = current; if (DialogResult.OK != dlg.ShowDialog(this)) { return; } this.Settings = current; }
private void comboSettings_SelectedIndexChanged(object sender, EventArgs e) { if (this.comboSettings.SelectedItem == null) { return; } GuiSettings settings = (GuiSettings)this.comboSettings.SelectedItem; this.btnSettingsDelete.Enabled = (settings.Name != DefaultSettingsName); this.Settings = settings; this.cube.ResetView(); }
private void btnSettingsDelete_Click(object sender, EventArgs e) { if (this.comboSettings.SelectedItem == null) { return; } GuiSettings settings = (GuiSettings)this.comboSettings.SelectedItem; if (settings.Name == DefaultSettingsName) { return; } this.comboSettings.Items.Remove(settings); File.Delete(settings.Path); }
private void btnSettingsSave_Click(object sender, EventArgs e) { using (InputDlg dlg = new InputDlg()) { // get a name for the settings dlg.Caption = "Save Settings"; dlg.Prompt = "Please provide a name for the new saved settings."; if (this.comboSettings.SelectedItem != null) { dlg.Value = ((GuiSettings)this.comboSettings.SelectedItem).Name; } if (DialogResult.OK != dlg.ShowDialog(this)) { return; } foreach (GuiSettings old in this.comboSettings.Items) { if (old.Name == dlg.Value) { this.comboSettings.Items.Remove(old); break; } } // the new settings they are saving GuiSettings s = this.Settings; s.Name = dlg.Value; // find where we can save it string baseFile = s.Name; foreach (char c in Path.GetInvalidFileNameChars()) { baseFile = baseFile.Replace(c, '_'); } string final = baseFile + ".settings"; int next = 1; while (System.IO.File.Exists(final)) { final = baseFile + (next++) + ".settings"; } s.Save(final); // add it to the list this.comboSettings.Items.Add(s); this.comboSettings.SelectedItem = s; } }
private void MainFrame_Load(object sender, EventArgs e) { // setup initial values this.cube.EnableRedraw = false; this.menuHilight1.CheckState = CheckState.Checked; this.menuHilight2.CheckState = CheckState.Checked; this.menuHilight3.CheckState = CheckState.Checked; this.menuHilight4.CheckState = CheckState.Checked; this.menuPuzzleFull.Checked = true; this.cube.EnableRedraw = true; // load all of our saved settings GuiSettings defSettings = null; foreach (string s in Directory.GetFiles(".", "*.settings")) { GuiSettings settings = new GuiSettings(); settings.Load(s); this.comboSettings.Items.Add(settings); if (settings.Name == DefaultSettingsName) { defSettings = settings; } } // make sure the "default" settings exist if (defSettings == null) { defSettings = new GuiSettings(); defSettings.Name = DefaultSettingsName; this.comboSettings.Items.Add(defSettings); } // select the default settings this.comboSettings.SelectedItem = defSettings; // give the draw surface the focus this.DrawSurface.Select(); }