Пример #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);
                }
            }
        }
Пример #2
0
 public static string GetIntervallState(intervall a, intervall b)
 {
     if ((a.From.GetAbsoluteTime() >= b.From.GetAbsoluteTime() && a.To.GetAbsoluteTime() <= b.To.GetAbsoluteTime()) ||
         (b.From.GetAbsoluteTime() >= a.From.GetAbsoluteTime() && b.To.GetAbsoluteTime() <= a.To.GetAbsoluteTime()))
     {
        return "NESTED";
     }
     else if (a.From.GetAbsoluteTime() < b.To.GetAbsoluteTime() && b.From.GetAbsoluteTime() < a.To.GetAbsoluteTime())
     {
         return "OVERLAP";
     }
     else if (a.To.GetAbsoluteTime() == b.From.GetAbsoluteTime() || b.To.GetAbsoluteTime() == a.From.GetAbsoluteTime())
     {
         return "TOUCH";
     }
     else
     {
         return "DISJOINT";
     }
 }