Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>1) In the main page XAML file, MainPage.xaml, add the following code in the StackPanel element, below the Button element named ShutterButton. This code is the button for the camera flash.</p> <pre><code>&lt;Button Name="FlashButton" Content="Fl:TBD" Click="changeFlash_Clicked" FontSize="26" FontWeight="ExtraBold" Height="75"/&gt; </code></pre> <p>2) Open the code-behind file for the main page, MainPage.xaml.cs, and add the following variable declarations above the MainPage class constructor:</p> <p>// Holds current flash mode.</p> <pre><code>private string currentFlashMode; </code></pre> <p>3) In MainPage.xaml.cs, add the following code to the OnNavigatedTo method, just below the Disable UI comment.</p> <pre><code>FlashButton.IsEnabled = false; </code></pre> <p>4) In MainPage.xaml.cs, add the following code to the cam_Initialized method, just below the txtDebug statement:</p> <p>// Set flash button text.</p> <pre><code>FlashButton.Content = "Fl:" + cam.FlashMode.ToString(); </code></pre> <p>This code displays the current flash mode on the FlashButton button.</p> <p>5) In MainPage.xaml.cs, add the following code to the MainPage class. This code implements the event handler for changeFlash_Clicked by switching to a different flash mode each time the button is pressed.</p> <pre><code>// Activate a flash mode. // Cycle through flash mode options when the flash button is pressed. private void changeFlash_Clicked(object sender, RoutedEventArgs e) { switch (cam.FlashMode) { case FlashMode.Off: if (cam.IsFlashModeSupported(FlashMode.On)) { // Specify that flash should be used. cam.FlashMode = FlashMode.On; FlashButton.Content = "Fl:On"; currentFlashMode = "Flash mode: On"; } break; case FlashMode.On: if (cam.IsFlashModeSupported(FlashMode.RedEyeReduction)) { // Specify that the red-eye reduction flash should be used. cam.FlashMode = FlashMode.RedEyeReduction; FlashButton.Content = "Fl:RER"; currentFlashMode = "Flash mode: RedEyeReduction"; } else if (cam.IsFlashModeSupported(FlashMode.Auto)) { // If red-eye reduction is not supported, specify automatic mode. cam.FlashMode = FlashMode.Auto; FlashButton.Content = "Fl:Auto"; currentFlashMode = "Flash mode: Auto"; } else { // If automatic is not supported, specify that no flash should be used. cam.FlashMode = FlashMode.Off; FlashButton.Content = "Fl:Off"; currentFlashMode = "Flash mode: Off"; } break; case FlashMode.RedEyeReduction: if (cam.IsFlashModeSupported(FlashMode.Auto)) { // Specify that the flash should be used in the automatic mode. cam.FlashMode = FlashMode.Auto; FlashButton.Content = "Fl:Auto"; currentFlashMode = "Flash mode: Auto"; } else { // If automatic is not supported, specify that no flash should be used. cam.FlashMode = FlashMode.Off; FlashButton.Content = "Fl:Off"; currentFlashMode = "Flash mode: Off"; } break; case FlashMode.Auto: if (cam.IsFlashModeSupported(FlashMode.Off)) { // Specify that no flash should be used. cam.FlashMode = FlashMode.Off; FlashButton.Content = "Fl:Off"; currentFlashMode = "Flash mode: Off"; } break; } // Display current flash mode. this.Dispatcher.BeginInvoke(delegate() { txtDebug.Text = currentFlashMode; }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload