/// <summary>
 /// Handles the <see cref="Keyboard.KeyDownEvent"/> attached event for the view's topmost <see cref="Grid"/> instance.
 /// </summary>
 /// <param name="dobj">The object that raised the event.</param>
 /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param>
 /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param>
 /// <param name="modifiers">A <see cref="ModifierKeys"/> value indicating which of the key modifiers are currently active.</param>
 /// <param name="data">The routed event metadata for this event invocation.</param>
 public void HandleKeyDown(DependencyObject dobj, KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data)
 {
     switch (key)
     {
         case Key.AppControlBack:
             {
                 owner.Ultraviolet.Host.Exit();
                 data.Handled = true;
             }
             break;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Activates any link at the current cursor position within the specified command stream.
        /// </summary>
        /// <param name="stream">The command stream to update.</param>
        /// <param name="element">The element that owns the command stream.</param>
        /// <param name="data">The event metadata for the routed event which prompted the link activation.</param>
        /// <returns><see langword="true"/> if the command stream's link was deactivated; otherwise, <see langword="false"/>.</returns>
        public static Boolean ActivateTextLink(TextLayoutCommandStream stream, UIElement element, RoutedEventData data)
        {
            Contract.Require(element, nameof(element));

            if (stream == null || element.View == null || !element.View.Resources.TextRenderer.ActivateLinkAtCursor(stream))
                return false;

            element.Focus();
            element.CaptureMouse();

            data.Handled = true;
            return true;
        }
        /// <summary>
        /// Raises a property change notification for all subscribers to the specified target.
        /// </summary>
        /// <param name="target">The target object for which to raise a notification.</param>
        /// <param name="data">The routed event data.</param>
        public void Notify(DependencyObject target, RoutedEventData data)
        {
            lock (subscriptions)
            {
                PooledLinkedList<IRoutedEventRaisedNotificationSubscriber> subscribers;
                if (!subscriptions.TryGetValue(target, out subscribers))
                    return;

                for (var current = subscribers.First; current != null; current = current.Next)
                {
                    current.Value.ReceiveRoutedEventRaisedNotification(target, routedEvent, data);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Executes any link at the current cursor position within the specified command stream.
        /// </summary>
        /// <param name="stream">The command stream to update.</param>
        /// <param name="element">The element that owns the command stream.</param>
        /// <param name="data">The event metadata for the routed event which prompted the link execution.</param>
        public static Boolean ExecuteTextLink(TextLayoutCommandStream stream, UIElement element, RoutedEventData data)
        {
            Contract.Require(element, nameof(element));

            if (stream == null || element.View == null)
                return false;

            if (stream.ActiveLinkIndex.HasValue)
                element.ReleaseMouseCapture();

            if (!element.View.Resources.TextRenderer.ExecuteActivatedLink(stream))
                return false;

            data.Handled = true;
            return true;
        }
        /// <summary>
        /// Handles the <see cref="Keyboard.KeyDownEvent"/> attached event for the view's topmost <see cref="Grid"/> instance.
        /// </summary>
        /// <param name="dobj">The object that raised the event.</param>
        /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param>
        /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param>
        /// <param name="modifiers">A <see cref="ModifierKeys"/> value indicating which of the key modifiers are currently active.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        public void HandleKeyDown(DependencyObject dobj, KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data)
        {
            switch (key)
            {
                case Key.Escape:
                    {
                        Modal.ShowDialogAsync(escMenuDialog).ContinueWith(HandleEscMenuDialogResult);
                        data.Handled = true;
                    }
                    break;

                case Key.AppControlBack:
                    {
                        ReturnToMainMenu();
                        data.Handled = true;
                    }
                    break;
            }
        }
 /// <summary>
 /// Invokes the <see cref="OnMouseMove"/> method.
 /// </summary>
 private static void OnMouseMoveProxy(DependencyObject element, MouseDevice device, Double x, Double y, Double dx, Double dy, RoutedEventData data)
 {
     ((UIElement)element).OnMouseMove(device, x, y, dx, dy, data);
 }
 /// <summary>
 /// Invokes the <see cref="OnLostMouseCapture"/> method.
 /// </summary>
 private static void OnLostMouseCaptureProxy(DependencyObject element, RoutedEventData data)
 {
     ((UIElement)element).OnLostMouseCapture(data);
 }
 /// <summary>
 /// Invokes the <see cref="OnKeyUp"/> method.
 /// </summary>
 private static void OnKeyUpProxy(DependencyObject element, KeyboardDevice device, Key key, RoutedEventData data)
 {
     ((UIElement)element).OnKeyUp(device, key, data);
 }
 /// <summary>
 /// Invokes the <see cref="OnLostKeyboardFocus"/> method.
 /// </summary>
 private static void OnLostKeyboardFocusProxy(DependencyObject element, KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, RoutedEventData data)
 {
     ((UIElement)element).OnLostKeyboardFocus(device, oldFocus, newFocus, data);
 }
        /// <summary>
        /// Invokes by the <see cref="GamePad.ButtonUpEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The game pad device.</param>
        /// <param name="button">The button that was released.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnGamePadButtonUp(GamePadDevice device, GamePadButton button, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invokes by the <see cref="GamePad.AxisUpEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The game pad device.</param>
        /// <param name="axis">The axis that was released.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnGamePadAxisUp(GamePadDevice device, GamePadAxis axis, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invokes by the <see cref="GamePad.AxisChangedEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The game pad device.</param>
        /// <param name="axis">The axis that was changed.</param>
        /// <param name="value">The value to which the axis was changed.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnGamePadAxisChanged(GamePadDevice device, GamePadAxis axis, Single value, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked when a <see cref="Keyboard.KeyUpEvent"/> attached routed event occurs.
        /// </summary>
        /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param>
        /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnKeyUp(KeyboardDevice device, Key key, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked when a <see cref="Keyboard.KeyDownEvent"/> attached routed event occurs.
        /// </summary>
        /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param>
        /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param>
        /// <param name="modifiers">A <see cref="ModifierKeys"/> value indicating which of the key modifiers are currently active.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data)
        {

        }
Esempio n. 15
0
 /// <summary>
 /// Closes the dialog box when the "Cancel" button is clicked.
 /// </summary>
 /// <param name="dobj">The object that raised the event.</param>
 /// <param name="data">The routed event data for this event invocation.</param>
 public void HandleClickCancel(DependencyObject dobj, ref RoutedEventData data)
 {
     MessageBoxResult = MessageBoxResult.Cancel;
 }
        /// <summary>
        /// Invoked when a <see cref="Keyboard.TextInputEvent"/> attached routed event occurs.
        /// </summary>
        /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnTextInput(KeyboardDevice device, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked by the <see cref="Touch.FingerMotionEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The touch device.</param>
        /// <param name="fingerID">The identifier of the finger that caused the touch.</param>
        /// <param name="x">The x-coordinate of the touch.</param>
        /// <param name="y">The y-coordinate of the touch.</param>
        /// <param name="dx">The amount of motion along the x-axis.</param>
        /// <param name="dy">The amount of motion along the y-axis.</param>
        /// <param name="pressure">The normalized pressure value of the touch.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnFingerMotion(TouchDevice device, Int64 fingerID,
            Double x, Double y, Double dx, Double dy, Single pressure, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked when a <see cref="Keyboard.TextEditingEvent"/> attached routed event occurs.
        /// </summary>
        /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnTextEditing(KeyboardDevice device, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invokes by the <see cref="GamePad.AxisDownEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The game pad device.</param>
        /// <param name="axis">The axis that was pressed.</param>
        /// <param name="value">The axis' value when it was pressed.</param>
        /// <param name="repeat">A value indicating whether this is a repeated axis press.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnGamePadAxisDown(GamePadDevice device, GamePadAxis axis, Single value, Boolean repeat, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked by the <see cref="Mouse.LostMouseCaptureEvent"/> attached routed event.
        /// </summary>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnLostMouseCapture(RoutedEventData data)
        {

        }
        /// <summary>
        /// Invokes by the <see cref="GamePad.ButtonDownEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The game pad device.</param>
        /// <param name="button">The button that was pressed.</param>
        /// <param name="repeat">A value indicating whether this is a repeated button press.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnGamePadButtonDown(GamePadDevice device, GamePadButton button, Boolean repeat, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked by the <see cref="Mouse.MouseMoveEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The mouse device.</param>
        /// <param name="x">The x-coordinate of the cursor in device-independent screen coordinates.</param>
        /// <param name="y">The y-coordinate of the cursor in device-independent screen coordinates.</param>
        /// <param name="dx">The difference between the x-coordinate of the mouse's 
        /// current position and the x-coordinate of the mouse's previous position.</param>
        /// <param name="dy">The difference between the y-coordinate of the mouse's 
        /// current position and the y-coordinate of the mouse's previous position.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnMouseMove(MouseDevice device, Double x, Double y, Double dx, Double dy, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked by the <see cref="Generic.GenericInteractionEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The input device.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnGenericInteraction(UltravioletResource device, RoutedEventData data)
        {

        }
        /// <summary>
        /// Invoked by the <see cref="Mouse.MouseLeaveEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The mouse device.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnMouseLeave(MouseDevice device, RoutedEventData data)
        {

        }
 /// <summary>
 /// Invokes the <see cref="OnKeyDown"/> method.
 /// </summary>
 private static void OnKeyDownProxy(DependencyObject element, KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data)
 {
     ((UIElement)element).OnKeyDown(device, key, modifiers, data);
 }
        /// <summary>
        /// Invoked by the <see cref="Mouse.MouseDoubleClickEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The mouse device.</param>
        /// <param name="button">The mouse button that was pressed or released.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnMouseDoubleClick(MouseDevice device, MouseButton button, RoutedEventData data)
        {

        }
 /// <summary>
 /// Invokes the <see cref="OnTextEditing"/> method.
 /// </summary>
 private static void OnTextEditingProxy(DependencyObject element, KeyboardDevice device, RoutedEventData data)
 {
     ((UIElement)element).OnTextEditing(device, data);
 }
        /// <summary>
        /// Invoked by the <see cref="Mouse.MouseWheelEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The mouse device.</param>
        /// <param name="x">The amount that the wheel was scrolled along the x-axis.</param>
        /// <param name="y">The amount that the wheel was scrolled along the y-axis.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnMouseWheel(MouseDevice device, Double x, Double y, RoutedEventData data)
        {

        }
 /// <summary>
 /// Invokes the <see cref="OnMouseLeave"/> method.
 /// </summary>
 private static void OnMouseLeaveProxy(DependencyObject element, MouseDevice device, RoutedEventData data)
 {
     var uiElement = ((UIElement)element);
     uiElement.OnMouseLeave(device, data);
 }
        /// <summary>
        /// Invoked by the <see cref="Touch.TapEvent"/> attached routed event.
        /// </summary>
        /// <param name="device">The touch device.</param>
        /// <param name="fingerID">The identifier of the finger that caused the touch.</param>
        /// <param name="x">The x-coordinate of the touch.</param>
        /// <param name="y">The y-coordinate of the touch.</param>
        /// <param name="data">The routed event metadata for this event invocation.</param>
        protected virtual void OnTap(TouchDevice device, Int64 fingerID,
            Double x, Double y, RoutedEventData data)
        {

        }
 /// <summary>
 /// Invokes the <see cref="OnMouseDown"/> method.
 /// </summary>
 private static void OnMouseDownProxy(DependencyObject element, MouseDevice device, MouseButton button, RoutedEventData data)
 {
     ((UIElement)element).OnMouseDown(device, button, data);
 }
Esempio n. 32
0
 /// <summary>
 /// Closes the dialog box when the "Yes" button is clicked.
 /// </summary>
 /// <param name="dobj">The object that raised the event.</param>
 /// <param name="data">The routed event data for this event invocation.</param>
 public void HandleClickYes(DependencyObject dobj, ref RoutedEventData data)
 {
     MessageBoxResult = MessageBoxResult.Yes;
 }