Exemplo n.º 1
0
 private void CommitChange()
 {
     ValueEditorUtils.ExecuteCommand(this.BeginCommand, (IInputElement)this, (object)null);
     if (this.UpdateValueFromInternalValues())
     {
         ValueEditorUtils.UpdateBinding((FrameworkElement)this, ChoiceEditor.ValueProperty, UpdateBindingType.Source);
         ValueEditorUtils.UpdateBinding((FrameworkElement)this, ChoiceEditor.ValueIndexProperty, UpdateBindingType.Source);
         ValueEditorUtils.ExecuteCommand(this.CommitCommand, (IInputElement)this, (object)null);
         ValueEditorUtils.UpdateBinding((FrameworkElement)this, ChoiceEditor.ValueProperty, UpdateBindingType.Target);
         ValueEditorUtils.UpdateBinding((FrameworkElement)this, ChoiceEditor.ValueIndexProperty, UpdateBindingType.Target);
     }
     else
     {
         this.CancelStartedChange();
     }
     this.lostFocusAction = ChoiceEditor.LostFocusAction.None;
 }
Exemplo n.º 2
0
 private void HandleLostFocus()
 {
     if (!this.isTextEditing)
     {
         return;
     }
     ChoiceEditor.LostFocusAction lostFocusAction = this.lostFocusAction;
     this.lostFocusAction = ChoiceEditor.LostFocusAction.None;
     this.isTextEditing   = false;
     if (lostFocusAction == ChoiceEditor.LostFocusAction.Commit)
     {
         this.CommitChange();
     }
     else if (lostFocusAction == ChoiceEditor.LostFocusAction.Cancel)
     {
         this.CancelChange();
     }
     this.CoerceValue(ChoiceEditor.ShowFullControlProperty);
 }
Exemplo n.º 3
0
        protected override void OnPreviewKeyDown(KeyEventArgs e)
        {
            bool handlesCommitKeys = ValueEditorUtils.GetHandlesCommitKeys((DependencyObject)this);

            if (e.Key == Key.Return || e.Key == Key.Return)
            {
                KeyEventArgs keyEventArgs = e;
                int          num          = keyEventArgs.Handled | handlesCommitKeys ? 1 : 0;
                keyEventArgs.Handled = num != 0;
                ChoiceEditor.LostFocusAction lostFocusAction = this.lostFocusAction;
                this.lostFocusAction = ChoiceEditor.LostFocusAction.None;
                if (lostFocusAction == ChoiceEditor.LostFocusAction.Commit)
                {
                    this.CommitChange();
                }
                if ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.None)
                {
                    this.OnFinishEditing();
                }
            }
            else if (e.Key == Key.Escape)
            {
                KeyEventArgs keyEventArgs = e;
                int          num          = keyEventArgs.Handled | handlesCommitKeys ? 1 : 0;
                keyEventArgs.Handled = num != 0;
                ChoiceEditor.LostFocusAction lostFocusAction = this.lostFocusAction;
                this.lostFocusAction = ChoiceEditor.LostFocusAction.None;
                if (lostFocusAction != ChoiceEditor.LostFocusAction.None)
                {
                    this.CancelChange();
                }
                this.OnFinishEditing();
            }
            if (this.InternalIsSelectingValue && this.collectionView != null && !this.collectionView.IsEmpty)
            {
                if (e.Key == Key.Up || !this.IsEditable && e.Key == Key.Left)
                {
                    this.SelectPreviousValue();
                    this.lostFocusAction = ChoiceEditor.LostFocusAction.Commit;
                    e.Handled            = true;
                }
                else if (e.Key == Key.Down || !this.IsEditable && e.Key == Key.Right)
                {
                    this.SelectNextValue();
                    this.lostFocusAction = ChoiceEditor.LostFocusAction.Commit;
                    e.Handled            = true;
                }
                else if (!this.IsEditable && e.Key == Key.Home)
                {
                    this.ValueIndex      = 0;
                    this.lostFocusAction = ChoiceEditor.LostFocusAction.Commit;
                    e.Handled            = true;
                }
                else if (!this.IsEditable && e.Key == Key.End)
                {
                    this.ValueIndex      = this.collectionView.Count - 1;
                    this.lostFocusAction = ChoiceEditor.LostFocusAction.Commit;
                    e.Handled            = true;
                }
            }
            base.OnPreviewKeyDown(e);
        }