コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        { // Edit hotkey
            if (dataGridView1.CurrentRow == null || dataGridView1.CurrentRow.Index < 0)
            {
                return;
            }
            var hk = Settings.Default.HotKeys.FirstOrDefault(x => x.HookId == (int)dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["HookId"].Value);

            if (hk == null)
            {
                return;
            }
            _newHotkey = new NewHotkey(hk);
            _newHotkey.ShowDialog(this);
        }
コード例 #2
0
        public PresetHotkeyForm(DisplayPresetCollection displayPresetCollection, PresetToHotkeyMap presetToHotkeyMap)
        {
            InitializeComponent();

            mNewHotkey = new NewHotkey();

            mPresetToHotkeyMap = presetToHotkeyMap;
            mPresetToHotkeyDictionaryForComboBox = new Dictionary <string, VirtualHotkey>(mPresetToHotkeyMap.GetHotkeyMappings());
            mPresetToHotkeyMap.OnPresetToHotkeyMappingChanged += OnPresetToHotkeyMapChanged;

            presetsComboBox.Items.AddRange(displayPresetCollection.GetPresets().ToArray());
            presetsComboBox.SelectedIndexChanged += PresetsComboBox_SelectedIndexChanged;
            if (presetsComboBox.Items.Count > 0)
            {
                presetsComboBox.SelectedIndex = 0;
            }
        }
コード例 #3
0
        /// <summary>
        /// Adding new hotkey.
        /// </summary>
        private void OnAddHotkey()
        {
            // Can't do unless game is loaded.
            //if (!CheckCanDo())
            //	return;

            try
            {
                // Create window for add hotkey.
                var win = new NewHotkey
                {
                    // Owner set to MainWindow.
                    Owner = Application.Current.MainWindow
                };

                // Get the VM for this window.
                var vm = win.DataContext as NewHotkeyViewModel;

                // Show the dialog for the hotkey window.
                if (win.ShowDialog() == true)
                {
                    // Initialize the creation of our hotkey with the hotkey name.
                    var p = new Models.Hotkey()
                    {
                        Name = vm.Name, preset = GetPresetByName(vm.Preset), Key = (System.Windows.Forms.Keys)Enum.GetValues(typeof(System.Windows.Forms.Keys)).GetValue(vm.Hotkey)
                    };
                    // Add the hotkey.
                    Hotkeys.Add(p);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Something happened while creating your hotkey!", "Paisley Park", MessageBoxButton.OK, MessageBoxImage.Error);
                logger.Error(ex, "Exception while adding a new hotkey.");
            }
        }
コード例 #4
0
 private void button1_Click(object sender, EventArgs e)
 { // Create new hotkey
     _newHotkey = new NewHotkey();
     _newHotkey.ShowDialog(this);
 }