コード例 #1
0
 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);
 }
コード例 #2
0
        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();
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        public void LoadAlarms()
        {
            List <AlarmTime> alarms = AlarmTime.DeserializeFromXml();

            this.WatchAlarm(alarms);
        }
コード例 #5
0
        public void SaveAlarms()
        {
            List <AlarmTime> alarms = this.GetAlarms();

            AlarmTime.SerializeToXml(alarms);
        }