Beispiel #1
0
        private void menuScrambleCustom_Click(object sender, EventArgs e)
        {
            using (InputDlg dlg = new InputDlg())
            {
                dlg.Caption = "Custom Scramble";
                dlg.Prompt  = "Please provide a number of twists to perform.";
                if (DialogResult.OK != dlg.ShowDialog(this))
                {
                    return;
                }

                string s   = dlg.Value;
                int    num = 0;
                try
                {
                    num = System.Convert.ToInt32(s);
                }
                catch
                {
                    MessageBox.Show(this, "Please retry with a valid number.   ", "Value is not a number",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                scramble(num);
            }
        }
Beispiel #2
0
        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;
            }
        }