public void WatchAlarm(AlarmTime alarm) { if (!m_Alarms.Contains(alarm)) { m_Alarms.Add(alarm); } alarm.OnAlarm -= new EventHandler(alarm_OnAlarm); alarm.OnAlarm += new EventHandler(alarm_OnAlarm); }
void alarm_OnAlarm(object sender, EventArgs e) { if (m_Sync.InvokeRequired) { m_Sync.Invoke(new MethodInvoker(delegate { alarm_OnAlarm(sender, e); }), null); return; } AlarmTime alarm = (AlarmTime)sender; if (alarm == null) { return; } if (!m_Alarms.Contains(alarm)) { alarm.OnAlarm -= new EventHandler(alarm_OnAlarm); return; } if (alarm.BalloonTip) { /* * NotifyIcon icon = new NotifyIcon(); * icon.BalloonTipClosed += (s, ea) => { icon.Visible = false; }; * icon.BalloonTipClicked += (s, ea) => { icon.Visible = false; }; * icon.Icon = DS_Timer.Properties.Resources.clockIcon; * icon.Visible = true; * icon.ShowBalloonTip(10000, "DS-Timer Alarm", "Nachricht: " + alarm.Message, ToolTipIcon.Info); */ m_Notify.ShowMessage(alarm.Message); } if (alarm.Sound) { Sound.Play(); } if (alarm.Popup) { FormAlarmPopup form = new FormAlarmPopup(alarm.Message); form.FormClosed += new FormClosedEventHandler(form_FormClosed); form.Show(); StartSoundLoop(); } }
void m_Alarms_ListChanged(object sender, ListChangedEventArgs e) { if (e.NewIndex < 0) { return; } if (e.NewIndex >= m_Alarms.Count) { return; } if (e.ListChangedType == ListChangedType.ItemAdded) { AlarmTime alarm = m_Alarms[e.NewIndex]; WatchAlarm(alarm); } }
public void LoadAlarms() { List <AlarmTime> alarms = AlarmTime.DeserializeFromXml(); this.WatchAlarm(alarms); }
public void SaveAlarms() { List <AlarmTime> alarms = this.GetAlarms(); AlarmTime.SerializeToXml(alarms); }