Beispiel #1
0
 protected override void OnLostFocus(RoutedEventArgs e)
 {
     base.OnLostFocus(e);
     this.IsEditing = false;
     ValueEditorUtils.ExecuteCommand(this.LostFocusCommand, this, null);
     e.Handled = true;
 }
Beispiel #2
0
 private void CancelStartedChange()
 {
     ValueEditorUtils.UpdateBinding((FrameworkElement)this, ChoiceEditor.ValueProperty, UpdateBindingType.Target);
     ValueEditorUtils.UpdateBinding((FrameworkElement)this, ChoiceEditor.ValueIndexProperty, UpdateBindingType.Target);
     this.UpdateInternalValuesFromValue();
     ValueEditorUtils.ExecuteCommand(this.CancelCommand, (IInputElement)this, (object)null);
 }
Beispiel #3
0
        private void OnFinishEditing()
        {
            ICommand finishEditingCommand = this.FinishEditingCommand;

            if (finishEditingCommand == null)
            {
                Keyboard.Focus(null);
                return;
            }
            ValueEditorUtils.ExecuteCommand(finishEditingCommand, this, null);
        }
Beispiel #4
0
 private void UpdateChange()
 {
     if (!this.transactionOpen)
     {
         ValueEditorUtils.ExecuteCommand(this.BeginCommand, this, null);
     }
     this.Value = base.Text;
     ValueEditorUtils.ExecuteCommand(this.UpdateCommand, this, null);
     this.transactionOpen = true;
     ValueEditorUtils.UpdateBinding(this, StringEditor.ValueProperty, UpdateBindingType.Target);
     this.UpdateTextFromValue();
 }
Beispiel #5
0
 private void CancelChange()
 {
     if (!this.transactionOpen)
     {
         ValueEditorUtils.ExecuteCommand(this.BeginCommand, this, null);
     }
     ValueEditorUtils.UpdateBinding(this, StringEditor.ValueProperty, false);
     ValueEditorUtils.ExecuteCommand(this.CancelCommand, this, null);
     this.transactionOpen = false;
     ValueEditorUtils.UpdateBinding(this, StringEditor.ValueProperty, UpdateBindingType.Target);
     this.UpdateTextFromValue();
 }
Beispiel #6
0
 private void OnLastAction()
 {
     if (this.LastActionCommand != null)
     {
         ValueEditorUtils.ExecuteCommand(this.LastActionCommand, (IInputElement)this, (object)null);
     }
     else
     {
         int num = this.SelectedIndex < 0 ? this.savedIndex : this.SelectedIndex;
         this.SelectedIndex = -1;
         this.SelectedIndex = num;
     }
 }
Beispiel #7
0
 protected override void OnTextChanged(TextChangedEventArgs e)
 {
     base.OnTextChanged(e);
     if (this.ignoreTextChanges)
     {
         return;
     }
     ValueEditorUtils.ExecuteCommand(this.TextChangedCommand, this, base.Text);
     if (this.IsEditing)
     {
         this.lostFocusAction = StringEditor.LostFocusAction.Commit;
     }
 }
Beispiel #8
0
        private void OnFinishEditing()
        {
            ICommand finishEditingCommand = this.FinishEditingCommand;

            if (finishEditingCommand != null)
            {
                ValueEditorUtils.ExecuteCommand(finishEditingCommand, (IInputElement)this, (object)null);
            }
            else
            {
                Keyboard.Focus((IInputElement)null);
            }
        }
Beispiel #9
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;
 }
Beispiel #10
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            bool handlesCommitKeys = ValueEditorUtils.GetHandlesCommitKeys(this);

            if (e.Key == Key.Return || e.Key == Key.Return)
            {
                StringEditor.LostFocusAction lostFocusAction = this.lostFocusAction;
                this.lostFocusAction = StringEditor.LostFocusAction.None;
                bool modifiers = (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.None;
                if (lostFocusAction == StringEditor.LostFocusAction.Commit)
                {
                    if (!modifiers)
                    {
                        this.UpdateChange();
                    }
                    else
                    {
                        this.CommitChange();
                    }
                }
                if (modifiers)
                {
                    this.OnFinishEditing();
                }
                KeyEventArgs handled = e;
                handled.Handled = handled.Handled | handlesCommitKeys;
            }
            else if (e.Key == Key.Escape && this.IsEditing)
            {
                StringEditor.LostFocusAction lostFocusAction1 = this.lostFocusAction;
                this.lostFocusAction = StringEditor.LostFocusAction.None;
                if (lostFocusAction1 != StringEditor.LostFocusAction.None)
                {
                    this.CancelChange();
                }
                this.OnFinishEditing();
                KeyEventArgs keyEventArg = e;
                keyEventArg.Handled = keyEventArg.Handled | handlesCommitKeys;
            }
            base.OnKeyDown(e);
        }
Beispiel #11
0
 public static void UpdateBinding(FrameworkElement element, DependencyProperty property, bool updateSource)
 {
     ValueEditorUtils.UpdateBinding(element, property, (updateSource ? UpdateBindingType.Both : UpdateBindingType.Target));
 }
Beispiel #12
0
 private void CancelChange()
 {
     ValueEditorUtils.ExecuteCommand(this.BeginCommand, (IInputElement)this, (object)null);
     this.CancelStartedChange();
 }
Beispiel #13
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);
        }