private void Control_CurrentStateChanged(object sender, RoutedEventArgs e) { switch (Control.CurrentState) { case Windows.UI.Xaml.Media.MediaElementState.Playing: if (Element.KeepScreenOn) { _request.RequestActive(); } break; case Windows.UI.Xaml.Media.MediaElementState.Paused: case Windows.UI.Xaml.Media.MediaElementState.Stopped: case Windows.UI.Xaml.Media.MediaElementState.Closed: if (Element.KeepScreenOn) { _request.RequestRelease(); } break; } if (Element != null) { Element.CurrentState = (MediaElementState)((int)Control.CurrentState); //((IElementController)Element).SetValueFromRenderer(MediaElement.CurrentStateProperty, (MediaElementState)((int)Control.CurrentState)); Element.RaiseCurrentStateChanged(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { SendLocation = !SendLocation; var displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest.RequestActive(); thisIdentifier = Guid.NewGuid(); while (SendLocation) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://whenwilldaddybehome.azurewebsites.net/"); var location = await new Windows.Devices.Geolocation.Geolocator().GetGeopositionAsync(); var content = new { Id = thisIdentifier.ToString(), Lat = location.Coordinate.Point.Position.Latitude, Long = location.Coordinate.Point.Position.Longitude }; await client.PostAsync("a/updatemylocation", new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json")); await Task.Delay(TimeSpan.FromSeconds(60)); } } }
public MainPage() { this.InitializeComponent(); Windows.System.Display.DisplayRequest dr = new Windows.System.Display.DisplayRequest(); dr.RequestActive(); }
private void Tracking_Click(object sender, RoutedEventArgs e) { if (Tracking.IsChecked == true) { _geolocator.PositionChanged += OnPositionChanged; if (dispRequest == null) { if (ApplicationData.Current.LocalSettings.Values["KeepScreenOn"].ToString() == "1") { dispRequest = new Windows.System.Display.DisplayRequest(); dispRequest.RequestActive(); } } Clear.IsEnabled = false; } else { _geolocator.PositionChanged -= OnPositionChanged; if (dispRequest != null) { dispRequest.RequestRelease(); dispRequest = null; } Clear.IsEnabled = true; } }
private async void MainPageLoaded(object sender, RoutedEventArgs e) { CreateConfig(); var coreTitleBar = CoreApplication.GetCurrentView().TitleBar; coreTitleBar.ExtendViewIntoTitleBar = true; //AppTitleBar.Height = coreTitleBar.Height; coreTitleBar.LayoutMetricsChanged += CoreTitleBarLayoutMetricsChanged; // Set XAML element as a draggable region. //AppTitleBar.Height = coreTitleBar.Height; UpdateTitleBarLayout(coreTitleBar); Window.Current.SetTitleBar(AppTitleBarORG); if (InstaApi == null || InstaApi != null && !InstaApi.IsUserAuthenticated) { SetStackPanelTitleVisibility(Visibility.Collapsed); NavigationService.Navigate(typeof(Views.Sign.SignInView)); } else { NavigateToMainView(); } if (!SettingsHelper.Settings.AskedAboutPosition) { SettingsGrid.Visibility = Visibility.Visible; } if (ScreenOnRequest != null) { ScreenOnRequest.RequestActive(); } CheckLicense(); try { if (Passcode.IsEnabled) { PassCodeView.Visibility = Visibility.Visible; LockControl.Visibility = Visibility.Visible; } else { PassCodeView.Visibility = Visibility.Collapsed; LockControl.Visibility = Visibility.Collapsed; } } catch { } try { await BackgroundExecutionManager.RequestAccessAsync(); } catch { } try { UserNotificationListener listener = UserNotificationListener.Current; await listener.RequestAccessAsync(); } catch { } }
private void Tracking_Click(object sender, RoutedEventArgs e) { if (Tracking.IsChecked == true) { _geolocator.PositionChanged += OnPositionChanged; if (dispRequest == null) { if (ApplicationData.Current.LocalSettings.Values["KeepScreenOn"].ToString() == "1") { dispRequest = new Windows.System.Display.DisplayRequest(); dispRequest.RequestActive(); } } Clear.IsEnabled = false; } else { _geolocator.PositionChanged -= OnPositionChanged; if (dispRequest != null) { dispRequest.RequestRelease(); dispRequest = null; } Clear.IsEnabled = true; } }
public MainPage() { this.InitializeComponent(); //don't let the app go idle _displayRequest = new Windows.System.Display.DisplayRequest(); _displayRequest.RequestActive(); //=================================== //Get values from config Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; //Some sample config getters from my other project. A reminder to myself... //enableWingsCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableWings"); //enableHeadCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableHead"); //enableLeftEyeCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableLeftEye"); //enableRightEyeCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableRightEye"); _slider = new CamSliderCommander.Isaac879SliderControl(); _slider.DeviceError += _component_DeviceError; _slider.MoveCompleted += _component_MoveCompleted; _slider.DeviceInfoMessage += _slider_DeviceInfoMessage; _slider.Initialize(); }
public DisplayRequestLevel1() { if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.Display.DisplayRequest")) { _displayRequest = new Windows.System.Display.DisplayRequest(); _displayRequest.RequestActive(); } }
private async void StartReceiverButton_Click(object sender, RoutedEventArgs e) { try { dispatcher = Window.Current.CoreWindow.Dispatcher; if (receiver == null) { receiver = new Windows.Media.PlayTo.PlayToReceiver(); } // Add Play To Receiver events and properties receiver.CurrentTimeChangeRequested += receiver_CurrentTimeChangeRequested; receiver.MuteChangeRequested += receiver_MuteChangeRequested; receiver.PauseRequested += receiver_PauseRequested; receiver.PlaybackRateChangeRequested += receiver_PlaybackRateChangeRequested; receiver.PlayRequested += receiver_PlayRequested; receiver.SourceChangeRequested += receiver_SourceChangeRequested; receiver.StopRequested += receiver_StopRequested; receiver.TimeUpdateRequested += receiver_TimeUpdateRequested; receiver.VolumeChangeRequested += receiver_VolumeChangeRequested; // <SnippetProperties> receiver.FriendlyName = "Sample Play To Receiver"; receiver.SupportsAudio = false; receiver.SupportsVideo = true; receiver.SupportsImage = false; // </SnippetProperties> // Add MediaElement events VideoPlayer.CurrentStateChanged += VideoPlayer_CurrentStateChanged; VideoPlayer.MediaEnded += VideoPlayer_MediaEnded; VideoPlayer.MediaFailed += VideoPlayer_MediaFailed; VideoPlayer.MediaOpened += VideoPlayer_MediaOpened; VideoPlayer.RateChanged += VideoPlayer_RateChanged; VideoPlayer.SeekCompleted += VideoPlayer_SeekCompleted; VideoPlayer.VolumeChanged += VideoPlayer_VolumeChanged; // <SnippetStartAsync> // Advertise the receiver on the local network and start receiving commands await receiver.StartAsync(); // Prevent the screen from locking if (display == null) { display = new Windows.System.Display.DisplayRequest(); } display.RequestActive(); StatusTextBlock.Text = "'" + receiver.FriendlyName + "' started."; // </SnippetStartAsync> } catch { receiver = null; StatusTextBlock.Text = "Failed to start receiver."; } }
private async void ActivateDisplay(StationLib.StationSocketListener SocketListener) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { // your code should be here SocketListener.FailedConnectionCount = SocketListener.FailedConnectionCount; m_displayRequest.RequestActive(); m_displayRequestCnt++; }); }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( Microsoft.ApplicationInsights.WindowsCollectors.Metadata | Microsoft.ApplicationInsights.WindowsCollectors.Session); this.InitializeComponent(); this.Suspending += OnSuspending; var displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest.RequestActive(); }
private void ActivateDisplay() { //create the request instance if needed if (_displayRequest == null) { _displayRequest = new Windows.System.Display.DisplayRequest(); } //make request to put in active state _displayRequest.RequestActive(); }
async void activate() { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (dispRequest == null) { dispRequest = new Windows.System.Display.DisplayRequest(); dispRequest.RequestActive(); } }); }
private static void SetTrue() { if (_displayRequestRefCount < MAX_COUNT) { if (_appDisplayRequest == null) { _appDisplayRequest = new Windows.System.Display.DisplayRequest(); } _appDisplayRequest.RequestActive(); _displayRequestRefCount++; } }
private async Task SetupUI() { var displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest.RequestActive(); // If we have a phone contract, hide the status bar if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0)) { var statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView(); await statusBar.HideAsync(); } }
public MainPage() { this.InitializeComponent(); var keepScreenOnRequest = new Windows.System.Display.DisplayRequest(); keepScreenOnRequest.RequestActive(); //ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); DispatcherHelper.Dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; DispatcherHelper.SyncContext = TaskScheduler.FromCurrentSynchronizationContext(); _usb = new UsbSerial("VID_1A86", "PID_7523"); _bluetooth = new BluetoothSerial("TinBot"); _body = new Body(_usb); //_body = new Body(_bluetooth); _commands = new Operations.Commands(media, _body, Ear, new Dictionary <Storyboard, int>() { [bravo] = 200, [feliz] = 100, [feliz_verde] = 100, [normal] = 0, [piscadela] = 0, [piscando] = 0, [piscando_duplo] = 0, [triste] = 200 }, new Dictionary <ETinBotFaces, Storyboard>() { [ETinBotFaces.Angry] = bravo, [ETinBotFaces.Happy] = feliz, [ETinBotFaces.HappyGreen] = feliz_verde, [ETinBotFaces.Normal] = normal, [ETinBotFaces.UniBlink] = piscadela, [ETinBotFaces.Blink] = piscando, [ETinBotFaces.BlinkDouble] = piscando_duplo, [ETinBotFaces.Sad] = triste }, new Dictionary <ETinBotToggle, int>() { [ETinBotToggle.Green] = 1, [ETinBotToggle.Red] = 2, [ETinBotToggle.Blue] = 3, [ETinBotToggle.Laser] = 4 } ); _body.ConnectionNotify += (sender, s) => ExecuteOnMainThread(() => Label.Text = s); _body.Setup(); }
private Windows.System.Display.DisplayRequest _displayRequest; // This should make the hub always be awake public void ActivateDisplay() { //create the request instance if needed if (_displayRequest == null) { _displayRequest = new Windows.System.Display.DisplayRequest(); } //make request to put in active state _displayRequest.RequestActive(); //Read more at https://blogs.windows.com/buildingapps/2016/05/24/how-to-prevent-screen-locks-in-your-uwp-apps/#VqWEXSXJBvGD8WzJ.99 }
public MainPage() { this.InitializeComponent(); var keepScreenOnRequest = new Windows.System.Display.DisplayRequest(); keepScreenOnRequest.RequestActive(); //ApplicationView.GetForCurrentView().TryEnterFullScreenMode(); DispatcherHelper.Dispatcher = CoreWindow.GetForCurrentThread().Dispatcher; DispatcherHelper.SyncContext = TaskScheduler.FromCurrentSynchronizationContext(); _usb = new UsbSerial("VID_1A86", "PID_7523"); _bluetooth = new BluetoothSerial("TinBot"); _body = new Body(_usb); //_body = new Body(_bluetooth); _commands = new Operations.Commands(media, _body, Ear, new Dictionary<Storyboard, int>() { [bravo] = 200, [feliz] = 100, [feliz_verde] = 100, [normal] = 0, [piscadela] = 0, [piscando] = 0, [piscando_duplo] = 0, [triste] = 200 }, new Dictionary<ETinBotFaces, Storyboard>() { [ETinBotFaces.Angry] = bravo, [ETinBotFaces.Happy] = feliz, [ETinBotFaces.HappyGreen] = feliz_verde, [ETinBotFaces.Normal] = normal, [ETinBotFaces.UniBlink] = piscadela, [ETinBotFaces.Blink] = piscando, [ETinBotFaces.BlinkDouble] = piscando_duplo, [ETinBotFaces.Sad] = triste }, new Dictionary<ETinBotToggle, int>() { [ETinBotToggle.Green] = 1, [ETinBotToggle.Red] = 2, [ETinBotToggle.Blue] = 3, [ETinBotToggle.Laser] = 4 } ); _body.ConnectionNotify += (sender, s) => ExecuteOnMainThread(() => Label.Text = s); _body.Setup(); }
/// <summary> /// Activates a display request. /// </summary> public void RequestActive() { #if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP _request.RequestActive(); #else if (s_refCount == 0) { #if __ANDROID__ || __UNIFIED || WINDOWS_PHONE || WIN32 RequestActiveImpl(); #endif } s_refCount++; #endif }
private void DisplayRequestRequestActive(bool screenStaysOn) { if (CurrDisplayRequest == null) { CurrDisplayRequest = new Windows.System.Display.DisplayRequest(); } if (screenStaysOn) { CurrDisplayRequest.RequestActive(); } else { CurrDisplayRequest.RequestRelease(); } }
public static void ActivatePersistentDisplay() { //create the request instance if needed if (_displayRequest == null) { _displayRequest = new Windows.System.Display.DisplayRequest(); } else if (isAlreadyRequested) { return; } //make request to put in active state _displayRequest.RequestActive(); isAlreadyRequested = true; }
private void OnKeepScreenOnChecked(object sender, RoutedEventArgs e) { if (CurrDisplayRequest == null) { CurrDisplayRequest = new Windows.System.Display.DisplayRequest(); } var ischeck = (sender as CheckBox).IsChecked.GetValueOrDefault(); if (ischeck) { CurrDisplayRequest.RequestActive(); } else { CurrDisplayRequest.RequestRelease(); } }
public Translate() { this.InitializeComponent(); speech = new SpeechSynthesizer(); mediaplayer = new MediaElement(); lstLanguages.ItemsSource = SpeechSynthesizer.AllVoices; lstLanguages.SelectedValuePath = "Language"; lstLanguages.SelectedValue = SpeechSynthesizer.DefaultVoice.Language; tr = new Translator(); lblResult.Text = instructions; Windows.System.Display.DisplayRequest dr = new Windows.System.Display.DisplayRequest(); dr.RequestActive(); }
/// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override async void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } if (_session == null) await PreventFromSuspending(); if (_displayRequest == null) { _displayRequest = new Windows.System.Display.DisplayRequest(); _displayRequest.RequestActive(); } }
// More information on this behavior is documented here: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/jj152728.aspx /// <summary> /// To prevent screens going to sleep or locking during video playback, send an activation request. /// </summary> public void ActivateDisplay() { try { // Create the request instance if needed if (_displayRequest == null) { _displayRequest = new Windows.System.Display.DisplayRequest(); } // Make request to put in active state _displayRequest.RequestActive(); } catch (Exception e) { Serilog.Log.Information(e, "Error sending display request"); } }
public MainPage() { this.InitializeComponent(); speech = new SpeechSynthesizer(); mediaplayer = new MediaElement(); lstLanguages.ItemsSource = SpeechSynthesizer.AllVoices; lstLanguages.SelectedValuePath = "Language"; lstLanguages.SelectedValue = SpeechSynthesizer.DefaultVoice.Language; tr = new Translator(); lblResult.Text = instructions; Windows.System.Display.DisplayRequest dr = new Windows.System.Display.DisplayRequest(); dr.RequestActive(); }
public MainPage() { InitializeComponent(); #if DEBUG // Avoid screen locks while debugging. if (System.Diagnostics.Debugger.IsAttached) { var keepActive = new Windows.System.Display.DisplayRequest(); keepActive.RequestActive(); } #endif SvgImageRenderer.InitializeForms(); LoadApplication(new XamSvg.Demo.App()); NavigationCacheMode = NavigationCacheMode.Required; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); appCallbacks = new AppCallbacks(); UnhandledException += LogUnhandledException; // Prevents display to dim while the app is visible: var displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest.RequestActive(); InitializeExceptionLogger(); #if DEBUG DebugSettings.EnableFrameRateCounter = true; #endif }
public MainPage() { this.InitializeComponent(); //ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow); var displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest.RequestActive(); int period = 200; ThreadPoolTimer PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer(TimerElapsedHandler, TimeSpan.FromMilliseconds(period)); PopUpCanvas.Margin = new Windows.UI.Xaml.Thickness(-85, -50, -97, -56); hostName = new HostName("192.168.0.100"); hostPort = "7777"; Windows.UI.ViewManagement.StatusBar.GetForCurrentView().HideAsync(); SoftJoy.Visibility = Windows.UI.Xaml.Visibility.Collapsed; SoftJoyBoundary.Visibility = Windows.UI.Xaml.Visibility.Collapsed; HorizontalLine.Visibility = Windows.UI.Xaml.Visibility.Collapsed; VerticalLine.Visibility = Windows.UI.Xaml.Visibility.Collapsed; PopUpCanvas.Visibility = Windows.UI.Xaml.Visibility.Collapsed; SoftJoy.Opacity = 0.2; faceCollection.Add(face1); faceCollection.Add(face2); faceCollection.Add(face3); faceCollection.Add(face4); faceCollection.Add(face5); //ValidIpAddressRegex = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"); //ValidIpAddressRegex = new Regex(@"([0-9]{1,3}\.){3}[0-9]{1,3}"); //ValidHostnameRegex = new Regex(@"^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$"); ValidHostnameRegex = new Regex(@"^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$"); RefreshHorizont(); //faceCollection = new { face1, face2, face3, face4, face5 }; this.NavigationCacheMode = NavigationCacheMode.Required; }
public MainPage() { this.InitializeComponent(); if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar")) { StatusBar.GetForCurrentView().HideAsync(); } _displayRequest = new Windows.System.Display.DisplayRequest(); _displayRequest.RequestActive(); AntaresNavigationView.SetRoutingService(new AntaresRoutingService()); AntaresNavigationView.Map.MapLongClick += (sender, args) => { AntaresNavigationView.StartNavigation(args.Point); AntaresNavigationView.Map.SetCenterAnchor(0.5f, 0.75f); }; }
/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> internal App() { TLIB.PlatformHelper.ModelHelper.Platform = new TLIB.Code.Uwp.UwpModelHelper(); TLIB.PlatformHelper.StringHelper.Platform = new TLIB.Code.Uwp.UwpStringHelper(); TAPPLICATION.IO.SharedIO.CurrentIO = new TLIB.Code.Uwp.UwpIO(); TAPPLICATION.Model.SharedSettingsModel.PlatformSettings = new TLIB.Code.Uwp.UwpSettings(); AppModel.Initialize(); SettingsModel.Initialize(); this.InitializeComponent(); _displayRequest = new Windows.System.Display.DisplayRequest(); _displayRequest.RequestActive(); this.Suspending += OnSuspending; this.UnhandledException += App_UnhandledExceptionAsync; UnhandledException += App_UnhandledExceptionAsync; SharedSettingsModel.Instance.FOLDERMODE = false; SharedSettingsModel.Instance.INTERN_SYNC = true; }
private async void DownloadLoop() { var displayRequest = new Windows.System.Display.DisplayRequest(); while (true) { await this.addSemaphore.WaitAsync(); var current = this.waitForDownloads.Dequeue(); await this.concurrentSemaphore.WaitAsync(); if (this.downloading.Count == 0) { displayRequest.RequestActive(); } this.downloading.Add(current); _ = Task.Run(() => current.StartDownload().ContinueWith(async t => { await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { this.concurrentSemaphore.Release(); this.downloading.Remove(current); this.allQueued.Remove(current); if (current.Finished.IsFaulted) { App.Current.NotifyError(current, current.Finished.Exception); } if (this.downloading.Count == 0) { displayRequest.RequestRelease(); } }); }));; } }
private void isDisplayRequest_Toggled(object sender, RoutedEventArgs e) //常亮按钮 { if (isDisplayRequest.IsOn) { //create the request instance if needed if (_displayRequest == null) { _displayRequest = new Windows.System.Display.DisplayRequest(); } //make request to put in active state _displayRequest.RequestActive(); } else { //must be same instance, so quit if it doesn't exist if (_displayRequest == null) { return; } //undo the request _displayRequest.RequestRelease(); } SaveSettings(); }
public MainPage() { ActionSchedule = new Dictionary <int, OwlCommand.Commands>(); this.InitializeComponent(); //don't let the app go idle _displayRequest = new Windows.System.Display.DisplayRequest(); _displayRequest.RequestActive(); //=================================== //Get values from config Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings; Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.LocalFolder; enableWingsCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableWings"); enableHeadCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableHead"); enableLeftEyeCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableLeftEye"); enableRightEyeCheckbox.IsChecked = GetConfig_Bool(localSettings, "EnableRightEye"); //=================================== _owl = new OwlMasterController.Owl( enableHeadCheckbox.IsChecked.GetValueOrDefault(), enableWingsCheckbox.IsChecked.GetValueOrDefault(), enableRightEyeCheckbox.IsChecked.GetValueOrDefault(), enableLeftEyeCheckbox.IsChecked.GetValueOrDefault()); _owl.DeviceError += _component_DeviceError; _owl.MoveCompleted += _component_MoveCompleted; _owl.DeviceInfoMessage += _owl_DeviceInfoMessage; _owl.Initialize(); this.PointerPressed += ScreensaverBG_PointerPressed; //Return the initializer call ASAP Task.Factory.StartNew(() => { ActionSchedule.Add(0, OwlCommand.Commands.RandomFull); ActionSchedule.Add(5, OwlCommand.Commands.Wink); ActionSchedule.Add(10, OwlCommand.Commands.HeadLeft); ActionSchedule.Add(15, OwlCommand.Commands.Wink); ActionSchedule.Add(20, OwlCommand.Commands.HeadRight); ActionSchedule.Add(25, OwlCommand.Commands.Wink); ActionSchedule.Add(30, OwlCommand.Commands.RandomShort); ActionSchedule.Add(35, OwlCommand.Commands.Wink); ActionSchedule.Add(40, OwlCommand.Commands.Surprise); ActionSchedule.Add(45, OwlCommand.Commands.Wink); ActionSchedule.Add(50, OwlCommand.Commands.SmallWiggle); ActionSchedule.Add(55, OwlCommand.Commands.Wink); StringBuilder sbList = new StringBuilder(); sbList.AppendLine("SCHEDULE"); sbList.AppendLine("======================================="); ActionSchedule.ToList().ForEach(v => { String line = String.Format(":{0} - {1}", v.Key.ToString("00"), v.Value.ToString()); sbList.AppendLine(line); }); this.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { _lastTouchDetected = DateTime.Now; startupDateTime = DateTime.Now; _startupDelayTimer = ThreadPoolTimer.CreatePeriodicTimer(__startupDelayTimer_Tick, TimeSpan.FromMilliseconds(500)); _autoClockTimer = ThreadPoolTimer.CreatePeriodicTimer(_clockTimer_Tick, TimeSpan.FromMilliseconds(5000)); _screensaverTimer = ThreadPoolTimer.CreatePeriodicTimer(_screensaver_Tick, TimeSpan.FromMilliseconds(5000)); SetStatusLight(Colors.Green); scheduleTextBlock.Text = sbList.ToString(); }); var newSession = new ExtendedExecutionForegroundSession(); newSession.Reason = ExtendedExecutionForegroundReason.Unconstrained; newSession.Description = "Long Running Processing"; newSession.Revoked += OnSessionRevoked; //ExtendedExecutionResult result = newSession.RequestExtensionAsync().GetAwaiter().GetResult(); newSession.RequestExtensionAsync().GetAwaiter().GetResult(); //switch (result) //{ // case ExtendedExecutionResult.Allowed: // DoLongRunningWork(); // break; // default: // case ExtendedExecutionResult.Denied: // DoShortRunningWork(); // break; //} }); }
private void RequestActive_Click(object sender, RoutedEventArgs e) { _displayRequest.RequestActive(); ActiveRequestCounter.Text = $"Currently active {(++_currentlyActive).ToString()} request"; }
public static void PrevenScreenLook() { // disable automatic screen lock var displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest.RequestActive(); }
/// <summary> /// This method request the display to prevent screen saver while the MediaElement is playing a video. /// </summary> public void RequestDisplay() { if (dispRequest == null) { // Activate a display-required request. If successful, the screen is // guaranteed not to turn off automatically due to user inactivity. dispRequest = new Windows.System.Display.DisplayRequest(); dispRequest.RequestActive(); } }
private async void Button_Click(object sender, RoutedEventArgs e) { SendLocation = !SendLocation; var displayRequest = new Windows.System.Display.DisplayRequest(); displayRequest.RequestActive(); thisIdentifier = Guid.NewGuid(); while (SendLocation) { using (var client = new HttpClient()) { client.BaseAddress = new Uri("https://whenwilldaddybehome.azurewebsites.net/"); var location = await new Windows.Devices.Geolocation.Geolocator().GetGeopositionAsync(); var content = new { Id = thisIdentifier.ToString(), Lat = location.Coordinate.Point.Position.Latitude, Long = location.Coordinate.Point.Position.Longitude }; await client.PostAsync("a/updatemylocation", new StringContent(JsonConvert.SerializeObject(content), Encoding.UTF8, "application/json")); await Task.Delay(TimeSpan.FromSeconds(60)); } } }
private void PreventLock() { _keepScreenOnRequest = new Windows.System.Display.DisplayRequest(); _keepScreenOnRequest.RequestActive(); }