Exemplo n.º 1
0
        //display update methods - this (and the related ToString() methods,
        //are going to almost certainly be replacing the above update*() method
        //at least where it contains the switch/case logic
        public static void updateEntry(EntryType.Entries whichType, int curr)
        {
            switch (whichType)
            {
            case EntryType.Entries.Alarm:
                mainForm.AlarmCLB.Items.Add(mainForm.activeAlarms[curr].ToString(), true);
                mainForm.AlarmCLB.Show();
                break;

            case EntryType.Entries.Timer:
                mainForm.TimerCLB.Items.Add(mainForm.activeTimers[curr].ToString(), true);
                mainForm.TimerCLB.Show();
                break;

            case EntryType.Entries.Reminder:
                mainForm.ReminderCLB.Items.Add(mainForm.activeReminders[curr].ToString(), true);
                mainForm.ReminderCLB.Show();
                break;

            default:
                //ouah
                break;
            }
        }
Exemplo n.º 2
0
        public static void updateDisplay(EntryType.Entries eType)
        {
            List <EntryType.Alarm>    activeAlarms    = new List <EntryType.Alarm>();
            List <EntryType.Timer>    activeTimers    = new List <EntryType.Timer>();
            List <EntryType.Reminder> activeReminders = new List <EntryType.Reminder>();

            activeAlarms    = mainForm.activeAlarms;
            activeTimers    = mainForm.activeTimers;
            activeReminders = mainForm.activeReminders;

            switch (eType)
            {
            case EntryType.Entries.Alarm:
                mainForm.AlarmCLB.Items.Clear();

                //swap this gross for loop out for a foreach like is done for
                //timer entries immediately below
                //or better yet, modularize
                for (int cntr2 = 0; cntr2 < activeAlarms.Count; cntr2++)
                {
                    //switch the above to a 'for' loop & remove cntr++ below
                    EntryType.Alarm al = activeAlarms[cntr2];

                    if (al.Running)
                    {
                        if (!al.IsPast())
                        {
                            updateEntry(EntryType.Entries.Alarm, cntr2);
                        }
                        else
                        {
                            if (Debug.tickDebugging && Debug.alarmDebugging)
                            {
                                Debug.ShowDbgOut("Toggling alarm #" + cntr2.ToString());
                            }

                            al.ToggleRunning();
                        }
                    }
                    else
                    {
                        mainForm.AlarmCLB.Items.Add(al.ActiveAt + " - " + al.Name, false);
                    }
                }
                break;

            case EntryType.Entries.Timer:
                mainForm.TimerCLB.Items.Clear();

                foreach (EntryType.Timer tm in activeTimers)
                {
                    if (tm.Running && (tm.Remaining > new TimeSpan(0)))
                    {
                        //clbTimers.Items.Add(tm.Remaining + " - " + tm.Name, true);
                        updateEntry(EntryType.Entries.Timer,
                                    activeTimers.IndexOf(tm));
                    }
                    else if (!tm.Running || (tm.Running && (tm.Remaining <= new TimeSpan(0))))
                    {
                        if (tm.Running)
                        {
                            tm.RingRingNeo();
                        }
                        mainForm.TimerCLB.Items.Add(tm.Remaining + " - " + tm.Name, false);
                    }
                }
                break;

            case EntryType.Entries.Reminder:
                mainForm.ReminderCLB.Items.Clear();

                foreach (EntryType.Reminder rm in activeReminders)
                {
                    if (rm.Running && (!rm.CheckInterval()))
                    {
                        updateEntry(EntryType.Entries.Reminder,
                                    activeReminders.IndexOf(rm));
                    }
                    else if (!rm.Running)
                    {
                        mainForm.ReminderCLB.Items.Add(rm.ActiveAt + " - " + rm.Name, false);
                    }
                }
                break;
            }
        }
Exemplo n.º 3
0
        private void EditEntry_Load(object sender, EventArgs e)
        {
            EntryType.Entries currentTypeEdited = new EntryType.Entries();

            if (mainForm.AlarmCLB.SelectedIndex != -1)
            {
                currentTypeEdited = EntryType.Entries.Alarm;
            }
            else if (mainForm.ReminderCLB.SelectedIndex != -1)
            {
                currentTypeEdited = EntryType.Entries.Reminder;
            }
            else
            {
                currentTypeEdited = EntryType.Entries.Timer;

                //lets change the controls accordingly
                //(no event handler to remove for the existing dtp
                this.Controls.Remove(dtpActiveAt);

                //change existing label
                lblRingAt.Text = "Duration:";

                //set up new control properties
                this.nudTmrHrs          = new System.Windows.Forms.NumericUpDown();
                this.nudTmrHrs.Location = new System.Drawing.Point(92, 39);
                this.nudTmrHrs.Name     = "nudTmrHrs";
                this.nudTmrHrs.Size     = new System.Drawing.Size(40, 20);
                this.nudTmrHrs.TabIndex = 8;
                this.nudTmrHrs.Minimum  = 0;
                this.nudTmrHrs.Maximum  = 23;

                this.lblTmrHours          = new System.Windows.Forms.Label();
                this.lblTmrHours.Location = new System.Drawing.Point(135, 44);
                this.lblTmrHours.Name     = "lblTmrHours";
                this.lblTmrHours.Size     = new System.Drawing.Size(23, 20);
                this.lblTmrHours.Text     = "Hrs";

                this.nudTmrMin          = new System.Windows.Forms.NumericUpDown();
                this.nudTmrMin.Location = new System.Drawing.Point(160, 39);
                this.nudTmrMin.Name     = "nudTmrMin";
                this.nudTmrMin.Size     = new System.Drawing.Size(40, 20);
                this.nudTmrMin.TabIndex = 9;
                this.nudTmrMin.Minimum  = 0;
                this.nudTmrMin.Maximum  = 59;

                this.lblTmrMinutes          = new System.Windows.Forms.Label();
                this.lblTmrMinutes.Location = new System.Drawing.Point(203, 44);
                this.lblTmrMinutes.Name     = "lblTmrMinutes";
                this.lblTmrMinutes.Size     = new System.Drawing.Size(23, 20);
                this.lblTmrMinutes.Text     = "Min";

                this.nudTmrSec          = new System.Windows.Forms.NumericUpDown();
                this.nudTmrSec.Location = new System.Drawing.Point(228, 39);
                this.nudTmrSec.Name     = "nudTmrSec";
                this.nudTmrSec.Size     = new System.Drawing.Size(40, 20);
                this.nudTmrSec.Text     = "Sec";
                this.nudTmrSec.TabIndex = 10;
                this.nudTmrSec.Minimum  = 0;
                this.nudTmrSec.Maximum  = 59;

                this.lblTmrSeconds          = new System.Windows.Forms.Label();
                this.lblTmrSeconds.Location = new System.Drawing.Point(271, 44);
                this.lblTmrSeconds.Name     = "lblTmrSeconds";
                this.lblTmrSeconds.Size     = new System.Drawing.Size(23, 20);
                this.lblTmrSeconds.Text     = "Sec";

                this.Controls.Add(nudTmrHrs);
                this.Controls.Add(lblTmrHours);
                this.Controls.Add(nudTmrMin);
                this.Controls.Add(lblTmrMinutes);
                this.Controls.Add(nudTmrSec);
                this.Controls.Add(lblTmrSeconds);
            }

            switch (currentTypeEdited)
            {
            case EntryType.Entries.Alarm:
                //edit our alarm entry heah
                tbxReminderText.Text    = "unavailable";
                tbxReminderText.Enabled = false;
                tbxName.Text            =
                    mainForm.activeAlarms[mainForm.AlarmCLB.SelectedIndex].Name;
                dtpActiveAt.Value =
                    mainForm.activeAlarms[mainForm.AlarmCLB.SelectedIndex].ActiveAt;

                break;

            case EntryType.Entries.Timer:
                //edit timer heah
                tbxReminderText.Text    = "unavailable";
                tbxReminderText.Enabled = false;
                tbxName.Text            =
                    mainForm.activeTimers[mainForm.TimerCLB.SelectedIndex].Name;

                break;

            case EntryType.Entries.Reminder:
                tbxReminderText.Enabled = true;
                //reminder tiem
                tbxReminderText.Text =
                    mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].Msg;
                tbxName.Text =
                    mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].Name;
                dtpActiveAt.Value =
                    mainForm.activeReminders[
                        mainForm.ReminderCLB.SelectedIndex].ActiveAt;

                break;
            }
        }
Exemplo n.º 4
0
        private void btnMakeChanges_Click(object sender, EventArgs e)
        {
            EntryType.Entries currentTypeEdited = new EntryType.Entries();
            if (mainForm.AlarmCLB.SelectedIndex != -1)
            {
                currentTypeEdited = EntryType.Entries.Alarm;
            }
            else if (mainForm.TimerCLB.SelectedIndex != -1)
            {
                currentTypeEdited = EntryType.Entries.Timer;
            }
            else
            {
                currentTypeEdited = EntryType.Entries.Reminder;
            }

            switch (currentTypeEdited)
            {
            //need to modularize this shit :|
            case (EntryType.Entries.Alarm):
                /* note that the following conditional will need to have soundbite
                 * information checking, as well */
                if (tbxName.Text.Equals(
                        mainForm.activeAlarms[mainForm.AlarmCLB.SelectedIndex].Name) &&
                    dtpActiveAt.Value.Equals(
                        mainForm.activeAlarms[mainForm.AlarmCLB.SelectedIndex].ActiveAt))
                {
                    //no changes made to settings
                    if (MessageBox.Show("You haven't made any changes!",
                                        "Nothing changed", MessageBoxButtons.OKCancel,
                                        MessageBoxIcon.Warning) == DialogResult.Cancel)
                    {
                        mainForm.Enabled = true;
                        this.Close();
                    }
                    break;
                }

                mainForm.activeAlarms[mainForm.AlarmCLB.SelectedIndex].Name =
                    tbxName.Text;
                mainForm.activeAlarms[mainForm.AlarmCLB.SelectedIndex].ActiveAt =
                    dtpActiveAt.Value;

                MessageBox.Show("Changes propagated (not yet saved!)",
                                "Changes made", MessageBoxButtons.OK, MessageBoxIcon.Information);

                mainForm.Enabled = true;
                Display.updateDisplay(EntryType.Entries.Alarm);
                this.Close();

                break;

            //timer & reminder need to follow here
            case (EntryType.Entries.Timer):
                /* note that the following conditional will need to have soundbite
                 * information checking, as well */
                if (tbxName.Text.Equals(
                        mainForm.activeTimers[mainForm.TimerCLB.SelectedIndex].Name) &&
                    new TimeSpan((int)nudTmrHrs.Value, (int)nudTmrMin.Value,
                                 (int)nudTmrSec.Value).Equals(
                        mainForm.activeTimers[mainForm.TimerCLB.SelectedIndex].Duration))
                {
                    //no changes made to settings
                    if (MessageBox.Show("You haven't made any changes!",
                                        "Nothing changed", MessageBoxButtons.OKCancel,
                                        MessageBoxIcon.Warning) == DialogResult.Cancel)
                    {
                        mainForm.Enabled = true;
                        this.Close();
                    }
                    break;
                }

                if (Debug.timerDebugging)
                {
                    MessageBox.Show("nud values: " + nudTmrHrs.Value + ":" +
                                    nudTmrMin.Value + ":" + nudTmrSec.Value + "\n" +
                                    "(casted) nud values: " + (int)nudTmrHrs.Value + ":" +
                                    (int)nudTmrMin.Value + ":" + (int)nudTmrSec.Value + "\n" +
                                    "TimeSpan conversion: " + new TimeSpan((int)nudTmrHrs.Value,
                                                                           (int)nudTmrMin.Value, (int)nudTmrSec.Value).ToString());
                }

                mainForm.activeTimers[mainForm.TimerCLB.SelectedIndex].Name =
                    tbxName.Text;
                mainForm.activeTimers[mainForm.TimerCLB.SelectedIndex].Duration =
                    new TimeSpan((int)nudTmrHrs.Value, (int)nudTmrMin.Value,
                                 (int)nudTmrSec.Value);
                mainForm.activeTimers[mainForm.TimerCLB.SelectedIndex].Remaining =
                    mainForm.activeTimers[mainForm.TimerCLB.SelectedIndex].Duration;

                MessageBox.Show("Changes propagated (not yet saved!)",
                                "Changes made", MessageBoxButtons.OK, MessageBoxIcon.Information);

                mainForm.Enabled = true;
                Display.updateDisplay(EntryType.Entries.Timer);
                this.Close();

                break;

            case (EntryType.Entries.Reminder):
                //this schitt needs to be modularized, also, Clarice
                //</Dr.Lecter>
                if (tbxName.Text.Equals(
                        mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].Name) &&
                    tbxReminderText.Equals(
                        mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].Msg) &&
                    dtpActiveAt.Equals(
                        mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].ActiveAt))
                {
                    //no changes made
                    //this cuntpasting grows old, Clarice; modularize or 8-x
                    if (MessageBox.Show("You haven't made any changes!",
                                        "Nothing changed", MessageBoxButtons.OKCancel,
                                        MessageBoxIcon.Warning) == DialogResult.Cancel)
                    {
                        mainForm.Enabled = true;
                        this.Close();
                    }
                }
                else
                {
                    mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].Name =
                        tbxName.Text;
                    mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].ActiveAt =
                        dtpActiveAt.Value;
                    mainForm.activeReminders[mainForm.ReminderCLB.SelectedIndex].Msg =
                        tbxReminderText.Text;

                    MessageBox.Show("Changes propagated (not yet saved!)",
                                    "Changes made", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    mainForm.Enabled = true;
                    Display.updateDisplay(EntryType.Entries.Timer);
                    this.Close();
                }

                break;
            }
        }