BlinkIDDemo.MainPage.mLightButton_Click C# (CSharp) Method

mLightButton_Click() private method

Handles "Light" button click event.
private mLightButton_Click ( object sender, RoutedEventArgs e ) : void
sender object
e System.Windows.RoutedEventArgs
return void
        private void mLightButton_Click(object sender, RoutedEventArgs e)
        {
            // check if the camera light is available
            if (mRecognizer.IsTorchSupported) {
                // toggle camera light
                mRecognizer.TorchOn = !mRecognizer.TorchOn;
                // toggle "Light" button icon
                if (mRecognizer.TorchOn) {
                    mLightImage.ImageSource = new BitmapImage(new Uri("Assets/Icons/icon_flashlight_selected.png", UriKind.Relative));
                } else {
                    mLightImage.ImageSource = new BitmapImage(new Uri("Assets/Icons/icon_flashlight.png", UriKind.Relative));
                }
            } else {
                // if camera light is not available display message
                MessageBox.Show("Camera light is not supported on this device!");
            }
        }