Example #1
0
        private void ToBeAlarm()
        {
            Console.WriteLine("====" + count++ + "==================");
            DateTime timeNow   = DateTime.Now;
            string   stringnow = timeNow.Hour + ":" + timeNow.Minute;

            foreach (var c in this.Controls)
            {
                if (c is SingleAlarm)
                {
                    SingleAlarm singleAlarm = c as SingleAlarm;
                    DateTime    timeAlarm   = singleAlarm.GetAlarmTime();
                    string      stringalarm = timeAlarm.Hour + ":" + timeAlarm.Minute;
                    if (singleAlarm.IsChecked())
                    {
                        if (stringalarm == stringnow)
                        {
                            if (comparestring != stringnow)
                            {
                                comparestring = stringnow;
                                ShowAlarm showAlarm = new ShowAlarm(stringalarm);
                                showAlarm.ShowDialog();
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        private void LoadSettedAlarm()
        {
            bool flag = true;

            List <string> timelist  = Settings.Default.TimeSetting.Split(',').ToList <string>();
            List <string> checklist = Settings.Default.CheckSetting.Split(',').ToList <string>();
            int           positionY = 0;

            for (int i = 0; i < timelist.Count - 1; i++)
            {
                SingleAlarm singleAlarm = new SingleAlarm(timelist[i], Convert.ToBoolean(checklist[i]));
                singleAlarm.Location = new Point(0, positionY);
                if (flag)
                {
                    singleAlarm.BackColor = Color.White;
                }
                else
                {
                    singleAlarm.BackColor = Color.WhiteSmoke;
                }
                flag = !flag;
                this.Controls.Add(singleAlarm);
                positionY += 38;
            }

            AddButton.Location = new Point(116, positionY + 5);
        }
Example #3
0
 public SubSetAlarm(SingleAlarm singleAlarm)
 {
     InitializeComponent();
     this.MaximizeBox          = false;
     numericUpDownHour.Minimum = 0;
     numericUpDownHour.Maximum = 23;
     numericUpDownMin.Minimum  = 0;
     numericUpDownMin.Maximum  = 59;
     this.FormBorderStyle      = FormBorderStyle.FixedSingle;
     single = singleAlarm;
 }
Example #4
0
        private void btSubAdd_Click(object sender, EventArgs e)
        {
            if (this.Text == "Set")
            {
                int count  = 0;
                int height = 0;
                foreach (Control c in Alarm.form1.Controls)
                {
                    if (c is SingleAlarm)
                    {
                        count++;
                        height += 38;
                    }
                }
                if (count >= 11)
                {
                    MessageBox.Show("The count of alarms reaches the upper limit");
                    return;
                }
                SingleAlarm sa = new SingleAlarm();
                sa.Location = new Point(0, height);
                string hour = numericUpDownHour.Value.ToString();
                if (hour.Length == 1)
                {
                    hour = "0" + hour;
                }
                string minute = numericUpDownMin.Value.ToString();
                if (minute.Length == 1)
                {
                    minute = "0" + minute;
                }
                sa.SetTime(hour + ":" + minute);
                if (count % 2 == 0)
                {
                    sa.BackColor = Color.White;
                }
                else
                {
                    sa.BackColor = Color.WhiteSmoke;
                }
                delSetAlarmHandler(sa);
                height += 38;
                count++;

                Alarm.form1.AddButton.Location = new Point(116, height + 5);
            }
            if (this.Text == "Modify")
            {
                string hour = numericUpDownHour.Value.ToString();
                if (hour.Length == 1)
                {
                    hour = "0" + hour;
                }
                string minute = numericUpDownMin.Value.ToString();
                if (minute.Length == 1)
                {
                    minute = "0" + minute;
                }
                single.SetTime(hour + ":" + minute);
            }
            this.Close();
        }
Example #5
0
 void SetAlarmFromSub(SingleAlarm sa)
 {
     this.Controls.Add(sa);
 }