Exemple #1
0
        private void btn_CalcIntervall_Click(object sender, EventArgs e)
        {
            try
            {
                time int1from = new time(Convert.ToInt32(txt_int1_from_hour.Text), Convert.ToInt32(txt_int1_from_minute.Text));
                time int1to = new time(Convert.ToInt32(txt_int1_to_hour.Text), Convert.ToInt32(txt_int1_to_minute.Text));
                time int2from = new time(Convert.ToInt32(txt_int2_from_hour.Text), Convert.ToInt32(txt_int2_from_minute.Text));
                time int2to = new time(Convert.ToInt32(txt_int2_to_hour.Text), Convert.ToInt32(txt_int2_to_minute.Text));
                intervall int1 = new intervall(int1from, int1to);
                intervall int2 = new intervall(int2from, int2to);

                MessageBox.Show(intervall.GetIntervallState(int1, int2));
            }
            catch (Exception ex)
            {
                if (ex is ArgumentOutOfRangeException || ex is FormatException)
                {
                    MessageBox.Show("Ungültige Eingabe!");
                    return;
                }
                else if (ex is ArgumentException)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
 public intervall(time f, time t)
 {
     if (f.GetAbsoluteTime() <= t.GetAbsoluteTime())
     {
         From = f;
         To = t;
     }
     else
     {
         throw new ArgumentException("Eines der angegebenen Intervalle ist ungültig!");
     };
 }