Exemple #1
0
        public bool TryHighlightSearchString(string searchTerm)
        {
            var index = _content.IndexOf(searchTerm, StringComparison.CurrentCultureIgnoreCase);

            if (index == -1 || string.IsNullOrWhiteSpace(searchTerm))
            {
                if (_accessKeyIndex != -1)
                {
                    // Unregister and let the content control handle access keys
                    AccessKeyManager.Unregister(_content[_accessKeyIndex].ToString(), _control);
                }

                _control.Content = _originalContent;
                return(false);
            }

            if (_accessKeyIndex != -1)
            {
                // Because we are overriding the content entirely, we have to handle access keys
                AccessKeyManager.Register(_content[_accessKeyIndex].ToString(), _control);
            }

            _control.Content = CreateHighlightingTextRun(index, searchTerm.Length);
            return(true);
        }
Exemple #2
0
 protected virtual void OnIsDefaultChanged(bool oldValue, bool newValue)
 {
     if (newValue)
     {
         AccessKeyManager.Register("\r", this);
     }
     else
     {
         AccessKeyManager.Unregister("\r", this);
     }
 }
Exemple #3
0
        // Token: 0x06004283 RID: 17027 RVA: 0x00130C64 File Offset: 0x0012EE64
        private static void OnIsCancelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Button element = d as Button;

            if ((bool)e.NewValue)
            {
                AccessKeyManager.Register("\u001b", element);
                return;
            }
            AccessKeyManager.Unregister("\u001b", element);
        }
Exemple #4
0
        private static void OnIsCancelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Button b = d as Button;

            if ((bool)e.NewValue)
            {
                AccessKeyManager.Register("\x001B", b);
            }
            else
            {
                AccessKeyManager.Unregister("\x001B", b);
            }
        }
Exemple #5
0
        private void RegisterAccessKey()
        {
            if (_currentlyRegistered != null)
            {
                AccessKeyManager.Unregister(_currentlyRegistered, this);
                _currentlyRegistered = null;
            }
            string key = _accessKey.Text;

            if (!string.IsNullOrEmpty(key))
            {
                AccessKeyManager.Register(key, this);
                _currentlyRegistered = key;
            }
        }
Exemple #6
0
        // Token: 0x06004214 RID: 16916 RVA: 0x0012E4D4 File Offset: 0x0012C6D4
        private void RegisterAccessKey()
        {
            if (this._currentlyRegistered != null)
            {
                AccessKeyManager.Unregister(this._currentlyRegistered, this);
                this._currentlyRegistered = null;
            }
            string text = this._accessKey.Text;

            if (!string.IsNullOrEmpty(text))
            {
                AccessKeyManager.Register(text, this);
                this._currentlyRegistered = text;
            }
        }
        private void DisonnectFromPresentationSource()
        {
            if (_rootInputElement != null)
            {
                foreach (string registeredKey in _renameAccessKeys)
                {
                    AccessKeyManager.Unregister(registeredKey, _rootInputElement);
                }

                AccessKeyManager.RemoveAccessKeyPressedHandler(_rootDependencyObject, OnAccessKeyPressed);
            }

            _presentationSource   = null;
            _rootDependencyObject = null;
            _rootInputElement     = null;
        }
Exemple #8
0
        private void RegisterAccessKey()
        {
            if (_registeredAccessKey != null)
            {
                AccessKeyManager.Unregister(_registeredAccessKey, this);
                _registeredAccessKey = null;
            }

            var accessKey = GetAccessKey();

            if (string.IsNullOrEmpty(accessKey))
            {
                return;
            }

            AccessKeyManager.Register(accessKey, this);
            _registeredAccessKey = accessKey;
        }
Exemple #9
0
        // initialize the plus button access key
        private static void PlusButtonAccessKeyPropertyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            string       source  = e.NewValue as string;
            string       old     = e.OldValue as string;
            EditSelector control = sender as EditSelector;

            if (source == null || control == null)
            {
                return;
            }
            // set the access key for the plus button
            AccessKeyManager.Register(source, control.PlusButton);
            // unregister the old access key if present
            if (old != null)
            {
                AccessKeyManager.Unregister(old, control.PlusButton);
            }
        }
Exemple #10
0
        // Token: 0x0600427F RID: 17023 RVA: 0x00130B8C File Offset: 0x0012ED8C
        private static void OnIsDefaultChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Button button = d as Button;
            KeyboardFocusChangedEventHandler keyboardFocusChangedEventHandler = Button.FocusChangedEventHandlerField.GetValue(button);

            if (keyboardFocusChangedEventHandler == null)
            {
                keyboardFocusChangedEventHandler = new KeyboardFocusChangedEventHandler(button.OnFocusChanged);
                Button.FocusChangedEventHandlerField.SetValue(button, keyboardFocusChangedEventHandler);
            }
            if ((bool)e.NewValue)
            {
                AccessKeyManager.Register("\r", button);
                KeyboardNavigation.Current.FocusChanged += keyboardFocusChangedEventHandler;
                button.UpdateIsDefaulted(Keyboard.FocusedElement);
                return;
            }
            AccessKeyManager.Unregister("\r", button);
            KeyboardNavigation.Current.FocusChanged -= keyboardFocusChangedEventHandler;
            button.UpdateIsDefaulted(null);
        }
Exemple #11
0
        private static void OnIsDefaultChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            Button b = d as Button;
            KeyboardFocusChangedEventHandler focusChangedEventHandler = FocusChangedEventHandlerField.GetValue(b);

            if (focusChangedEventHandler == null)
            {
                focusChangedEventHandler = new KeyboardFocusChangedEventHandler(b.OnFocusChanged);
                FocusChangedEventHandlerField.SetValue(b, focusChangedEventHandler);
            }

            if ((bool)e.NewValue)
            {
                AccessKeyManager.Register("\x000D", b);
                KeyboardNavigation.Current.FocusChanged += focusChangedEventHandler;
                b.UpdateIsDefaulted(Keyboard.FocusedElement);
            }
            else
            {
                AccessKeyManager.Unregister("\x000D", b);
                KeyboardNavigation.Current.FocusChanged -= focusChangedEventHandler;
                b.UpdateIsDefaulted(null);
            }
        }