Exemplo n.º 1
0
 protected override void WndProc(ref Message keyPressed)
 {
     //热键被按下
     if (keyPressed.Msg == WinAPI.WM_HOTKEY)
     {
         //TODO: 快速添加闹钟
         WndQuickAddAlarm quickAddAlarm = new WndQuickAddAlarm();
         quickAddAlarm.Focus();
         if (quickAddAlarm.ShowDialog() == DialogResult.OK)
         {
             CreateAlarmItem(AlarmUtil.ParseAlarmInfo(Pub.QuickAlarmInfo), false);
         }
     }
     base.WndProc(ref keyPressed);
 }
Exemplo n.º 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            RegisterHotkey();

            timer1.Enabled = true;

            Pub.dbHelper = new DBAssistant();
            //读取数据库中的闹钟
            util = new AlarmUtil();
            var table  = Pub.dbHelper.GetValidAlarmList();
            var alarms = util.GetAlarmInfoFromTable(ref table);

            foreach (var alarm in alarms)
            {
                CreateAlarmItem(alarm, true);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 创建闹钟对象,并添加到数据库
 /// </summary>
 /// <param name="alarmInfo">一个存储闹钟信息的结构体变量</param>
 /// <param name="readFlag">该标志指示是读取(true)或创建(false)</param>
 private void CreateAlarmItem(AlarmUtil.ALARMINFO alarmInfo, bool readFlag)
 {
     if (!readFlag) //创建新的闹钟项目
     {
         try
         {
             Pub.dbHelper.InsertData(Pub.dbHelper.MainTableName, AlarmUtil.GetStringArrayFromAlarmInfo(alarmInfo));
             AlarmItem item = new AlarmItem(ref alarmInfo);
             LayoutPanel_AlarmItems.Controls.Add(item);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else //从数据库中读取,然后显示的项目
     {
         AlarmItem item = new AlarmItem(ref alarmInfo);
         LayoutPanel_AlarmItems.Controls.Add(item);
     }
 }