コード例 #1
0
ファイル: App.xaml.cs プロジェクト: fossabot/needabreak
        private async void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (IsSuspended && SuspensionCause == SuspensionCause.Manual)
            {
                // App was manually suspended, only user can unsuspend it
                return;
            }

            if (NeedABreak.Properties.Settings.Default.AutomaticSuspension)
            {
                UserNotificationState state = QueryUserNotificationState.GetState();

                if (IsSuspended)
                {
                    // App was automatically suspended, shall we unsuspend it ?
                    if (state == UserNotificationState.AcceptsNotifications)
                    {
                        Resume();
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    // App is not suspended, shall we automatically suspend it ?
                    switch (state)
                    {
                    case UserNotificationState.Busy:
                    case UserNotificationState.RunningDirect3dFullScreen:
                    case UserNotificationState.PresentationMode:
                        Suspend(SuspensionCause.Automatic);
                        return;
                    }
                }
            }

            double minutesLeft = GetMinutesLeft();

            if (minutesLeft <= 0)
            {
                await TimesUp();
            }
            else if (minutesLeft <= 1)
            {
                await TimesAlmostUp();
            }
        }
コード例 #2
0
 private static extern int SHQueryUserNotificationState(out QueryUserNotificationState state);
コード例 #3
0
 public static extern int SHQueryUserNotificationState(out QueryUserNotificationState pquns);