コード例 #1
0
        private void preAlertTimer_Tick(object sender, EventArgs e)
        {
            //到达预提醒时间弹出通知
            Debug.WriteLine(DateTime.Now.ToString());

            if (main.isBreakReset())
            {
                //跳过本次
                SetPreAlertAction(PreAlertAction.Break);
            }
            else
            {
                //预提醒弹出

                preAlertHasTime = config.options.Style.PreAlertTime - 1;

                //通知数据模型
                var toastModel = new PreAlertModel();
                ParseModel(toastModel);

                //通知弹窗
                var toast = new Project1UIToast();
                if (config.options.Style.PreAlertIcon != "")
                {
                    toast.SetIcon(config.options.Style.PreAlertIcon);
                }
                toast.OnAutoHide    += Toast_OnAutoHide;
                toast.OnButtonClick += Toast_OnButtonClick;
                toast.Alert(toastModel, config.options.Style.PreAlertTime,
                            new string[] {
                    "好的",
                    "跳过本次"
                });

                //播放通知提示音
                if (config.options.Style.IsPreAlertSound)
                {
                    sound.Play();
                }

                //计时器
                var timer = new DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, 1);
                timer.Tick    += (ee, cc) =>
                {
                    preAlertHasTime--;
                    ParseModel(toastModel);
                    if (preAlertHasTime <= 0)
                    {
                        timer.Stop();
                    }
                };
                timer.Start();
            }
        }
コード例 #2
0
 private void ParseModel(PreAlertModel model)
 {
     model.Title    = ParseContent(config.options.Style.PreAlertTitle);
     model.Subtitle = ParseContent(config.options.Style.PreAlertSubtitle);
     model.Message  = ParseContent(config.options.Style.PreAlertMessage);
 }