コード例 #1
0
ファイル: FrmMain.cs プロジェクト: usetool/MyProjects
 /// <summary>
 /// 窗体加载事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FrmMain_Load(object sender, EventArgs e)
 {
     //窗体加载时检测数据库文件是否存在,存在->读取信息 ,不存在->提示新建计划
     //bin目录用于存放配置文件
     if (!Directory.Exists("bin"))
     {
         Directory.CreateDirectory("bin");
         this.btnTodayPlan.Text    = "未设立";
         this.btnTodayPlan.Enabled = true;
         //初次运行
         FrmFirstInfo first = new FrmFirstInfo();
         //first.ShowDialog();
         if (!File.Exists("bin/plan.db"))
         {
             DataOperation.CreateDB(Config.path, Config.pwd);
         }
         first.ShowDialog();
         DialogResult result = MessageBox.Show("系统检测到您还没有计划信息,是否要创建?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         if (result == DialogResult.OK)
         {
             //打开创建计划窗口
             FrmLongPlan frm = new FrmLongPlan();
             frm.ShowDialog();
         }
     }
     else
     {
         InitialQuestionType();
         this.timerOfTime.Start();
         //每次运行时展示励志句子
         List <Plan> sentence = dp.GetAllHistoryPlan(PlanType.Sentence);
         if (sentence.Count > 0)
         {
             int         rand     = new Random().Next(0, sentence.Count);
             FrmShowInfo showInfo = new FrmShowInfo(sentence[rand].PlanContent, PlanType.Sentence);
             showInfo.Show();
         }
         ProgressInitial();
         if (!todayPlanIsCreate)
         {
             this.btnTodayPlan.Text    = "未设立";
             this.btnTodayPlan.Enabled = true;
             MessageBox.Show("今日计划还没有规划呢!快去做计划吧", "提示!");
             FrmDayPlan frm = new FrmDayPlan();
             frm.ShowDialog();
         }
         else
         {
             timerOfOneHour.Start();
         }
     }
 }
コード例 #2
0
ファイル: FrmMain.cs プロジェクト: usetool/MyProjects
        private void timerOfOneHour_Tick(object sender, EventArgs e)
        {
            string      info  = "";
            List <Plan> plans = dp.GetAllNowPlan();

            foreach (Plan item in plans)
            {
                if (item.MyPlanType == PlanType.DayPlan)
                {
                    string[] contents = item.PlanContent.Split('|');
                    foreach (string str in contents)
                    {
                        info += str + "\n";
                    }
                }
            }
            FrmShowInfo showInfo = new FrmShowInfo(info, PlanType.DayPlan);

            showInfo.Show();
            InitialQuestionType();
        }