Beispiel #1
0
        // This initialization method tells the control if it is the first one in the container form
        public actionClockControl(string initStartTime, string initEndTime, string initName, bool isFirst = false) : this()
        {
            m_ErrorCount = 0;
            //Match matchStart = Regex.Match(initStartTime, @"[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] s?([ap]m)?$", RegexOptions.IgnoreCase);
            Match matchStart  = Regex.Match(initStartTime, @"[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$", RegexOptions.IgnoreCase);
            Match matchLength = Regex.Match(initEndTime, @"[0-9][0-9]:[0-9][0-9]:[0-9][0-9]$", RegexOptions.IgnoreCase);

            if ((matchStart.Success == false) || (matchLength.Success == false) || (initName == ""))
            {
                m_Action = new TimerDatastore(System.DateTime.Now.ToString(), "00:00:01", "ERROR");
            }
            else
            {
                m_Action = new TimerDatastore(initStartTime, initEndTime, initName);
            }
            // Parse all the stuff used to initialize the timer.


            uxTimeOfAction.Text = m_Action.StartOffset.ToString();
            uxEndOfAction.Text  = m_Action.Length.ToString();
            uxNameLabel.Text    = m_Action.Name;
            if (isFirst == true)
            {
                m_isFirst = true;
            }
            EventMessenger.SendMessage(this, m_Action, true, false);
        }
Beispiel #2
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);

                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");
            }
        }