Exemple #1
0
 private void DisplayChange(object sender, RoutedEventArgs e)
 {
     string message = "Complex, Vector, Fraction and Matrix values not supported";
     var s = (sender as MenuItem)?.Name;
     try
     {
         switch (s)
         {
             case "DispNumSys":
                 var nd = new NumberSystemDisplayDialog();
                 nd.SetDisplay(Engine.Ans);
                 MainWindow.ShowDialog(nd);
                 return;
             case "DispText":
                 var ntd = new NumberToTextDialog();
                 ntd.SetNumber(Engine.Ans);
                 MainWindow.ShowDialog(ntd);
                 return;
             case "DispFractions":
                 if (!Helpers.IsSpecialType(Engine.Ans))
                 {
                     var f = new Fraction((double)Engine.Ans);
                     message = f.ToString();
                 }
                 break;
             case "DispFileSize":
                 if (!Helpers.IsSpecialType(Engine.Ans))
                 {
                     double x = Convert.ToDouble(Engine.Ans);
                     message = Helpers.DivideToFileSize(x);
                 }
                 break;
             case "DispPercent":
                 if (!Helpers.IsSpecialType(Engine.Ans))
                 {
                     double x = Convert.ToDouble(Engine.Ans);
                     x *= 100;
                     message = string.Format("{0}%", x);
                 }
                 break;
             case "DispPrefixes":
                 if (!Helpers.IsSpecialType(Engine.Ans))
                 {
                     var prefixes = new PrefixDictionary();
                     double x = Convert.ToDouble(Engine.Ans);
                     message = prefixes.DivideToPrefix(x);
                 }
                 break;
             default:
                 message = "Operation is not yet implemented in code. Sorry";
                 break;
         }
     }
     catch (Exception)
     {
         message = "Operation is not possible";
     }
     MainWindow.ShowDialog("Result as Fraction", message, MahApps.Metro.Controls.Dialogs.MessageDialogStyle.Affirmative);
 }
Exemple #2
0
        private void DisplayChange(object sender, RoutedEventArgs e)
        {
            string message = "Complex, Vector, Fraction and Matrix values not supported";
            var    s       = (sender as MenuItem)?.Name;

            try
            {
                switch (s)
                {
                case "DispNumSys":
                    var nd = new NumberSystemDisplayDialog();
                    nd.SetDisplay(Engine.Ans);
                    MainWindow.ShowDialog(nd);
                    return;

                case "DispText":
                    var ntd = new NumberToTextDialog();
                    ntd.SetNumber(Engine.Ans);
                    MainWindow.ShowDialog(ntd);
                    return;

                case "DispFractions":
                    if (!Helpers.IsSpecialType(Engine.Ans))
                    {
                        var f = new Fraction((double)Engine.Ans);
                        message = f.ToString();
                    }
                    break;

                case "DispFileSize":
                    if (!Helpers.IsSpecialType(Engine.Ans))
                    {
                        double x = Convert.ToDouble(Engine.Ans);
                        message = Helpers.DivideToFileSize(x);
                    }
                    break;

                case "DispPercent":
                    if (!Helpers.IsSpecialType(Engine.Ans))
                    {
                        double x = Convert.ToDouble(Engine.Ans);
                        x      *= 100;
                        message = string.Format("{0}%", x);
                    }
                    break;

                case "DispPrefixes":
                    if (!Helpers.IsSpecialType(Engine.Ans))
                    {
                        var    prefixes = new PrefixDictionary();
                        double x        = Convert.ToDouble(Engine.Ans);
                        message = prefixes.DivideToPrefix(x);
                    }
                    break;

                default:
                    message = "Operation is not yet implemented in code. Sorry";
                    break;
                }
            }
            catch (Exception)
            {
                message = "Operation is not possible";
            }
            MainWindow.ShowDialog("Result as Fraction", message, MahApps.Metro.Controls.Dialogs.MessageDialogStyle.Affirmative);
        }