Пример #1
0
        void mouseDownHandler(object sender, MouseButtonEventArgs args)
        {
            KeyboardRecord kRA = null;

            kRA      = new KeyboardRecord();
            kRA.Name = "MouseDown";
            IFrameworkInputElement frameworkElement = (IFrameworkInputElement)args.Source;

            kRA.SourceID = frameworkElement.Name;
            AddRecord(kRA);
        }
Пример #2
0
        void keyUpHandler(object sender, KeyEventArgs args)
        {
            KeyboardRecord kRA = null;

            kRA      = new KeyboardRecord();
            kRA.Name = "KeyUp";

            AddRecord(kRA);

            stateKey(args, kRA);
        }
Пример #3
0
        void stateKey(KeyEventArgs args, KeyboardRecord kRA)
        {
            kRA.Key = args.Key.ToString();

            // Store for any character

            if (args.Key == System.Windows.Input.Key.ImeProcessed)
            {
                kRA.ImeProcessedKey = args.ImeProcessedKey.ToString();
            }


            // Store State for Shift, Alt and Control Key


            KeyStates states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.RightShift);

            if (states == KeyStates.Down)
            {
                kRA.Shift = true;
            }

            states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.LeftShift);
            if (states == KeyStates.Down)
            {
                kRA.Shift = true;
            }


            states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.LeftAlt);
            if (states == KeyStates.Down)
            {
                kRA.Alt = true;
            }

            states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.RightAlt);
            if (states == KeyStates.Down)
            {
                kRA.Alt = true;
            }

            states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.RightCtrl);
            if (states == KeyStates.Down)
            {
                kRA.Control = true;
            }

            states = System.Windows.Input.Keyboard.GetKeyStates(System.Windows.Input.Key.LeftCtrl);
            if (states == KeyStates.Down)
            {
                kRA.Control = true;
            }
        }
Пример #4
0
        void lostFocusHandler(object o, KeyboardFocusChangedEventArgs args)
        {
            KeyboardRecord kRA = null;

            kRA      = new KeyboardRecord();
            kRA.Name = "LostKeyboardFocus";

            string oldFocus = "", newFocus = "";

            if (args.OldFocus != null && args.OldFocus is FrameworkElement)
            {
                oldFocus = ((FrameworkElement)args.OldFocus).Name;
            }
            else if (args.OldFocus == null)
            {
                oldFocus = "null";
            }
            else
            {
                throw new InvalidOperationException("LostKeyboardFocus OldFocus the value type is not expected");
            }
            if (args.NewFocus != null && args.NewFocus is FrameworkElement)
            {
                newFocus = ((FrameworkElement)args.NewFocus).Name;
            }
            else if (args.NewFocus == null)
            {
                newFocus = "null";
            }
            else
            {
                throw new InvalidOperationException("LostKeyboardFocus NewFocus the value type is not expected");
            }

            kRA.Focus = new FocusInfo(oldFocus, newFocus);
            AddRecord(kRA);
        }