예제 #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);
            }
        }
예제 #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);
     }
 }