protected virtual void OnCurrentModeChanged(EventArgs args)
        {
            if (ConversionPanel.Visible == true)
            {
                string[] items = CurrentMode switch
                {
                    CalculatorMode.Developer => new string[4]
                    {
                        Texts.GetString("BIN"),
                        Texts.GetString("OCT"),
                        Texts.GetString("DEC"),
                        Texts.GetString("HEX")
                    },
                    CalculatorMode.Degrees => new string[3]
                    {
                        Texts.GetString("Celsius"),
                        Texts.GetString("Fahrenheit"),
                        Texts.GetString("Kelvin")
                    },
                    _ => throw new InvalidEnumArgumentException(nameof(CurrentMode), 0, typeof(CalculatorMode)),
                };
                FromComboBox.Items.Clear();
                FromComboBox.Items.AddRange(items);
                FromComboBox.SelectedIndex = 0;

                ToComboBox.Items.Clear();
                ToComboBox.Items.AddRange(items);
                ToComboBox.SelectedIndex = 1;
            }

            EventHandler handler = CurrentModeChanged;

            handler?.Invoke(this, args);
        }
Exemple #2
0
 public static void ShowWarning(IWin32Window parent, string message, string helpPath)
 {
     if (string.IsNullOrWhiteSpace(helpPath))
     {
         MessageBox.Show(parent, message, Texts.GetString("Warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, Constants.GetMessageBoxOptions());
     }
     MessageBox.Show(parent, message, Texts.GetString("Warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, Constants.GetMessageBoxOptions(), helpPath);
 }
        private void MainForm_TextChanged(object sender, EventArgs e)
        {
            string caption = Texts.GetString("Name");

            if (Text != caption)
            {
                Text = caption;
            }
        }
Exemple #4
0
 public static void ShowHelp(IWin32Window parent, string helpText, string helpPath)
 {
     if (helpPath == null)
     {
         MessageBox.Show(parent, helpText, Texts.GetString("Help"), MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, Constants.GetMessageBoxOptions());
     }
     else
     {
         MessageBox.Show(parent, helpText, Texts.GetString("Help"), MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, Constants.GetMessageBoxOptions(), helpPath);
     }
 }
Exemple #5
0
        public static void ThrowError(ApplicationErrors error, params object[] data)
        {
#if DEBUG
            SmartCalculatorException ex = GetException(error, data);
            if (ex.Message.StartsWith("Unknown error, "))
            {
                LogException(ex);
            }
            throw ex;
#else
            ShowError(null, Texts.GetString(error.ToString()), Constants.ReadMeFileName);
#endif
        }
Exemple #6
0
 public static SmartCalculatorException GetException(ApplicationErrors error, params object[] data)
 {
     return(error switch
     {
         ApplicationErrors.ConversionError => new ConversionException(Program.MainForm.CurrentModeComboBox.SelectedItem.ToString()),
         ApplicationErrors.CalculatingError => new CalculatingException(Texts.GetString(error.ToString()))
         {
             HelpLink = Constants.ReadMeFileName
         },
         ApplicationErrors.OperationError => new SmartCalculatorException(Program.MainForm),
         ApplicationErrors.ReadingFileError => new ReadingFileException("ReadingFileError", data[0].ToString()),
         ApplicationErrors.UnknownError => new SmartCalculatorException("Unknown error, Send to [email protected]")
         {
             Window = Form.ActiveForm
         },
         _ => throw new ArgumentException("Not supported error!", nameof(error)),
     });
        private bool ParseOperation(string oper)
        {
            if (Result == null)
            {
                ClearResult();
            }
            if (!ApplyOperation)
            {
                if (ApplyMinus && oper == "-")
                {
                    MathExeprission += oper;
                    ApplyMinus       = false;
                }
                return(false);
            }

            foreach (string operation in AppliedOperations)
            {
                if (oper == operation)
                {
                    goto Next;
                }
            }
#if DEBUG
            throw new ArgumentException("Not Applied operation!", nameof(oper));
#else
            Error.ShowError(this, Texts.GetString("OperationError"), Constants.ReadMeFileName);
#endif

Next:
            if (!string.IsNullOrEmpty(ResultLabel.Text))
            {
                MathExeprission  = ResultLabel.Text;
                ResultLabel.Text = "";
            }

            string operText = $" {oper} ";
            MathExeprission += operText;
            ApplyOperation   = false;
            ApplyDot         = true;
            ApplyMinus       = true;
            return(true);
        }
 private void VariablesForm_HelpButtonClicked(object sender, CancelEventArgs e)
 {
     Helper.ShowHelp(this, Texts.GetString(Constants.GetHelpKey(AvaliableWindows.VariablesForm)), Constants.ReadMeFileName);
 }
Exemple #9
0
 public static DialogResult AreYouSure(IWin32Window parent, string text, MessageBoxDefaultButton defaultButton)
 {
     return(MessageBox.Show(parent, text, Texts.GetString("AreYouSure"), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, defaultButton, ArabicMessageOptions));
 }
 protected void ShowError(ApplicationErrors error)
 {
     ResultLabel.Text      = Texts.GetString(error.ToString());
     ResultLabel.BackColor = Color.Red;
     CurrentError          = error;
 }
Exemple #11
0
 private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     Error.ShowError(null, Texts.GetString("AreYouSure"), "mailto:[email protected]");
 }
Exemple #12
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     Error.ShowError(null, Texts.GetString("AreYouSure"), "mailto:[email protected]");
     Exception ex = e.ExceptionObject as Exception;
 }
Exemple #13
0
 public CalculatingException() : base(Texts.GetString("CalculatingError"))
 {
 }