Beispiel #1
0
        public AlarmNotice(Alarm alarm)
        {
            InitializeComponent();

            this.lblDateTime.Text = DateTime.Now.ToString("G");
            this.txtMessage.Text = alarm.Message;
        }
Beispiel #2
0
        public EditAlarm(Alarm alarm, RefreshAlarmList ral)
        {
            InitializeComponent();
            this.Text = "Edit Alarm";
            this.alarm = alarm;
            this.ral = ral;

            this.PopulateForm();
        }
Beispiel #3
0
        private void AddQuickAlarm(int minutes)
        {
            Alarm alarm = new Alarm();
            alarm.Trigger = DateTime.Now.AddMinutes(minutes);
            alarm.Message = minutes.ToString() + "-minute reminder (set on " +
                DateTime.Now.ToString("G") + ")";

            AlarmCache.Instance.Save(alarm);

            this.RefreshAlarmList();
        }
Beispiel #4
0
        private void listAlarms_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left || e.Button == MouseButtons.Middle)
                return;

            if (listAlarms.SelectedItems.Count != 1)
                return;

            ListViewItem sel = listAlarms.SelectedItems[0];

            if (sel != null)
            {
                Alarm alarm = new Alarm();
                alarm.Id = new Guid(sel.SubItems[2].Text);
                alarm.Trigger = DateTime.Parse(sel.SubItems[0].Text);
                alarm.Message = sel.SubItems[1].Text;

                new EditAlarm(alarm, this.RefreshList).Show();
            }
        }
Beispiel #5
0
        public Alarm Save(Alarm alarm)
        {
            Guid id = new AlarmStorage().Save(alarm);
            Alarm newAlarm;

            if (this.GetAlarm(id) == null)
            {
                newAlarm = new Alarm();
                newAlarm.Id = id;
                newAlarm.Message = alarm.Message;
                newAlarm.Trigger = alarm.Trigger;

                this.alarms.Add(newAlarm);
            }
            else
            {
                newAlarm = this.GetAlarm(id);
                newAlarm.Message = alarm.Message;
                newAlarm.Trigger = alarm.Trigger;
            }

            return newAlarm;
        }
Beispiel #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (DateIsInPast())
                MessageBox.Show("Selected date/time is in the past", "SnapAlarm", MessageBoxButtons.OK, MessageBoxIcon.Error);
            else
            {
                if (this.alarm == null)
                {
                    this.alarm = new Alarm();
                    this.alarm.Trigger = this.GetDateTime();
                    this.alarm.Message = txtMessage.Text;
                }
                else
                {
                    this.alarm.Trigger = this.GetDateTime();
                    this.alarm.Message = txtMessage.Text;
                }

                AlarmCache.Instance.Save(this.alarm);

                this.ral();
                this.Close();
            }
        }
Beispiel #7
0
        public Alarm Fetch(Guid id)
        {
            XmlElement xe = (XmlElement)this.xd.SelectSingleNode(String.Format("/SnapAlarm/Alarm[@id='{0}']", id));

            if (xe == null)
                return null;
            else
            {
                Alarm alarm = new Alarm();
                alarm.Id = id;
                alarm.Message = xe.SelectSingleNode("Message").InnerText;
                alarm.Trigger = DateTime.Parse(xe.SelectSingleNode("Trigger").InnerText);

                return alarm;
            }
        }
Beispiel #8
0
        public Guid Save(Alarm alarm)
        {
            Guid retGuid = new Guid();

            if (!this.AlarmExists(alarm.Id))
            {
                retGuid = Guid.NewGuid();

                XmlElement xe = (XmlElement)this.xd.DocumentElement.AppendChild(this.xd.CreateElement("Alarm"));
                xe.SetAttribute("id", retGuid.ToString());
                xe.AppendChild(this.xd.CreateElement("Message")).InnerText = alarm.Message;
                xe.AppendChild(this.xd.CreateElement("Trigger")).InnerText = alarm.Trigger.ToString("G");
            }
            else
            {
                retGuid = alarm.Id;

                XmlElement xe = (XmlElement)this.xd.SelectSingleNode("//SnapAlarm/Alarm[@id='" + alarm.Id.ToString() + "']");
                xe.SelectSingleNode("Message").InnerText = alarm.Message;
                xe.SelectSingleNode("Trigger").InnerText = alarm.Trigger.ToString("G");
            }

            this.xd.Save(Utility.StorageFile);

            return retGuid;
        }