Esempio n. 1
0
 private void btn_preset_delete_Click(object sender, EventArgs e)
 {
     if (settings.Presets.Length == 1)
     {
         File.Delete("setting_presets.xml");
         // Reload
         LoadPresets();
         return;
     }
     // Remove at currently selected index
     settings.Presets = Global.RemoveAt(settings.Presets, cBox_presets.SelectedIndex);
     // New index
     if (settings.Presets.Length > 0)
     {
         settings.selected_index = 0;
         // Save
         XmlSerializing.SerializeToPlain(settings);
         // Reload
         LoadPresets();
     }
     else
     {
         File.Delete("setting_presets.xml");
         // Reload
         LoadPresets();
     }
 }
Esempio n. 2
0
        private void btn_preset_saveas_Click(object sender, EventArgs e)
        {
            Input_dialog input = new Input_dialog();

            if (input.ShowDialog() == DialogResult.OK)
            {
                if (settings.Presets == null)
                {
                    settings.Presets = new Preset[1];
                }
                else
                {
                    Array.Resize(ref settings.Presets, settings.Presets.Length + 1);
                }
                settings.Presets[settings.Presets.Length - 1] = new Preset()
                {
                    preset_name   = input.Result,
                    brightness_th = (int)nUD_brightness.Value,
                    dot_pause_th  = (int)nUD_dot.Value,
                    char_pause_th = (int)nUD_char.Value,
                    word_pause_th = (int)nUD_word.Value,
                    frameinterval = (int)nUD_finterval.Value
                };

                settings.selected_index = settings.Presets.Length - 1;
            }

            // Save
            XmlSerializing.SerializeToPlain(settings);
            // Reload
            LoadPresets();
        }
Esempio n. 3
0
        private void btn_preset_save_Click(object sender, EventArgs e)
        {
            if (cBox_presets.SelectedIndex == -1 || cBox_presets.SelectedIndex >= settings.Presets.Length)
            {
                return;
            }

            settings.Presets[cBox_presets.SelectedIndex].brightness_th = (int)nUD_brightness.Value;
            settings.Presets[cBox_presets.SelectedIndex].dot_pause_th  = (int)nUD_dot.Value;
            settings.Presets[cBox_presets.SelectedIndex].char_pause_th = (int)nUD_char.Value;
            settings.Presets[cBox_presets.SelectedIndex].word_pause_th = (int)nUD_word.Value;
            settings.Presets[cBox_presets.SelectedIndex].frameinterval = (int)nUD_finterval.Value;

            // Save
            XmlSerializing.SerializeToPlain(settings);
        }
Esempio n. 4
0
        private void cBox_presets_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cBox_presets.SelectedIndex == -1 || cBox_presets.SelectedIndex >= settings.Presets.Length)
            {
                return;
            }

            nUD_brightness.Value = settings.Presets[cBox_presets.SelectedIndex].brightness_th;
            nUD_dot.Value        = settings.Presets[cBox_presets.SelectedIndex].dot_pause_th;
            nUD_char.Value       = settings.Presets[cBox_presets.SelectedIndex].char_pause_th;
            nUD_word.Value       = settings.Presets[cBox_presets.SelectedIndex].word_pause_th;
            nUD_finterval.Value  = settings.Presets[cBox_presets.SelectedIndex].frameinterval;

            // Save
            settings.selected_index = cBox_presets.SelectedIndex;
            XmlSerializing.SerializeToPlain(settings);
        }
Esempio n. 5
0
 private void LoadPresets(string file_path = "setting_presets.xml")
 {
     if (!File.Exists(file_path))
     {
         settings = new Settings();
         cBox_presets.Items.Clear();
         return;
     }
     // DeSerialize the presets xml
     settings = XmlSerializing.DeSerialize(file_path);
     // Read them
     cBox_presets.Items.Clear();
     for (int i = 0; i < settings.Presets.Length; i++)
     {
         cBox_presets.Items.Add(settings.Presets[i].preset_name);
     }
     // Select the saved index
     if (cBox_presets.Items.Count > settings.selected_index)
     {
         cBox_presets.SelectedIndex = settings.selected_index;
     }
 }