private void uxAddTimer_Click(object sender, EventArgs e)
 {
     // The try/catches are an easier way to avoid stupid crashes, and give the user information to give to the developer
     try
     {
         if (uxFlowPanel.Controls.Count == 0)
         {
             // Make a normal actionClockControl
             actionClockControl scc = new actionClockControl(Timers.MasterTime.GetOffset().ToString(), uxLengthOfAction.Text, uxNameOfAction.Text);
             Timers.MasterTime.SetOffset(Timers.MasterTime.GetOffset(), uxLengthOfAction.Text);
             scc.Parent = uxFlowPanel;
             scc.Show();
         }
         else
         {
             actionClockControl scc = new actionClockControl(Timers.MasterTime.GetOffset().ToString(), uxLengthOfAction.Text, uxNameOfAction.Text);
             Timers.MasterTime.SetOffset(Timers.MasterTime.GetOffset(), uxLengthOfAction.Text);
             scc.Parent = uxFlowPanel;
             scc.Show();
         }
         // Blank all the input parameters and set the focus to the first one.
         // This makes it easier to begin typing the next set of parameters
         uxNameOfAction.Text   = "";
         uxLengthOfAction.Text = "";
         uxTimeOfAction.Focus();
     }
     catch
     {
         // Errors should be formatted like this, "Error in <filename>, <method>"
         MessageBox.Show("Error in uxContainerForm, uxAddTimer_Click");
     }
 }
        private void LoadControls()
        {
            m_Container = SaveStore.LoadControls();

            for (int i = 0; i < m_Container.Timers.Count(); i++)
            {
                actionClockControl acc = new actionClockControl(m_Container.getTimer(i));
                uxFlowPanel.Controls.Add(acc);
            }
        }
        private void uxDebugBtn_Click(object sender, EventArgs e)
        {
            DateTime  theDate = new DateTime();
            TimeSpan  theEnd  = new TimeSpan();
            Parsetime parser  = new Parsetime();

            theEnd  = parser.ParseTS("01:00:00");
            theDate = DateTime.Now;
            theDate = theDate.AddMinutes(1 + m_Container.Timers.Count());
            //MessageBox.Show(theDate.ToString());
            String             newDate = Convert.ToDateTime(theDate).ToString("MM/dd/yyyy hh:mm:ss tt");
            actionClockControl scc     = new actionClockControl(newDate, "00:01:00", "Test " + m_Container.Timers.Count());

            scc.Parent = uxFlowPanel;
            scc.Show();
        }
 void uxNameOfAction_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
 {
     // KeyValue 13 is the enter button
     // We want to treat an enter key event as pressing the add timer button.
     // Possibly replace the code after this if with a function to reduce code size
     if (e.KeyValue == 13)
     {
         try
         {
             if (uxFlowPanel.Controls.Count == 0)
             {
                 actionClockControl scc = new actionClockControl(uxTimeOfAction.Text, uxLengthOfAction.Text, uxNameOfAction.Text);
                 scc.Parent = uxFlowPanel;
                 scc.Show();
             }
             else
             {
                 actionClockControl scc = new actionClockControl(uxTimeOfAction.Text, uxLengthOfAction.Text, uxNameOfAction.Text);
                 scc.Parent = uxFlowPanel;
                 scc.Show();
             }
             // Clear all the data parameters and prepare for the next entry
             uxTimeOfAction.Text   = "";
             uxNameOfAction.Text   = "";
             uxLengthOfAction.Text = "";
             uxTimeOfAction.Focus();
         }
         catch
         {
             MessageBox.Show("Error in uxContainerForm, uxNameOfAction_KeyDown");
         }
     }
     else
     {
         //e.Handled = false;
     }
 }
Esempio n. 5
0
        private void killControl()
        {
            // Keep all cleanup procedures in this function, and ONLY close the control using this function.

            try
            {
                // We need to figure out who owns us
                Control control = this.Parent;
                EventMessenger.SendMessage(this, m_Action, false, true);

                // This checks if we are the first control, if so, we need to make a new "first" control before self-destructing
                if (m_isFirst == true)
                {
                    // We need to modify the date the next show begins, it is exactly one week after this one.
                    // Make a new DateTime to help calculate it
                    DateTime modStart = m_Action.Start;
                    // It's just easier to do it this way
                    String modEnd = m_Action.Length.ToString();
                    // It's really this easy to add 7 days to a datetime? Wow!
                    modStart = modStart.AddDays(7);
                    // Re-convert it to a string to pass back to a new actionClockControl
                    String s_modStart = Convert.ToDateTime(modStart).ToString("MM/dd/yyyy hh:mm:ss tt");

                    // Here's where it starts getting screwey, create a new control
                    actionClockControl acc = new actionClockControl(s_modStart, modEnd, "YRU-Up", true);
                    // Set the parent of the control we just made to our parent
                    acc.Parent = control;
                    // And show it
                    acc.Show();
                }
                if (this.Parent.Controls.Contains(this) == true)
                {
                    // Don't dispose until we're removed from the parent
                    this.Parent.Controls.Remove(this);
                }
                else
                {
                    // We're removed from the parent, dispose.
                    this.Dispose();
                }
                // Just to make sure, dispose again. ;)
                this.Dispose();
            }
            catch
            {
                // If something in this function fails, dispose and throw a messagebox
                this.Dispose();
                MessageBox.Show("Error in actionClockControl, killControl");
            }
        }