mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-24 06:55:19 -07:00
Merge branch 'master' into polymorphic
This commit is contained in:
commit
32797b05dc
9 changed files with 13 additions and 16 deletions
|
@ -87,7 +87,7 @@ The ViewModel layer is contained in the [CalcViewModel][CalcViewModel folder] pr
|
||||||
data for the UI to bind against and act as the intermediary separating pure business logic from UI components that
|
data for the UI to bind against and act as the intermediary separating pure business logic from UI components that
|
||||||
should not care about the model's implementation. Just as the View layer consists of a hierarchy of XAML files, the
|
should not care about the model's implementation. Just as the View layer consists of a hierarchy of XAML files, the
|
||||||
ViewModel consists of a hierarchy of ViewModel files. The relationship between XAML and ViewModel files is often 1:1.
|
ViewModel consists of a hierarchy of ViewModel files. The relationship between XAML and ViewModel files is often 1:1.
|
||||||
Here are the noteable ViewModel files to start exploring with:
|
Here are the notable ViewModel files to start exploring with:
|
||||||
|
|
||||||
* [ApplicationViewModel.h][ApplicationViewModel.h]: The ViewModel for [MainPage.xaml][MainPage.xaml]. This ViewModel
|
* [ApplicationViewModel.h][ApplicationViewModel.h]: The ViewModel for [MainPage.xaml][MainPage.xaml]. This ViewModel
|
||||||
is the root of the other mode-specific ViewModels. The application changes between modes by updating the `Mode` property
|
is the root of the other mode-specific ViewModels. The application changes between modes by updating the `Mode` property
|
||||||
|
@ -199,4 +199,4 @@ The RatPack (short for Rational Pack) is the core of the Calculator model and co
|
||||||
[CalcManager folder]: ../src/CalcManager
|
[CalcManager folder]: ../src/CalcManager
|
||||||
[CalculatorManager.h]: ../src/CalcManager/CalculatorManager.h
|
[CalculatorManager.h]: ../src/CalcManager/CalculatorManager.h
|
||||||
[CalcEngine.h]: ../src/CalcManager/Header Files/CalcEngine.h
|
[CalcEngine.h]: ../src/CalcManager/Header Files/CalcEngine.h
|
||||||
[ratpak.h]: ../src/CalcManager/Ratpack/ratpak.h
|
[ratpak.h]: ../src/CalcManager/Ratpack/ratpak.h
|
||||||
|
|
|
@ -161,7 +161,7 @@ void CHistoryCollector::PopLastOpndStart()
|
||||||
|
|
||||||
void CHistoryCollector::AddOpenBraceToHistory()
|
void CHistoryCollector::AddOpenBraceToHistory()
|
||||||
{
|
{
|
||||||
int iCommandEnd = AddCommand(std::make_shared<CParentheses>(IDC_OPENP));
|
AddCommand(std::make_shared<CParentheses>(IDC_OPENP));
|
||||||
int ichOpndStart = IchAddSzToEquationSz(CCalcEngine::OpCodeToString(IDC_OPENP), -1);
|
int ichOpndStart = IchAddSzToEquationSz(CCalcEngine::OpCodeToString(IDC_OPENP), -1);
|
||||||
PushLastOpndStart(ichOpndStart);
|
PushLastOpndStart(ichOpndStart);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void CHistoryCollector::AddOpenBraceToHistory()
|
||||||
|
|
||||||
void CHistoryCollector::AddCloseBraceToHistory()
|
void CHistoryCollector::AddCloseBraceToHistory()
|
||||||
{
|
{
|
||||||
int iCommandEnd = AddCommand(std::make_shared<CParentheses>(IDC_CLOSEP));
|
AddCommand(std::make_shared<CParentheses>(IDC_CLOSEP));
|
||||||
IchAddSzToEquationSz(CCalcEngine::OpCodeToString(IDC_CLOSEP), -1);
|
IchAddSzToEquationSz(CCalcEngine::OpCodeToString(IDC_CLOSEP), -1);
|
||||||
SetExpressionDisplay();
|
SetExpressionDisplay();
|
||||||
PopLastOpndStart();
|
PopLastOpndStart();
|
||||||
|
@ -450,20 +450,16 @@ std::shared_ptr<CalculatorVector<int>> CHistoryCollector::GetOperandCommandsFrom
|
||||||
std::shared_ptr<CalculatorVector<int>> commands = std::make_shared<CalculatorVector<int>>();
|
std::shared_ptr<CalculatorVector<int>> commands = std::make_shared<CalculatorVector<int>>();
|
||||||
// Check for negate
|
// Check for negate
|
||||||
bool fNegative = (numStr[0] == L'-');
|
bool fNegative = (numStr[0] == L'-');
|
||||||
bool fSciFmt = false;
|
|
||||||
bool fDecimal = false;
|
|
||||||
|
|
||||||
for (size_t i = (fNegative ? 1 : 0); i < numStr.length(); i++)
|
for (size_t i = (fNegative ? 1 : 0); i < numStr.length(); i++)
|
||||||
{
|
{
|
||||||
if (numStr[i] == m_decimalSymbol)
|
if (numStr[i] == m_decimalSymbol)
|
||||||
{
|
{
|
||||||
IFT(commands->Append(IDC_PNT));
|
IFT(commands->Append(IDC_PNT));
|
||||||
fDecimal = true;
|
|
||||||
}
|
}
|
||||||
else if (numStr[i] == L'e')
|
else if (numStr[i] == L'e')
|
||||||
{
|
{
|
||||||
IFT(commands->Append(IDC_EXP));
|
IFT(commands->Append(IDC_EXP));
|
||||||
fSciFmt = true;
|
|
||||||
}
|
}
|
||||||
else if (numStr[i] == L'-')
|
else if (numStr[i] == L'-')
|
||||||
{
|
{
|
||||||
|
|
|
@ -173,6 +173,7 @@ CalcEngine::Rational CCalcEngine::SciCalcFunctions(CalcEngine::Rational const& r
|
||||||
// the degrees functionality was achieved as 'Inv' of 'dms' operation,
|
// the degrees functionality was achieved as 'Inv' of 'dms' operation,
|
||||||
// so setting the IDC_INV command first and then performing 'dms' operation as global variables m_bInv, m_bRecord
|
// so setting the IDC_INV command first and then performing 'dms' operation as global variables m_bInv, m_bRecord
|
||||||
// are set properly through ProcessCommand(IDC_INV)
|
// are set properly through ProcessCommand(IDC_INV)
|
||||||
|
[[fallthrough]];
|
||||||
case IDC_DMS:
|
case IDC_DMS:
|
||||||
{
|
{
|
||||||
if (!m_fIntegerMode)
|
if (!m_fIntegerMode)
|
||||||
|
|
|
@ -903,7 +903,7 @@ shared_ptr<IConverterDataLoader> UnitConverter::GetDataLoaderForCategory(const C
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the intial values for m_fromType and m_toType.
|
/// Sets the initial values for m_fromType and m_toType.
|
||||||
/// This is an internal helper method as opposed to SetCurrentUnits
|
/// This is an internal helper method as opposed to SetCurrentUnits
|
||||||
/// which is for external use by clients.
|
/// which is for external use by clients.
|
||||||
/// If we fail to set units, we will fallback to the EMPTY_UNIT.
|
/// If we fail to set units, we will fallback to the EMPTY_UNIT.
|
||||||
|
|
|
@ -441,8 +441,8 @@ void KeyboardShortcutManager::OnVirtualKeyControlInverseChordPropertyChanged(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In the three event handlers bellow we will not mark the event as handled
|
// In the three event handlers below we will not mark the event as handled
|
||||||
// because this is a sumplemental operation and we don't want to interfere with
|
// because this is a supplemental operation and we don't want to interfere with
|
||||||
// the normal keyboard handling.
|
// the normal keyboard handling.
|
||||||
void KeyboardShortcutManager::OnCharacterReceivedHandler(CoreWindow^ sender, CharacterReceivedEventArgs^ args)
|
void KeyboardShortcutManager::OnCharacterReceivedHandler(CoreWindow^ sender, CharacterReceivedEventArgs^ args)
|
||||||
{
|
{
|
||||||
|
|
|
@ -398,7 +398,7 @@ namespace Utils
|
||||||
static void On##name##PropertyChangedImpl(Windows::UI::Xaml::DependencyObject^ sender, Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ args) {\
|
static void On##name##PropertyChangedImpl(Windows::UI::Xaml::DependencyObject^ sender, Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ args) {\
|
||||||
On##name##PropertyChanged(sender, safe_cast<type>(args->OldValue), safe_cast<type>(args->NewValue)); } public:
|
On##name##PropertyChanged(sender, safe_cast<type>(args->OldValue), safe_cast<type>(args->NewValue)); } public:
|
||||||
|
|
||||||
// This goes into the cpp to initalize the static variable
|
// This goes into the cpp to initialize the static variable
|
||||||
#define DEPENDENCY_PROPERTY_INITIALIZATION(owner, name)\
|
#define DEPENDENCY_PROPERTY_INITIALIZATION(owner, name)\
|
||||||
Windows::UI::Xaml::DependencyProperty^ owner::s_##name##Property =\
|
Windows::UI::Xaml::DependencyProperty^ owner::s_##name##Property =\
|
||||||
owner::Initialize##name##Property();
|
owner::Initialize##name##Property();
|
||||||
|
|
|
@ -103,13 +103,13 @@ void SupplementaryResults::OnConverterPropertyChanged(Object^ /*sender*/, Proper
|
||||||
|
|
||||||
void SupplementaryResults::OnWindowSizeChanged(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e)
|
void SupplementaryResults::OnWindowSizeChanged(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e)
|
||||||
{
|
{
|
||||||
// to reload supplementary results everytime the window is resized
|
// to reload supplementary results every time the window is resized
|
||||||
RefreshData();
|
RefreshData();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SupplementaryResults::OnSupplementaryValuesLayoutUpdated(Platform::Object^ sender, Platform::Object^ e)
|
void SupplementaryResults::OnSupplementaryValuesLayoutUpdated(Platform::Object^ sender, Platform::Object^ e)
|
||||||
{
|
{
|
||||||
// This means we overflowed and are cutting off, or in a very rare case we fit exactly. Unforunately
|
// This means we overflowed and are cutting off, or in a very rare case we fit exactly. Unfortunately
|
||||||
// the fitting exactly case will still have an item removed, as there is no other way for us to
|
// the fitting exactly case will still have an item removed, as there is no other way for us to
|
||||||
// detect that we need to trim.
|
// detect that we need to trim.
|
||||||
Grid^ parentGrid = dynamic_cast<Grid^>(VisualTreeHelper::GetParent(this));
|
Grid^ parentGrid = dynamic_cast<Grid^>(VisualTreeHelper::GetParent(this));
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace CalculatorUnitTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform calculations on diferent calculator modes and verify that they work independently
|
// Perform calculations on different calculator modes and verify that they work independently
|
||||||
TEST_METHOD(MultipleModesCalculationTest)
|
TEST_METHOD(MultipleModesCalculationTest)
|
||||||
{
|
{
|
||||||
std::vector<StandardCalculatorViewModel^> viewModels(3);
|
std::vector<StandardCalculatorViewModel^> viewModels(3);
|
||||||
|
|
|
@ -509,7 +509,7 @@ namespace CalculatorUnitTests
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch Calculator Mode and verify if mode switch is happening as expected.
|
// Switch Calculator Mode and verify if mode switch is happening as expected.
|
||||||
// Test precendence to check if mode switch is happening
|
// Test precedence to check if mode switch is happening
|
||||||
// Standard mode 1+2*3 = 9; Scientific mode 1+2*3 = 7
|
// Standard mode 1+2*3 = 9; Scientific mode 1+2*3 = 7
|
||||||
// Intermediate value is also different. after 1 + 2 * , standard shows 3, scientific shows 2
|
// Intermediate value is also different. after 1 + 2 * , standard shows 3, scientific shows 2
|
||||||
TEST_METHOD(ButtonPressedCalculatorModeSwitch)
|
TEST_METHOD(ButtonPressedCalculatorModeSwitch)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue