private void OnMemoryClick(object sender, EventArgs e) { Button b = (Button)sender; string memoryClick = b.Text; if (String.IsNullOrEmpty(_shownText)) { _messageBoxDisplayService.Show("You can not use an invalid value!"); } else { switch (memoryClick) { case "MC": string message = "Do you want to empty the memory"; string title = "Memory Clear"; bool clearMemoryStored = _messageBoxDisplayService.PromptUser(message, title); if (clearMemoryStored) { _calculatorEngine.MemoryClear(); } break; case "MR": _shownText = FormatShownText(_calculatorEngine.MemoryRestore()); _calculatorView.SetResultBoxText(_shownText); break; case "MS": _calculatorEngine.MemoryStore(decimal.Parse(_shownText)); break; case "M+": try { _calculatorEngine.MemoryAdd(Convert.ToDecimal(_shownText)); } catch (FormatException formatEx) { _messageBoxDisplayService.Show(formatEx.Message); } break; case "M-": try { _calculatorEngine.MemoryDiff(Convert.ToDecimal(_shownText)); } catch (FormatException formatEx) { _messageBoxDisplayService.Show(formatEx.Message); } break; case "M": _calculatorView.MemoryButtonShow(FormatShownText(_calculatorEngine.MemoryShow())); break; } if (!_calculatorEngine.HasMemoryStored) { _calculatorView.DisableMemoryButtons(); } else { _calculatorView.EnableMemoryButtons(); } } }