예제 #1
0
        public WpfPresentationSource(UIElement rootElement, IWpfValueConverter converter)
        {
            this.RootElement = rootElement;
            this.converter = converter;

            RootElement.IsRootElement = true;

            MouseDevice = new MouseDevice(this);
            KeyboardDevice = new KeyboardDevice(this);

            container = new wpf::System.Windows.Controls.Canvas { Background = wpf::System.Windows.Media.Brushes.Transparent };
            container.PreviewMouseMove += OnContainerMouseMove;
            container.PreviewMouseDown += OnContainerMouseDown;
            container.PreviewMouseUp += OnContainerMouseUp;
            container.PreviewMouseWheel += (sender, e) => e.Handled = MouseDevice.ProcessRawEvent(new RawMouseWheelEventArgs(e.Delta, converter.ConvertBack(e.GetPosition(container)), GetTimestamp()));

            MouseDevice.CursorChanged += (sender, e) => container.Cursor = converter.Convert(MouseDevice.Cursor);
            container.Cursor = converter.Convert(MouseDevice.Cursor);

            window = new wpf::System.Windows.Window { UseLayoutRounding = true, Content = container };
            window.Activated += (sender, e) => MouseDevice.Activate();
            window.Deactivated += (sender, e) => MouseDevice.Deactivate();
            window.SizeChanged += (sender, e) => SetRootElementSize();
            window.PreviewKeyDown += (sender, e) => e.Handled = KeyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(converter.ConvertBack(e.Key), converter.ConvertBack(e.KeyStates), e.IsRepeat, GetTimestamp()));
            window.PreviewKeyUp += (sender, e) => e.Handled = KeyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(converter.ConvertBack(e.Key), converter.ConvertBack(e.KeyStates), e.IsRepeat, GetTimestamp()));
            window.Show();

            container.Children.Add(((IWpfRenderElement)rootElement.GetRenderElement(WpfRenderElementFactory.Default)).WpfElement);
            SetRootElementSize();

            MouseDevice.Activate();
            KeyboardDevice.Activate();
        }
예제 #2
0
		public KeyEventArgs (KeyboardDevice keyboard, PresentationSource inputSource,
				     int timestamp, Key key)
			: base (keyboard, timestamp)
		{
			this.inputSource = inputSource;
			this.key = key;
		}
예제 #3
0
 private void DG1_KeyDown(object sender, KeyEventArgs e)
 {
     System.Windows.Input.KeyboardDevice kd = e.KeyboardDevice;
     if ((kd.GetKeyStates(Key.LeftCtrl) & kd.GetKeyStates(Key.V)) > 0 || (kd.GetKeyStates(Key.LeftCtrl) & kd.GetKeyStates(Key.V)) > 0)
     {
         DataGirdViewCellPaste();
     }
 }
예제 #4
0
        /// <summary>
        /// キー入力内容をキーイベントから抜き出す
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static EnableKeys ToEnableKeys(System.Windows.Input.Key key, System.Windows.Input.KeyboardDevice keyboard)
        {
            EnableKeys keyConbination = ToEnableKeysConbination(key, keyboard);

            if (keyConbination != EnableKeys.Else)
            {
                return(keyConbination);
            }

            return(ToEnableKeysOneKey(key));
        }
예제 #5
0
        /// <summary> 
        ///     Constructs an instance of the KeyboardFocusChangedEventArgs class.
        /// </summary> 
        /// <param name="keyboard"> 
        ///     The logical keyboard device associated with this event.
        /// </param> 
        /// <param name="timestamp">
        ///     The time when the input occured.
        /// </param>
        /// <param name="oldFocus"> 
        ///     The element that previously had focus.
        /// </param> 
        /// <param name="newFocus"> 
        ///     The element that now has focus.
        /// </param> 
        public KeyboardFocusChangedEventArgs(KeyboardDevice keyboard, int timestamp, IInputElement oldFocus, IInputElement newFocus) : base(keyboard, timestamp)
        {
            if (oldFocus != null && !InputElement.IsValid(oldFocus))
                throw new InvalidOperationException(SR.Get(SRID.Invalid_IInputElement, oldFocus.GetType())); 

            if (newFocus != null && !InputElement.IsValid(newFocus)) 
                throw new InvalidOperationException(SR.Get(SRID.Invalid_IInputElement, newFocus.GetType())); 

            _oldFocus = oldFocus; 
            _newFocus = newFocus;
        }
예제 #6
0
        public static bool IsKeysDown(this System.Windows.Input.KeyboardDevice keyboardDevice, params Key[] keys)
        {
            bool isdown = false;

            if (keys.All(key => (keyboardDevice.GetKeyStates(key) & System.Windows.Input.KeyStates.Down) > 0))
            {
                isdown = true;
            }

            return(isdown);
        }
예제 #7
0
 private void Window_KeyDown(object sender, KeyEventArgs e)
 {
     System.Windows.Input.KeyboardDevice kd = e.KeyboardDevice;
     if ((kd.GetKeyStates(Key.LeftAlt) & System.Windows.Input.KeyStates.Down) > 0 ||
         (kd.GetKeyStates(Key.RightAlt) & System.Windows.Input.KeyStates.Down) > 0)
     {
         if ((kd.GetKeyStates(Key.F4) & System.Windows.Input.KeyStates.Down) > 0)
         {
             this.capFra.StopAndDispose();
         }
     }
 }
예제 #8
0
        public static bool IsKeysDown(this System.Windows.Input.KeyboardDevice keyboardDevice, params Key[] keys)
        {
            bool isShift = false;

            if ((keyboardDevice.GetKeyStates(Key.B) & System.Windows.Input.KeyStates.Down) > 0 &&
                (keyboardDevice.GetKeyStates(Key.C) & System.Windows.Input.KeyStates.Down) > 0)
            {
                isShift = true;
            }
            if (isShift)
            {
                isShift = false;
            }

            return(isShift);
        }
예제 #9
0
        public KeyEventArgs(KeyboardDevice keyboard, PresentationSource inputSource, int timestamp, Key key) : base(keyboard, timestamp)
        {
            if (inputSource == null)
                throw new ArgumentNullException("inputSource");

            if (!Keyboard.IsValidKey(key))
                throw new System.ComponentModel.InvalidEnumArgumentException("key", (int)key, typeof(Key));

            _inputSource = inputSource;

            _realKey = key;
            _isRepeat = false;

            // Start out assuming that this is just a normal key.
            MarkNormal();
        }
예제 #10
0
파일: EditGesture.cs 프로젝트: faboo/Agent
        private bool IsModDown(KeyboardDevice keyboard)
        {
            bool down = true;

            down &= (Mods & ModifierKeys.Alt) == ModifierKeys.Alt
                == (keyboard.IsKeyDown(Key.LeftAlt) || keyboard.IsKeyDown(Key.RightAlt));

            down &= (Mods & ModifierKeys.Control) == ModifierKeys.Control
                == (keyboard.IsKeyDown(Key.LeftCtrl) || keyboard.IsKeyDown(Key.RightCtrl));

            down &= (Mods & ModifierKeys.Shift) == ModifierKeys.Shift
                == (keyboard.IsKeyDown(Key.LeftShift) || keyboard.IsKeyDown(Key.RightShift));

            down &= (Mods & ModifierKeys.Windows) == ModifierKeys.Windows
                == (keyboard.IsKeyDown(Key.LWin) || keyboard.IsKeyDown(Key.RWin));

            return down;
        }
예제 #11
0
        /// <summary>
        ///     Constructs an instance of the KeyEventArgs class.
        /// </summary>
        /// <param name="keyboard">
        ///     The logical keyboard device associated with this event.
        /// </param>
        /// <param name="inputSource">
        ///     The input source that provided this input.
        /// </param>
        /// <param name="timestamp">
        ///     The time when the input occured.
        /// </param>
        /// <param name="key">
        ///     The key referenced by the event.
        /// </param>
        public KeyEventArgs(KeyboardDevice keyboard, PresentationSource inputSource, int timestamp, Key key) : base(keyboard, timestamp)
        {
            if (inputSource == null)
            {
                throw new ArgumentNullException("inputSource");
            }

            if (!Keyboard.IsValidKey(key))
            {
                throw new System.ComponentModel.InvalidEnumArgumentException("key", (int)key, typeof(Key));
            }

            _inputSource = inputSource;

            _realKey  = key;
            _isRepeat = false;

            // Start out assuming that this is just a normal key.
            MarkNormal();
        }
예제 #12
0
        public KeyboardState(KeyboardDevice device)
        {
            CurrentKeyStates = new Dictionary<Key, KeyStates>();
            foreach (Key k in Enum.GetValues(typeof(Key)))
            {
                if (CurrentKeyStates.ContainsKey(k))
                {
                    continue;
                }

                CurrentKeyStates.Add(k, KeyStates.None);
            }

            PrevKeyStates = new Dictionary<Key, KeyStates>();
            foreach (KeyValuePair<Key, KeyStates> kvp in CurrentKeyStates)
            {
                PrevKeyStates.Add(kvp.Key, kvp.Value);
            }

            Update(device);
        }
예제 #13
0
        public PresentationSource(UIElement rootElement, IHtmlValueConverter converter)
        {
            this.RootElement = rootElement;
            this.converter = converter;

            RootElement.IsRootElement = true;

            MouseDevice = new MouseDevice(this);
            KeyboardDevice = new KeyboardDevice(this);

            window = System.Html.Window.Instance;

            MouseDevice.CursorChanged += (sender, e) => System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor);
            System.Html.Window.Document.Body.Style.Cursor = converter.ToCursorString(MouseDevice.Cursor);

            System.Html.Window.OnKeydown = OnKeyDown;
            System.Html.Window.OnKeyup = OnKeyUp;
            System.Html.Window.OnKeypress = PreventKeyboardHandled;
            System.Html.Window.OnMousemove = OnMouseMove;
            System.Html.Window.OnMousedown = OnMouseDown;
            System.Html.Window.OnMouseup = OnMouseUp;
            System.Html.Window.OnScroll = OnMouseWheel;
            System.Html.Window.OnFocus = e => MouseDevice.Activate();
            System.Html.Window.OnBlur = e => MouseDevice.Deactivate();
            System.Html.Window.OnResize = e => SetRootElementSize();
            System.Html.Window.OnClick = PreventMouseHandled;
            System.Html.Window.OnDblclick = PreventMouseHandled;
            System.Html.Window.OnContextmenu = PreventMouseHandled;
            System.Html.Window.AddEventListener("wheel", OnMouseWheel);

            SetRootElementSize();
            System.Html.Window.Document.Body.Style.Overflow = "hidden";
            System.Html.Window.Document.Body.AppendChild(((HtmlRenderElement)RootElement.GetRenderElement(HtmlRenderElementFactory.Default)).HtmlElement);

            MouseDevice.Activate();
            KeyboardDevice.Activate();
        }
예제 #14
0
 public KeyboardEventArgs(KeyboardDevice keyboard, int timestamp) : base(default(InputDevice), default(int))
 {
 }
예제 #15
0
 public KeyEventArgs(RoutedEvent routedEvent, object originalSource, KeyboardDevice keyboardDevice, int timestamp, Key key, KeyStates keyStates, bool isRepeat)
     : base(routedEvent, originalSource, keyboardDevice, timestamp)
 {
     this.Key = key;
     this.KeyStates = keyStates;
     this.IsRepeat = isRepeat;
 }
 public KeyboardInputProviderAcquireFocusEventArgs(KeyboardDevice keyboard, int timestamp, bool focusAcquired) : base (default(KeyboardDevice), default(int))
 {
 }
예제 #17
0
 public KeyboardEventArgs(RoutedEvent routedEvent, object originalSource, KeyboardDevice keyboardDevice, int timestamp) :
     base(routedEvent, originalSource, keyboardDevice, timestamp)
 {
     this.KeyboardDevice = keyboardDevice;
 }
예제 #18
0
        public static IDisposable Focus(IInputElement element)
        {
            KeyboardDevice keyboardDevice = ApplicationHost.Current.GetKeyboardDeviceFromElement((FrameworkElement)element);

            return(keyboardDevice != null?keyboardDevice.Focus(element) : null);
        }
예제 #19
0
        public void KeyboardDeviceBasicTest()
        {
            FrameworkElement element = new FrameworkElement();

            int eventIndex = 0;

            int previewKeyDownIndex = 0;
            int previewKeyUpIndex = 0;
            int previewGotKeyboardFocusIndex = 0;
            int previewLostKeyboardFocusIndex = 0;
            int keyDownIndex = 0;
            int keyUpIndex = 0;
            int gotKeyboardFocusIndex = 0;
            int lostKeyboardFocusIndex = 0;

            element.PreviewKeyDown += (sender, e) => previewKeyDownIndex = ++eventIndex;
            element.PreviewKeyUp += (sender, e) => previewKeyUpIndex = ++eventIndex;
            element.PreviewGotKeyboardFocus += (sender, e) => previewGotKeyboardFocusIndex = ++eventIndex;
            element.PreviewLostKeyboardFocus += (sender, e) => previewLostKeyboardFocusIndex = ++eventIndex;
            element.KeyDown += (sender, e) => keyDownIndex = ++eventIndex;
            element.KeyUp += (sender, e) => keyUpIndex = ++eventIndex;
            element.GotKeyboardFocus += (sender, e) => gotKeyboardFocusIndex = ++eventIndex;
            element.LostKeyboardFocus += (sender, e) => lostKeyboardFocusIndex = ++eventIndex;

            TestPresentationSource presentationSource = new TestPresentationSource();
            KeyboardDevice keyboardDevice = new KeyboardDevice(presentationSource);

            keyboardDevice.Activate();

            IDisposable focus = keyboardDevice.Focus(element);
            Assert.AreEqual(1, previewGotKeyboardFocusIndex);
            Assert.AreEqual(2, gotKeyboardFocusIndex);
            Assert.IsTrue(element.IsKeyboardFocused);

            keyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(Key.Enter, KeyStates.Down, false, 0));
            Assert.AreEqual(KeyStates.Down, keyboardDevice.GetKeyStates(Key.Enter));
            Assert.AreEqual(3, previewKeyDownIndex);
            Assert.AreEqual(4, keyDownIndex);

            keyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(Key.Enter, KeyStates.None, false, 0));
            Assert.AreEqual(KeyStates.None, keyboardDevice.GetKeyStates(Key.Enter));
            Assert.AreEqual(5, previewKeyUpIndex);
            Assert.AreEqual(6, keyUpIndex);

            focus.Dispose();
            Assert.AreEqual(7, previewLostKeyboardFocusIndex);
            Assert.AreEqual(8, lostKeyboardFocusIndex);
            Assert.IsFalse(element.IsKeyboardFocused);

            focus = keyboardDevice.Focus(element);
            keyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(Key.Enter, KeyStates.Down, false, 0));
            focus.Dispose();
            Assert.AreEqual(13, previewKeyUpIndex);
            Assert.AreEqual(14, keyUpIndex);
            Assert.AreEqual(15, previewLostKeyboardFocusIndex);
            Assert.AreEqual(16, lostKeyboardFocusIndex);

            keyboardDevice.Focus(element);
            keyboardDevice.ProcessRawEvent(new RawKeyboardEventArgs(Key.Enter, KeyStates.Down, false, 0));
            keyboardDevice.Deactivate();
            Assert.AreEqual(23, previewKeyUpIndex);
            Assert.AreEqual(24, keyUpIndex);
        }
    private static DependencyObject PredictNextElement( FrameworkElement source, KeyboardDevice device )
    {
      foreach( var direction in NavigationHelper.GetFocusNavigationDirections( source, device ) )
      {
        var target = source.PredictFocus( direction );
        if( target != null )
          return target;
      }

      return null;
    }
 public KeyEventArgs(KeyboardDevice keyboard, System.Windows.PresentationSource inputSource, int timestamp, Key key) : base (default(KeyboardDevice), default(int))
 {
 }
    internal static bool HandleTabKey(
      DataGridControl dataGridControl,
      DataGridContext dataGridContext,
      FrameworkElement source,
      KeyboardDevice device )
    {
      if( ( dataGridControl == null ) || !dataGridControl.IsKeyboardFocusWithin )
        return false;

      Debug.Assert( dataGridControl.CurrentContext == dataGridContext );

      if( !dataGridControl.IsBeingEdited )
      {
        Debug.Assert( dataGridContext != null );
        return false;
      }

      if( NavigationHelper.ValidateTabKeyHandleIsWithin( dataGridControl, source, device ) )
        return false;

      var columns = dataGridContext.VisibleColumns;
      if( columns.Count <= 0 )
        return false;

      bool handled;

      if( dataGridContext.CurrentColumn == null )
      {
        handled = NavigationHelper.MoveFocusToFirstVisibleColumn( dataGridContext );
      }
      else
      {
        if( ( device.Modifiers & ModifierKeys.Shift ) == ModifierKeys.Shift )
        {
          handled = NavigationHelper.MoveFocusToPreviousVisibleColumn( dataGridContext );
        }
        else
        {
          handled = NavigationHelper.MoveFocusToNextVisibleColumn( dataGridContext );
        }
      }

      if( !handled )
        throw new DataGridException( "Trying to edit while no cell is focusable.", dataGridControl );

      return true;
    }
    private static bool ValidateTabKeyHandleIsWithin(
      DataGridControl dataGridControl,
      FrameworkElement source,
      KeyboardDevice device )
    {
      if( ( dataGridControl == null ) || ( source == null ) )
        return false;

      var nextControl = NavigationHelper.PredictNextElement( source, device );
      if( nextControl == null )
        return false;

      //If the original source is not a control (e.g. the cells panel instead of a cell), columns will be used to move focus.
      var cell = Cell.FindFromChild( nextControl );
      if( ( cell == null ) || ( cell.ParentColumn != dataGridControl.CurrentColumn ) )
        return false;

      return object.Equals( cell.ParentRow.DataContext, dataGridControl.CurrentItemInEdition );
    }
 public KeyboardFocusChangedEventArgs(KeyboardDevice keyboard, int timestamp, System.Windows.IInputElement oldFocus, System.Windows.IInputElement newFocus) : base (default(KeyboardDevice), default(int))
 {
 }
예제 #25
0
 void SetPrimaryKeyboardDevice(KeyboardDevice keyboardDevice)
 {
     this.keyboardDevice = keyboardDevice;
 }
 public KeyboardFocusChangedEventArgs(KeyboardDevice keyboard, int timestamp, System.Windows.IInputElement oldFocus, System.Windows.IInputElement newFocus) : base(default(KeyboardDevice), default(int))
 {
 }
예제 #27
0
 public KeyboardFocusChangedEventArgs(RoutedEvent routedEvent, object originalSource, KeyboardDevice keyboardDevice, int timestamp, IInputElement oldFocus, IInputElement newFocus)
     : base(routedEvent, originalSource, keyboardDevice, timestamp)
 {
     this.OldFocus = oldFocus;
     this.NewFocus = newFocus;
 }
    private static IEnumerable<FocusNavigationDirection> GetFocusNavigationDirections( FrameworkElement source, KeyboardDevice device )
    {
      if( source == null )
        yield break;

      //In the case of a ListBox set with Cycle or Contained navigation mode, we must move in the other direction if on the first or last item,
      //since PredictFocus will throw is we use FocusNavigationDirection.First/Last.
      if( ( device.Modifiers & ModifierKeys.Shift ) == ModifierKeys.Shift )
      {
        yield return FocusNavigationDirection.Left;
        yield return FocusNavigationDirection.Up;

        var navigationMode = ( KeyboardNavigationMode )source.GetValue( KeyboardNavigation.TabNavigationProperty );
        if( navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained )
        {
          yield return FocusNavigationDirection.Right;
          yield return FocusNavigationDirection.Down;
        }
      }
      else
      {
        yield return FocusNavigationDirection.Right;
        yield return FocusNavigationDirection.Down;

        var navigationMode = ( KeyboardNavigationMode )source.GetValue( KeyboardNavigation.TabNavigationProperty );
        if( navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained )
        {
          yield return FocusNavigationDirection.Left;
          yield return FocusNavigationDirection.Up;
        }
      }
    }
예제 #29
0
        public void Update(KeyboardDevice device)
        {
            foreach (KeyValuePair<Key, KeyStates> kvp in CurrentKeyStates)
            {
                PrevKeyStates[kvp.Key] = kvp.Value;
            }

            foreach (Key k in Enum.GetValues(typeof(Key)))
            {
                if (k == Key.None)
                {
                    continue;
                }

                CurrentKeyStates[k] = device.GetKeyStates(k);
            }
        }
예제 #30
0
        private void autoCities_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            bool isRightCtrl = false;

            System.Windows.Input.KeyboardDevice kd = e.KeyboardDevice;
            if ((kd.GetKeyStates(Key.RightCtrl) & System.Windows.Input.KeyStates.Down) > 0)
            {
                isRightCtrl = true;//激活打开文件位置功能
            }


            if (e.Key == Key.Enter && this.autoCities.Text != string.Empty)
            {
                switch (this.autoCities.Text.Trim().ToUpper())
                {
                case "HELP":

                    break;

                case "SET":
                    this.autoCities.Text = string.Empty;
                    WinProInf wd = new WinProInf();
                    wd.WindowState           = WindowState.Normal;
                    wd.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    wd.ShowInTaskbar         = false;
                    wd.Closed += wd_Closed;
                    wd.Topmost = true;
                    wd.ShowDialog();
                    break;

                case "EXIT":
                    this.Close();
                    break;

                case "RELOAD":
                    loadXML();
                    break;

                case "UPDATE":
                    Process proc = new System.Diagnostics.Process();
                    proc.StartInfo.FileName = "http://pan.baidu.com/s/1CGL36";
                    proc.Start();
                    break;

                default:
                    break;
                }
                if (autoCities.Items.Count > 0)
                {
                    if (autoCities.SelectedIndex == -1)
                    {
                        autoCities.SelectedIndex = 0;
                    }

                    Program city = (Program)(autoCities.SelectedItem);
                    WinHidden();
                    try
                    {
                        if (isRightCtrl)
                        {
                            FileInfo f = new FileInfo(city.Link);
                            Process.Start(f.Directory.ToString());
                        }
                        else
                        {
                            System.Diagnostics.Process.Start(city.Link);
                            this.autoCities.Text = string.Empty;
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message.Contains("用户已取消操作"))
                        {
                            MessageBox.Show("文件已失效");
                        }
                        else
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
            else if (e.Key == Key.Escape)
            {
                WinHidden();
            }

            else
            {
            }
        }
예제 #31
0
        private static EnableKeys ToEnableKeysConbination(System.Windows.Input.Key key, System.Windows.Input.KeyboardDevice keyboard)
        {
            // Ctrl + Shift + 何か
            if (keyboard.Modifiers == (ModifierKeys.Control | ModifierKeys.Shift))
            {
                if (key == Key.OemPlus)
                {
                    return(EnableKeys.RotatePlusWithCtrl);
                }
                else if (key == Key.OemMinus)
                {
                    return(EnableKeys.RotateMinusWithCtrl);
                }
            }

            // Ctrl + 何か
            if (keyboard.Modifiers == ModifierKeys.Control)
            {
                if (key == Key.Z)
                {
                    return(EnableKeys.Cancel);
                }
                else if (key == Key.Y)
                {
                    return(EnableKeys.Redo);
                }
                else if (key == Key.OemMinus)
                {
                    return(EnableKeys.RotateMinusWithCtrl);
                }
                else if (key == Key.O)
                {
                    return(EnableKeys.FileOpen);
                }
                else if (key == Key.S)
                {
                    return(EnableKeys.FileSave);
                }
                else if (key == Key.P)
                {
                    return(EnableKeys.PreviewWindowOpen);
                }
            }

            // Shift + 何か
            if (keyboard.Modifiers == ModifierKeys.Shift)
            {
                if (key == Key.OemPlus)
                {
                    return(EnableKeys.RotatePlus);
                }
            }

            return(EnableKeys.Else);
        }
예제 #32
0
		void SetPrimaryKeyboardDevice (KeyboardDevice keyboardDevice)
		{
			this.keyboardDevice = keyboardDevice;
		}
    internal bool ValidateTabKeyHandleIsWithin( FrameworkElement originalSource, KeyboardDevice keyboardDevice )
    {
      DependencyObject predictedNextVisual = null;

      //If the original source is not a control (e.g. the cells panel instead of a cell), columns will be used to move focus.
      //In the case of a ListBox set with Cycle or Contained navigation mode, we must move in the other direction if on the first or last item,
      //since PedictFocus will throw is we use FocusNavigationDirection.First/Last.
      if( originalSource != null )
      {
        if( ( keyboardDevice.Modifiers & ModifierKeys.Shift ) == ModifierKeys.Shift )
        {
          predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Left );
          if( predictedNextVisual == null )
          {
            predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Up );
            if( predictedNextVisual == null )
            {
              KeyboardNavigationMode navigationMode = ( KeyboardNavigationMode )originalSource.GetValue( KeyboardNavigation.TabNavigationProperty );
              if( navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained )
              {
                predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Right );
                if( predictedNextVisual == null )
                {
                  predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Down );
                }
              }
            }
          }
        }
        else
        {
          predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Right );
          if( predictedNextVisual == null )
          {
            predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Down );
            if( predictedNextVisual == null )
            {
              KeyboardNavigationMode navigationMode = ( KeyboardNavigationMode )originalSource.GetValue( KeyboardNavigation.TabNavigationProperty );
              if( navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained )
              {
                predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Left );
                if( predictedNextVisual == null )
                {
                  predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Up );
                }
              }
            }
          }
        }
      }

      if( predictedNextVisual != null )
      {
        Cell ownerCell = Cell.FindFromChild( predictedNextVisual );

        if( ( ownerCell != null ) && ( ownerCell.ParentColumn == this.ParentDataGridControl.CurrentColumn ) )
        {
          if( object.Equals( ownerCell.ParentRow.DataContext, this.ParentDataGridControl.CurrentItemInEdition ) )
            return true;
        }
      }

      return false;
    }
예제 #34
0
 public KeyboardEventArgs(RoutedEvent routedEvent, object originalSource, KeyboardDevice keyboardDevice, int timestamp)
     : base(routedEvent, originalSource, keyboardDevice, timestamp)
 {
     this.KeyboardDevice = keyboardDevice;
 }
 /// <summary>
 ///     Constructs an instance of the KeyboardInputProviderAcquireFocusEventArgs class.
 /// </summary>
 /// <param name="keyboard">
 ///     The logical keyboard device associated with this event.
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured.
 /// </param>
 /// <param name="focusAcquired">
 ///     Whether or not interop focus was acquired.
 /// </param>
 public KeyboardInputProviderAcquireFocusEventArgs(KeyboardDevice keyboard, int timestamp, bool focusAcquired) : base(keyboard, timestamp)
 {
     _focusAcquired = focusAcquired;
 }
 public KeyboardInputProviderAcquireFocusEventArgs(KeyboardDevice keyboard, int timestamp, bool focusAcquired) : base(default(KeyboardDevice), default(int))
 {
 }
예제 #37
0
 public KeyEventArgs(KeyboardDevice keyboard, System.Windows.PresentationSource inputSource, int timestamp, Key key) : base(default(KeyboardDevice), default(int))
 {
 }
예제 #38
0
 /// <summary>
 ///     Initializes a new instance of the KeyboardEventArgs class.
 /// </summary>
 /// <param name="keyboard">
 ///     The logical keyboard device associated with this event.
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured.
 /// </param>
 public KeyboardEventArgs(KeyboardDevice keyboard, int timestamp) : base(keyboard, timestamp)
 {
 }
예제 #39
0
 public KeyboardFocusChangedEventArgs(RoutedEvent routedEvent, object originalSource, KeyboardDevice keyboardDevice, int timestamp, IInputElement oldFocus, IInputElement newFocus) :
     base(routedEvent, originalSource, keyboardDevice, timestamp)
 {
     this.OldFocus = oldFocus;
     this.NewFocus = newFocus;
 }
예제 #40
0
		public KeyboardEventArgs (KeyboardDevice keyboard,
					  int timestamp) : base (keyboard, timestamp)
		{
			throw new NotImplementedException ();
		}
		public KeyboardFocusChangedEventArgs (KeyboardDevice keyboard, int timestamp,
						      IInputElement oldFocus, IInputElement newFocus)
			: base (keyboard, timestamp)
		{
			throw new NotImplementedException ();
		}
예제 #42
0
 /// <summary>
 ///     Initializes a new instance of the KeyboardEventArgs class.
 /// </summary> 
 /// <param name="keyboard">
 ///     The logical keyboard device associated with this event. 
 /// </param> 
 /// <param name="timestamp">
 ///     The time when the input occured. 
 /// </param>
 public KeyboardEventArgs(KeyboardDevice keyboard, int timestamp) : base(keyboard, timestamp)
 {
 } 
 public KeyboardEventArgs(KeyboardDevice keyboard, int timestamp) : base (default(InputDevice), default(int))
 {
 }
 private bool IsScrollLockToggled(KeyboardDevice keyboard)
 {
     return keyboard.IsKeyToggled(Key.Scroll);
 }
예제 #45
0
 /// <summary>
 ///     Constructs an instance of the KeyboardInputProviderAcquireFocusEventArgs class.
 /// </summary>
 /// <param name="keyboard">
 ///     The logical keyboard device associated with this event.
 /// </param>
 /// <param name="timestamp">
 ///     The time when the input occured.
 /// </param>
 /// <param name="focusAcquired">
 ///     Whether or not interop focus was acquired.
 /// </param>
 public KeyboardInputProviderAcquireFocusEventArgs(KeyboardDevice keyboard, int timestamp, bool focusAcquired) : base(keyboard, timestamp)
 {
     _focusAcquired = focusAcquired;
 }
예제 #46
0
        private bool ProcessKeyState(KeyboardDevice device, Key curKey, Key retKey, params Key[] addlKeys)
        {
            if (curKey == Key.LeftCtrl || curKey == Key.RightCtrl) return false;

            if (!(addlKeys.Any(aKey => device.IsKeyDown(aKey)) || device.IsKeyDown(retKey)))
                return true;

            var msgs = _mDict.ProcessKey(retKey);
            msgs.Do(msg => msg.Invoke(this));
            return true;
        }
예제 #47
0
 public KeyboardEventArgs(KeyboardDevice keyboard,
                          int timestamp) : base(keyboard, timestamp)
 {
     throw new NotImplementedException();
 }
예제 #48
0
 public KeyboardFocusChangedEventArgs(KeyboardDevice keyboard, int timestamp,
                                      IInputElement oldFocus, IInputElement newFocus)
     : base(keyboard, timestamp)
 {
     throw new NotImplementedException();
 }