コード例 #1
0
 void ConvertCommandExecute()
 {
     if (FirstValue.Trim() == null)
     {
         MessageBox.Show("You must enter a value.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         if (FirstLabel == "Arabic")
         {
             int number = 0;
             try
             {
                 number = int.Parse(FirstValue.Trim());
                 if (number < 1)
                 {
                     MessageBox.Show("You can not enter a negative value", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
                 else
                 {
                     arabic      = new Arabic(FirstValue);
                     SecondValue = arabic.ConvertToRoman(number);
                 }
             }
             catch (Exception)
             {
                 MessageBox.Show("You did not enter an arabic number, try again.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         else if (FirstLabel == "Roman")
         {
             String number = FirstValue.Trim();
             roman       = new Roman(FirstValue);
             SecondValue = roman.ConvertToArabic();
         }
     }
 }