Advertisement
benhurrus

flash(light) MainPage.xaml.cs

Dec 12th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System;
  2. using System.IO.IsolatedStorage;
  3. using System.Diagnostics;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Navigation;
  10. using Microsoft.Phone.Controls;
  11. using Microsoft.Phone.Shell;
  12. using Microsoft.Phone.Media;
  13. using Windows.Phone.Media.Capture;
  14. using flashlight.Resources;
  15. using flashlightSettings;
  16.  
  17. namespace flashlight
  18. {
  19.     public partial class MainPage : PhoneApplicationPage
  20.     {
  21.         // Constructor
  22.         public MainPage()
  23.         {
  24.             InitializeComponent();
  25.  
  26.         }
  27.  
  28.         /*private bool NightMode;
  29.  
  30.         private void setNight()
  31.         {
  32.  
  33.         }*/
  34.         async void Button1_Click(object sender, EventArgs e)
  35.         {
  36.             CameraSensorLocation camLocation = CameraSensorLocation.Back;
  37.  
  38.             IReadOnlyList<object> CameraModes;
  39.             CameraModes = AudioVideoCaptureDevice.GetSupportedPropertyValues(camLocation, KnownCameraAudioVideoProperties.VideoTorchMode);
  40.  
  41.             if (CameraModes.ToList().Contains((UInt32)VideoTorchMode.On))
  42.             {
  43.                 AudioVideoCaptureDevice flashLight;
  44.                 flashLight = await AudioVideoCaptureDevice.OpenAsync(camLocation, AudioVideoCaptureDevice.GetAvailableCaptureResolutions(camLocation).First());
  45.  
  46.                 flashLight.SetProperty(KnownCameraAudioVideoProperties.VideoTorchMode, VideoTorchMode.On);
  47.             }
  48.         }
  49.  
  50.         private void Button2_Click(object sender, EventArgs e)
  51.         {
  52.             NavigationService.Navigate(new Uri("/Settings.xaml", UriKind.Relative));
  53.         }
  54.  
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement