예제 #1
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            if ((alarmState == AlarmStates.Pending) && (DateTime.Now >= reminder.NextOccurance))
            {
                AlarmState = AlarmStates.Alarming;
            }

            if (alarmState == AlarmStates.Alarming)
            {
                switch (alarmAnimationFrame++)
                {
                case 0: {
                    notifyIcon.Icon = global::mxplx.Properties.Resources.Alarm1;
                    break;
                }

                case 1: {
                    notifyIcon.Icon = global::mxplx.Properties.Resources.Reminder;
                    break;
                }

                case 2: {
                    notifyIcon.Icon     = global::mxplx.Properties.Resources.Alarm2;
                    alarmAnimationFrame = 0;
                    break;
                }
                }
            }
        }
예제 #2
0
        private void SetButton_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(nameCombo.Text))
            {
                MessageBox.Show("Name can not be blank");
                return;
            }

            if (reminder == null)
            {
                reminder = new Reminder();
                MainForm.AllReminders.Add(reminder);
            }

            reminder.Name         = nameCombo.Text;
            reminder.ReminderType = (atRadio.Checked) ? ReminderTypes.Time : ReminderTypes.Interval;
            reminder.Time         = (reminder.ReminderType == ReminderTypes.Time) ? TimeSpan.Parse(atTimePicker.Text) : new TimeSpan(0, (int)inMinutesNud.Value, 0);

            notifyIcon.Text = string.Format("{0} at {1}", reminder.Name, reminder.NextOccurance);
            timer.Enabled   = true;

            AlarmState = AlarmStates.Pending;

            Hide();
        }
예제 #3
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            if ((alarmState == AlarmStates.Pending) && (DateTime.Now >= reminder.NextOccurence))
            {
                AlarmState = AlarmStates.Alarming;
            }

            if (alarmState == AlarmStates.Alarming)
            {
                alarmAnimationFrame = (alarmAnimationFrame + 1) % animationFrames.Length;
                notifyIcon.Icon     = animationFrames[alarmAnimationFrame];
            }
        }
예제 #4
0
        /// <summary>
        /// Changes the program's state from the current one to the input, if possible.
        /// </summary>
        /// <param name="s">A state to move to</param>
        public void UpdateState(AlarmStates s)
        {
            switch (state)
            {
            case AlarmStates.Off:     // If the alarm is off, it can begin running
                if (s == AlarmStates.Running)
                {
                    state = AlarmStates.Running;
                }
                break;

            case AlarmStates.Running:     // If the alarm is running, it can go off, and nothing else
                if (s == AlarmStates.Beeping)
                {
                    state = AlarmStates.Beeping;
                }
                break;

            case AlarmStates.Beeping:     // If the alarm is currently going off, it can be snoozed, or cleared
                if (s == AlarmStates.Snoozing)
                {
                    state      = AlarmStates.Snoozing;
                    snoozeTime = 30;
                }
                else if (s == AlarmStates.Off)
                {
                    state = AlarmStates.Off;
                }
                break;

            default:     // If the alarm is running, it can go off, or be turned off.
                if (s == AlarmStates.Off)
                {
                    state = AlarmStates.Off;
                }
                else if (s == AlarmStates.Beeping)
                {
                    state = AlarmStates.Beeping;
                }
                break;
            }
            view.UpdateTextBox(s);
        }
예제 #5
0
        /// <summary>
        /// Updates the text box based on the current state
        /// </summary>
        /// <param name="s">The current state of the alarm clock</param>
        public void UpdateTextBox(AlarmStates s)
        {
            switch (s)
            {
            case AlarmStates.Off:
            {
                uXStatusBox.Text      = "Alarm stopped";
                uXStopButton.Enabled  = false;
                uXSleepButton.Enabled = false;
                break;
            }

            case AlarmStates.Running:
            {
                uXStatusBox.Text      = "Alarm activated";
                uXStopButton.Enabled  = true;
                uXSleepButton.Enabled = false;
                break;
            }

            case AlarmStates.Snoozing:
            {
                uXStatusBox.Text      = "Snoozing for 30 seconds";
                uXStopButton.Enabled  = true;
                uXSleepButton.Enabled = false;
                break;
            }

            case AlarmStates.Beeping:
            {
                uXStatusBox.Text      = "Alarm went off";
                uXStopButton.Enabled  = true;
                uXSleepButton.Enabled = true;
                break;
            }
            }
        }
예제 #6
0
 private void ClearButton_Click(object sender, EventArgs e)
 {
     AlarmState = AlarmStates.Off;
     Close();
 }
예제 #7
0
        /// <summary>
        /// Converting source value to target value
        /// </summary>
        /// <param name="value">Source object</param>
        /// <seealso cref="System.object">
        /// <param name="targetType">The target type to convert</param>
        /// <seealso cref="Type">
        /// <param name="CultureInfo">The culture info</param>
        /// <seealso cref="CultureInfo">
        /// <returns>Depending on the repeat image's visibility, control Alarm name label's translationX value</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            AlarmStates         activeItem = (AlarmStates)value;
            AlarmModelComponent comp       = (AlarmModelComponent)parameter;

            if (activeItem == AlarmStates.Inactive)
            {
                switch (comp)
                {
                case AlarmModelComponent.Time:
                    return(AlarmStyle.ATO001D);

                case AlarmModelComponent.AmPm:
                    return(AlarmStyle.ATO002D);

                case AlarmModelComponent.Name:
                    return(AlarmStyle.ATO003D);

                case AlarmModelComponent.Weekly:
                    return(AlarmStyle.ATO004D);

                case AlarmModelComponent.Date:
                    return(AlarmStyle.ATO044D);

                case AlarmModelComponent.State:
                    return(false);

                case AlarmModelComponent.Repeat:
                    return(Color.FromHex("66000000"));

                default:
                    return(AlarmStyle.ATO001D);
                }
            }
            else
            {
                switch (comp)
                {
                case AlarmModelComponent.Time:
                    return(AlarmStyle.ATO001);

                case AlarmModelComponent.AmPm:
                    return(AlarmStyle.ATO002);

                case AlarmModelComponent.Name:
                    return(AlarmStyle.ATO003);

                case AlarmModelComponent.Weekly:
                    return(AlarmStyle.ATO004);

                case AlarmModelComponent.Date:
                    return(AlarmStyle.ATO044);

                case AlarmModelComponent.State:
                    return(true);

                case AlarmModelComponent.Repeat:
                    return(Color.FromHex("FFFFFF"));

                default:
                    return(AlarmStyle.ATO001);
                }
            }
        }