Exemple #1
0
        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  = KeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text);
                    keyPressInfo.LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem;
                    _sortedList.Add(GetNewKeyValue(), keyPressInfo);

                    DataGridSequences.DataContext = _sortedList;
                    DataGridSequences.ItemsSource = _sortedList;
                    DataGridSequences.Items.Refresh();
                    SetIsDirty();
                    SetFormState();
                }
            }
            catch (Exception ex)
            {
                Common.ShowErrorMessageBox(ex);
            }
        }
Exemple #2
0
 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  = KeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text);
             _sortedList[keyValuePair.Key].LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem;
             DataGridSequences.DataContext = _sortedList;
             DataGridSequences.ItemsSource = _sortedList;
             DataGridSequences.Items.Refresh();
             SetIsDirty();
         }
     }
     catch (Exception ex)
     {
         Common.ShowErrorMessageBox(ex);
     }
 }
Exemple #3
0
        private void AddKeyPress()
        {
            var keyPressWindow = new KeyPressReadingBigWindow(_supportIndefinite);

            keyPressWindow.ShowDialog();
            if (keyPressWindow.DialogResult.HasValue && keyPressWindow.DialogResult.Value)
            {
                // Clicked OK
                var keyPressInfo = new KeyPressInfo
                {
                    LengthOfBreak    = (KeyPressLength)keyPressWindow.ComboBoxBreak.SelectedItem,
                    VirtualKeyCodes  = KeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text),
                    LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem
                };
                _sortedList.Add(GetNewKeyValue(), keyPressInfo);

                DataGridSequences.DataContext = _sortedList;
                DataGridSequences.ItemsSource = _sortedList;
                DataGridSequences.Items.Refresh();
                SetIsDirty();
                SetFormState();
            }
        }
Exemple #4
0
        private void EditKeyPress()
        {
            var keyValuePair   = (KeyValuePair <int, IKeyPressInfo>)DataGridSequences.SelectedItem;
            var keyPressWindow = new KeyPressReadingBigWindow((KeyPressInfo)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  = KeyPress.SplitStringKeyCodes(keyPressWindow.TextBoxKeyPress.Text);
                _sortedList[keyValuePair.Key].LengthOfKeyPress = (KeyPressLength)keyPressWindow.ComboBoxKeyPressTime.SelectedItem;
                DataGridSequences.DataContext = _sortedList;
                DataGridSequences.ItemsSource = _sortedList;
                DataGridSequences.Items.Refresh();
                SetIsDirty();
            }
        }