private void ButtonAddClick(object sender, RoutedEventArgs e)
        {
            try
            {
                var keyPressWindow = new KeyPressWindow();
                keyPressWindow.ShowDialog();
                if (keyPressWindow.DialogResult.HasValue && keyPressWindow.DialogResult.Value)
                {
                    //Clicked OK
                    var keyPressInfo = new KeyPressInfo();
                    keyPressInfo.LengthOfBreak    = (KeyPressLength)keyPressWindow.ComboBoxBreak.SelectedItem;
                    keyPressInfo.VirtualKeyCodes  = OSKeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text);
                    keyPressInfo.LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem;
                    _sortedList.Add(GetNewKeyValue(), keyPressInfo);

                    DataGridSequences.DataContext = _sortedList;
                    DataGridSequences.ItemsSource = _sortedList;
                    DataGridSequences.Items.Refresh();
                    _isDirty = true;
                    SetFormState();
                }
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(1065, ex);
            }
        }
 private void ButtonEditClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var keyValuePair   = (KeyValuePair <int, KeyPressInfo>)DataGridSequences.SelectedItem;
         var keyPressWindow = new KeyPressWindow(keyValuePair.Value);
         keyPressWindow.ShowDialog();
         if (keyPressWindow.DialogResult.HasValue && keyPressWindow.DialogResult.Value)
         {
             //Clicked OK
             if (!keyPressWindow.IsDirty)
             {
                 //User made no changes
                 return;
             }
             _sortedList[keyValuePair.Key].LengthOfBreak    = (KeyPressLength)keyPressWindow.ComboBoxBreak.SelectedItem;
             _sortedList[keyValuePair.Key].VirtualKeyCodes  = OSKeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text);
             _sortedList[keyValuePair.Key].LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem;
             DataGridSequences.DataContext = _sortedList;
             DataGridSequences.ItemsSource = _sortedList;
             DataGridSequences.Items.Refresh();
             _isDirty = true;
         }
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(1083, ex);
     }
 }
Example #3
0
 private void MenuContextEditTextBoxClick(object sender, RoutedEventArgs e)
 {
     try
     {
         var textBox = GetTextBoxInFocus();
         if (textBox == null)
         {
             throw new Exception("Failed to locate which textbox is focused.");
         }
         SequenceWindow sequenceWindow;
         if (((TagDataClassTPM)textBox.Tag).ContainsKeySequence())
         {
             sequenceWindow = new SequenceWindow(textBox.Text, ((TagDataClassTPM)textBox.Tag).GetKeySequence());
         }
         else
         {
             sequenceWindow = new SequenceWindow();
         }
         sequenceWindow.ShowDialog();
         if (sequenceWindow.DialogResult.HasValue && sequenceWindow.DialogResult.Value)
         {
             //Clicked OK
             //If the user added only a single key stroke combo then let's not treat this as a sequence
             if (!sequenceWindow.IsDirty)
             {
                 //User made no changes
                 return;
             }
             var sequenceList = sequenceWindow.GetSequence;
             if (sequenceList.Count > 1)
             {
                 var osKeyPress = new OSKeyPress("Key press sequence", sequenceList);
                 ((TagDataClassTPM)textBox.Tag).KeyPress             = osKeyPress;
                 ((TagDataClassTPM)textBox.Tag).KeyPress.Information = sequenceWindow.GetInformation;
                 if (!string.IsNullOrEmpty(sequenceWindow.GetInformation))
                 {
                     textBox.Text = sequenceWindow.GetInformation;
                 }
                 UpdateKeyBindingProfileSequencedKeyStrokesTPM(textBox);
             }
             else
             {
                 //If only one press was created treat it as a simple keypress
                 ((TagDataClassTPM)textBox.Tag).ClearAll();
                 var osKeyPress = new OSKeyPress(sequenceList[0].VirtualKeyCodesAsString, sequenceList[0].LengthOfKeyPress);
                 ((TagDataClassTPM)textBox.Tag).KeyPress             = osKeyPress;
                 ((TagDataClassTPM)textBox.Tag).KeyPress.Information = sequenceWindow.GetInformation;
                 textBox.Text = sequenceList[0].VirtualKeyCodesAsString;
                 UpdateKeyBindingProfileSimpleKeyStrokes(textBox);
             }
         }
         TextBoxLogTPM.Focus();
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(2044, ex);
     }
 }
        public void Execute(CancellationToken threadCancellationToken)
        {
            Common.PlaySoundFile(SoundFile, Volume);

            if (!PluginManager.DisableKeyboardAPI)
            {
                OSKeyPress.Execute(threadCancellationToken);
            }

            if (PluginManager.PlugSupportActivated && PluginManager.HasPlugin())
            {
                PluginManager.DoEvent(
                    DCSFPProfile.SelectedProfile.Description,
                    StreamDeckPanelInstance.HIDInstance,
                    StreamDeckCommon.ConvertEnum(_streamDeckPanel.TypeOfPanel),
                    (int)StreamDeckButtonName,
                    true,
                    OSKeyPress.KeyPressSequence);
            }
        }
Example #5
0
 public void Execute(CancellationToken threadCancellationToken)
 {
     OSKeyPress.Execute(threadCancellationToken);
 }
Example #6
0
 public bool IsRunning()
 {
     return(OSKeyPress.IsRunning());
 }