コード例 #1
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();
            }
        }
コード例 #2
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();
            }
        }