mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-21 22:03:11 -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
|
||||
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.
|
||||
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
|
||||
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
|
||||
[CalculatorManager.h]: ../src/CalcManager/CalculatorManager.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()
|
||||
{
|
||||
int iCommandEnd = AddCommand(std::make_shared<CParentheses>(IDC_OPENP));
|
||||
AddCommand(std::make_shared<CParentheses>(IDC_OPENP));
|
||||
int ichOpndStart = IchAddSzToEquationSz(CCalcEngine::OpCodeToString(IDC_OPENP), -1);
|
||||
PushLastOpndStart(ichOpndStart);
|
||||
|
||||
|
@ -171,7 +171,7 @@ void CHistoryCollector::AddOpenBraceToHistory()
|
|||
|
||||
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);
|
||||
SetExpressionDisplay();
|
||||
PopLastOpndStart();
|
||||
|
@ -450,20 +450,16 @@ std::shared_ptr<CalculatorVector<int>> CHistoryCollector::GetOperandCommandsFrom
|
|||
std::shared_ptr<CalculatorVector<int>> commands = std::make_shared<CalculatorVector<int>>();
|
||||
// Check for negate
|
||||
bool fNegative = (numStr[0] == L'-');
|
||||
bool fSciFmt = false;
|
||||
bool fDecimal = false;
|
||||
|
||||
for (size_t i = (fNegative ? 1 : 0); i < numStr.length(); i++)
|
||||
{
|
||||
if (numStr[i] == m_decimalSymbol)
|
||||
{
|
||||
IFT(commands->Append(IDC_PNT));
|
||||
fDecimal = true;
|
||||
}
|
||||
else if (numStr[i] == L'e')
|
||||
{
|
||||
IFT(commands->Append(IDC_EXP));
|
||||
fSciFmt = true;
|
||||
}
|
||||
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,
|
||||
// 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)
|
||||
[[fallthrough]];
|
||||
case IDC_DMS:
|
||||
{
|
||||
if (!m_fIntegerMode)
|
||||
|
|
|
@ -903,7 +903,7 @@ shared_ptr<IConverterDataLoader> UnitConverter::GetDataLoaderForCategory(const C
|
|||
}
|
||||
|
||||
/// <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
|
||||
/// which is for external use by clients.
|
||||
/// 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
|
||||
// because this is a sumplemental operation and we don't want to interfere with
|
||||
// In the three event handlers below we will not mark the event as handled
|
||||
// because this is a supplemental operation and we don't want to interfere with
|
||||
// the normal keyboard handling.
|
||||
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) {\
|
||||
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)\
|
||||
Windows::UI::Xaml::DependencyProperty^ owner::s_##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)
|
||||
{
|
||||
// to reload supplementary results everytime the window is resized
|
||||
// to reload supplementary results every time the window is resized
|
||||
RefreshData();
|
||||
}
|
||||
|
||||
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
|
||||
// detect that we need to trim.
|
||||
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)
|
||||
{
|
||||
std::vector<StandardCalculatorViewModel^> viewModels(3);
|
||||
|
|
|
@ -509,7 +509,7 @@ namespace CalculatorUnitTests
|
|||
}
|
||||
|
||||
// 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
|
||||
// Intermediate value is also different. after 1 + 2 * , standard shows 3, scientific shows 2
|
||||
TEST_METHOD(ButtonPressedCalculatorModeSwitch)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue