diff --git a/README.md b/README.md
index 23afe0de..ffba40c0 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
The Windows Calculator app is a modern Windows app written in C++ that ships pre-installed with Windows.
The app provides standard, scientific, and programmer calculator functionality, as well as a set of converters between various units of measurement and currencies.
-Calculator ships regularly with new features and bug fixes. You can get the latest version of Calculator in the [Microsoft Store.](https://www.microsoft.com/store/apps/9WZDNCRFHVN5)
+Calculator ships regularly with new features and bug fixes. You can get the latest version of Calculator in the [Microsoft Store](https://www.microsoft.com/store/apps/9WZDNCRFHVN5).
[](https://dev.azure.com/ms/calculator/_build/latest?definitionId=57&branchName=master)
@@ -18,14 +18,14 @@ Calculator ships regularly with new features and bug fixes. You can get the late
## Getting started
Prerequisites:
-- Your computer must be running Windows 10, version 1803 or newer
-- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient)
- - Install the "Universal Windows Platform Development" workload
- - Install the optional "C++ Universal Windows Platform tools" component
- - Install the latest Windows 10 SDK
+- Your computer must be running Windows 10, version 1803 or newer.
+- Install the latest version of [Visual Studio](https://developer.microsoft.com/en-us/windows/downloads) (the free community edition is sufficient).
+ - Install the "Universal Windows Platform Development" workload.
+ - Install the optional "C++ Universal Windows Platform tools" component.
+ - Install the latest Windows 10 SDK.

-- Install the [XAML Styler](https://marketplace.visualstudio.com/items?itemName=TeamXavalon.XAMLStyler) Visual Studio extension
+- Install the [XAML Styler](https://marketplace.visualstudio.com/items?itemName=TeamXavalon.XAMLStyler) Visual Studio extension.
- Get the code:
```
diff --git a/internal/Calculator.UIAutomationLibrary/Components/Pages/MainPagePom.cs b/internal/Calculator.UIAutomationLibrary/Components/Pages/MainPagePom.cs
index aecca8f7..7fa70bb9 100644
--- a/internal/Calculator.UIAutomationLibrary/Components/Pages/MainPagePom.cs
+++ b/internal/Calculator.UIAutomationLibrary/Components/Pages/MainPagePom.cs
@@ -11,9 +11,6 @@ namespace Calculator.UIAutomationLibrary.Components
///
/// Physical Object Model for the app window.
/// POM is the implementation model of the app.
- /// See following references to POM:
- /// * https://blogs.msdn.microsoft.com/wltester/2011/11/14/object-model-design/
- /// * https://blogs.msdn.microsoft.com/micahel/2005/06/03/how-do-i-invoke-thee-let-me-count-the-ways-the-physical-object-model/
/// See https://en.wikipedia.org/wiki/Model-based_testing for model-based testing.
///
public class MainPagePom : UIObject
diff --git a/src/.editorconfig b/src/.editorconfig
new file mode 100644
index 00000000..602092c6
--- /dev/null
+++ b/src/.editorconfig
@@ -0,0 +1,10 @@
+root = true
+
+[*.{xaml,cpp,h}]
+charset = utf-8-bom
+indent_style = space
+indent_size = 4
+
+[*.{cpp,h}]
+insert_final_newline = true
+trim_trailing_whitespace = true
diff --git a/src/CalcManager/CEngine/CalcInput.cpp b/src/CalcManager/CEngine/CalcInput.cpp
index f7037aa3..4994e025 100644
--- a/src/CalcManager/CEngine/CalcInput.cpp
+++ b/src/CalcManager/CEngine/CalcInput.cpp
@@ -261,7 +261,7 @@ void CalcInput::SetDecimalSymbol(wchar_t decSymbol)
}
}
-wstring CalcInput::ToString(uint32_t radix, bool isIntegerMode)
+wstring CalcInput::ToString(uint32_t radix)
{
// In theory both the base and exponent could be C_NUM_MAX_DIGITS long.
wstringstream resStream;
diff --git a/src/CalcManager/CEngine/History.cpp b/src/CalcManager/CEngine/History.cpp
index 4056848c..278e4a54 100644
--- a/src/CalcManager/CEngine/History.cpp
+++ b/src/CalcManager/CEngine/History.cpp
@@ -223,11 +223,11 @@ void CHistoryCollector::AddUnaryOpToHistory(int nOpCode, bool fInv, ANGLE_TYPE a
{
angleOpCode = CalculationManager::Command::CommandDEG;
}
- if (angletype == ANGLE_RAD)
+ else if (angletype == ANGLE_RAD)
{
angleOpCode = CalculationManager::Command::CommandRAD;
}
- if (angletype == ANGLE_GRAD)
+ else // (angletype == ANGLE_GRAD)
{
angleOpCode = CalculationManager::Command::CommandGRAD;
}
@@ -428,7 +428,7 @@ void CHistoryCollector::UpdateHistoryExpression(uint32_t radix, int32_t precisio
std::shared_ptr opndCommand = std::static_pointer_cast(expCommand);
if (opndCommand != nullptr)
{
- token.first = opndCommand->GetString(radix, precision, m_decimalSymbol);
+ token.first = opndCommand->GetString(radix, precision);
IFT(m_spTokens->SetAt(i, token));
opndCommand->SetCommands(GetOperandCommandsFromString(token.first));
}
diff --git a/src/CalcManager/CEngine/scidisp.cpp b/src/CalcManager/CEngine/scidisp.cpp
index 431a3990..e01cc239 100644
--- a/src/CalcManager/CEngine/scidisp.cpp
+++ b/src/CalcManager/CEngine/scidisp.cpp
@@ -104,7 +104,7 @@ void CCalcEngine::DisplayNum(void)
if (m_bRecord)
{
// Display the string and return.
- m_numberString = m_input.ToString(m_radix, m_fIntegerMode);
+ m_numberString = m_input.ToString(m_radix);
}
else
{
diff --git a/src/CalcManager/CalcException.h b/src/CalcManager/CalcException.h
index 60d82bbb..e63b1837 100644
--- a/src/CalcManager/CalcException.h
+++ b/src/CalcManager/CalcException.h
@@ -1,7 +1,7 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
+// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-class CalcException : std::exception
+class CalcException : public std::exception
{
public:
CalcException(HRESULT hr)
diff --git a/src/CalcManager/CalcManager.vcxproj b/src/CalcManager/CalcManager.vcxproj
index 4455336c..4a098141 100644
--- a/src/CalcManager/CalcManager.vcxproj
+++ b/src/CalcManager/CalcManager.vcxproj
@@ -155,6 +155,8 @@
true
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
@@ -169,6 +171,8 @@
true
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
@@ -183,6 +187,8 @@
true
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
@@ -197,6 +203,8 @@
true
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
@@ -212,6 +220,8 @@
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
_UNICODE;UNICODE;%(PreprocessorDefinitions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
@@ -226,6 +236,8 @@
true
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
@@ -240,6 +252,8 @@
true
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
@@ -254,6 +268,8 @@
true
/Zm250 /await /std:c++17 /permissive- /Zc:twoPhase- %(AdditionalOptions)
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
+ Level4
+ true
Console
diff --git a/src/CalcManager/CalcManager.vcxproj.filters b/src/CalcManager/CalcManager.vcxproj.filters
index 5ceff3e3..9be2a455 100644
--- a/src/CalcManager/CalcManager.vcxproj.filters
+++ b/src/CalcManager/CalcManager.vcxproj.filters
@@ -136,9 +136,6 @@
Header Files
-
- Header Files
-
diff --git a/src/CalcManager/ExpressionCommand.cpp b/src/CalcManager/ExpressionCommand.cpp
index 914c731a..08ee293c 100644
--- a/src/CalcManager/ExpressionCommand.cpp
+++ b/src/CalcManager/ExpressionCommand.cpp
@@ -135,7 +135,7 @@ void COpndCommand::AppendCommand(int command)
if (command == IDC_PNT)
{
m_fDecimal = true;
-}
+ }
}
void COpndCommand::ToggleSign()
@@ -178,11 +178,11 @@ void COpndCommand::RemoveFromEnd()
if (nOpCode == IDC_PNT)
{
m_fDecimal = false;
- }
+ }
m_commands->RemoveAt(nCommands - 1);
+ }
}
}
-}
bool COpndCommand::IsNegative() const
{
@@ -287,7 +287,7 @@ const wstring & COpndCommand::GetToken(wchar_t decimalSymbol)
return m_token;
}
-wstring COpndCommand::GetString(uint32_t radix, int32_t precision, wchar_t decimalSymbol)
+wstring COpndCommand::GetString(uint32_t radix, int32_t precision)
{
wstring result{};
@@ -303,4 +303,3 @@ void COpndCommand::Accept(_In_ ISerializeCommandVisitor &commandVisitor)
{
commandVisitor.Visit(*this);
}
-
diff --git a/src/CalcManager/ExpressionCommand.h b/src/CalcManager/ExpressionCommand.h
index 0953ab26..2958f4f8 100644
--- a/src/CalcManager/ExpressionCommand.h
+++ b/src/CalcManager/ExpressionCommand.h
@@ -6,47 +6,47 @@
#include "Header Files/CalcEngine.h"
#include "Header Files/Rational.h"
-class CParentheses : public IParenthesisCommand
+class CParentheses final : public IParenthesisCommand
{
public:
CParentheses(_In_ int command);
- int GetCommand() const;
- CalculationManager::CommandType GetCommandType() const;
- void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
+ int GetCommand() const override;
+ CalculationManager::CommandType GetCommandType() const override;
+ void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
private:
int m_command;
};
-class CUnaryCommand : public IUnaryCommand
+class CUnaryCommand final : public IUnaryCommand
{
public:
CUnaryCommand(int command);
CUnaryCommand(int command1, int command2);
- const std::shared_ptr> & GetCommands() const;
- CalculationManager::CommandType GetCommandType() const;
- void SetCommand(int command);
- void SetCommands(int command1, int command2);
- void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
+ const std::shared_ptr> & GetCommands() const override;
+ CalculationManager::CommandType GetCommandType() const override;
+ void SetCommand(int command) override;
+ void SetCommands(int command1, int command2) override;
+ void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
private:
std::shared_ptr> m_command;
};
-class CBinaryCommand : public IBinaryCommand
+class CBinaryCommand final : public IBinaryCommand
{
public:
CBinaryCommand(int command);
- void SetCommand(int command);
- int GetCommand() const;
- CalculationManager::CommandType GetCommandType() const;
- void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
+ void SetCommand(int command) override;
+ int GetCommand() const override;
+ CalculationManager::CommandType GetCommandType() const override;
+ void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
private:
int m_command;
};
-class COpndCommand : public IOpndCommand
+class COpndCommand final : public IOpndCommand
{
public:
COpndCommand(
@@ -56,18 +56,18 @@ public:
bool fSciFmt);
void Initialize(CalcEngine::Rational const& rat);
- const std::shared_ptr> & GetCommands() const;
- void SetCommands(std::shared_ptr> const& commands);
- void AppendCommand(int command);
- void ToggleSign();
- void RemoveFromEnd();
- bool IsNegative() const;
- bool IsSciFmt() const;
- bool IsDecimalPresent() const;
- const std::wstring & GetToken(wchar_t decimalSymbol);
- CalculationManager::CommandType GetCommandType() const;
- void Accept(_In_ ISerializeCommandVisitor &commandVisitor);
- std::wstring GetString(uint32_t radix, int32_t precision, wchar_t decimalSymbol);
+ const std::shared_ptr> & GetCommands() const override;
+ void SetCommands(std::shared_ptr> const& commands) override;
+ void AppendCommand(int command) override;
+ void ToggleSign() override;
+ void RemoveFromEnd() override;
+ bool IsNegative() const override;
+ bool IsSciFmt() const override;
+ bool IsDecimalPresent() const override;
+ const std::wstring & GetToken(wchar_t decimalSymbol) override;
+ CalculationManager::CommandType GetCommandType() const override;
+ void Accept(_In_ ISerializeCommandVisitor &commandVisitor) override;
+ std::wstring GetString(uint32_t radix, int32_t precision);
private:
std::shared_ptr> m_commands;
diff --git a/src/CalcManager/ExpressionCommandInterface.h b/src/CalcManager/ExpressionCommandInterface.h
index bf19bf2f..ce89dd81 100644
--- a/src/CalcManager/ExpressionCommandInterface.h
+++ b/src/CalcManager/ExpressionCommandInterface.h
@@ -30,7 +30,7 @@ public:
class IBinaryCommand : public IOperatorCommand
{
public:
- virtual void SetCommand(int command) = 0;
+ virtual void SetCommand(int command) override = 0;
virtual int GetCommand() const = 0;
};
diff --git a/src/CalcManager/Header Files/CalcInput.h b/src/CalcManager/Header Files/CalcInput.h
index b80651e8..60d628c1 100644
--- a/src/CalcManager/Header Files/CalcInput.h
+++ b/src/CalcManager/Header Files/CalcInput.h
@@ -22,7 +22,7 @@ namespace CalcEngine
bool IsEmpty() { return value.empty(); }
bool IsNegative() { return m_isNegative; }
- void IsNegative(bool value) { m_isNegative = value; }
+ void IsNegative(bool isNegative) { m_isNegative = isNegative; }
std::wstring value;
@@ -53,7 +53,7 @@ namespace CalcEngine
bool TryBeginExponent();
void Backspace();
void SetDecimalSymbol(wchar_t decSymbol);
- std::wstring ToString(uint32_t radix, bool isIntegerMode);
+ std::wstring ToString(uint32_t radix);
Rational ToRational(uint32_t radix, int32_t precision);
private:
diff --git a/src/CalcManager/Ratpack/conv.cpp b/src/CalcManager/Ratpack/conv.cpp
index d7a03195..60ba7555 100644
--- a/src/CalcManager/Ratpack/conv.cpp
+++ b/src/CalcManager/Ratpack/conv.cpp
@@ -566,7 +566,7 @@ wchar_t NormalizeCharDigit(wchar_t c, uint32_t radix)
// is in the range where this is not ambiguous.
if (size_t{ radix } >= DIGITS.find(L'A') && size_t { radix } <= DIGITS.find(L'Z'))
{
- return toupper(c);
+ return towupper(c);
}
return c;
@@ -1057,10 +1057,6 @@ wstring NumberToString(_Inout_ PNUMBER& pnum, int format, uint32_t radix, int32_
length = precision;
}
- // 2 for signs, 1 for 'e'(or leading zero), 1 for dp, 1 for null and
- // 10 for maximum exponent size.
- int cchNum = (precision + 16);
-
// If there is a chance a round has to occur, round.
// - if number is zero no rounding
// - if number of digits is less than the maximum output no rounding
diff --git a/src/CalcManager/Ratpack/rat.cpp b/src/CalcManager/Ratpack/rat.cpp
index 82a116f8..e101458a 100644
--- a/src/CalcManager/Ratpack/rat.cpp
+++ b/src/CalcManager/Ratpack/rat.cpp
@@ -38,7 +38,7 @@ using namespace std;
//
//-----------------------------------------------------------------------------
-void gcdrat( PRAT *pa, uint32_t radix, int32_t precision)
+void gcdrat( PRAT *pa, int32_t precision)
{
PNUMBER pgcd= nullptr;
diff --git a/src/CalcManager/Ratpack/ratpak.h b/src/CalcManager/Ratpack/ratpak.h
index f5a508ee..693380bc 100644
--- a/src/CalcManager/Ratpack/ratpak.h
+++ b/src/CalcManager/Ratpack/ratpak.h
@@ -424,7 +424,7 @@ extern void divrat( _Inout_ PRAT *pa, _In_ PRAT b, int32_t precision);
extern void fracrat( _Inout_ PRAT *pa , uint32_t radix, int32_t precision);
extern void factrat( _Inout_ PRAT *pa, uint32_t radix, int32_t precision);
extern void modrat( _Inout_ PRAT *pa, _In_ PRAT b );
-extern void gcdrat( _Inout_ PRAT *pa, uint32_t radix, int32_t precision);
+extern void gcdrat( _Inout_ PRAT *pa, int32_t precision);
extern void intrat( _Inout_ PRAT *px, uint32_t radix, int32_t precision);
extern void mulnum( _Inout_ PNUMBER *pa, _In_ PNUMBER b, uint32_t radix);
extern void mulnumx( _Inout_ PNUMBER *pa, _In_ PNUMBER b );
diff --git a/src/CalcManager/UnitConverter.cpp b/src/CalcManager/UnitConverter.cpp
index fd371c02..bb1df9d6 100644
--- a/src/CalcManager/UnitConverter.cpp
+++ b/src/CalcManager/UnitConverter.cpp
@@ -302,8 +302,8 @@ wstring UnitConverter::Serialize()
out << std::to_wstring(m_currentHasDecimal) << delimiter << std::to_wstring(m_returnHasDecimal) << delimiter << std::to_wstring(m_switchedActive) << delimiter;
out << m_currentDisplay << delimiter << m_returnDisplay << delimiter << "|";
wstringstream categoryString(wstringstream::out);
- wstringstream categoryToUnitString(wstringstream::out);;
- wstringstream unitToUnitToDoubleString(wstringstream::out);;
+ wstringstream categoryToUnitString(wstringstream::out);
+ wstringstream unitToUnitToDoubleString(wstringstream::out);
for (const Category& c : m_categories)
{
categoryString << CategoryToString(c, delimiter) << ",";
diff --git a/src/CalcViewModel/CalcViewModel.vcxproj b/src/CalcViewModel/CalcViewModel.vcxproj
index 33715487..e2e98ab9 100644
--- a/src/CalcViewModel/CalcViewModel.vcxproj
+++ b/src/CalcViewModel/CalcViewModel.vcxproj
@@ -154,6 +154,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
@@ -172,6 +174,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
@@ -190,6 +194,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
@@ -208,6 +214,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
@@ -226,6 +234,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
@@ -244,6 +254,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
@@ -262,6 +274,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
@@ -280,6 +294,8 @@
$(SolutionDir)..\src\;%(AdditionalIncludeDirectories)
4453
/bigobj /await /std:c++17 %(AdditionalOptions)
+ Level4
+ true
Console
diff --git a/src/CalcViewModel/Common/CopyPasteManager.cpp b/src/CalcViewModel/Common/CopyPasteManager.cpp
index 28210bfb..3b621c2b 100644
--- a/src/CalcViewModel/Common/CopyPasteManager.cpp
+++ b/src/CalcViewModel/Common/CopyPasteManager.cpp
@@ -15,7 +15,6 @@ using namespace Windows::Foundation;
using namespace Windows::System;
using namespace Windows::ApplicationModel::DataTransfer;
-size_t maxOperandLength;
unsigned long long maxOperandNumber;
String^ CopyPasteManager::supportedFormats[] =
@@ -533,7 +532,7 @@ size_t CopyPasteManager::ProgrammerOperandLength(const wstring& operand, int num
suffixes.insert(suffixes.end(), uintSuffixes.begin(), uintSuffixes.end());
wstring operandUpper = operand;
- transform(operandUpper.begin(), operandUpper.end(), operandUpper.begin(), toupper);
+ transform(operandUpper.begin(), operandUpper.end(), operandUpper.begin(), towupper);
// Detect if there is a suffix and subtract its length
// Check suffixes first to allow e.g. "0b" to result in length 1 (value 0), rather than length 0 (no value).
diff --git a/src/CalcViewModel/Common/KeyboardShortcutManager.cpp b/src/CalcViewModel/Common/KeyboardShortcutManager.cpp
index edf02564..a6a82109 100644
--- a/src/CalcViewModel/Common/KeyboardShortcutManager.cpp
+++ b/src/CalcViewModel/Common/KeyboardShortcutManager.cpp
@@ -43,7 +43,6 @@ static multimap> s_VirtualKeyControlS
static multimap> s_VirtualKeyInverseChordsForButtons;
static multimap> s_VirtualKeyControlInverseChordsForButtons;
-static const TimeSpan c_lightUpTime = { 500000 }; // Quarter of a second
static multimap s_ShiftKeyPressed;
static multimap s_ControlKeyPressed;
static multimap s_ShiftButtonChecked;
@@ -88,7 +87,15 @@ namespace CalculatorApp
// This timer will only fire once after which it will be destroyed
auto timer = ref new DispatcherTimer();
timer->Interval = c_lightUpTime;
-
+
+ // This timer will fire after lightUpTime and make the button
+ // go back to the normal state.
+ // This timer will only fire once after which it will be destroyed
+ auto timer = ref new DispatcherTimer();
+ TimeSpan lightUpTime{};
+ lightUpTime.Duration = 500000L; // Half second (in 100-ns units)
+ timer->Interval = lightUpTime;
+
WeakReference timerWeakReference(timer);
WeakReference buttonWeakReference(button);
timer->Tick += ref new EventHandler