Esempio n. 1
0
 private void mnuStopScreenSaver_Click(object sender, EventArgs e)
 {
     if (mnuStopScreenSaver.Checked)
     {
         ScreenSaver.SetScreenSaverActive(0);
     }
     else
     {
         ScreenSaver.SetScreenSaverActive(1);
     }
 }
Esempio n. 2
0
        private void timAlerter_Tick(object sender, EventArgs e)
        {
            //bool p = false;
            for (int i = 0; i < TimePlanTable.Count; i++)
            {
                if ((DateTime.Now - LastAlert).TotalSeconds >= 60)
                {
                    if (mnuStopScreenSaverWhenStudy.Checked)
                    {
                        if (((TimePlanItem)TimePlanTable[i]).TimeFrom == DateTime.Now.ToString("HH:mm"))
                        {
                            ScreenSaver.SetScreenSaverActive(0);
                            mnuStopScreenSaver.Checked = true;
                        }
                        else if (((TimePlanItem)TimePlanTable[i]).TimeTo == DateTime.Now.ToString("HH:mm"))
                        {
                            ScreenSaver.SetScreenSaverActive(1);
                            mnuStopScreenSaver.Checked = false;
                        }
                    }
                }
                if (((TimePlanItem)TimePlanTable[i]).TimeFrom == DateTime.Now.ToString("HH:mm") ||
                    ((TimePlanItem)TimePlanTable[i]).TimeTo == DateTime.Now.ToString("HH:mm") ||
                    (mnuPrepBell.Checked && i < TimePlanTable.Count - 1 &&
                     ((TimePlanItem)TimePlanTable[i + 1]).TimeFrom == DateTime.Now.AddMinutes(2).ToString("HH:mm")))
                {
                    if (Alert())
                    {
                        lblCountDown.Text = string.Format("离考试还有{0}天", Convert.ToInt32((DateTime.Parse("2009-1-10") - DateTime.Now).TotalDays));

                        foreach (Control ctrl in panFlow.Controls)
                        {
                            if (Type.GetType(ctrl.ToString()) == typeof(TimePlan))
                            {
                                ((TimePlan)ctrl).RefreshPlan();
                            }
                        }
                        if ((!mnuPrepBell.Checked && ((TimePlanItem)TimePlanTable[i]).TimeFrom == DateTime.Now.ToString("HH:mm")) ||
                            (mnuPrepBell.Checked && i < TimePlanTable.Count - 1 &&
                             ((TimePlanItem)TimePlanTable[i + 1]).TimeFrom == DateTime.Now.AddMinutes(2).ToString("HH:mm")))
                        {
                            isClassStart = true;
                        }
                        else if (((TimePlanItem)TimePlanTable[i]).TimeTo == DateTime.Now.ToString("HH:mm"))
                        {
                            isClassStart = false;
                        }
                    }
                }
                DateTime dtto   = DateTime.Parse(((TimePlanItem)TimePlanTable[i]).TimeTo);
                DateTime dtfrom = DateTime.Parse(((TimePlanItem)TimePlanTable[i]).TimeFrom);
                DateTime dtnow  = DateTime.Parse(DateTime.Now.ToString("HH:mm"));
                DateTime dtnext = DateTime.Now;
                if (i < TimePlanTable.Count - 1)
                {
                    dtnext = DateTime.Parse(((TimePlanItem)TimePlanTable[i + 1]).TimeFrom);
                }
                if (dtto.Hour < 4)
                {
                    dtto = dtto.AddDays(1);
                }
                if (dtfrom.Hour < 4)
                {
                    dtfrom = dtfrom.AddDays(1);
                }
                if (dtnow.Hour < 4)
                {
                    dtnow = dtnow.AddDays(1);
                }
                if (dtnext.Hour < 4)
                {
                    dtnext = dtnext.AddDays(1);
                }
                if ((dtnow - dtfrom).TotalMilliseconds >= 0 && (dtnow - dtto).TotalMilliseconds < 0)
                {
                    ntfTray.Icon = DrawState((dtnow - dtfrom).TotalMilliseconds, (dtto - dtfrom).TotalMilliseconds);
                    ntfTray.Text = string.Format("离[{1}]课下课还有{0}分钟!", (dtto - dtnow).TotalMinutes, ((TimePlanItem)TimePlanTable[i]).Detail);
                    if (mnuShowCurrentState.Checked)
                    {
                        _osd.Show(new Point(Screen.PrimaryScreen.Bounds.Width - 350, 30), 100,
                                  _textColor, new Font("仿宋", 22f, FontStyle.Bold), 0, FloatingWindow.AnimateMode.ExpandCollapse, 0,
                                  string.Format("{1}课  剩余{0}分钟!", (dtto - dtnow).TotalMinutes, ((TimePlanItem)TimePlanTable[i]).Detail));
                    }
                    break;
                }
                else if ((dtnow - dtto).TotalMilliseconds >= 0 && i < TimePlanTable.Count - 1 && (dtnext - dtnow).TotalMilliseconds > 0)
                {
                    ntfTray.Icon = icoRestIcon[RestIconFrame++ % 11];
                    ntfTray.Text = string.Format("休息时间,离上课还有{0}分钟!", (dtnext - dtnow).TotalMinutes);
                    if (mnuShowCurrentState.Checked)
                    {
                        if ((dtnext - dtnow).TotalMinutes <= 10)
                        {
                            _osd.Show(new Point(Screen.PrimaryScreen.Bounds.Width - 350, 30), 100,
                                      _textColor, new Font("仿宋", 22f, FontStyle.Bold), 0, FloatingWindow.AnimateMode.ExpandCollapse, 0,
                                      string.Format("离{1}课还有{0}分钟!", (dtnext - dtnow).TotalMinutes, ((TimePlanItem)TimePlanTable[i + 1]).Detail));
                        }
                        else
                        {
                            _osd.Hide();
                        }
                    }
                    break;
                }
                else if (i == TimePlanTable.Count - 1)
                {
                    ntfTray.Icon = icoRestIcon[RestIconFrame++ % 11];
                    if (dtnow.Hour < 4)
                    {
                        ntfTray.Text = "今日行程结束!";
                    }
                    else
                    {
                        ntfTray.Text = "今日行程即将开始!";
                    }
                    _osd.Hide();
                }
            }
            //if (!p)
            //{
            //        //ntfTray.Icon = DrawState((dtnow - dtfrom).TotalMilliseconds, (dtto - dtfrom).TotalMilliseconds);
            //}
        }