Beispiel #1
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;
            }
        }
Beispiel #2
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;
            }
        }