private void OnButtonUp(object sender, ButtonEventArgs e)
 {
     // hide window
     this.Visibility = Visibility.Hidden;
     // but this finally removes it
     Close();
 }
        public MFTestResults UIElement_RaiseEvent_ButtonEvent_Test1()
        {
            MFTestResults testResult = MFTestResults.Pass;
            Log.Comment("Raising ButtonEvents and Verifying");
            //addToEvtRoute = false;
            btnEvent = true;
            fcsEvent = false;
            _btnEventCntr = 0;
            rEvents = new RoutedEvent[] { Buttons.ButtonDownEvent, Buttons.ButtonUpEvent,             
                Buttons.PreviewButtonDownEvent, Buttons.PreviewButtonUpEvent};
            for (int i = 0; i < rEvents.Length; i++)
            {
                //rEvent = rEvents[i];
                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(AddToHandler), rEvents[i]);

                ButtonEventArgs bea = new ButtonEventArgs(null, null, DateTime.Now, Hardware.Button.AppDefined1);
                bea.RoutedEvent = rEvents[i];

                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(RaiseEvent), bea);
                if (_btnEventCntr != i + 1)
                {
                    Log.Comment("ButtonEvent '" + rEvents[i].Name + "' event not raised");
                    testResult = MFTestResults.Fail;
                }
            }
            btnEvent = false;

            return testResult;
        }
Example #3
0
 private void OnButtonUp(object sender, ButtonEventArgs e)
 {
     // Show a modeless dialog window
     SecondWindow wnd = new SecondWindow();
     wnd.Visibility = Visibility.Visible;
     // Right after showing the window execution immediatelly continues here
 }
Example #4
0
        private void OnButtonDown(object sender, ButtonEventArgs e)
        {
            // Picture data buffer
            byte[] pictureData;

            // Get instant Jpeg picture - give some process delay
            camera.GetJpegPicture(C328R.PictureType.Jpeg, out pictureData, 800);

            // If some data exists - show'em
            if (pictureData.Length > 0)
            {
                mainWindow.Background = new SolidColorBrush(Colors.Black);
                imageView.Bitmap = new Bitmap(pictureData, Bitmap.BitmapImageType.Jpeg);
                imageView.Invalidate();

                // Save operation takes some time
                SaveFileOnDisk(pictureData);
            }
            else
            {
                // if no image was taken - turn background red and reset camera
                mainWindow.Background = new SolidColorBrush(Colors.Red);
                imageView.Bitmap = new Bitmap(10, 10);

                mainWindow.Invalidate();
                camera.Reset(true);
            }

            InitCamera();
        }
        /// <summary>
        /// Removes this window from the Window Manager.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnButtonDown(ButtonEventArgs e)
        {
            // Removes this window form the Window Manager.
            this.Close();

            // When any button is pressed, go back to the Home page.
            _program.GoHome();
        }
Example #6
0
        protected override void OnButtonDown(Microsoft.SPOT.Input.ButtonEventArgs e)
        {
            switch (e.Button)
            {
            case Microsoft.SPOT.Hardware.Button.VK_UP:
                if (_scrollingStyle == ScrollingStyle.LineByLine)
                {
                    LineUp();
                }
                else
                {
                    PageUp();
                }
                break;

            case Microsoft.SPOT.Hardware.Button.VK_DOWN:
                if (_scrollingStyle == ScrollingStyle.LineByLine)
                {
                    LineDown();
                }
                else
                {
                    PageDown();
                }
                break;

            case Microsoft.SPOT.Hardware.Button.VK_LEFT:
                if (_scrollingStyle == ScrollingStyle.LineByLine)
                {
                    LineLeft();
                }
                else
                {
                    PageLeft();
                }
                break;

            case Microsoft.SPOT.Hardware.Button.VK_RIGHT:
                if (_scrollingStyle == ScrollingStyle.LineByLine)
                {
                    LineRight();
                }
                else
                {
                    PageRight();
                }
                break;

            default:
                return;
            }

            if (_previousHorizontalOffset != _horizontalOffset || _previousVerticalOffset != _verticalOffset)
            {
                e.Handled = true;
            }
        }
Example #7
0
        protected override void OnButtonUp(ButtonEventArgs e)
        {
            switch (e.Button)
            {
                case Button.VK_0:
                    channel = 0;
                    break;
                case Button.VK_1:
                    channel = 1;
                    break;
                case Button.VK_2:
                    channel = 2;
                    break;
                case Button.VK_3:
                    channel = 3;
                    break;
                case Button.VK_4:
                    channel = 4;
                    break;
                case Button.VK_5:
                    channel = 5;
                    break;
                case Button.VK_6:
                    channel = 6;
                    break;
                case Button.VK_7:
                    channel = 7;
                    break;
                case Button.VK_8:
                    channel = 8;
                    break;
                case Button.VK_9:
                    channel = 9;
                    break;
                case Button.VK_NEXT:
                    channel += 1;
                    break;
                case Button.VK_PRIOR:
                    channel -= 1;
                    break;
                case Button.VK_VOLUME_UP:
                    volumeBar.Value += 1;
                    break;
                case Button.VK_VOLUME_DOWN:
                    volumeBar.Value -= 1;
                    break;
            }

            channelLabel.TextContent = channel.ToString();
        }
 /// <summary>
 /// Button event handler
 /// </summary>
 /// <param name="e"></param>
 protected override void OnButtonDown(ButtonEventArgs e)
 {
     if (e.Button == Button.Select)
     {
         switch (menuListBox.SelectedIndex)
         {
             case 0:
                 StartGame(1);
                 break;
             case 1:
                 StartGame(5);
                 break;
             case 2:
                 StartGame(10);
                 break;
             case 3:
                 ViewHighScore(-1);
                 break;
         }
     }
 }
Example #9
0
        private void OnButtonUp(object sender, ButtonEventArgs e)
        {
            // Show a modal dialog window

            // Create and show new window
            SecondWindow wnd = new SecondWindow();
            wnd.Visibility = Visibility.Visible;
            wnd.Topmost = true; // move on top of all others

            DispatcherFrame modalFrame = new DispatcherFrame();

            // Create a handler that will terminate the loop when the window will be hidden
            PropertyChangedEventHandler handler = delegate
            {
                if (wnd.Visibility != Visibility.Visible) // when the windows was hidden
                    modalFrame.Continue = false; // tell the frame to exit the loop
            };

            wnd.IsVisibleChanged += handler; // add handler to terminate the loop
            Dispatcher.PushFrame(modalFrame); // start the loop and block the calling thread
            // Here we go when the modal dialog was closed
            wnd.IsVisibleChanged -= handler; // remove handler
        }
Example #10
0
 private void listBox_ButtonDown(object sender, ButtonEventArgs args)
 {
     ListBox listBox = (ListBox)sender;
     if (args.Button == Button.VK_SELECT)
         Debug.Print("Item " + listBox.SelectedIndex + " was pressed.");
 }
        public MFTestResults UIElement_AddHandlerTest3()
        {
            MFTestResults testResult = MFTestResults.Pass;
            //addToEvtRoute = false;
            btnEvent = true;
            _btnEventCntr = 0;
            handledEventsToo = false;
            mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                 new DispatcherOperationCallback(AddToHandler), Buttons.ButtonDownEvent);

            ButtonEventArgs bea = new ButtonEventArgs(null, null, DateTime.Now, Hardware.Button.AppDefined1);
            bea.RoutedEvent = Buttons.ButtonDownEvent;

            mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(RaiseEvent), bea);

            Log.Comment("registering handler NOT to be invoked when event is marked handled");
            if (_btnEventCntr != 1)
            {
                Log.Comment("Expected ButtonHandler called '1' but got '" + _btnEventCntr + "'");
                testResult = MFTestResults.Fail;
            }
            _btnEventCntr = 0;
            Log.Comment("registering handler to be invoked even when event is marked handled");
            handledEventsToo = true;
            mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                 new DispatcherOperationCallback(AddToHandler), Buttons.ButtonDownEvent);
            bea = new ButtonEventArgs(null, null, DateTime.Now, Hardware.Button.AppDefined2);
            bea.RoutedEvent = Buttons.ButtonDownEvent;
            mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(RaiseEvent), bea);

            if (_btnEventCntr <= 1)
            {
                Log.Comment("Expected ButtonHandler called more than '1' but got '" + _btnEventCntr + "'");
                testResult = MFTestResults.Fail;
            }
            handledEventsToo = false;

            return testResult;
        }
Example #12
0
 private void textFlow_ButtonDown(object sender, ButtonEventArgs args)
 {
     Debug.Print("Button: " + args.Button);
 }
        object AddToHandler(object obj)
        {
            if (obj is RoutedEvent && btnEvent)
            {
                mainWindow.AddHandler((RoutedEvent)obj, new RoutedEventHandler(HandleButtonEvents), handledEventsToo);
            }
            if (obj is RoutedEvent &&  fcsEvent)
            {
                mainWindow.AddHandler((RoutedEvent)obj, new RoutedEventHandler(HandleFocusChangedEvent), handledEventsToo);
            }
            if (obj is EventRoute)
            {
                RoutedEventArgs args = null;

                if (btnEvent)
                {
                    args = new ButtonEventArgs(null, null, DateTime.Now, Hardware.Button.AppDefined1);
                    args.RoutedEvent = Buttons.ButtonDownEvent;
                }
                else
                {
                    args = new FocusChangedEventArgs(null, DateTime.Now, mainWindow, mainWindow);
                    args.RoutedEvent = Buttons.LostFocusEvent;
                }
                mainWindow.AddToEventRoute((EventRoute)obj, args);
            }
            return null;
        }
        public MFTestResults UIElement_AddToEventRouteTest4()
        {
            MFTestResults testResult = MFTestResults.Pass;
            rEvents = new RoutedEvent[] { Buttons.ButtonDownEvent, Buttons.ButtonUpEvent,             
                Buttons.PreviewButtonDownEvent, Buttons.PreviewButtonUpEvent};
            handledEventsToo = false;
            //addToEvtRoute = true;
            Log.Comment("Setting Both Event Counters to zero (0)");
            _btnEventCntr = 0;
            _fcsEventCntr = 0;
            Log.Comment("Adding all ButtonDownEvents to the EventRoute");
            btnEvent = true;
            fcsEvent = false;
            for (int i = 0; i < rEvents.Length; i++)
            {
                eRoute = new EventRoute(rEvents[i]);
                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                        new DispatcherOperationCallback(AddToHandler), eRoute);
            }
            Log.Comment("Raising the Events and Verifying");
            for (int i = 0; i < rEvents.Length; i++)
            {
                ButtonEventArgs bea = new ButtonEventArgs(null, null, DateTime.Now, Hardware.Button.AppDefined1);
                bea.RoutedEvent = rEvents[i];

                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                        new DispatcherOperationCallback(RaiseEvent), bea);
            }

            Log.Comment("This currently fails, getting one additional button event than expected, investigating");
            if (_btnEventCntr != rEvents.Length)
            {
                Log.Comment("Expected ButtonEvents = '" + rEvents.Length +
                    "' but got '" + _btnEventCntr + "'");
                testResult = MFTestResults.Skip;
            }
            Log.Comment("Adding all FocuseChangedEvents to the EventRoute");
            btnEvent = false;
            fcsEvent = true;
            rEvents = new RoutedEvent[] { Buttons.GotFocusEvent, Buttons.LostFocusEvent };
            for (int i = 0; i < rEvents.Length; i++)
            {
                eRoute = new EventRoute(rEvents[i]);
                mainWindow.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                    new DispatcherOperationCallback(AddToHandler), eRoute);
            }
            Log.Comment("Raising the Events and Verifying");
            for (int i = 0; i < rEvents.Length; i++)
            {
                FocusChangedEventArgs fcea = new FocusChangedEventArgs(null, DateTime.Now, mainWindow, mainWindow);
                fcea.RoutedEvent = rEvents[i];

                Application.Current.Dispatcher.Invoke(new TimeSpan(0, 0, 5),
                        new DispatcherOperationCallback(RaiseEvent), fcea);
            }

            if (_fcsEventCntr != rEvents.Length)
            {
                Log.Comment("Expected FocusChangedEvent = '" + rEvents.Length +
                    "' but got '" + _fcsEventCntr + "'");
                testResult = MFTestResults.Fail;
            }

            return testResult;
        }
Example #15
0
        private void PreNotifyInput(object sender, NotifyInputEventArgs e)
        {
            RawButtonInputReport buttonInput = ExtractRawButtonInputReport(e, InputManager.PreviewInputReportEvent);

            if (buttonInput != null)
            {
                CheckForDisconnectedFocus();

                /*
                 *
                 * REFACTOR --
                 *
                 * the keyboard device is only active per app domain basis -- so like if your app domain doesn't have
                 * focus your keyboard device is not going to give you the real state of the keyboard.
                 *
                 * When it gets focus, it needs to know about this somehow.   We could use this keyboard action
                 * type stuff to do so.  Though this design really seem to be influenced a lot from living in
                 * the windows world.
                 *
                 * Essentially the input stack is being used like a message pump to say, hey dude you can
                 * use the keyboard now -- it's not real input, it's more or less a message.
                 *
                 * It could be interesting for elements to know about this -- since I think
                 * they will probalby still have focus (or do they get a Got and Lost Focus when the keyboard activates -- I don't think so,
                 * we need to know what we were focused on when the window gets focus again.
                 *
                 * So maybe elements want to stop some animation or something when input focus moves away from the activesource, and
                 * start them again later.  Could be interesting.
                 */

                if ((buttonInput.Actions & RawButtonActions.Activate) == RawButtonActions.Activate)
                {
                    //System.Console.WriteLine("Initializing the button state.");

#if TRACK_BUTTON_STATE
                    // Clear out our key state storage.
                    for (int i = 0; i < _buttonState.Length; i++)
                    {
                        _buttonState[i] = 0;
                    }
#endif
                    // we are now active.
                    // we should track which source is active so we don't confuse deactivations.
                    _isActive = true;
                }

                // Generally, we need to check against redundant actions.
                // We never prevet the raw event from going through, but we
                // will only generate the high-level events for non-redundant
                // actions.  We store the set of non-redundant actions in
                // the dictionary of this event.

                // If the input is reporting a button down, the action is never
                // considered redundant.
                if ((buttonInput.Actions & RawButtonActions.ButtonDown) == RawButtonActions.ButtonDown)
                {
                    RawButtonActions actions = GetNonRedundantActions(e);
                    actions |= RawButtonActions.ButtonDown;
                    e.StagingItem.SetData(_tagNonRedundantActions, actions);

                    // Pass along the button that was pressed, and update our state.
                    e.StagingItem.SetData(_tagButton, buttonInput.Button);

#if TRACK_BUTTON_STATE
                    ButtonState buttonState = GetButtonState(buttonInput.Button);

                    if ((buttonState & ButtonState.Down) == ButtonState.Down)
                    {
                        buttonState = ButtonState.Down | ButtonState.Held;
                    }
                    else
                    {
                        buttonState |= ButtonState.Down;
                    }

                    SetButtonState(buttonInput.Button, buttonState);
#endif

                    // Tell the InputManager that the MostRecentDevice is us.
                    if (_inputManager != null)
                    {
                        _inputManager.MostRecentInputDevice = (InputDevice)this;
                    }
                }

                // need to detect redundant ups.
                if ((buttonInput.Actions & RawButtonActions.ButtonUp) == RawButtonActions.ButtonUp)
                {
                    RawButtonActions actions = GetNonRedundantActions(e);
                    actions |= RawButtonActions.ButtonUp;
                    e.StagingItem.SetData(_tagNonRedundantActions, actions);

                    // Pass along the button that was pressed, and update our state.
                    e.StagingItem.SetData(_tagButton, buttonInput.Button);

#if TRACK_BUTTON_STATE
                    ButtonState buttonState = GetButtonState(buttonInput.Button);

                    if ((buttonState & ButtonState.Down) == ButtonState.Down)
                    {
                        buttonState &= (~ButtonState.Down) & (ButtonState.Down | ButtonState.Held);
                    }
                    else
                    {
                        buttonState |= ButtonState.Held;
                    }

                    SetButtonState(buttonInput.Button, buttonState);
#endif

                    // Tell the InputManager that the MostRecentDevice is us.
                    if (_inputManager != null)
                    {
                        _inputManager.MostRecentInputDevice = (InputDevice)this;
                    }
                }
            }

            // On ButtonDown, we might need to set the Repeat flag

            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent)
            {
                CheckForDisconnectedFocus();

                ButtonEventArgs args = (ButtonEventArgs)e.StagingItem.Input;

                // Is this the same as the previous button?
                if (_previousButton == args.Button)
                {
                    // Yes, this is a repeat (we got the buttondown for it twice, with no ButtonUp in between)
                    // what about chording?
                    args._isRepeat = true;
                }

                // Otherwise, keep this button to check against next time.
                else
                {
                    _previousButton = args.Button;
                    args._isRepeat  = false;
                }
            }

            // On ButtonUp, we clear Repeat flag
            else if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonUpEvent)
            {
                CheckForDisconnectedFocus();

                ButtonEventArgs args = (ButtonEventArgs)e.StagingItem.Input;
                args._isRepeat = false;

                // Clear _previousButton, so that down/up/down/up doesn't look like a repeat
                _previousButton = Button.None;
            }
        }
Example #16
0
 private void OnButtonUp(object sender, ButtonEventArgs e)
 {
     // Print the button code to the Visual Studio output window.
     //Debug.Print(e.Button.ToString());
 }
Example #17
0
 /// <summary>
 ///     An event reporting a button was released.
 /// </summary>
 protected virtual void OnButtonUp(ButtonEventArgs e) { }
Example #18
0
 /// <summary>
 ///     An event reporting a button was released.
 /// </summary>
 protected virtual void OnPreviewButtonUp(ButtonEventArgs e) { }
        /// <summary>
        /// Handles button click events.
        /// </summary>
        /// <param name="e">The button event arguments.</param>
        protected override void OnButtonDown(ButtonEventArgs e)
        {
            switch (e.Button)
            {
                // If <Enter> button is pressed, go into the selected demo
                case Button.VK_SELECT:
                    {
                        switch (m_MenuItemPanel.CurrentChild)
                        {
                            case 0:  // Vertical Stack Panel Demo
                                new StackPanelDemo(_program, Orientation.Vertical);
                                break;
                            case 1:  // Horizontal Stack Panel Demo
                                new StackPanelDemo(_program,
                                    Orientation.Horizontal);
                                break;
                            case 2:  // Canvas Panel Demo
                                new CanvasPanelDemo(_program);
                                break;
                            case 3:  // Scrollable Panel Demo
                                new ScrollPanelDemo(_program);
                                break;
                            case 4:  // Free Drawing Panel Demo
                                new FreeDrawingDemo(_program);
                                break;
                        }
                    }
                    break;

                // If <Left> button is pressed, change the menu item left one.
                case Button.VK_LEFT:
                    {
                        if (m_MenuItemPanel != null)
                            m_MenuItemPanel.CurrentChild--;
                    }
                    break;

                // If <Right> button is pressed, change the menu item right one.
                case Button.VK_RIGHT:
                    {
                        if (m_MenuItemPanel != null)
                            m_MenuItemPanel.CurrentChild++;
                    }
                    break;
            }

            // Don't call base implementation (base.OnButtonDown) or we'll go back 
            // Home.
        }
Example #20
0
 private static void OnButtonUp(object sender, ButtonEventArgs e)
 {
     // Print the button code to the Visual Studio output window.
     Debug.Print("Pressed Button " + e.Button.ToString());
     /*switch (e.Button)
     {
         case Microsoft.SPOT.Hardware.Button.VK_UP:
             if (!hoggerThread.IsAlive)
                 hoggerThread.Start();
             break;
         case Microsoft.SPOT.Hardware.Button.VK_SELECT:
             MeasureDebugOutputTime();
             break;
         case Microsoft.SPOT.Hardware.Button.VK_DOWN:
             if (hoggerThread.IsAlive)
                 hoggerThread.Abort();
             break;
     }*/
 }
Example #21
0
        //
        // We have this thunking layer because the delegates for class handlers are static,
        // but we need to call instance methods.  An alternative would be to either not have class handlers (inconsistent),
        // or to use per-instance storage for every class handler (wasteful).  So we will trade off some code size here
        // to get class handlers.

        private static void OnPreviewButtonDownThunk(object sender, ButtonEventArgs e) { ((UIElement)sender).OnPreviewButtonDown(e); }
Example #22
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            // PreviewButtonDown --> ButtonDown
            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    ButtonEventArgs previewButtonDown = (ButtonEventArgs)e.StagingItem.Input;
                    ButtonEventArgs buttonDown        = new ButtonEventArgs(this, previewButtonDown.InputSource, previewButtonDown.Timestamp, previewButtonDown.Button);

                    buttonDown._isRepeat   = previewButtonDown.IsRepeat;
                    buttonDown.RoutedEvent = Buttons.ButtonDownEvent;

                    e.PushInput(buttonDown, e.StagingItem);
                }
            }

            // PreviewButtonUp --> ButtonUp
            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonUpEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    ButtonEventArgs previewButtonUp = (ButtonEventArgs)e.StagingItem.Input;

                    ButtonEventArgs buttonUp = new ButtonEventArgs(this, previewButtonUp.InputSource, previewButtonUp.Timestamp, previewButtonUp.Button);

                    buttonUp.RoutedEvent = Buttons.ButtonUpEvent;

                    e.PushInput(buttonUp, e.StagingItem);
                }
            }

            RawButtonInputReport buttonInput = ExtractRawButtonInputReport(e, InputManager.InputReportEvent);

            if (buttonInput != null)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    // In general, this is where we promote the non-redundant
                    // reported actions to our premier events.
                    RawButtonActions actions = GetNonRedundantActions(e);

                    // Raw --> PreviewButtonDown
                    if ((actions & RawButtonActions.ButtonDown) == RawButtonActions.ButtonDown)
                    {
                        Button button = (Button)e.StagingItem.GetData(_tagButton);
                        if (button != Button.None)
                        {
                            ButtonEventArgs previewButtonDown = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button);
                            previewButtonDown.RoutedEvent = Buttons.PreviewButtonDownEvent;
                            e.PushInput(previewButtonDown, e.StagingItem);
                        }
                    }

                    // Raw --> PreviewButtonUp
                    if ((actions & RawButtonActions.ButtonUp) == RawButtonActions.ButtonUp)
                    {
                        Button button = (Button)e.StagingItem.GetData(_tagButton);
                        if (button != Button.None)
                        {
                            ButtonEventArgs previewButtonUp = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button);
                            previewButtonUp.RoutedEvent = Buttons.PreviewButtonUpEvent;
                            e.PushInput(previewButtonUp, e.StagingItem);
                        }
                    }
                }

                // Deactivate
                if ((buttonInput.Actions & RawButtonActions.Deactivate) == RawButtonActions.Deactivate)
                {
                    if (_isActive)
                    {
                        _isActive = false;

                        // Even if handled, a button deactivate results in a lost focus.
                        ChangeFocus(null, e.StagingItem.Input.Timestamp);
                    }
                }
            }
        }
        /// <summary>
        /// A button handler.
        /// </summary>
        /// <param name="e">The button-press event arguments.</param>
        protected override void OnButtonDown(ButtonEventArgs e)
        {
            switch (e.Button)
            {
                case Button.VK_SELECT:

                    // Remove this window from the Window Manager.
                    this.Close();

                    // When the <Select> button is pressed, go back to the Home 
                    // page.
                    _program.GoHome();
                    break;

                case Button.VK_UP:
                    // Scroll the viewer up one line.
                    _viewer.LineUp();
                    break;

                case Button.VK_DOWN:
                    // Scroll the viewer down one line.
                    _viewer.LineDown();
                    break;

                case Button.VK_LEFT:
                    // Scroll the viewer left one line.
                    _viewer.LineLeft();
                    break;

                case Button.VK_RIGHT:
                    // Scroll the viewer right one line.
                    _viewer.LineRight();
                    break;
            }
        }
        /// <summary>
        /// Button down handler
        /// </summary>        
        protected override void OnButtonDown(ButtonEventArgs e)
        {
            // Close windows if not editing
            if (!editMode)
            {
                this.Close();
                parentApp.SetFocus();
            }
            else
            {
                switch (e.Button)
                {
                    case Button.Up:
                        letterIndexes[selectedLetter]++;
                        break;
                    case Button.Down:
                        letterIndexes[selectedLetter]--;
                        break;
                    case Button.Left:
                        selectedLetter--;
                        break;
                    case Button.Right:
                        selectedLetter++;
                        break;
                    case Button.Select:
                        SaveItem();
                        break;

                }
                UpdateName();
            }
        }
Example #25
0
        /// <summary>
        /// Button handler
        /// </summary>        
        protected override void OnButtonDown(ButtonEventArgs e)
        {
            // If game is over then every key close the window
            if (gameUniverse.Statistics.GameOver)
            {
                this.Close();
                parentApp.SetFocus();

                if (OnClose != null)
                    OnClose(this, gameUniverse.Statistics);
            }
            // else handle the keys
            else
            {
                switch (e.Button)
                {
                    case Button.Left:
                        gameUniverse.StepLeft();
                        break;
                    case Button.Right:
                        gameUniverse.StepRight();
                        break;
                    case Button.Up:
                        gameUniverse.Rotate();
                        break;
                    case Button.Select:
                        gameUniverse.DropDown();
                        break;
                }
            }

            universeView.Invalidate();
        }
Example #26
0
        private void PostProcessInput(object sender, ProcessInputEventArgs e)
        {
            // PreviewButtonDown --> ButtonDown
            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonDownEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    ButtonEventArgs previewButtonDown = (ButtonEventArgs)e.StagingItem.Input;
                    ButtonEventArgs buttonDown = new ButtonEventArgs(this, previewButtonDown.InputSource, previewButtonDown.Timestamp, previewButtonDown.Button);

                    buttonDown._isRepeat = previewButtonDown.IsRepeat;
                    buttonDown.RoutedEvent = Buttons.ButtonDownEvent;

                    e.PushInput(buttonDown, e.StagingItem);
                }
            }

            // PreviewButtonUp --> ButtonUp
            if (e.StagingItem.Input.RoutedEvent == Buttons.PreviewButtonUpEvent)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    ButtonEventArgs previewButtonUp = (ButtonEventArgs)e.StagingItem.Input;

                    ButtonEventArgs buttonUp = new ButtonEventArgs(this, previewButtonUp.InputSource, previewButtonUp.Timestamp, previewButtonUp.Button);

                    buttonUp.RoutedEvent = Buttons.ButtonUpEvent;

                    e.PushInput(buttonUp, e.StagingItem);
                }
            }

            RawButtonInputReport buttonInput = ExtractRawButtonInputReport(e, InputManager.InputReportEvent);
            if (buttonInput != null)
            {
                CheckForDisconnectedFocus();

                if (!e.StagingItem.Input.Handled)
                {
                    // In general, this is where we promote the non-redundant
                    // reported actions to our premier events.
                    RawButtonActions actions = GetNonRedundantActions(e);

                    // Raw --> PreviewButtonDown
                    if ((actions & RawButtonActions.ButtonDown) == RawButtonActions.ButtonDown)
                    {
                        Button button = (Button)e.StagingItem.GetData(_tagButton);
                        if (button != Button.None)
                        {
                            ButtonEventArgs previewButtonDown = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button);
                            previewButtonDown.RoutedEvent = Buttons.PreviewButtonDownEvent;
                            e.PushInput(previewButtonDown, e.StagingItem);
                        }
                    }

                    // Raw --> PreviewButtonUp
                    if ((actions & RawButtonActions.ButtonUp) == RawButtonActions.ButtonUp)
                    {
                        Button button = (Button)e.StagingItem.GetData(_tagButton);
                        if (button != Button.None)
                        {
                            ButtonEventArgs previewButtonUp = new ButtonEventArgs(this, buttonInput.InputSource, buttonInput.Timestamp, button);
                            previewButtonUp.RoutedEvent = Buttons.PreviewButtonUpEvent;
                            e.PushInput(previewButtonUp, e.StagingItem);
                        }
                    }
                }

                // Deactivate
                if ((buttonInput.Actions & RawButtonActions.Deactivate) == RawButtonActions.Deactivate)
                {
                    if (_isActive)
                    {
                        _isActive = false;

                        // Even if handled, a button deactivate results in a lost focus.
                        ChangeFocus(null, e.StagingItem.Input.Timestamp);
                    }
                }
            }
        }
Example #27
0
 private static void OnButtonUpThunk(object sender, ButtonEventArgs e) { ((UIElement)sender).OnButtonUp(e); }