示例#1
0
        private void OnButtonUp(object sender, RoutedEventArgs evt)
        {
            ButtonEventArgs e = (ButtonEventArgs)evt;

            // Print the button code to the Visual Studio output window.
            Debug.Print(e.Button.ToString());
        }
示例#2
0
 private void OnButtonUp(object sender, RoutedEventArgs evt)
 {
     ButtonEventArgs e = (ButtonEventArgs)evt;
     int button = (int)e.Button;
     this.OnAction(button);
 }
示例#3
0
        /// <summary>
        ///     Add the event handlers for this element to the route.
        /// </summary>
        // REFACTOR -- do we need this to be public?
        public void AddToEventRoute(EventRoute route, RoutedEventArgs args)
        {
            if (route == null || args == null)
                throw new ArgumentNullException();

            AddToEventRouteImpl(route, args);
        }
示例#4
0
        private void AddToEventRouteImpl(EventRoute route, RoutedEventArgs args)
        {
            //
            // add class listeners then instance listeners.
            //
            Hashtable store = _classEventHandlersStore;
            RoutedEvent evt = args._routedEvent;
            for (int repeat = 0; repeat < 2; repeat++)
            {
                if (store != null)
                {
                    ArrayList eventListeners = (ArrayList)store[evt];

                    // Add all listeners for this UIElement
                    if (eventListeners != null)
                    {
                        for (int i = 0, count = eventListeners.Count; i < count; i++)
                        {
                            RoutedEventHandlerInfo eventListener = (RoutedEventHandlerInfo)eventListeners[i];
                            route.Add(this, eventListener._handler, eventListener._handledEventsToo);
                        }
                    }
                }

                store = _instanceEventHandlersStore;
            }
        }
示例#5
0
 private static void OnTouchUpThunk(object sender, RoutedEventArgs e)
 {
     ((UIElement)sender).OnTouchUp((TouchEventArgs)e);
 }
示例#6
0
 private static void OnPreviewButtonUpThunk(object sender, RoutedEventArgs e)
 {
     ((UIElement)sender).OnPreviewButtonUp((ButtonEventArgs)e);
 }
示例#7
0
 private static void OnLostFocusThunk(object sender, RoutedEventArgs e)
 {
     ((UIElement)sender).OnLostFocus((FocusChangedEventArgs)e);
 }
示例#8
0
 private void OnGotFocus(object sender, RoutedEventArgs evt)
 {
     FocusChangedEventArgs e = (FocusChangedEventArgs)evt;
     _timeText.TextContent = (((DateTime.UtcNow - e.Timestamp).Ticks) / TimeSpan.TicksPerMillisecond).ToString() + "ms";
     _buttonText.TextContent = e.RoutedEvent.Name;
 }
示例#9
0
 private static void OnButtonDownThunk(object sender, RoutedEventArgs e)
 {
     ((UIElement)sender).OnButtonDown((ButtonEventArgs)e);
 }
示例#10
0
        /// <summary>
        ///     Raise the events specified by
        ///     <see cref="RoutedEventArgs.RoutedEvent"/>
        /// </summary>
        /// <remarks>
        ///     This method is a shorthand for
        ///     This method walks up the visual tree, calling
        ///     <see cref="UIElement.BuildRouteCore"/>
        ///     on every <see cref="UIElement"/> <para/>
        ///     <para/>
        ///
        ///     NOTE: The RoutedEvent in RoutedEventArgs
        ///     and EventRoute must be matched
        ///
        ///     Once the route is built, it calls InvokeHandlers()
        /// </remarks>
        /// <param name="args">
        ///     <see cref="RoutedEventArgs"/> for the event to
        ///     be raised
        /// </param>
        public void RaiseEvent(RoutedEventArgs args)
        {
            if (args == null)
                throw new ArgumentNullException();

            EventRoute route = new EventRoute(args._routedEvent);

            // Set Source
            args.Source = this;

            // direct.
            if (args._routedEvent._routingStrategy == RoutingStrategy.Direct)
            {
                AddToEventRouteImpl(route, args);
            }
            else
            {
                int cElements = 0;

                UIElement uiElement = this;

                do
                {
                    // Protect against infinite loops by limiting the number of elements
                    // that we will process.
                    if (cElements++ > MAX_ELEMENTS_IN_ROUTE)
                    {
                        throw new InvalidOperationException(/*SR.Get(SRID.TreeLoop) */);
                    }

                    uiElement.AddToEventRouteImpl(route, args);

                    uiElement = uiElement._parent;

                } while (uiElement != null);
            }

            route.InvokeHandlers(this, args);

            // Reset Source to OriginalSource
            args.Source = args.OriginalSource;
        }
示例#11
0
        /// <summary>
        /// Handles a button click.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnButtonUp(object sender, RoutedEventArgs evt)
        {
            ButtonEventArgs e = (ButtonEventArgs)evt;
            
            // Any button will start the calibration process.
            mainWindow.CalibrateScreen();

            // Print the button code to the Visual Studio output window.
            Debug.Print(e.Button.ToString());
        }
示例#12
0
        /// <summary>
        /// Processes button input.
        /// </summary>
        /// <param name="sender">Generic sender.  Not used.</param>
        /// <param name="e">Button event argument that holds information about 
        /// the button that was pressed.</param>
        private void OnButtonUp(object sender, RoutedEventArgs evt)
        {
            ButtonEventArgs e = (ButtonEventArgs)evt;

            // Switch based on what button was pressed.
            switch (e.Button)
            {
                case Button.VK_UP:    // Process the up button.
                    _targetTemp++;    // Increment the target temperature.
                    UpdateUI();       // Update the user interface.
                    break;

                case Button.VK_DOWN:  // Process the down button.
                    _targetTemp--;    // Decrement the target temperature.
                    UpdateUI();       // Update the user interface.
                    break;

                case Button.VK_SELECT:  // Process the select button.

                    // Switch the temperature format between Celcius and 
                    // Fahrenheit.
                    if (_tempMode == TempMode.Celcius)
                    {
                        // Set the new mode
                        _tempMode = TempMode.Fahrenheit;

                        // Modify the current target temperature.
                        _targetTemp = System.Math.Round((_targetTemp * 1.8) + 32);
                    }
                    else
                    {
                        // Set the new mode.
                        _tempMode = TempMode.Celcius;

                        // Modify the current target temperature.
                        _targetTemp = System.Math.Round((_targetTemp - 32) / 1.8);
                    }

                    // Update the user interface.
                    UpdateUI();
                    break;
            }
        }
示例#13
0
        private void OnButtonUp(object sender, RoutedEventArgs evt)
        {
            ButtonEventArgs e = (ButtonEventArgs)evt;
            
            if (e.Button == Microsoft.SPOT.Hardware.Button.VK_UP)
            {
                // reset the time to an arbitrary value
                TimeService.SetUtcTime(128752416000000000);
                TimeService.SetTimeZoneOffset(-420);
            }
            else if (e.Button == Microsoft.SPOT.Hardware.Button.VK_SELECT)
            {
                // Perform a one time sync with the time server
                TimeServiceStatus status = TimeService.UpdateNow( TimeServerIPAddress, 10);

                TimeService.SetTimeZoneOffset(-420); // time origin
            }
            else if (e.Button == Microsoft.SPOT.Hardware.Button.VK_DOWN)
            {
                // start a scheduled periodic sync
                TimeServiceSettings settings = new TimeServiceSettings();

                settings.PrimaryServer = TimeServerIPAddress;
                settings.RefreshTime = 10; // sycn every 10 seconds

                TimeService.Settings = settings;

                TimeService.Start();
                TimeService.SetTimeZoneOffset(-420);  // time origin 
            }
        }
示例#14
0
 private void OnButtonUp(object sender, RoutedEventArgs routedEventArgs)
 {
     // Print the button code to the Visual Studio output window.
     Debug.Print(routedEventArgs.Source.ToString());
 }
示例#15
0
        /// <summary>
        ///     Invokes all the handlers that have been
        ///     added to the route
        /// </summary>
        /// <remarks>
        ///     NOTE: If the <see cref="RoutingStrategy"/>
        ///     of the associated <see cref="RoutedEvent"/>
        ///     is <see cref="RoutingStrategy.Bubble"/>
        ///     the last handlers added are the
        ///     last ones invoked <para/>
        ///     However if the <see cref="RoutingStrategy"/>
        ///     of the associated <see cref="RoutedEvent"/>
        ///     is <see cref="RoutingStrategy.Tunnel"/>,
        ///     the last handlers added are the
        ///     first ones invoked.
        ///     However the handlers for a particular object
        ///     are always invoked in the order they were added
        ///     regardless of whether its a tunnel or buble.
        ///
        /// </remarks>
        /// <param name="source">
        ///     <see cref="RoutedEventArgs.Source"/>
        ///     that raised the RoutedEvent
        /// </param>
        /// <param name="args">
        ///     <see cref="RoutedEventArgs"/> that carry
        ///     all the details specific to this RoutedEvent
        /// </param>
        internal void InvokeHandlers(object source, RoutedEventArgs args)
        {
            // Check RoutingStrategy to know the order of invocation
            if (args.RoutedEvent.RoutingStrategy == RoutingStrategy.Bubble ||
                args.RoutedEvent.RoutingStrategy == RoutingStrategy.Direct)
            {

                // If the RoutingStrategy of the associated is
                // Bubble the handlers for the last target
                // added are the last ones invoked
                // Invoke class listeners
                for (int i = 0, count = _routeItemList.Count; i < count; i++)
                {
                    RouteItem ri = ((RouteItem)_routeItemList[i]);
                    args.InvokeHandler(ri);
                }
            }
            else
            {
                int endTargetIndex = _routeItemList.Count - 1;
                int startTargetIndex;

                // If the RoutingStrategy of the associated is
                // Tunnel the handlers for the last target
                // added are the first ones invoked
                while (endTargetIndex >= 0)
                {
                    // For tunnel events we need to invoke handlers for the last target first.
                    // However the handlers for that individual target must be fired in the right order.
                    object currTarget = ((RouteItem)_routeItemList[endTargetIndex]).Target;
                    for (startTargetIndex = endTargetIndex; startTargetIndex >= 0; startTargetIndex--)
                    {
                        if (((RouteItem)_routeItemList[startTargetIndex]).Target != currTarget)
                        {
                            if(startTargetIndex == endTargetIndex && endTargetIndex > 0)
                            {
                                endTargetIndex--;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    for (int i = startTargetIndex + 1; i <= endTargetIndex; i++)
                    {
                        RouteItem ri = ((RouteItem)_routeItemList[i]);
                        args.InvokeHandler(ri);
                    }

                    endTargetIndex = startTargetIndex;
                }
            }
        }
示例#16
0
 private static void OnGenericEventThunk(object sender, RoutedEventArgs e)
 {
     ((UIElement)sender).OnGenericEvent((GenericEventArgs)e);
 }
示例#17
0
        private void OnButtonUp(object sender, RoutedEventArgs evt)
        {
            ButtonEventArgs e = (ButtonEventArgs)evt;

            const int timeZoneOffsetInMinutes = -8 * 60;

            switch (e.Button)
            {
                case Microsoft.SPOT.Hardware.Button.VK_UP:
                    // Reset the time to an arbitrary value.
                    TimeService.SetUtcTime(128752416000000000);
                    TimeService.SetTimeZoneOffset(timeZoneOffsetInMinutes);
                    break;

                case Microsoft.SPOT.Hardware.Button.VK_SELECT:
                    // Perform a one time sync with the time server.
                    TimeServiceStatus status = TimeService.UpdateNow(TimeServerIPAddress, 10);
                    TimeService.SetTimeZoneOffset(timeZoneOffsetInMinutes);
                    break;

                case Microsoft.SPOT.Hardware.Button.VK_DOWN:
                    // Start a scheduled periodic sync.
                    TimeServiceSettings settings = new TimeServiceSettings();

                    // Sync every 10 seconds.
                    settings.PrimaryServer = TimeServerIPAddress;
                    settings.RefreshTime = 10;

                    TimeService.Settings = settings;

                    TimeService.Start();
                    TimeService.SetTimeZoneOffset(timeZoneOffsetInMinutes);
                    break;
            }
        }
示例#18
0
 private void OnButtonDown(object sender, RoutedEventArgs evt)
 {
     ButtonEventArgs e = (ButtonEventArgs)evt;
     _timeText.TextContent = (((DateTime.UtcNow - e.Timestamp).Ticks) / TimeSpan.TicksPerMillisecond).ToString() + "ms";
     _buttonText.TextContent = e.RoutedEvent.Name + " : " + buttonNames[(int)e.Button];
 }