コード例 #1
0
        public void Bind()
        {
            if (this.HasBinded)
            {
                this.Unbind();
            }

            this.HasBinded = true;
            DependencyObject bindedELement = this.BindedElement;

            if (bindedELement != null)
            {
                Keyboard.AddGotKeyboardFocusHandler(bindedELement,
                                                    this._keyboardFocusChanged);
                Keyboard.AddLostKeyboardFocusHandler(bindedELement,
                                                     this._keyboardFocusChanged);

                if (this._hiddenElements != null && !this.BindingToRoot)
                {
                    foreach (var hiddenElement in this._hiddenElements)
                    {
                        Keyboard.AddGotKeyboardFocusHandler(hiddenElement,
                                                            this._keyboardFocusChanged);
                        Keyboard.AddLostKeyboardFocusHandler(hiddenElement,
                                                             this._keyboardFocusChanged);
                    }
                }

                this.UpdateFocusElement(Keyboard.FocusedElement, true);
            }
        }
コード例 #2
0
 private void KeyBoardControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (IsEnabled)
     {
         Keyboard.AddGotKeyboardFocusHandler(Parent, GotKeyBoardHandler);
     }
 }
コード例 #3
0
        public ViewPage()
        {
            InitializeComponent();

            DataContext = this;

            if (!string.IsNullOrEmpty(App.Command))
            {
                mCurrentPage = new HistoryItem(App.Command);
            }
            else
            {
                mCurrentPage = new HistoryItem(PagesDal.DEFAULT_PAGE);
            }

            Keyboard.AddGotKeyboardFocusHandler(this, gotKeyboardFocus);
            Keyboard.AddLostKeyboardFocusHandler(this, lostKeyboardFocus);

            webBrowser1.Navigating    += webBrowser1_Navigating;
            webBrowser1.LoadCompleted += webBrowser1_LoadCompleted;
            var jsinterop = new JavascriptInterop();

            webBrowser1.ObjectForScripting  = jsinterop;
            jsinterop.InvokeFromJavascript += jsinterop_InvokeFromJavascript;
            webBrowser1.PreviewKeyDown     += webBrowser1_KeyDown;

            mSearchWatermarkText      = textBoxSearch.Text;
            mSearchWatermarkBrush     = textBoxSearch.Foreground;
            mSearchWatermarkFontStyle = textBoxSearch.FontStyle;

            mDal = new PagesDal();

            EditCommand = new RelayCommand(() => buttonEdit_Click(null, null));
            InputBindings.Add(new KeyBinding(EditCommand, new KeyGesture(Key.E, ModifierKeys.Control)));
            BackCommand = new RelayCommand(() => buttonBack_Click(null, null));
            HomeCommand = new RelayCommand(() => buttonHome_Click(null, null));
            InputBindings.Add(new KeyBinding(HomeCommand, new KeyGesture(Key.Home, ModifierKeys.Alt)));
            FindCommand = new RelayCommand(() => textBoxSearch.Focus());
            InputBindings.Add(new KeyBinding(FindCommand, new KeyGesture(Key.OemQuestion, ModifierKeys.Control)));
            RecentCommand = new RelayCommand(() => recentModifications());
            InputBindings.Add(new KeyBinding(RecentCommand, new KeyGesture(Key.R, ModifierKeys.Control)));

            initWatcher();

            refresh();

            restorePosition();

            Loaded   += (sender, e) => registerHotkey();
            Unloaded += (sender, e) => unregisterHotkey();
        }
コード例 #4
0
 private void KeyBoardControl_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (Parent != null)
     {
         if (IsEnabled)
         {
             Keyboard.AddGotKeyboardFocusHandler(Parent, GotKeyBoardHandler);
         }
         else
         {
             Keyboard.RemoveGotKeyboardFocusHandler(Parent, GotKeyBoardHandler);
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Subscribe to touch keyboard notifications.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ParentWindowLoaded(object sender, RoutedEventArgs e)
        {
            Window w = sender as Window;

            if (w != null)
            {
                // Register the window for touch KB notifications
                TouchKeyboardEventManager.AddHandlers(w, HandleTouchKeyboardShowing, HandleTouchKeyboardHiding);

                // Also register for focus changes to detect situations where a shift has caused a clipped top/bottom control
                Keyboard.AddGotKeyboardFocusHandler(w, HandleKeyboardFocus);

                w.Loaded -= ParentWindowLoaded;
            }
        }
コード例 #6
0
 public MainWindow()
 {
     Keyboard.AddGotKeyboardFocusHandler(this, Handler);
     InitializeComponent();
 }