Ejemplo n.º 1
0
        public LockScreen()
        {
            InitializeComponent();
            BindingContext = new LockScreenViewModel();

            // Modal Page
            NavigationPage.SetHasNavigationBar(this, false);
            Controller.RemoveCallback    = new RemoveFromStack(this.RemoveFromStack);
            Controller.ResetViewCallback = new ResetView(this.ResetView);

            UnlockButton.IsEnabled = false;
        }
Ejemplo n.º 2
0
        private void ResetCountDown()
        {
            //休息结束
            if (_lastLockScreenViewModel != null)
            {
                _lastLockScreenViewModel.TryClose();
                _lastLockScreenViewModel = null;
            }

            _timer.Stop();
            IsResting = false;

            Countdown        = Setting.App.AlarmInterval;
            CountdownPercent = 100;

            _timer.Start();
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> LockScreen(LockScreenViewModel model)
        {
            if (ModelState.IsValid)
            {
                var dotUser = _userManager.FindById(User.Id);

                var isValidPassword = _userManager.CheckPassword(dotUser, model.Password);

                if (isValidPassword)
                {
                    dotUser.ScreenLocked = false;

                    await RefreshUserClaims(dotUser);

                    return(GetDefaultRedirectRoute());
                }

                ModelState.AddModelError("Password", UserResources.InvalidPasswordMessage);
            }

            return(View(model));
        }
Ejemplo n.º 4
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (IsPaused)
            {
                PausedTime = PausedTime.Add(TimeSpan.FromMilliseconds(_timer.Interval));
                if (_taskbarIcon == null)
                {
                    _taskbarIcon = IoC.Get <TaskbarIcon>();
                    _sourceIcon  = _taskbarIcon.Icon;
                }
            }
            else
            {
                PausedTime = new TimeSpan();
                //游戏中,延迟
                if (IsDelaying)
                {
                    warned     = false;
                    IsDelaying = false;
                    ResetCountDown();
                }
                //正常运行中
                else if (!IsResting)
                {
                    //倒计时减1秒
                    Countdown        = Countdown.Subtract(new TimeSpan(0, 0, 1));
                    CountdownPercent = Countdown.TotalSeconds / Setting.App.AlarmInterval.TotalSeconds * 100;
                    //提前30秒警告一次
                    if (!warned && Countdown.TotalSeconds <= 30 && Countdown.TotalSeconds >= 20)
                    {
                        warned = true;
                        ////游戏中不播放警告声音
                        //bool isMaximized = new OtherProgramChecker(_currentPID, true).CheckMaximized();
                        //if (!isMaximized)
                        //还是加上提示,害怕突然说话过于惊悚
                        _eventAggregator.PublishOnUIThread(new PlayAudioEvent()
                        {
                            Source = @"Resources\Sounds\breakpre.mp3"
                        });
                    }
                    //判断休息
                    if (Countdown.TotalSeconds <= 0)
                    {
                        _timer.Stop();

                        bool isMaximized = new OtherProgramChecker(Process.GetCurrentProcess(), true).CheckMaximized();
                        //bool isMaximized = true;

                        if (isMaximized && Setting.Speech.Enable)
                        {
                            //正在全屏,语音提示
                            IsDelaying = true;
                            PlaySpeech();
                        }
                        else
                        {//没有全屏玩游戏,立即休息
                            IsResting = true;
                            _lastLockScreenViewModel = IoC.Get <LockScreenViewModel>();
                            Execute.OnUIThread(() =>
                            {
                                _windowManager.ShowWindow(_lastLockScreenViewModel);
                                _lastLockScreenViewModel.Deactivated += _lastLockScreenViewModel_Deactivated;
                            });
                            PlayRestingAudio(IsResting);
                        }

                        RestTimeCountdown = Setting.App.RestTime;

                        _timer.Start();
                    }
                }
                //休息中
                else
                {
                    warned                   = false;
                    RestTimeCountdown        = RestTimeCountdown.Subtract(new TimeSpan(0, 0, 1));
                    RestTimeCountdownPercent = RestTimeCountdown.TotalSeconds / Setting.App.RestTime.TotalSeconds * 100;
                    if (RestTimeCountdown.TotalSeconds <= 0)
                    {
                        //休息完毕
                        ResetCountDown();
                        PlayRestingAudio(IsResting);
                        _totalPlayTime = new TimeSpan();
                    }
                }
            }
        }
 public LockScreenWindow()
 {
     InitializeComponent();
     lockScreenViewModel = this.DataContext as LockScreenViewModel;
 }
Ejemplo n.º 6
0
        public ActionResult LockScreenModal()
        {
            var model = new LockScreenViewModel();

            return(PartialView(model));
        }