Beispiel #1
0
        public PageMenu()
        {
            InitializeComponent();

            this.ShowsNavigationUI = false;

            this.Loaded     += PageMenu_Loaded;
            this.Unloaded   += PageMenu_Unloaded;
            this.DataContext = App.CurrentApp;

            InitWallpaper();

            MenuPage = this;
        }
Beispiel #2
0
        public PageMenu()
        {
            InitializeComponent();

            this.ShowsNavigationUI = false;

            this.Loaded     += PageMenu_Loaded;
            this.Unloaded   += PageMenu_Unloaded;
            this.DataContext = App.CurrentApp;

            InitWallpaper();

            MenuPage = this;

            {
                // https://stackoverflow.com/questions/4963135/wpf-inactivity-and-activity
                InputManager.Current.PreProcessInput += OnActivity;
                _activityTimer = new DispatcherTimer {
                    Interval = TimeSpan.FromSeconds(30), IsEnabled = true
                };
                _activityTimer.Tick += OnInactivity;
            }
        }
Beispiel #3
0
        private async void PageSetting_Loaded(object sender, RoutedEventArgs e)
        {
            /*
             * try
             * {
             *  // 首次设置密码,或者登录
             *  InitialPage();
             *  if (this.password.Visibility == Visibility.Visible)
             *      this.password.Focus();
             * }
             * finally
             * {
             *  App.PauseBarcodeScan();
             * }
             */
            App.Invoke(new Action(() =>
            {
                this.mainGrid.Visibility = Visibility.Collapsed;
            }));
            try
            {
                // 首次设置密码
                if (App.IsLockingPasswordEmpty())
                {
REDO_SET:
                    var password = GetPassword("首次设置锁屏密码");
                    if (password == null)
                    {
                        ErrorBox("放弃设置锁屏密码", "yellow", "auto_close");
                        this.NavigationService.Navigate(PageMenu.MenuPage);
                        return;
                    }
                    if (string.IsNullOrEmpty(password))
                    {
                        ErrorBox("锁屏密码不允许设置为空", "red", "auto_close");
                        await Task.Delay(TimeSpan.FromSeconds(1));

                        goto REDO_SET;
                    }
                    App.SetLockingPassword(password);
                    return;
                }


                // 验证锁屏密码
                {
REDO:
                    if (passwordErrorCount > 5)
                    {
                        ErrorBox("密码错误次数太多,功能被禁用", "red", "auto_close");
                        // 延时 10 分钟清除 passwordErrorCount
                        if (delayClear == null)
                        {
                            delayClear = Task.Run(async() =>
                            {
                                await Task.Delay(TimeSpan.FromMinutes(5));
                                passwordErrorCount = 0;
                                delayClear         = null;
                            });
                        }

                        this.NavigationService.Navigate(PageMenu.MenuPage);
                        return;
                    }
                    var password = GetPassword("验证锁屏密码");
                    if (password == null)
                    {
                        PageMenu.RetunMenuPage();
                        // this.NavigationService.Navigate(PageMenu.MenuPage);
                        return;
                    }
                    if (App.MatchLockingPassword(password) == false)
                    {
                        passwordErrorCount++;
                        ErrorBox("密码不正确", "red", "auto_close");
                        await Task.Delay(TimeSpan.FromSeconds(1));

                        goto REDO;
                    }
                }
            }
            finally
            {
                App.Invoke(new Action(() =>
                {
                    this.mainGrid.Visibility = Visibility.Visible;
                }));
            }
        }