From 79cfa59cda98f3c39e6d1848bc8a74c504d17898 Mon Sep 17 00:00:00 2001 From: Austin Putland Date: Thu, 21 Jul 2022 19:04:26 -0600 Subject: [PATCH] Add XAML and data binding code for Engineering Notation Remove Auto and Sci enums, and unused toEngineeringNumber function Add Button elements for Auto,SCI,ENG options Add data binding code for Auto,SCI,ENG buttons Add an enum member for Eng. notation command Add EngButton method for sending Eng button command maybe fix merge conflicts Add IDC_ENG case for engineering notation Add the unused toEngineeringNumber function that gets removed later on change automationId to camelCase --- src/CalcManager/CEngine/scicomm.cpp | 7 ++- src/CalcManager/Command.h | 1 + src/CalcManager/Header Files/CCommand.h | 1 + .../Common/CalculatorButtonUser.h | 1 + .../StandardCalculatorViewModel.cpp | 6 ++ .../StandardCalculatorViewModel.h | 1 + .../CalculatorScientificAngleButtons.xaml | 43 +++++++++------ .../CalculatorScientificAngleButtons.xaml.cs | 55 ++++++++++++++++--- 8 files changed, 90 insertions(+), 25 deletions(-) diff --git a/src/CalcManager/CEngine/scicomm.cpp b/src/CalcManager/CEngine/scicomm.cpp index 701fb21c..46bec0a1 100644 --- a/src/CalcManager/CEngine/scicomm.cpp +++ b/src/CalcManager/CEngine/scicomm.cpp @@ -389,7 +389,7 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam) } /* Now branch off to do other commands and functions. */ - switch (wParam) + switch (wParam) //wParam { case IDC_CLEAR: /* Total clear. */ { @@ -780,6 +780,11 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam) DisplayNum(); break; + case IDC_ENG: + m_nFE = NumberFormat::Engineering; + DisplayNum(); + break; + case IDC_EXP: if (m_bRecord && !m_fIntegerMode && m_input.TryBeginExponent()) { diff --git a/src/CalcManager/Command.h b/src/CalcManager/Command.h index 8d27dc79..c6f2b46c 100644 --- a/src/CalcManager/Command.h +++ b/src/CalcManager/Command.h @@ -66,6 +66,7 @@ namespace CalculationManager CommandGRAD = 323, CommandDegrees = 324, CommandHYP = 325, + CommandENG = 326, CommandNULL = 0, diff --git a/src/CalcManager/Header Files/CCommand.h b/src/CalcManager/Header Files/CCommand.h index 2696181a..a56c7757 100644 --- a/src/CalcManager/Header Files/CCommand.h +++ b/src/CalcManager/Header Files/CCommand.h @@ -29,6 +29,7 @@ #define IDM_RAD 322 #define IDM_GRAD 323 #define IDM_DEGREES 324 +#define IDC_ENG 326 #define IDC_HEX IDM_HEX #define IDC_DEC IDM_DEC diff --git a/src/CalcViewModel/Common/CalculatorButtonUser.h b/src/CalcViewModel/Common/CalculatorButtonUser.h index 4885e488..1c64eac6 100644 --- a/src/CalcViewModel/Common/CalculatorButtonUser.h +++ b/src/CalcViewModel/Common/CalculatorButtonUser.h @@ -38,6 +38,7 @@ namespace CalculatorApp::ViewModel::Common Radians = (int)CM::Command::CommandRAD, Grads = (int)CM::Command::CommandGRAD, Degrees = (int)CM::Command::CommandDegrees, + Engineering = (int)CM::Command::CommandENG, OpenParenthesis = (int)CM::Command::CommandOPENP, CloseParenthesis = (int)CM::Command::CommandCLOSEP, Pi = (int)CM::Command::CommandPI, diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index 22554ca6..736497bd 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -448,6 +448,12 @@ void StandardCalculatorViewModel::FtoEButtonToggled() OnButtonPressed(NumbersAndOperatorsEnum::FToE); } +void StandardCalculatorViewModel::EngButton() +{ + OnButtonPressed(NumbersAndOperatorsEnum::Engineering); +} + + void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum) { DisplayExpressionToken ^ displayExpressionToken = ExpressionTokens->GetAt(m_TokenPosition); diff --git a/src/CalcViewModel/StandardCalculatorViewModel.h b/src/CalcViewModel/StandardCalculatorViewModel.h index 0af82478..187b2bf2 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.h +++ b/src/CalcViewModel/StandardCalculatorViewModel.h @@ -258,6 +258,7 @@ namespace CalculatorApp void SetOpenParenthesisCountNarratorAnnouncement(); void SwitchAngleType(CalculatorApp::ViewModel::Common::NumbersAndOperatorsEnum num); void FtoEButtonToggled(); + void EngButton(); internal: void OnPaste(Platform::String ^ pastedString); diff --git a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml index ca30815c..ba3fe1ec 100644 --- a/src/Calculator/Views/CalculatorScientificAngleButtons.xaml +++ b/src/Calculator/Views/CalculatorScientificAngleButtons.xaml @@ -98,21 +98,32 @@ CommandParameter="2" Content="GRAD" Visibility="Collapsed"/> - - - FToE - - + +