コード例 #1
0
        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();
            }
        }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
 async void deactivate()
 {
     await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (dispRequest != null)
         {
             dispRequest.RequestRelease();
             dispRequest = null;
         }
     });
 }
コード例 #4
0
        private void ReleaseDisplay()
        {
            //must be same instance, so quit if it doesn't exist
            if (_displayRequest == null)
            {
                return;
            }

            //undo the request
            _displayRequest.RequestRelease();
        }
コード例 #5
0
 private static void SetFalse()
 {
     if (_displayRequestRefCount > 0)
     {
         if (_appDisplayRequest == null)
         {
             _appDisplayRequest = new Windows.System.Display.DisplayRequest();
         }
         _appDisplayRequest.RequestRelease();
         _displayRequestRefCount--;
     }
 }
コード例 #6
0
ファイル: PersistentDisplay.cs プロジェクト: kallistam/Roamit
        public static void ReleasePersistentDisplay()
        {
            //must be same instance, so quit if it doesn't exist
            if (_displayRequest == null)
            {
                return;
            }

            //undo the request
            _displayRequest.RequestRelease();
            isAlreadyRequested = false;
        }
コード例 #7
0
        private async void ReleaseDisplay(StationLib.StationSocketListener SocketListener)
        {
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            { // your code should be here
                SocketListener.FailedConnectionCount = SocketListener.FailedConnectionCount;

                if (m_displayRequest == null)
                {
                    return;
                }

                if (SocketListener.FailedConnectionCount <= 1) // noch keinen FailedCount
                {
                    if (m_displayRequestCnt > 0)
                    {
                        //undo the request
                        m_displayRequest.RequestRelease();
                        m_displayRequestCnt--;
                    }
                }
            });
        }
 /// <summary>
 /// Once video playback has ended, release the display so Windows can handle the display state normally.
 /// </summary>
 public void ReleaseDisplay()
 {
     try
     {
         if (_displayRequest != null)
         {
             _displayRequest.RequestRelease();
         }
     }
     catch (Exception e)
     {
         Serilog.Log.Information(e, "Error releasing display");
     }
 }
コード例 #9
0
 public void ReleaseDisplay()
 {
     //must be same instance, so quit if it doesn't exist
     if (_displayRequest == null)
     {
         return;
     }
     if (_displayRequestCount > 0)
     {
         //undo the request
         _displayRequest.RequestRelease();
         _displayRequestCount--;
     }
 }
コード例 #10
0
 private void DisplayRequestRequestActive(bool screenStaysOn)
 {
     if (CurrDisplayRequest == null)
     {
         CurrDisplayRequest = new Windows.System.Display.DisplayRequest();
     }
     if (screenStaysOn)
     {
         CurrDisplayRequest.RequestActive();
     }
     else
     {
         CurrDisplayRequest.RequestRelease();
     }
 }
コード例 #11
0
ファイル: DisplayRequest.cs プロジェクト: baskren/Pontoon
        /// <summary>
        /// Deactivates a display request.
        /// </summary>
        public void RequestRelease()
        {
#if WINDOWS_UWP || WINDOWS_APP || WINDOWS_PHONE_APP
            _request.RequestRelease();
#else
            s_refCount--;

            if (s_refCount == 0)
            {
#if __ANDROID__ || __UNIFIED || WINDOWS_PHONE || WIN32
                RequestReleaseImpl();
#endif
            }
#endif
        }
コード例 #12
0
        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();
            }
        }
コード例 #13
0
        private async void StopReceiverButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // <SnippetStopAsync>
                if (receiver != null)
                {
                    await receiver.StopAsync();

                    if (display != null)
                    {
                        display.RequestRelease();
                    }

                    // Remove Play To Receiver events
                    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;

                    //  Remove MediaElement events
                    VideoPlayer.Pause();

                    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;

                    StatusTextBlock.Text = "Stopped '" + receiver.FriendlyName + "'.";
                }
                // </SnippetStopAsync>
            }
            catch
            {
                StatusTextBlock.Text = "Failed to stop '" + receiver.FriendlyName + "'.";
            }
        }
コード例 #14
0
ファイル: MainPage.xaml.cs プロジェクト: Anushiravani/Minista
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     base.OnNavigatedFrom(e);
     NavigationService.StopService();
     try
     {
         if (ScreenOnRequest != null)
         {
             ScreenOnRequest.RequestRelease();
         }
     }
     catch { }
     try
     {
         DragOver -= OnDragOver;
         Drop     -= OnDrop;
     }
     catch { }
 }
コード例 #15
0
        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();
                        }
                    });
                }));;
            }
        }
コード例 #16
0
 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();
 }
コード例 #17
0
ファイル: DisplayRequest.cs プロジェクト: zyhong/LediReader
 public void Dispose()
 {
     _displayRequest?.RequestRelease();
     _displayRequest = null;
 }
コード例 #18
0
 private void RequestRelease_Click(object sender, RoutedEventArgs e)
 {
     _displayRequest.RequestRelease();
     ActiveRequestCounter.Text = $"Currently active {(--_currentlyActive).ToString()} request";
 }