Esempio n. 1
0
        private void Setalarm_Click(object sender, EventArgs e)
        {
            int seconds = (int)secondsnum.Value;
            int minuts  = (int)minutsnum.Value;
            int hours   = (int)hoursnum.Value;
            int day     = DateTime.Now.Day;
            int month   = DateTime.Now.Month;
            int year    = DateTime.Now.Year;

            ((sender as Control).Parent.Parent as TabPage).Text = alarmname.Text;

            hours = mcombo.SelectedItem.ToString() == "PM" ? hours + 12 : hours;
            DateTime alarmtime = new DateTime(year, month, day, hours, minuts, seconds);

            if (countdownto.Checked)
            {
                alarmtime = DateTime.Now;
                alarmtime = alarmtime.AddSeconds(seconds);
                alarmtime = alarmtime.AddMinutes(minuts);
                alarmtime = alarmtime.AddHours(hours);
            }

            Alaram.TaskType task = Alaram.TaskType.None;
            if (taskbtn.Checked)
            {
                if (shutdownbtn.Checked)
                {
                    task = Alaram.TaskType.ShutDown;
                }
                else if (restartbtn.Checked)
                {
                    task = Alaram.TaskType.Restart;
                }
                else if (lockbtn.Checked)
                {
                    task = Alaram.TaskType.Lock;
                }
                else if (sleepbtn.Checked)
                {
                    task = Alaram.TaskType.Sleep;
                }
            }

            // DateTime alarmtime = new DateTime(year, month, day, hours, minuts, seconds);
            myalarm           = new Alaram(alarmtime, alarmtxt.Text, alarmname.Text, alarmtonetxt.Text, task);
            myalarm.AlarmEnd += editalarm_Click;
            foreach (Control c in this.Controls)
            {
                c.Visible = false;
            }
            editalarm.Visible     = true;
            AlarmTimeShow.Visible = true;
            if (countdownto.Checked)
            {
                AlarmTimeShow.Text = "Alarm Runs After";

                t.Tick    += (s, ex) => { countdown(alarmtime); };
                t.Interval = 1;
                t.Enabled  = true;
            }
            else
            {
                AlarmTimeLabel.Text = alarmtime.ToLongTimeString();
                AlarmTimeShow.Text  = "Alarm Set To";
            }
        }
Esempio n. 2
0
 private void Deletalarm_Click(object sender, EventArgs e)
 {
     myalarm = null;
     GC.Collect();
     ((sender as Control).Parent.Parent.Parent as TabControl).TabPages.Remove((sender as Control).Parent.Parent as TabPage);
 }