예제 #1
0
 protected override bool ProcessKeyPreview(ref Message m)
 {
     if (ignore_message)
     {
         return(base.ProcessKeyPreview(ref m));
     }
     ignore_message = true;
     if (m.Msg == (int)KeyboardMessage.WM_KEYUP || m.Msg == (int)KeyboardMessage.WM_SYSKEYUP)
     {
         int  KeyCode  = (int)(((ulong)m.LParam & 0xFF0000) >> 16);
         bool extended = (int)((ulong)m.LParam & 0x01000000) != 0;
         if (KeyCode == LShift)
         {
             hook.action_button_keyboard = VirtualKeyCode.LSHIFT;
             ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.LSHIFT);
         }
         else if (KeyCode == RShift)
         {
             hook.action_button_keyboard = VirtualKeyCode.RSHIFT;
             ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.RSHIFT);
         }
         else if (KeyCode == Ctrl)
         {
             if (extended)
             {
                 hook.action_button_keyboard = VirtualKeyCode.RCONTROL;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.RCONTROL);
             }
             else
             {
                 hook.action_button_keyboard = VirtualKeyCode.LCONTROL;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.LCONTROL);
             }
         }
         else if (KeyCode == Alt)
         {
             if (extended)
             {
                 hook.action_button_keyboard = VirtualKeyCode.RMENU;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.RMENU);
             }
             else
             {
                 hook.action_button_keyboard = VirtualKeyCode.LMENU;
                 ScanKeyTextBox.Text         = vk_to_appropriate_string(VirtualKeyCode.LMENU);
             }
         }
         else
         {
             throw new NotImplementedException();
         }
         Saver.save_hook(hook.hook_target, hook.action_button_keyboard);
     }
     return(base.ProcessKeyPreview(ref m));
 }
예제 #2
0
 private void DeletePresetButton_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == MessageBox.Show("Are you sure you want to delete [" + current_preset.name
                                            + "] preset?", "Warning",
                                            MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
     {
         Saver.delete_preset(current_preset.name);
         presets.Remove(current_preset);
         PresetComboBox.Items.Remove(current_preset.name);
         PresetComboBox.SelectedItem = Program.default_preset_name;
     }
 }
예제 #3
0
 private void RenamePresetButton_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == presetName.ShowDialog(current_preset.name))
     {
         string newName = presetName.textBox1.Text.Trim();
         Saver.update_preset_name(current_preset.name, newName);
         PresetComboBox.SelectedIndexChanged -= PresetComboBox_SelectedIndexChanged;
         PresetComboBox.Items[PresetComboBox.SelectedIndex] = newName;
         PresetComboBox.SelectedIndexChanged += PresetComboBox_SelectedIndexChanged;
         presets.Find(x => x.name == current_preset.name).name = newName;
         current_preset.name = newName;
     }
 }
예제 #4
0
 private void defaultTextcolorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     ColorPicker.Color = current_preset.default_textcolor;
     if (DialogResult.OK == ColorPicker.ShowDialog())
     {
         current_preset.default_textcolor = check_color_is_transparency_key(ColorPicker.Color);
         Saver.save_preset_default_textcolor(current_preset.name, current_preset.default_textcolor);
         foreach (CustomButton button in Panel.Controls.OfType <CustomButton>())
         {
             button.ForeColor        = current_preset.default_textcolor;
             button.property_watcher = true;
         }
     }
 }
예제 #5
0
 private void defaultFontToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FontPicker.Font      = current_preset.default_font;
     FontPicker.ShowApply = false;
     if (DialogResult.OK == FontPicker.ShowDialog())
     {
         current_preset.default_font = FontPicker.Font;
         Saver.save_preset_default_font(current_preset.name, current_preset.default_font);
         foreach (CustomButton button in Panel.Controls.OfType <CustomButton>())
         {
             button.Font             = FontPicker.Font;
             button.property_watcher = true;
         }
     }
 }
예제 #6
0
 private void ScanKeyTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     e.SuppressKeyPress = true;
     FakeLabel.Focus();
     if (e.KeyCode == Keys.ShiftKey || e.KeyCode == Keys.ControlKey || e.KeyCode == Keys.Menu)
     {
         ignore_message = false;
     }
     else
     {
         hook.action_button_keyboard = (VirtualKeyCode)e.KeyValue;
         ScanKeyTextBox.Text         = vk_to_appropriate_string((VirtualKeyCode)e.KeyValue);
         ignore_message = true;
         Saver.save_hook(hook.hook_target, hook.action_button_keyboard);
     }
 }
예제 #7
0
 private void CopyPresetButton_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == presetName.ShowDialog(""))
     {
         Preset preset = current_preset.Clone();
         preset.name = presetName.textBox1.Text.Trim();
         presets.Add(preset);
         PresetComboBox.Items.Add(preset.name);
         PresetComboBox.SelectedItem = preset.name;
         Saver.save_add_preset(preset.name);
         foreach (var item in preset.buttons)
         {
             Saver.save_button_settings(preset.name, item, true);
         }
     }
 }
예제 #8
0
 private void AddPresetButton_Click(object sender, EventArgs e)
 {
     if (DialogResult.OK == presetName.ShowDialog(""))
     {
         Preset preset = new Preset();
         preset.name              = presetName.textBox1.Text.Trim();
         preset.buttons           = new List <CustomButton>();
         preset.default_backcolor = Color.White;
         preset.default_textcolor = Color.Black;
         preset.default_font      = new Font("Consolas", 14.25F, FontStyle.Regular);
         presets.Add(preset);
         PresetComboBox.Items.Add(preset.name);
         PresetComboBox.SelectedItem = preset.name;
         Saver.save_add_preset(preset.name);
     }
 }
예제 #9
0
 private void MouseradioButton_CheckedChanged(object sender, EventArgs e)
 {
     if (hook.hook_target == Hook_target.Mouse)
     {
         hook.hook_target             = Hook_target.Keyboard;
         ScanKeyTextBox.Text          = vk_to_appropriate_string(hook.action_button_keyboard);
         MouseButtonsComboBox.Visible = false;
         ScanKeyTextBox.Visible       = true;
         Saver.save_hook(hook.hook_target, hook.action_button_keyboard);
     }
     else if (hook.hook_target == Hook_target.Keyboard)
     {
         hook.hook_target = Hook_target.Mouse;
         MouseButtonsComboBox.SelectedItem = vk_to_appropriate_string(hook.action_button_mouse);
         MouseButtonsComboBox.Visible      = true;
         ScanKeyTextBox.Visible            = false;
         Saver.save_hook(hook.hook_target, hook.action_button_mouse);
     }
 }
예제 #10
0
        private string apply_changes_to_button(CustomButton customButton)
        {
            List <IAction> actions_storage = customButton.actions.ToList();

            customButton.actions.Clear();
            string error_message = parse_button_command(customButton);

            if (error_message != "")
            {
                customButton.actions = actions_storage;
                return(error_message);
            }
            CustomButton target_button;
            var          a = current_preset.buttons.Where(x => x.Id == customButton.Id).ToArray();

            if (a.Length == 0)
            {
                target_button = new CustomButton();
                current_preset.buttons.Add(target_button);

                if (current_preset == buttons_form.current_preset)
                {
                    buttons_form.add_button_if_auto_switch_disabled(target_button);
                }

                Saver.save_button_settings(current_preset.name, customButton, true);
            }
            else if (a.Length == 1)
            {
                target_button = a[0];
                Saver.save_button_settings(current_preset.name, customButton, false);
            }
            else
            {
                throw new Exception("Identity problem");
            }

            CustomButton.OverWrite(target_button, customButton);
            customButton.property_watcher = false;
            return("");
        }
예제 #11
0
 private void Deletebutton_Click(object sender, EventArgs e)
 {
     CustomButton[] a = current_preset.buttons.Where(x => x.Id == currentButton.Id).ToArray();
     if (a.Length == 0)
     {
         delete_button_from_panel(currentButton);
     }
     else if (a.Length == 1)
     {
         if (DialogResult.OK == MessageBox.Show("Are you sure you want to delete this performer?", "Warning",
                                                MessageBoxButtons.OKCancel, MessageBoxIcon.Question))
         {
             Saver.delete_button(current_preset.name, currentButton);
             a[0].Parent = null;
             current_preset.buttons.Remove(a[0]);
             delete_button_from_panel(currentButton);
         }
     }
     else if (a.Length > 1)
     {
         throw new Exception("Identity problem");
     }
 }
        private void OKButton_Click(object sender, EventArgs e)
        {
            Preset       preset = settings.presets.Where(x => x.name == comboBox1.SelectedItem.ToString()).Single();
            CustomButton button = settings.currentButton.Clone();

            button.Location = new Point(0, 0);
            if (!PreservebackcolorcheckBox.Checked)
            {
                button.BackColor = preset.default_backcolor;
            }
            if (!PreservetextcolorcheckBox.Checked)
            {
                button.ForeColor = preset.default_textcolor;
            }
            if (!PreservefontcheckBox.Checked)
            {
                button.Font = preset.default_font;
            }
            if (preset == settings.current_preset)
            {
                button.Id = settings.get_new_id();
                settings.add_button_to_panel(button.Clone());
            }
            else
            {
                button.Id = settings.get_new_id(preset);
            }
            if (preset == buttons_form.current_preset)
            {
                buttons_form.add_button_if_auto_switch_disabled(button);
            }
            preset.buttons.Add(button);
            Saver.save_button_settings(preset.name, button, true);

            this.Close();
        }
예제 #13
0
 private void MouseButtonsComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     hook.action_button_mouse = string_to_mouse_vk(MouseButtonsComboBox.SelectedItem.ToString());
     Saver.save_hook(hook.hook_target, hook.action_button_mouse);
 }