Secondary formatting changes (#489)

Description of the changes:
Adjusted some of the values in .clang-format
Add clang-format-all.ps1
Fix path to .clang-format in Calculator.sln

How changes were validated:
Manual.
This commit is contained in:
Daniel Belcher 2019-05-02 16:48:33 -07:00 committed by GitHub
parent 2826d37056
commit 9f01c8168b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
113 changed files with 1780 additions and 819 deletions

View file

@ -1,11 +1,11 @@
AccessModifierOffset: -4 AccessModifierOffset: -4
AlignAfterOpenBracket: Align AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right AlignEscapedNewlines: Right
AlignOperands: true AlignOperands: true
AlignTrailingComments: true AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None AllowShortFunctionsOnASingleLine: None
@ -15,8 +15,8 @@ AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true AlwaysBreakTemplateDeclarations: true
BinPackArguments: true BinPackArguments: false
BinPackParameters: true BinPackParameters: false
BreakBeforeBinaryOperators: NonAssignment BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Allman BreakBeforeBraces: Allman
BreakBeforeInheritanceComma: false BreakBeforeInheritanceComma: false
@ -28,7 +28,7 @@ BreakStringLiterals: true
ColumnLimit: 160 ColumnLimit: 160
CommentPragmas: '^ IWYU pragma:' CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: true CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4 ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4 ContinuationIndentWidth: 4
Cpp11BracedListStyle: false Cpp11BracedListStyle: false

View file

@ -0,0 +1,91 @@
<#
.DESCRIPTION
Helper script to format all header and source files in the repository.
By default, the script will recursively search under the repo root for
files to format. Users can give explicit parameters indicating how the
search should include and exclude filetypes.
If users don't want the search functionality, they can instead provide
an explicit list of files to format.
.PARAMETER RepoRoot
Full path to the root of the repository which is the target of the search.
Will default to the root of the current working directory.
.PARAMETER Include
Array of filetype extensions to target for formatting.
By default, targets standard extensions for header and source files.
Follows the same rules as the -Include parameter for Get-ChildItem.
.PARAMETER Exclude
Array of filetype extensions to exclude from formatting.
By default, excludes generated XAML files.
Follows the same rules as the -Exclude paramter for Get-ChildItem.
.PARAMETER Files
Array of files to format. The script will exit if one of the provided
filepaths does not exist.
.EXAMPLE
.\clang-format-all.ps1
Formats all header and source files under the repository root.
.EXAMPLE
.\clang-format-all.ps1 -RepoRoot 'S:\repos\calculator' -Include '*.h', '*.cpp' -Exclude '*.g.*'
Formats all *.h and *.cpp files under 'S:\repos\calculator', excluding files with an extension
like *.g.*
.EXAMPLE
.\clang-format-all.ps1 -File 'S:\repos\calculator\src\CalcViewModel\UnitConverterViewModel.h', 'S:\repos\calculator\src\CalcViewModel\MemoryItemViewModel.cpp'
Formats the specified files.
#>
[CmdletBinding( DefaultParameterSetName = 'Search' )]
param(
[Parameter( ParameterSetName = 'Search' )]
[ValidateScript({ Test-Path -PathType Container -Path $_ })]
[string] $RepoRoot = "$( git rev-parse --show-toplevel )",
[Parameter( ParameterSetName = 'Search' )]
[string[]] $Include = ( '*.h', '*.hh', '*.hpp', '*.c', '*.cc', '*.cpp' ),
[Parameter( ParameterSetName = 'Search' )]
[string[]] $Exclude = '*.g.*',
[Parameter(
ParameterSetName = 'Explicit',
Mandatory)]
[ValidateScript({
$_ | Where-Object { -not (Test-Path -PathType Leaf -Path $_) } |
ForEach-Object { throw "Could not find file: [$_]" }
return $true
})]
[string[]] $Files
)
if ($PSCmdlet.ParameterSetName -eq 'Explicit')
{
# Use the file paths we were given.
$targetFiles = @($Files)
}
else
{
# Gather the files to be formatted.
$targetFiles = @(
Get-ChildItem -Recurse -Path $RepoRoot -Include $Include -Exclude $Exclude |
Select-Object -ExpandProperty FullName
)
}
# Format the files.
$formatParams = @(
'-i' # In-place
'-style=file' # Search for a .clang-format file in the parent directory of the source file.
'-verbose'
)
clang-format $formatParams $targetFiles

View file

@ -40,7 +40,10 @@ void CHistoryCollector::ReinitHistory()
// Constructor // Constructor
// Can throw Out of memory error // Can throw Out of memory error
CHistoryCollector::CHistoryCollector(ICalcDisplay* pCalcDisplay, std::shared_ptr<IHistoryDisplay> pHistoryDisplay, wchar_t decimalSymbol) CHistoryCollector::CHistoryCollector(ICalcDisplay* pCalcDisplay, std::shared_ptr<IHistoryDisplay> pHistoryDisplay, wchar_t decimalSymbol)
: m_pHistoryDisplay(pHistoryDisplay), m_pCalcDisplay(pCalcDisplay), m_iCurLineHistStart(-1), m_decimalSymbol(decimalSymbol) : m_pHistoryDisplay(pHistoryDisplay)
, m_pCalcDisplay(pCalcDisplay)
, m_iCurLineHistStart(-1)
, m_decimalSymbol(decimalSymbol)
{ {
ReinitHistory(); ReinitHistory();
} }
@ -300,8 +303,8 @@ void CHistoryCollector::CompleteHistoryLine(wstring_view numStr)
{ {
if (nullptr != m_pCalcDisplay) if (nullptr != m_pCalcDisplay)
{ {
m_pCalcDisplay->SetExpressionDisplay(std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), m_pCalcDisplay->SetExpressionDisplay(
std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>()); std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
} }
if (nullptr != m_pHistoryDisplay) if (nullptr != m_pHistoryDisplay)
@ -322,8 +325,8 @@ void CHistoryCollector::ClearHistoryLine(wstring_view errStr)
{ {
if (nullptr != m_pCalcDisplay) if (nullptr != m_pCalcDisplay)
{ {
m_pCalcDisplay->SetExpressionDisplay(std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), m_pCalcDisplay->SetExpressionDisplay(
std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>()); std::make_shared<CalculatorVector<std::pair<std::wstring, int>>>(), std::make_shared<CalculatorVector<std::shared_ptr<IExpressionCommand>>>());
} }
m_iCurLineHistStart = -1; // It will get recomputed at the first Opnd m_iCurLineHistStart = -1; // It will get recomputed at the first Opnd
ReinitHistory(); ReinitHistory();

View file

@ -7,15 +7,22 @@ using namespace std;
namespace CalcEngine namespace CalcEngine
{ {
Number::Number() noexcept : Number(1, 0, { 0 }) Number::Number() noexcept
: Number(1, 0, { 0 })
{ {
} }
Number::Number(int32_t sign, int32_t exp, vector<uint32_t> const& mantissa) noexcept : m_sign{ sign }, m_exp{ exp }, m_mantissa{ mantissa } Number::Number(int32_t sign, int32_t exp, vector<uint32_t> const& mantissa) noexcept
: m_sign{ sign }
, m_exp{ exp }
, m_mantissa{ mantissa }
{ {
} }
Number::Number(PNUMBER p) noexcept : m_sign{ p->sign }, m_exp{ p->exp }, m_mantissa{} Number::Number(PNUMBER p) noexcept
: m_sign{ p->sign }
, m_exp{ p->exp }
, m_mantissa{}
{ {
m_mantissa.reserve(p->cdigit); m_mantissa.reserve(p->cdigit);
copy(p->mant, p->mant + p->cdigit, back_inserter(m_mantissa)); copy(p->mant, p->mant + p->cdigit, back_inserter(m_mantissa));

View file

@ -7,7 +7,9 @@ using namespace std;
namespace CalcEngine namespace CalcEngine
{ {
Rational::Rational() noexcept : m_p{}, m_q{ 1, 0, { 1 } } Rational::Rational() noexcept
: m_p{}
, m_q{ 1, 0, { 1 } }
{ {
} }
@ -23,7 +25,9 @@ namespace CalcEngine
m_q = Number(1, qExp, { 1 }); m_q = Number(1, qExp, { 1 });
} }
Rational::Rational(Number const& p, Number const& q) noexcept : m_p{ p }, m_q{ q } Rational::Rational(Number const& p, Number const& q) noexcept
: m_p{ p }
, m_q{ q }
{ {
} }
@ -58,7 +62,9 @@ namespace CalcEngine
m_q = Number{ temp.Q() }; m_q = Number{ temp.Q() };
} }
Rational::Rational(PRAT prat) noexcept : m_p{ Number{ prat->pp } }, m_q{ Number{ prat->pq } } Rational::Rational(PRAT prat) noexcept
: m_p{ Number{ prat->pp } }
, m_q{ Number{ prat->pq } }
{ {
} }

View file

@ -58,8 +58,12 @@ void CCalcEngine::InitialOneTimeOnlySetup(CalculationManager::IResourceProvider&
// CCalcEngine::CCalcEngine // CCalcEngine::CCalcEngine
// //
////////////////////////////////////////////////// //////////////////////////////////////////////////
CCalcEngine::CCalcEngine(bool fPrecedence, bool fIntegerMode, CalculationManager::IResourceProvider* const pResourceProvider, CCalcEngine::CCalcEngine(
__in_opt ICalcDisplay* pCalcDisplay, __in_opt shared_ptr<IHistoryDisplay> pHistoryDisplay) bool fPrecedence,
bool fIntegerMode,
CalculationManager::IResourceProvider* const pResourceProvider,
__in_opt ICalcDisplay* pCalcDisplay,
__in_opt shared_ptr<IHistoryDisplay> pHistoryDisplay)
: m_fPrecedence(fPrecedence) : m_fPrecedence(fPrecedence)
, m_fIntegerMode(fIntegerMode) , m_fIntegerMode(fIntegerMode)
, m_pCalcDisplay(pCalcDisplay) , m_pCalcDisplay(pCalcDisplay)

View file

@ -382,8 +382,8 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
if (nullptr != m_pCalcDisplay) if (nullptr != m_pCalcDisplay)
{ {
m_pCalcDisplay->SetParenthesisNumber(0); m_pCalcDisplay->SetParenthesisNumber(0);
m_pCalcDisplay->SetExpressionDisplay(make_shared<CalculatorVector<pair<wstring, int>>>(), m_pCalcDisplay->SetExpressionDisplay(
make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>()); make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
} }
m_HistoryCollector.ClearHistoryLine(wstring()); m_HistoryCollector.ClearHistoryLine(wstring());
@ -476,8 +476,8 @@ void CCalcEngine::ProcessCommandWorker(OpCode wParam)
m_HistoryCollector.CompleteHistoryLine(groupedString); m_HistoryCollector.CompleteHistoryLine(groupedString);
if (nullptr != m_pCalcDisplay) if (nullptr != m_pCalcDisplay)
{ {
m_pCalcDisplay->SetExpressionDisplay(make_shared<CalculatorVector<pair<wstring, int>>>(), m_pCalcDisplay->SetExpressionDisplay(
make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>()); make_shared<CalculatorVector<pair<wstring, int>>>(), make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>());
} }
} }

View file

@ -7,12 +7,15 @@
using namespace std; using namespace std;
using namespace CalculationManager; using namespace CalculationManager;
CalculatorHistory::CalculatorHistory(size_t maxSize) : m_maxHistorySize(maxSize) CalculatorHistory::CalculatorHistory(size_t maxSize)
: m_maxHistorySize(maxSize)
{ {
} }
unsigned int CalculatorHistory::AddToHistory(_In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens, unsigned int CalculatorHistory::AddToHistory(
_In_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands, _In_ wstring_view result) _In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
_In_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands,
_In_ wstring_view result)
{ {
unsigned int addedIndex; unsigned int addedIndex;
wstring generatedExpression; wstring generatedExpression;

View file

@ -30,8 +30,10 @@ namespace CalculationManager
{ {
public: public:
CalculatorHistory(const size_t maxSize); CalculatorHistory(const size_t maxSize);
unsigned int AddToHistory(_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens, unsigned int AddToHistory(
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& spCommands, std::wstring_view result); _In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens,
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& spCommands,
std::wstring_view result);
std::vector<std::shared_ptr<HISTORYITEM>> const& GetHistory(); std::vector<std::shared_ptr<HISTORYITEM>> const& GetHistory();
std::shared_ptr<HISTORYITEM> const& GetHistoryItem(unsigned int uIdx); std::shared_ptr<HISTORYITEM> const& GetHistoryItem(unsigned int uIdx);
void ClearHistory(); void ClearHistory();

View file

@ -85,8 +85,9 @@ namespace CalculationManager
/// Used to set the expression display value on ViewModel /// Used to set the expression display value on ViewModel
/// </summary> /// </summary>
/// <param name="expressionString">wstring representing expression to be displayed</param> /// <param name="expressionString">wstring representing expression to be displayed</param>
void CalculatorManager::SetExpressionDisplay(_Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens, void CalculatorManager::SetExpressionDisplay(
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands) _Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands)
{ {
if (!m_inHistoryItemLoadMode) if (!m_inHistoryItemLoadMode)
{ {

View file

@ -91,8 +91,9 @@ namespace CalculationManager
// ICalcDisplay // ICalcDisplay
void SetPrimaryDisplay(_In_ const std::wstring& displayString, _In_ bool isError) override; void SetPrimaryDisplay(_In_ const std::wstring& displayString, _In_ bool isError) override;
void SetIsInError(bool isError) override; void SetIsInError(bool isError) override;
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, void SetExpressionDisplay(
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) override; _Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) override;
void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override; void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override;
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override; void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override;
void SetParenthesisNumber(_In_ unsigned int parenthesisCount) override; void SetParenthesisNumber(_In_ unsigned int parenthesisCount) override;

View file

@ -13,7 +13,8 @@ constexpr wchar_t chNegate = L'-';
constexpr wchar_t chExp = L'e'; constexpr wchar_t chExp = L'e';
constexpr wchar_t chPlus = L'+'; constexpr wchar_t chPlus = L'+';
CParentheses::CParentheses(_In_ int command) : m_command(command) CParentheses::CParentheses(_In_ int command)
: m_command(command)
{ {
} }
@ -73,7 +74,8 @@ void CUnaryCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
commandVisitor.Visit(*this); commandVisitor.Visit(*this);
} }
CBinaryCommand::CBinaryCommand(int command) : m_command(command) CBinaryCommand::CBinaryCommand(int command)
: m_command(command)
{ {
} }
@ -98,7 +100,12 @@ void CBinaryCommand::Accept(_In_ ISerializeCommandVisitor& commandVisitor)
} }
COpndCommand::COpndCommand(shared_ptr<CalculatorVector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt) COpndCommand::COpndCommand(shared_ptr<CalculatorVector<int>> const& commands, bool fNegative, bool fDecimal, bool fSciFmt)
: m_commands(commands), m_fNegative(fNegative), m_fSciFmt(fSciFmt), m_fDecimal(fDecimal), m_fInitialized(false), m_value{} : m_commands(commands)
, m_fNegative(fNegative)
, m_fSciFmt(fSciFmt)
, m_fDecimal(fDecimal)
, m_fInitialized(false)
, m_value{}
{ {
} }

View file

@ -54,8 +54,12 @@ namespace CalculatorEngineTests
class CCalcEngine class CCalcEngine
{ {
public: public:
CCalcEngine(bool fPrecedence, bool fIntegerMode, CalculationManager::IResourceProvider* const pResourceProvider, __in_opt ICalcDisplay* pCalcDisplay, CCalcEngine(
__in_opt std::shared_ptr<IHistoryDisplay> pHistoryDisplay); bool fPrecedence,
bool fIntegerMode,
CalculationManager::IResourceProvider* const pResourceProvider,
__in_opt ICalcDisplay* pCalcDisplay,
__in_opt std::shared_ptr<IHistoryDisplay> pHistoryDisplay);
void ProcessCommand(OpCode wID); void ProcessCommand(OpCode wID);
void DisplayError(uint32_t nError); void DisplayError(uint32_t nError);
std::unique_ptr<CalcEngine::Rational> PersistedMemObject(); std::unique_ptr<CalcEngine::Rational> PersistedMemObject();

View file

@ -13,7 +13,9 @@ namespace CalcEngine
class CalcNumSec class CalcNumSec
{ {
public: public:
CalcNumSec() : value(), m_isNegative(false) CalcNumSec()
: value()
, m_isNegative(false)
{ {
} }
@ -41,11 +43,18 @@ namespace CalcEngine
class CalcInput class CalcInput
{ {
public: public:
CalcInput() : CalcInput(L'.') CalcInput()
: CalcInput(L'.')
{ {
} }
CalcInput(wchar_t decSymbol) : m_hasExponent(false), m_hasDecimal(false), m_decPtIndex(0), m_decSymbol(decSymbol), m_base(), m_exponent() CalcInput(wchar_t decSymbol)
: m_hasExponent(false)
, m_hasDecimal(false)
, m_decPtIndex(0)
, m_decSymbol(decSymbol)
, m_base()
, m_exponent()
{ {
} }

View file

@ -12,8 +12,9 @@ class ICalcDisplay
public: public:
virtual void SetPrimaryDisplay(const std::wstring& pszText, bool isError) = 0; virtual void SetPrimaryDisplay(const std::wstring& pszText, bool isError) = 0;
virtual void SetIsInError(bool isInError) = 0; virtual void SetIsInError(bool isInError) = 0;
virtual void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, virtual void SetExpressionDisplay(
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) = 0; _Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) = 0;
virtual void SetParenthesisNumber(_In_ unsigned int count) = 0; virtual void SetParenthesisNumber(_In_ unsigned int count) = 0;
virtual void OnNoRightParenAdded() = 0; virtual void OnNoRightParenAdded() = 0;
virtual void MaxDigitsReached() = 0; // not an error but still need to inform UI layer. virtual void MaxDigitsReached() = 0; // not an error but still need to inform UI layer.

View file

@ -8,7 +8,8 @@ class IHistoryDisplay
{ {
public: public:
virtual ~IHistoryDisplay(){}; virtual ~IHistoryDisplay(){};
virtual unsigned int AddToHistory(_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, virtual unsigned int AddToHistory(
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands, _In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
_In_ std::wstring_view result) = 0; _In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands,
_In_ std::wstring_view result) = 0;
}; };

View file

@ -356,12 +356,14 @@ uint64_t rattoUi64(_In_ PRAT prat, uint32_t radix, int32_t precision);
extern PNUMBER _createnum(_In_ uint32_t size); // returns an empty number structure with size digits extern PNUMBER _createnum(_In_ uint32_t size); // returns an empty number structure with size digits
extern PNUMBER nRadixxtonum(_In_ PNUMBER a, uint32_t radix, int32_t precision); extern PNUMBER nRadixxtonum(_In_ PNUMBER a, uint32_t radix, int32_t precision);
extern PNUMBER gcd(_In_ PNUMBER a, _In_ PNUMBER b); extern PNUMBER gcd(_In_ PNUMBER a, _In_ PNUMBER b);
extern PNUMBER StringToNumber(std::wstring_view numberString, uint32_t radix, extern PNUMBER StringToNumber(
int32_t precision); // takes a text representation of a number and returns a number. std::wstring_view numberString,
uint32_t radix,
int32_t precision); // takes a text representation of a number and returns a number.
// takes a text representation of a number as a mantissa with sign and an exponent with sign. // takes a text representation of a number as a mantissa with sign and an exponent with sign.
extern PRAT StringToRat(bool mantissaIsNegative, std::wstring_view mantissa, bool exponentIsNegative, std::wstring_view exponent, uint32_t radix, extern PRAT
int32_t precision); StringToRat(bool mantissaIsNegative, std::wstring_view mantissa, bool exponentIsNegative, std::wstring_view exponent, uint32_t radix, int32_t precision);
extern PNUMBER i32factnum(int32_t ini32, uint32_t radix); extern PNUMBER i32factnum(int32_t ini32, uint32_t radix);
extern PNUMBER i32prodnum(int32_t start, int32_t stop, uint32_t radix); extern PNUMBER i32prodnum(int32_t start, int32_t stop, uint32_t radix);

View file

@ -34,7 +34,8 @@ unordered_map<wstring, wchar_t> unquoteConversions;
/// Constructor, sets up all the variables and requires a configLoader /// Constructor, sets up all the variables and requires a configLoader
/// </summary> /// </summary>
/// <param name="dataLoader">An instance of the IConverterDataLoader interface which we use to read in category/unit names and conversion data</param> /// <param name="dataLoader">An instance of the IConverterDataLoader interface which we use to read in category/unit names and conversion data</param>
UnitConverter::UnitConverter(_In_ const shared_ptr<IConverterDataLoader>& dataLoader) : UnitConverter::UnitConverter(dataLoader, nullptr) UnitConverter::UnitConverter(_In_ const shared_ptr<IConverterDataLoader>& dataLoader)
: UnitConverter::UnitConverter(dataLoader, nullptr)
{ {
} }

View file

@ -29,9 +29,19 @@ namespace UnitConversionManager
{ {
} }
Unit(int id, std::wstring currencyName, std::wstring countryName, std::wstring abbreviation, bool isRtlLanguage, bool isConversionSource, Unit(
bool isConversionTarget) int id,
: id(id), abbreviation(abbreviation), isConversionSource(isConversionSource), isConversionTarget(isConversionTarget), isWhimsical(false) std::wstring currencyName,
std::wstring countryName,
std::wstring abbreviation,
bool isRtlLanguage,
bool isConversionSource,
bool isConversionTarget)
: id(id)
, abbreviation(abbreviation)
, isConversionSource(isConversionSource)
, isConversionTarget(isConversionTarget)
, isWhimsical(false)
{ {
std::wstring nameValue1 = isRtlLanguage ? currencyName : countryName; std::wstring nameValue1 = isRtlLanguage ? currencyName : countryName;
std::wstring nameValue2 = isRtlLanguage ? countryName : currencyName; std::wstring nameValue2 = isRtlLanguage ? countryName : currencyName;
@ -76,7 +86,10 @@ namespace UnitConversionManager
{ {
} }
Category(int id, std::wstring name, bool supportsNegative) : id(id), name(name), supportsNegative(supportsNegative) Category(int id, std::wstring name, bool supportsNegative)
: id(id)
, name(name)
, supportsNegative(supportsNegative)
{ {
} }
@ -125,7 +138,10 @@ namespace UnitConversionManager
ConversionData() ConversionData()
{ {
} }
ConversionData(double ratio, double offset, bool offsetFirst) : ratio(ratio), offset(offset), offsetFirst(offsetFirst) ConversionData(double ratio, double offset, bool offsetFirst)
: ratio(ratio)
, offset(offset)
, offsetFirst(offsetFirst)
{ {
} }
@ -155,9 +171,10 @@ namespace UnitConversionManager
}; };
typedef std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit> CategorySelectionInitializer; typedef std::tuple<std::vector<UnitConversionManager::Unit>, UnitConversionManager::Unit, UnitConversionManager::Unit> CategorySelectionInitializer;
typedef std::unordered_map<UnitConversionManager::Unit, typedef std::unordered_map<
std::unordered_map<UnitConversionManager::Unit, UnitConversionManager::ConversionData, UnitConversionManager::UnitHash>, UnitConversionManager::Unit,
UnitConversionManager::UnitHash> std::unordered_map<UnitConversionManager::Unit, UnitConversionManager::ConversionData, UnitConversionManager::UnitHash>,
UnitConversionManager::UnitHash>
UnitToUnitToConversionDataMap; UnitToUnitToConversionDataMap;
typedef std::unordered_map<UnitConversionManager::Category, std::vector<UnitConversionManager::Unit>, UnitConversionManager::CategoryHash> typedef std::unordered_map<UnitConversionManager::Category, std::vector<UnitConversionManager::Unit>, UnitConversionManager::CategoryHash>
CategoryToUnitVectorMap; CategoryToUnitVectorMap;
@ -188,10 +205,10 @@ namespace UnitConversionManager
{ {
public: public:
virtual void SetViewModelCallback(const std::shared_ptr<UnitConversionManager::IViewModelCurrencyCallback>& callback) = 0; virtual void SetViewModelCallback(const std::shared_ptr<UnitConversionManager::IViewModelCurrencyCallback>& callback) = 0;
virtual std::pair<std::wstring, std::wstring> GetCurrencySymbols(_In_ const UnitConversionManager::Unit& unit1, virtual std::pair<std::wstring, std::wstring>
_In_ const UnitConversionManager::Unit& unit2) = 0; GetCurrencySymbols(_In_ const UnitConversionManager::Unit& unit1, _In_ const UnitConversionManager::Unit& unit2) = 0;
virtual std::pair<std::wstring, std::wstring> GetCurrencyRatioEquality(_In_ const UnitConversionManager::Unit& unit1, virtual std::pair<std::wstring, std::wstring>
_In_ const UnitConversionManager::Unit& unit2) = 0; GetCurrencyRatioEquality(_In_ const UnitConversionManager::Unit& unit1, _In_ const UnitConversionManager::Unit& unit2) = 0;
virtual std::wstring GetCurrencyTimestamp() = 0; virtual std::wstring GetCurrencyTimestamp() = 0;
virtual concurrency::task<bool> TryLoadDataFromCacheAsync() = 0; virtual concurrency::task<bool> TryLoadDataFromCacheAsync() = 0;

View file

@ -9,7 +9,8 @@ namespace CalculatorApp
{ {
ref class AlwaysSelectedCollectionView sealed : public Windows::UI::Xaml::DependencyObject, public Windows::UI::Xaml::Data::ICollectionView ref class AlwaysSelectedCollectionView sealed : public Windows::UI::Xaml::DependencyObject, public Windows::UI::Xaml::Data::ICollectionView
{ {
internal : AlwaysSelectedCollectionView(Windows::UI::Xaml::Interop::IBindableVector ^ source) : m_currentPosition(-1) internal : AlwaysSelectedCollectionView(Windows::UI::Xaml::Interop::IBindableVector ^ source)
: m_currentPosition(-1)
{ {
m_source = source; m_source = source;
@ -47,8 +48,8 @@ namespace CalculatorApp
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
property Windows::Foundation::Collections::IObservableVector<Platform::Object ^> ^ CollectionGroups { property Windows::Foundation::Collections::IObservableVector<Platform::Object ^> ^ CollectionGroups {
virtual Windows::Foundation::Collections::IObservableVector<Platform::Object virtual Windows::Foundation::Collections::IObservableVector<
^> ^ get() = Windows::UI::Xaml::Data::ICollectionView::CollectionGroups::get Platform::Object ^> ^ get() = Windows::UI::Xaml::Data::ICollectionView::CollectionGroups::get
{ {
return ref new Platform::Collections::Vector<Platform::Object ^>(); return ref new Platform::Collections::Vector<Platform::Object ^>();
} }
@ -80,8 +81,9 @@ namespace CalculatorApp
// restore the selection to the way we wanted it to begin with // restore the selection to the way we wanted it to begin with
if (m_currentPosition >= 0 && m_currentPosition < static_cast<int>(m_source->Size)) if (m_currentPosition >= 0 && m_currentPosition < static_cast<int>(m_source->Size))
{ {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() {
ref new Windows::UI::Core::DispatchedHandler([this]() { m_currentChanged(this, nullptr); })); m_currentChanged(this, nullptr);
}));
} }
return false; return false;
} }
@ -167,14 +169,14 @@ namespace CalculatorApp
{ {
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
virtual unsigned int virtual unsigned int GetMany(
GetMany(unsigned int /*startIndex*/, unsigned int /*startIndex*/,
Platform::WriteOnlyArray<Platform::Object ^> ^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::GetMany Platform::WriteOnlyArray<Platform::Object ^> ^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::GetMany
{ {
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
virtual Windows::Foundation::Collections::IVectorView<Platform::Object ^> ^ GetView() = Windows::Foundation::Collections::IVector<Platform::Object virtual Windows::Foundation::Collections::IVectorView<Platform::Object ^> ^ GetView() = Windows::Foundation::Collections::IVector<
^>::GetView Platform::Object ^>::GetView
{ {
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
@ -263,8 +265,11 @@ namespace CalculatorApp
private: private:
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ Convert(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert
{ {
auto result = dynamic_cast<Windows::UI::Xaml::Interop::IBindableVector ^>(value); auto result = dynamic_cast<Windows::UI::Xaml::Interop::IBindableVector ^>(value);
if (result) if (result)
@ -275,8 +280,11 @@ namespace CalculatorApp
} }
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ /*value*/, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ ConvertBack(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack Platform::Object ^ /*value*/,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack
{ {
return Windows::UI::Xaml::DependencyProperty::UnsetValue; return Windows::UI::Xaml::DependencyProperty::UnsetValue;
} }

View file

@ -9,7 +9,8 @@ using namespace Windows::UI::Xaml::Automation;
using namespace Windows::UI::Xaml::Automation::Peers; using namespace Windows::UI::Xaml::Automation::Peers;
using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls;
LiveRegionHost::LiveRegionHost() : m_host(nullptr) LiveRegionHost::LiveRegionHost()
: m_host(nullptr)
{ {
} }

View file

@ -25,9 +25,15 @@ namespace CalculatorApp::Common::Automation
} }
} }
NarratorAnnouncement::NarratorAnnouncement(String ^ announcement, String ^ activityId, AutomationNotificationKind kind, NarratorAnnouncement::NarratorAnnouncement(
AutomationNotificationProcessing processing) String ^ announcement,
: m_announcement(announcement), m_activityId(activityId), m_kind(kind), m_processing(processing) String ^ activityId,
AutomationNotificationKind kind,
AutomationNotificationProcessing processing)
: m_announcement(announcement)
, m_activityId(activityId)
, m_kind(kind)
, m_processing(processing)
{ {
} }
@ -58,66 +64,78 @@ bool NarratorAnnouncement::IsValid(NarratorAnnouncement ^ announcement)
NarratorAnnouncement ^ CalculatorAnnouncement::GetDisplayUpdatedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetDisplayUpdatedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::DisplayUpdated, AutomationNotificationKind::Other, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement, CalculatorActivityIds::DisplayUpdated, AutomationNotificationKind::Other, AutomationNotificationProcessing::ImportantMostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetMaxDigitsReachedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetMaxDigitsReachedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::MaxDigitsReached, AutomationNotificationKind::Other, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement, CalculatorActivityIds::MaxDigitsReached, AutomationNotificationKind::Other, AutomationNotificationProcessing::ImportantMostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetMemoryClearedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetMemoryClearedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::MemoryCleared, AutomationNotificationKind::ItemRemoved, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement, CalculatorActivityIds::MemoryCleared, AutomationNotificationKind::ItemRemoved, AutomationNotificationProcessing::ImportantMostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetMemoryItemChangedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetMemoryItemChangedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::MemoryItemChanged, AutomationNotificationKind::ActionCompleted, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::MostRecent); announcement, CalculatorActivityIds::MemoryItemChanged, AutomationNotificationKind::ActionCompleted, AutomationNotificationProcessing::MostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetMemoryItemAddedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetMemoryItemAddedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::MemoryItemAdded, AutomationNotificationKind::ItemAdded, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::MostRecent); announcement, CalculatorActivityIds::MemoryItemAdded, AutomationNotificationKind::ItemAdded, AutomationNotificationProcessing::MostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetHistoryClearedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetHistoryClearedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::HistoryCleared, AutomationNotificationKind::ItemRemoved, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::MostRecent); announcement, CalculatorActivityIds::HistoryCleared, AutomationNotificationKind::ItemRemoved, AutomationNotificationProcessing::MostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetCategoryNameChangedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetCategoryNameChangedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::CategoryNameChanged, AutomationNotificationKind::ActionCompleted, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement,
CalculatorActivityIds::CategoryNameChanged,
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::ImportantMostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetUpdateCurrencyRatesAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetUpdateCurrencyRatesAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::UpdateCurrencyRates, AutomationNotificationKind::ActionCompleted, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement,
CalculatorActivityIds::UpdateCurrencyRates,
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::ImportantMostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetDisplayCopiedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetDisplayCopiedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::DisplayCopied, AutomationNotificationKind::ActionCompleted, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement, CalculatorActivityIds::DisplayCopied, AutomationNotificationKind::ActionCompleted, AutomationNotificationProcessing::ImportantMostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::OpenParenthesisCountChanged, AutomationNotificationKind::ActionCompleted, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement,
CalculatorActivityIds::OpenParenthesisCountChanged,
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::ImportantMostRecent);
} }
NarratorAnnouncement ^ CalculatorAnnouncement::GetNoRightParenthesisAddedAnnouncement(String ^ announcement) NarratorAnnouncement ^ CalculatorAnnouncement::GetNoRightParenthesisAddedAnnouncement(String ^ announcement)
{ {
return ref new NarratorAnnouncement(announcement, CalculatorActivityIds::NoParenthesisAdded, AutomationNotificationKind::ActionCompleted, return ref new NarratorAnnouncement(
AutomationNotificationProcessing::ImportantMostRecent); announcement,
CalculatorActivityIds::NoParenthesisAdded,
AutomationNotificationKind::ActionCompleted,
AutomationNotificationProcessing::ImportantMostRecent);
} }

View file

@ -58,8 +58,11 @@ public
// class that can access the private constructor. // class that can access the private constructor.
friend class CalculatorAnnouncement; friend class CalculatorAnnouncement;
NarratorAnnouncement(Platform::String ^ announcement, Platform::String ^ activityId, AutomationNotificationKind kind, NarratorAnnouncement(
AutomationNotificationProcessing processing); Platform::String ^ announcement,
Platform::String ^ activityId,
AutomationNotificationKind kind,
AutomationNotificationProcessing processing);
Platform::String ^ m_announcement; Platform::String ^ m_announcement;
Platform::String ^ m_activityId; Platform::String ^ m_activityId;

View file

@ -30,11 +30,13 @@ void NarratorNotifier::Announce(NarratorAnnouncement ^ announcement)
void NarratorNotifier::RegisterDependencyProperties() void NarratorNotifier::RegisterDependencyProperties()
{ {
s_announcementProperty = DependencyProperty::Register(L"Announcement", // The name of the dependency property. s_announcementProperty = DependencyProperty::Register(
NarratorAnnouncement::typeid, // The type of the dependency property. L"Announcement", // The name of the dependency property.
NarratorNotifier::typeid, // The owner of the dependency property. NarratorAnnouncement::typeid, // The type of the dependency property.
ref new PropertyMetadata(nullptr, // Default value of the dependency property. NarratorNotifier::typeid, // The owner of the dependency property.
ref new PropertyChangedCallback(OnAnnouncementChanged))); ref new PropertyMetadata(
nullptr, // Default value of the dependency property.
ref new PropertyChangedCallback(OnAnnouncementChanged)));
} }
void NarratorNotifier::OnAnnouncementChanged(_In_ DependencyObject ^ dependencyObject, _In_ DependencyPropertyChangedEventArgs ^ e) void NarratorNotifier::OnAnnouncementChanged(_In_ DependencyObject ^ dependencyObject, _In_ DependencyPropertyChangedEventArgs ^ e)

View file

@ -31,8 +31,8 @@ public
^ AnnouncementProperty { Windows::UI::Xaml::DependencyProperty ^ get() { return s_announcementProperty; } } ^ AnnouncementProperty { Windows::UI::Xaml::DependencyProperty ^ get() { return s_announcementProperty; } }
static NarratorAnnouncement static NarratorAnnouncement
^ GetAnnouncement(Windows::UI::Xaml::DependencyObject ^ GetAnnouncement(
^ element) { return safe_cast<NarratorAnnouncement ^>(element->GetValue(s_announcementProperty)); } Windows::UI::Xaml::DependencyObject ^ element) { return safe_cast<NarratorAnnouncement ^>(element->GetValue(s_announcementProperty)); }
static void SetAnnouncement(Windows::UI::Xaml::DependencyObject ^ element, NarratorAnnouncement ^ value) static void SetAnnouncement(Windows::UI::Xaml::DependencyObject ^ element, NarratorAnnouncement ^ value)
{ {
@ -40,8 +40,9 @@ public
} }
private: private:
static void OnAnnouncementChanged(_In_ Windows::UI::Xaml::DependencyObject ^ dependencyObject, static void OnAnnouncementChanged(
_In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ eventArgs); _In_ Windows::UI::Xaml::DependencyObject ^ dependencyObject,
_In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ eventArgs);
static Windows::UI::Xaml::DependencyProperty ^ s_announcementProperty; static Windows::UI::Xaml::DependencyProperty ^ s_announcementProperty;

View file

@ -10,7 +10,8 @@ using namespace Windows::UI::Xaml::Automation;
using namespace Windows::UI::Xaml::Automation::Peers; using namespace Windows::UI::Xaml::Automation::Peers;
using namespace Windows::UI::Xaml::Controls; using namespace Windows::UI::Xaml::Controls;
NotificationHost::NotificationHost() : m_host(nullptr) NotificationHost::NotificationHost()
: m_host(nullptr)
{ {
} }
@ -34,8 +35,11 @@ void NotificationHost::Announce(NarratorAnnouncement ^ announcement)
auto peer = FrameworkElementAutomationPeer::FromElement(m_host); auto peer = FrameworkElementAutomationPeer::FromElement(m_host);
if (peer != nullptr) if (peer != nullptr)
{ {
peer->RaiseNotificationEvent(GetWindowsNotificationKind(announcement->Kind), GetWindowsNotificationProcessing(announcement->Processing), peer->RaiseNotificationEvent(
announcement->Announcement, announcement->ActivityId); GetWindowsNotificationKind(announcement->Kind),
GetWindowsNotificationProcessing(announcement->Processing),
announcement->Announcement,
announcement->ActivityId);
} }
} }

View file

@ -18,7 +18,8 @@ namespace CalculatorApp
PROPERTY_R(CalculatorApp::NumbersAndOperatorsEnum, Operation); PROPERTY_R(CalculatorApp::NumbersAndOperatorsEnum, Operation);
CalculatorButtonPressedEventArgs(Platform::String ^ feedback, CalculatorApp::NumbersAndOperatorsEnum operation) CalculatorButtonPressedEventArgs(Platform::String ^ feedback, CalculatorApp::NumbersAndOperatorsEnum operation)
: m_AuditoryFeedback(feedback), m_Operation(operation) : m_AuditoryFeedback(feedback)
, m_Operation(operation)
{ {
} }

View file

@ -69,8 +69,9 @@ void CalculatorDisplay::SetIsInError(bool isError)
} }
} }
void CalculatorDisplay::SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, void CalculatorDisplay::SetExpressionDisplay(
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) _Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands)
{ {
if (m_callbackReference != nullptr) if (m_callbackReference != nullptr)
{ {

View file

@ -18,8 +18,9 @@ namespace CalculatorApp
private: private:
void SetPrimaryDisplay(_In_ const std::wstring& displayString, _In_ bool isError) override; void SetPrimaryDisplay(_In_ const std::wstring& displayString, _In_ bool isError) override;
void SetIsInError(bool isError) override; void SetIsInError(bool isError) override;
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, void SetExpressionDisplay(
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) override; _Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands) override;
void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override; void SetMemorizedNumbers(_In_ const std::vector<std::wstring>& memorizedNumbers) override;
void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override; void OnHistoryItemAdded(_In_ unsigned int addedItemIndex) override;
void SetParenthesisNumber(_In_ unsigned int parenthesisCount) override; void SetParenthesisNumber(_In_ unsigned int parenthesisCount) override;

View file

@ -9,7 +9,8 @@ using namespace concurrency;
using namespace std; using namespace std;
ConversionResultTaskHelper::ConversionResultTaskHelper(unsigned int delay, const function<void()> functionToRun) ConversionResultTaskHelper::ConversionResultTaskHelper(unsigned int delay, const function<void()> functionToRun)
: m_delay{ delay }, m_storedFunction{ functionToRun } : m_delay{ delay }
, m_storedFunction{ functionToRun }
{ {
auto token = m_cts.get_token(); auto token = m_cts.get_token();
auto delayTask = CompleteAfter(delay); auto delayTask = CompleteAfter(delay);

View file

@ -38,9 +38,10 @@ static const wstring c_uIntSuffixes = L"[uU]?[lL]{0,2}";
// RegEx Patterns used by various modes // RegEx Patterns used by various modes
static const array<wregex, 1> standardModePatterns = { wregex(c_wspc + c_signedDecFloat + c_wspc) }; static const array<wregex, 1> standardModePatterns = { wregex(c_wspc + c_signedDecFloat + c_wspc) };
static const array<wregex, 2> scientificModePatterns = { wregex(L"(" + c_wspc + L"[-+]?)|(" + c_wspcLParenSigned + L")" + c_signedDecFloat + c_wspcRParens), static const array<wregex, 2> scientificModePatterns = {
wregex(L"(" + c_wspc + L"[-+]?)|(" + c_wspcLParenSigned + L")" + c_signedDecFloat wregex(L"(" + c_wspc + L"[-+]?)|(" + c_wspcLParenSigned + L")" + c_signedDecFloat + c_wspcRParens),
+ L"[e]([+]|[-])+\\d+" + c_wspcRParens) }; wregex(L"(" + c_wspc + L"[-+]?)|(" + c_wspcLParenSigned + L")" + c_signedDecFloat + L"[e]([+]|[-])+\\d+" + c_wspcRParens)
};
static const array<array<wregex, 5>, 4> programmerModePatterns = { static const array<array<wregex, 5>, 4> programmerModePatterns = {
{ // Hex numbers like 5F, 4A0C, 0xa9, 0xFFull, 47CDh { // Hex numbers like 5F, 4A0C, 0xa9, 0xFFull, 47CDh
{ wregex(c_wspcLParens + L"(0[xX])?" + c_hexProgrammerChars + c_uIntSuffixes + c_wspcRParens), { wregex(c_wspcLParens + L"(0[xX])?" + c_hexProgrammerChars + c_uIntSuffixes + c_wspcRParens),
@ -75,9 +76,11 @@ task<String ^> CopyPasteManager::GetStringToPaste(ViewMode mode, CategoryGroupTy
//-- add support to allow pasting for expressions like 1.3e12(as of now we allow 1.3e+12) //-- add support to allow pasting for expressions like 1.3e12(as of now we allow 1.3e+12)
return create_task((dataPackageView->GetTextAsync(::StandardDataFormats::Text))) return create_task((dataPackageView->GetTextAsync(::StandardDataFormats::Text)))
.then([mode, modeType, programmerNumberBase, .then(
bitLengthType](String ^ pastedText) { return ValidatePasteExpression(pastedText, mode, modeType, programmerNumberBase, bitLengthType); }, [mode, modeType, programmerNumberBase, bitLengthType](String ^ pastedText) {
task_continuation_context::use_arbitrary()); return ValidatePasteExpression(pastedText, mode, modeType, programmerNumberBase, bitLengthType);
},
task_continuation_context::use_arbitrary());
} }
int CopyPasteManager::ClipboardTextFormat() int CopyPasteManager::ClipboardTextFormat()

View file

@ -26,8 +26,11 @@ namespace CalculatorApp
{ {
public: public:
static void CopyToClipboard(Platform::String ^ stringToCopy); static void CopyToClipboard(Platform::String ^ stringToCopy);
static concurrency::task<Platform::String ^> GetStringToPaste(CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, static concurrency::task<Platform::String ^> GetStringToPaste(
int programmerNumberBase = -1, int bitLengthType = -1); CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase = -1,
int bitLengthType = -1);
static bool HasStringToPaste() static bool HasStringToPaste()
{ {
return ClipboardTextFormat() >= 0; return ClipboardTextFormat() >= 0;
@ -40,20 +43,34 @@ namespace CalculatorApp
static Platform::String static Platform::String
^ ValidatePasteExpression(Platform::String ^ pastedText, CalculatorApp::Common::ViewMode mode, int programmerNumberBase, int bitLengthType); ^ ValidatePasteExpression(Platform::String ^ pastedText, CalculatorApp::Common::ViewMode mode, int programmerNumberBase, int bitLengthType);
static Platform::String static Platform::String
^ ValidatePasteExpression(Platform::String ^ pastedText, CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, ^ ValidatePasteExpression(
int programmerNumberBase, int bitLengthType); Platform::String ^ pastedText,
CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase,
int bitLengthType);
static std::vector<std::wstring> ExtractOperands(const std::wstring& pasteExpression, CalculatorApp::Common::ViewMode mode, static std::vector<std::wstring>
int programmerNumberBase = -1, int bitLengthType = -1); ExtractOperands(const std::wstring& pasteExpression, CalculatorApp::Common::ViewMode mode, int programmerNumberBase = -1, int bitLengthType = -1);
static bool ExpressionRegExMatch(std::vector<std::wstring> operands, CalculatorApp::Common::ViewMode mode, static bool ExpressionRegExMatch(
CalculatorApp::Common::CategoryGroupType modeType, int programmerNumberBase = -1, int bitLengthType = -1); std::vector<std::wstring> operands,
CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase = -1,
int bitLengthType = -1);
static std::pair<size_t, uint64_t> GetMaxOperandLengthAndValue(CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, static std::pair<size_t, uint64_t> GetMaxOperandLengthAndValue(
int programmerNumberBase = -1, int bitLengthType = -1); CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase = -1,
int bitLengthType = -1);
static std::wstring SanitizeOperand(const std::wstring& operand); static std::wstring SanitizeOperand(const std::wstring& operand);
static bool TryOperandToULL(const std::wstring& operand, int numberBase, unsigned long long int& result); static bool TryOperandToULL(const std::wstring& operand, int numberBase, unsigned long long int& result);
static size_t OperandLength(const std::wstring& operand, CalculatorApp::Common::ViewMode mode, CalculatorApp::Common::CategoryGroupType modeType, static size_t OperandLength(
int programmerNumberBase = -1); const std::wstring& operand,
CalculatorApp::Common::ViewMode mode,
CalculatorApp::Common::CategoryGroupType modeType,
int programmerNumberBase = -1);
static size_t StandardScientificOperandLength(const std::wstring& operand); static size_t StandardScientificOperandLength(const std::wstring& operand);
static size_t ProgrammerOperandLength(const std::wstring& operand, int numberBase); static size_t ProgrammerOperandLength(const std::wstring& operand, int numberBase);
static std::wstring RemoveUnwantedCharsFromWstring(const std::wstring& input); static std::wstring RemoveUnwantedCharsFromWstring(const std::wstring& input);

View file

@ -44,12 +44,17 @@ namespace CalculatorApp
DateCalculationEngine(_In_ Platform::String ^ calendarIdentifier); DateCalculationEngine(_In_ Platform::String ^ calendarIdentifier);
// Public Methods // Public Methods
bool __nothrow AddDuration(_In_ Windows::Foundation::DateTime startDate, _In_ const DateDifference& duration, bool __nothrow
_Out_ Windows::Foundation::DateTime* endDate); AddDuration(_In_ Windows::Foundation::DateTime startDate, _In_ const DateDifference& duration, _Out_ Windows::Foundation::DateTime* endDate);
bool __nothrow SubtractDuration(_In_ Windows::Foundation::DateTime startDate, _In_ const DateDifference& duration, bool __nothrow SubtractDuration(
_Out_ Windows::Foundation::DateTime* endDate); _In_ Windows::Foundation::DateTime startDate,
void __nothrow GetDateDifference(_In_ Windows::Foundation::DateTime date1, _In_ Windows::Foundation::DateTime date2, _In_ DateUnit outputFormat, _In_ const DateDifference& duration,
_Out_ DateDifference* difference); _Out_ Windows::Foundation::DateTime* endDate);
void __nothrow GetDateDifference(
_In_ Windows::Foundation::DateTime date1,
_In_ Windows::Foundation::DateTime date2,
_In_ DateUnit outputFormat,
_Out_ DateDifference* difference);
private: private:
// Private Variables // Private Variables

View file

@ -14,7 +14,9 @@ namespace CalculatorApp
typedef void (TTarget::*CommandHandlerFunc)(Platform::Object ^); typedef void (TTarget::*CommandHandlerFunc)(Platform::Object ^);
DelegateCommand(TTarget ^ target, CommandHandlerFunc func) : m_weakTarget(target), m_function(func) DelegateCommand(TTarget ^ target, CommandHandlerFunc func)
: m_weakTarget(target)
, m_function(func)
{ {
} }

View file

@ -18,7 +18,12 @@ public
[Windows::UI::Xaml::Data::Bindable] public ref class DisplayExpressionToken sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged [Windows::UI::Xaml::Data::Bindable] public ref class DisplayExpressionToken sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
internal : DisplayExpressionToken(Platform::String ^ token, int tokenPosition, bool fEditable, TokenType type) internal : DisplayExpressionToken(Platform::String ^ token, int tokenPosition, bool fEditable, TokenType type)
: m_Token(token), m_TokenPosition(tokenPosition), m_IsTokenEditable(fEditable), m_Type(type), m_OriginalToken(token), m_InEditMode(false) : m_Token(token)
, m_TokenPosition(tokenPosition)
, m_IsTokenEditable(fEditable)
, m_Type(type)
, m_OriginalToken(token)
, m_InEditMode(false)
{ {
} }

View file

@ -7,7 +7,8 @@
using namespace CalculatorApp::Common; using namespace CalculatorApp::Common;
using namespace Windows::Storage::Streams; using namespace Windows::Storage::Streams;
CommandDeserializer::CommandDeserializer(_In_ DataReader ^ dataReader) : m_dataReader(dataReader) CommandDeserializer::CommandDeserializer(_In_ DataReader ^ dataReader)
: m_dataReader(dataReader)
{ {
} }

View file

@ -7,7 +7,8 @@
using namespace CalculatorApp::Common; using namespace CalculatorApp::Common;
using namespace Windows::Storage::Streams; using namespace Windows::Storage::Streams;
SerializeCommandVisitor::SerializeCommandVisitor(_In_ DataWriter ^ dataWriter) : m_dataWriter(dataWriter) SerializeCommandVisitor::SerializeCommandVisitor(_In_ DataWriter ^ dataWriter)
: m_dataWriter(dataWriter)
{ {
} }

View file

@ -446,8 +446,9 @@ const std::multimap<MyVirtualKey, WeakReference>& GetCurrentKeyDictionary(MyVirt
{ {
return s_VirtualKeyAltChordsForButtons.find(viewId)->second; return s_VirtualKeyAltChordsForButtons.find(viewId)->second;
} }
else if ((s_ShiftKeyPressed.find(viewId)->second) else if (
&& ((Window::Current->CoreWindow->GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down)) (s_ShiftKeyPressed.find(viewId)->second)
&& ((Window::Current->CoreWindow->GetKeyState(VirtualKey::Control) & CoreVirtualKeyStates::Down) == CoreVirtualKeyStates::Down))
{ {
return s_VirtualKeyControlShiftChordsForButtons.find(viewId)->second; return s_VirtualKeyControlShiftChordsForButtons.find(viewId)->second;
} }

View file

@ -62,13 +62,13 @@ namespace CalculatorApp
static void OnVirtualKeyInverseChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue); static void OnVirtualKeyInverseChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
static void OnVirtualKeyControlInverseChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, static void
MyVirtualKey newValue); OnVirtualKeyControlInverseChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
static void OnVirtualKeyAltChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue); static void OnVirtualKeyAltChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
static void OnVirtualKeyControlShiftChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, static void
MyVirtualKey newValue); OnVirtualKeyControlShiftChordPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, MyVirtualKey oldValue, MyVirtualKey newValue);
static void OnCharacterReceivedHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args); static void OnCharacterReceivedHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::CharacterReceivedEventArgs ^ args);
static void OnKeyDownHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args); static void OnKeyDownHandler(Windows::UI::Core::CoreWindow ^ sender, Windows::UI::Core::KeyEventArgs ^ args);

View file

@ -434,28 +434,41 @@ unordered_map<wstring, wstring> LocalizationService::GetTokenToReadableNameMap()
// change given that the engine heavily relies on perfect ordering of certain elements. // change given that the engine heavily relies on perfect ordering of certain elements.
// To compromise, we'll declare a map from engine resource key to automation name from the // To compromise, we'll declare a map from engine resource key to automation name from the
// standard project resources. // standard project resources.
static vector<pair<wstring, wstring>> s_parenEngineKeyResourceMap = { static vector<pair<wstring, wstring>> s_parenEngineKeyResourceMap = { // Sine permutations
// Sine permutations make_pair<wstring, wstring>(L"67", L"SineDegrees"),
make_pair<wstring, wstring>(L"67", L"SineDegrees"), make_pair<wstring, wstring>(L"73", L"SineRadians"), make_pair<wstring, wstring>(L"73", L"SineRadians"),
make_pair<wstring, wstring>(L"79", L"SineGradians"), make_pair<wstring, wstring>(L"70", L"InverseSineDegrees"), make_pair<wstring, wstring>(L"79", L"SineGradians"),
make_pair<wstring, wstring>(L"76", L"InverseSineRadians"), make_pair<wstring, wstring>(L"82", L"InverseSineGradians"), make_pair<wstring, wstring>(L"70", L"InverseSineDegrees"),
make_pair<wstring, wstring>(L"25", L"HyperbolicSine"), make_pair<wstring, wstring>(L"85", L"InverseHyperbolicSine"), make_pair<wstring, wstring>(L"76", L"InverseSineRadians"),
make_pair<wstring, wstring>(L"82", L"InverseSineGradians"),
make_pair<wstring, wstring>(L"25", L"HyperbolicSine"),
make_pair<wstring, wstring>(L"85", L"InverseHyperbolicSine"),
// Cosine permutations // Cosine permutations
make_pair<wstring, wstring>(L"68", L"CosineDegrees"), make_pair<wstring, wstring>(L"74", L"CosineRadians"), make_pair<wstring, wstring>(L"68", L"CosineDegrees"),
make_pair<wstring, wstring>(L"80", L"CosineGradians"), make_pair<wstring, wstring>(L"71", L"InverseCosineDegrees"), make_pair<wstring, wstring>(L"74", L"CosineRadians"),
make_pair<wstring, wstring>(L"77", L"InverseCosineRadians"), make_pair<wstring, wstring>(L"83", L"InverseCosineGradians"), make_pair<wstring, wstring>(L"80", L"CosineGradians"),
make_pair<wstring, wstring>(L"26", L"HyperbolicCosine"), make_pair<wstring, wstring>(L"86", L"InverseHyperbolicCosine"), make_pair<wstring, wstring>(L"71", L"InverseCosineDegrees"),
make_pair<wstring, wstring>(L"77", L"InverseCosineRadians"),
make_pair<wstring, wstring>(L"83", L"InverseCosineGradians"),
make_pair<wstring, wstring>(L"26", L"HyperbolicCosine"),
make_pair<wstring, wstring>(L"86", L"InverseHyperbolicCosine"),
// Tangent permutations // Tangent permutations
make_pair<wstring, wstring>(L"69", L"TangentDegrees"), make_pair<wstring, wstring>(L"75", L"TangentRadians"), make_pair<wstring, wstring>(L"69", L"TangentDegrees"),
make_pair<wstring, wstring>(L"81", L"TangentGradians"), make_pair<wstring, wstring>(L"72", L"InverseTangentDegrees"), make_pair<wstring, wstring>(L"75", L"TangentRadians"),
make_pair<wstring, wstring>(L"78", L"InverseTangentRadians"), make_pair<wstring, wstring>(L"84", L"InverseTangentGradians"), make_pair<wstring, wstring>(L"81", L"TangentGradians"),
make_pair<wstring, wstring>(L"27", L"HyperbolicTangent"), make_pair<wstring, wstring>(L"87", L"InverseHyperbolicTangent"), make_pair<wstring, wstring>(L"72", L"InverseTangentDegrees"),
make_pair<wstring, wstring>(L"78", L"InverseTangentRadians"),
make_pair<wstring, wstring>(L"84", L"InverseTangentGradians"),
make_pair<wstring, wstring>(L"27", L"HyperbolicTangent"),
make_pair<wstring, wstring>(L"87", L"InverseHyperbolicTangent"),
// Miscellaneous Scientific functions // Miscellaneous Scientific functions
make_pair<wstring, wstring>(L"94", L"Factorial"), make_pair<wstring, wstring>(L"35", L"DegreeMinuteSecond"), make_pair<wstring, wstring>(L"94", L"Factorial"),
make_pair<wstring, wstring>(L"28", L"NaturalLog"), make_pair<wstring, wstring>(L"91", L"Square") make_pair<wstring, wstring>(L"35", L"DegreeMinuteSecond"),
make_pair<wstring, wstring>(L"28", L"NaturalLog"),
make_pair<wstring, wstring>(L"91", L"Square")
}; };
static vector<pair<wstring, wstring>> s_noParenEngineKeyResourceMap = { // Programmer mode functions static vector<pair<wstring, wstring>> s_noParenEngineKeyResourceMap = { // Programmer mode functions

View file

@ -44,8 +44,10 @@ namespace CalculatorApp
static Windows::Globalization::NumberFormatting::DecimalFormatter ^ GetRegionalSettingsAwareDecimalFormatter(); static Windows::Globalization::NumberFormatting::DecimalFormatter ^ GetRegionalSettingsAwareDecimalFormatter();
static Windows::Globalization::DateTimeFormatting::DateTimeFormatter ^ GetRegionalSettingsAwareDateTimeFormatter(_In_ Platform::String ^ format); static Windows::Globalization::DateTimeFormatting::DateTimeFormatter ^ GetRegionalSettingsAwareDateTimeFormatter(_In_ Platform::String ^ format);
static Windows::Globalization::DateTimeFormatting::DateTimeFormatter static Windows::Globalization::DateTimeFormatting::DateTimeFormatter
^ GetRegionalSettingsAwareDateTimeFormatter(_In_ Platform::String ^ format, _In_ Platform::String ^ calendarIdentifier, ^ GetRegionalSettingsAwareDateTimeFormatter(
_In_ Platform::String ^ clockIdentifier); _In_ Platform::String ^ format,
_In_ Platform::String ^ calendarIdentifier,
_In_ Platform::String ^ clockIdentifier);
static Windows::Globalization::NumberFormatting::CurrencyFormatter ^ GetRegionalSettingsAwareCurrencyFormatter(); static Windows::Globalization::NumberFormatting::CurrencyFormatter ^ GetRegionalSettingsAwareCurrencyFormatter();
@ -60,8 +62,10 @@ namespace CalculatorApp
// Attached property callbacks // Attached property callbacks
static void OnFontTypePropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, LanguageFontType oldValue, LanguageFontType newValue); static void OnFontTypePropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, LanguageFontType oldValue, LanguageFontType newValue);
static void OnFontWeightPropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, Windows::UI::Text::FontWeight oldValue, static void OnFontWeightPropertyChanged(
Windows::UI::Text::FontWeight newValue); Windows::UI::Xaml::DependencyObject ^ target,
Windows::UI::Text::FontWeight oldValue,
Windows::UI::Text::FontWeight newValue);
static void OnFontSizePropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, double oldValue, double newValue); static void OnFontSizePropertyChanged(Windows::UI::Xaml::DependencyObject ^ target, double oldValue, double newValue);
static void UpdateFontFamilyAndSize(Windows::UI::Xaml::DependencyObject ^ target); static void UpdateFontFamilyAndSize(Windows::UI::Xaml::DependencyObject ^ target);

View file

@ -60,16 +60,22 @@ namespace CalculatorApp
// Get locale info for List Separator, eg. comma is used in many locales // Get locale info for List Separator, eg. comma is used in many locales
wchar_t listSeparatorString[4] = L""; wchar_t listSeparatorString[4] = L"";
result = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SLIST, listSeparatorString, result = ::GetLocaleInfoEx(
static_cast<int>(std::size(listSeparatorString))); // Max length of the expected return value is 4 LOCALE_NAME_USER_DEFAULT,
LOCALE_SLIST,
listSeparatorString,
static_cast<int>(std::size(listSeparatorString))); // Max length of the expected return value is 4
if (result == 0) if (result == 0)
{ {
throw std::runtime_error("Unexpected error while getting locale info"); throw std::runtime_error("Unexpected error while getting locale info");
} }
int currencyTrailingDigits = 0; int currencyTrailingDigits = 0;
result = GetLocaleInfoEx(m_resolvedName.c_str(), LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER, (LPWSTR)&currencyTrailingDigits, result = GetLocaleInfoEx(
sizeof(currencyTrailingDigits) / sizeof(WCHAR)); m_resolvedName.c_str(),
LOCALE_ICURRDIGITS | LOCALE_RETURN_NUMBER,
(LPWSTR)&currencyTrailingDigits,
sizeof(currencyTrailingDigits) / sizeof(WCHAR));
if (result == 0) if (result == 0)
{ {
throw std::runtime_error("Unexpected error while getting locale info"); throw std::runtime_error("Unexpected error while getting locale info");
@ -78,8 +84,11 @@ namespace CalculatorApp
// Currency symbol precedence is either 0 or 1. // Currency symbol precedence is either 0 or 1.
// A value of 0 indicates the symbol follows the currency value. // A value of 0 indicates the symbol follows the currency value.
int currencySymbolPrecedence = 1; int currencySymbolPrecedence = 1;
result = GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IPOSSYMPRECEDES | LOCALE_RETURN_NUMBER, (LPWSTR)&currencySymbolPrecedence, result = GetLocaleInfoEx(
sizeof(currencySymbolPrecedence) / sizeof(WCHAR)); LOCALE_NAME_USER_DEFAULT,
LOCALE_IPOSSYMPRECEDES | LOCALE_RETURN_NUMBER,
(LPWSTR)&currencySymbolPrecedence,
sizeof(currencySymbolPrecedence) / sizeof(WCHAR));
// As CalcEngine only supports the first character of the decimal separator, // As CalcEngine only supports the first character of the decimal separator,
// Only first character of the decimal separator string is supported. // Only first character of the decimal separator string is supported.
@ -101,10 +110,11 @@ namespace CalculatorApp
// Get FirstDayOfWeek Date and Time setting // Get FirstDayOfWeek Date and Time setting
wchar_t day[80] = L""; wchar_t day[80] = L"";
::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, ::GetLocaleInfoEx(
LOCALE_IFIRSTDAYOFWEEK, // The first day in a week LOCALE_NAME_USER_DEFAULT,
reinterpret_cast<PWSTR>(day), // Argument is of type PWSTR LOCALE_IFIRSTDAYOFWEEK, // The first day in a week
static_cast<int>(std::size(day))); // Max return size are 80 characters reinterpret_cast<PWSTR>(day), // Argument is of type PWSTR
static_cast<int>(std::size(day))); // Max return size are 80 characters
// The LOCALE_IFIRSTDAYOFWEEK integer value varies from 0, 1, .. 6 for Monday, Tuesday, ... Sunday // The LOCALE_IFIRSTDAYOFWEEK integer value varies from 0, 1, .. 6 for Monday, Tuesday, ... Sunday
// DayOfWeek enum value varies from 0, 1, .. 6 for Sunday, Monday, ... Saturday // DayOfWeek enum value varies from 0, 1, .. 6 for Sunday, Monday, ... Saturday

View file

@ -49,42 +49,142 @@ static constexpr int CURRENCY_ID = 16;
// ^^^ THESE CONSTANTS SHOULD NEVER CHANGE ^^^ // ^^^ THESE CONSTANTS SHOULD NEVER CHANGE ^^^
// The order of items in this list determines the order of items in the menu. // The order of items in this list determines the order of items in the menu.
static constexpr array<const NavCategoryInitializer, 17> s_categoryManifest = { static constexpr array<const NavCategoryInitializer, 17> s_categoryManifest = { NavCategoryInitializer{ ViewMode::Standard,
NavCategoryInitializer{ ViewMode::Standard, STANDARD_ID, L"Standard", L"StandardMode", L"\uE8EF", CategoryGroupType::Calculator, MyVirtualKey::Number1, STANDARD_ID,
SUPPORTS_ALL }, L"Standard",
NavCategoryInitializer{ ViewMode::Scientific, SCIENTIFIC_ID, L"Scientific", L"ScientificMode", L"\uF196", CategoryGroupType::Calculator, L"StandardMode",
MyVirtualKey::Number2, SUPPORTS_ALL }, L"\uE8EF",
NavCategoryInitializer{ ViewMode::Programmer, PROGRAMMER_ID, L"Programmer", L"ProgrammerMode", L"\uECCE", CategoryGroupType::Calculator, CategoryGroupType::Calculator,
MyVirtualKey::Number3, SUPPORTS_ALL }, MyVirtualKey::Number1,
NavCategoryInitializer{ ViewMode::Date, DATE_ID, L"Date", L"DateCalculationMode", L"\uE787", CategoryGroupType::Calculator, MyVirtualKey::Number4, SUPPORTS_ALL },
SUPPORTS_ALL }, NavCategoryInitializer{ ViewMode::Scientific,
NavCategoryInitializer{ ViewMode::Currency, CURRENCY_ID, L"Currency", L"CategoryName_Currency", L"\uEB0D", CategoryGroupType::Converter, MyVirtualKey::None, SCIENTIFIC_ID,
POSITIVE_ONLY }, L"Scientific",
NavCategoryInitializer{ ViewMode::Volume, VOLUME_ID, L"Volume", L"CategoryName_Volume", L"\uF1AA", CategoryGroupType::Converter, MyVirtualKey::None, L"ScientificMode",
POSITIVE_ONLY }, L"\uF196",
NavCategoryInitializer{ ViewMode::Length, LENGTH_ID, L"Length", L"CategoryName_Length", L"\uECC6", CategoryGroupType::Converter, MyVirtualKey::None, CategoryGroupType::Calculator,
POSITIVE_ONLY }, MyVirtualKey::Number2,
NavCategoryInitializer{ ViewMode::Weight, WEIGHT_ID, L"Weight and Mass", L"CategoryName_Weight", L"\uF4C1", CategoryGroupType::Converter, SUPPORTS_ALL },
MyVirtualKey::None, POSITIVE_ONLY }, NavCategoryInitializer{ ViewMode::Programmer,
NavCategoryInitializer{ ViewMode::Temperature, TEMPERATURE_ID, L"Temperature", L"CategoryName_Temperature", L"\uE7A3", CategoryGroupType::Converter, PROGRAMMER_ID,
MyVirtualKey::None, SUPPORTS_NEGATIVE }, L"Programmer",
NavCategoryInitializer{ ViewMode::Energy, ENERGY_ID, L"Energy", L"CategoryName_Energy", L"\uECAD", CategoryGroupType::Converter, MyVirtualKey::None, L"ProgrammerMode",
POSITIVE_ONLY }, L"\uECCE",
NavCategoryInitializer{ ViewMode::Area, AREA_ID, L"Area", L"CategoryName_Area", L"\uE809", CategoryGroupType::Converter, MyVirtualKey::None, CategoryGroupType::Calculator,
POSITIVE_ONLY }, MyVirtualKey::Number3,
NavCategoryInitializer{ ViewMode::Speed, SPEED_ID, L"Speed", L"CategoryName_Speed", L"\uEADA", CategoryGroupType::Converter, MyVirtualKey::None, SUPPORTS_ALL },
POSITIVE_ONLY }, NavCategoryInitializer{ ViewMode::Date,
NavCategoryInitializer{ ViewMode::Time, TIME_ID, L"Time", L"CategoryName_Time", L"\uE917", CategoryGroupType::Converter, MyVirtualKey::None, DATE_ID,
POSITIVE_ONLY }, L"Date",
NavCategoryInitializer{ ViewMode::Power, POWER_ID, L"Power", L"CategoryName_Power", L"\uE945", CategoryGroupType::Converter, MyVirtualKey::None, L"DateCalculationMode",
POSITIVE_ONLY }, L"\uE787",
NavCategoryInitializer{ ViewMode::Data, DATA_ID, L"Data", L"CategoryName_Data", L"\uF20F", CategoryGroupType::Converter, MyVirtualKey::None, CategoryGroupType::Calculator,
POSITIVE_ONLY }, MyVirtualKey::Number4,
NavCategoryInitializer{ ViewMode::Pressure, PRESSURE_ID, L"Pressure", L"CategoryName_Pressure", L"\uEC4A", CategoryGroupType::Converter, MyVirtualKey::None, SUPPORTS_ALL },
POSITIVE_ONLY }, NavCategoryInitializer{ ViewMode::Currency,
NavCategoryInitializer{ ViewMode::Angle, ANGLE_ID, L"Angle", L"CategoryName_Angle", L"\uF515", CategoryGroupType::Converter, MyVirtualKey::None, CURRENCY_ID,
POSITIVE_ONLY } L"Currency",
}; L"CategoryName_Currency",
L"\uEB0D",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Volume,
VOLUME_ID,
L"Volume",
L"CategoryName_Volume",
L"\uF1AA",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Length,
LENGTH_ID,
L"Length",
L"CategoryName_Length",
L"\uECC6",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Weight,
WEIGHT_ID,
L"Weight and Mass",
L"CategoryName_Weight",
L"\uF4C1",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Temperature,
TEMPERATURE_ID,
L"Temperature",
L"CategoryName_Temperature",
L"\uE7A3",
CategoryGroupType::Converter,
MyVirtualKey::None,
SUPPORTS_NEGATIVE },
NavCategoryInitializer{ ViewMode::Energy,
ENERGY_ID,
L"Energy",
L"CategoryName_Energy",
L"\uECAD",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Area,
AREA_ID,
L"Area",
L"CategoryName_Area",
L"\uE809",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Speed,
SPEED_ID,
L"Speed",
L"CategoryName_Speed",
L"\uEADA",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Time,
TIME_ID,
L"Time",
L"CategoryName_Time",
L"\uE917",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Power,
POWER_ID,
L"Power",
L"CategoryName_Power",
L"\uE945",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Data,
DATA_ID,
L"Data",
L"CategoryName_Data",
L"\uF20F",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Pressure,
PRESSURE_ID,
L"Pressure",
L"CategoryName_Pressure",
L"\uEC4A",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY },
NavCategoryInitializer{ ViewMode::Angle,
ANGLE_ID,
L"Angle",
L"CategoryName_Angle",
L"\uF515",
CategoryGroupType::Converter,
MyVirtualKey::None,
POSITIVE_ONLY } };
// This function should only be used when storing the mode to app data. // This function should only be used when storing the mode to app data.
int NavCategory::Serialize(ViewMode mode) int NavCategory::Serialize(ViewMode mode)
@ -105,8 +205,9 @@ ViewMode NavCategory::Deserialize(Platform::Object ^ obj)
if (boxed != nullptr) if (boxed != nullptr)
{ {
int serializationId = boxed->Value; int serializationId = boxed->Value;
auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), [serializationId](const NavCategoryInitializer& initializer) {
[serializationId](const NavCategoryInitializer& initializer) { return initializer.serializationId == serializationId; }); return initializer.serializationId == serializationId;
});
if (iter != s_categoryManifest.end()) if (iter != s_categoryManifest.end())
{ {
@ -144,8 +245,9 @@ bool NavCategory::IsConverterViewMode(ViewMode mode)
bool NavCategory::IsModeInCategoryGroup(ViewMode mode, CategoryGroupType type) bool NavCategory::IsModeInCategoryGroup(ViewMode mode, CategoryGroupType type)
{ {
auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), [mode, type](const NavCategoryInitializer& initializer) {
[mode, type](const NavCategoryInitializer& initializer) { return initializer.viewMode == mode && initializer.groupType == type; }); return initializer.viewMode == mode && initializer.groupType == type;
});
return iter != s_categoryManifest.end(); return iter != s_categoryManifest.end();
} }
@ -160,8 +262,9 @@ String ^ NavCategory::GetFriendlyName(ViewMode mode)
ViewMode NavCategory::GetViewModeForFriendlyName(String ^ name) ViewMode NavCategory::GetViewModeForFriendlyName(String ^ name)
{ {
auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), [name](const NavCategoryInitializer& initializer) {
[name](const NavCategoryInitializer& initializer) { return wcscmp(initializer.friendlyName, name->Data()) == 0; }); return wcscmp(initializer.friendlyName, name->Data()) == 0;
});
return (iter != s_categoryManifest.end()) ? iter->viewMode : ViewMode::None; return (iter != s_categoryManifest.end()) ? iter->viewMode : ViewMode::None;
} }
@ -238,8 +341,9 @@ int NavCategory::GetPosition(ViewMode mode)
ViewMode NavCategory::GetViewModeForVirtualKey(MyVirtualKey virtualKey) ViewMode NavCategory::GetViewModeForVirtualKey(MyVirtualKey virtualKey)
{ {
auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), auto iter = find_if(begin(s_categoryManifest), end(s_categoryManifest), [virtualKey](const NavCategoryInitializer& initializer) {
[virtualKey](const NavCategoryInitializer& initializer) { return initializer.virtualKey == virtualKey; }); return initializer.virtualKey == virtualKey;
});
return (iter != s_categoryManifest.end()) ? iter->viewMode : ViewMode::None; return (iter != s_categoryManifest.end()) ? iter->viewMode : ViewMode::None;
} }
@ -258,7 +362,8 @@ vector<MyVirtualKey> NavCategory::GetCategoryAcceleratorKeys()
return accelerators; return accelerators;
} }
NavCategoryGroup::NavCategoryGroup(const NavCategoryGroupInitializer& groupInitializer) : m_Categories(ref new Vector<NavCategory ^>()) NavCategoryGroup::NavCategoryGroup(const NavCategoryGroupInitializer& groupInitializer)
: m_Categories(ref new Vector<NavCategory ^>())
{ {
m_GroupType = groupInitializer.type; m_GroupType = groupInitializer.type;
@ -285,9 +390,14 @@ NavCategoryGroup::NavCategoryGroup(const NavCategoryGroupInitializer& groupIniti
String ^ categoryAutomationName = ref new String( String ^ categoryAutomationName = ref new String(
LocalizationStringUtil::GetLocalizedString(navCategoryItemAutomationNameFormat->Data(), categoryName->Data(), m_Name->Data()).c_str()); LocalizationStringUtil::GetLocalizedString(navCategoryItemAutomationNameFormat->Data(), categoryName->Data(), m_Name->Data()).c_str());
m_Categories->Append(ref new NavCategory(categoryName, categoryAutomationName, StringReference(categoryInitializer.glyph), m_Categories->Append(ref new NavCategory(
resProvider.GetResourceString(nameResourceKey + "AccessKey"), groupMode, categoryInitializer.viewMode, categoryName,
categoryInitializer.supportsNegative)); categoryAutomationName,
StringReference(categoryInitializer.glyph),
resProvider.GetResourceString(nameResourceKey + "AccessKey"),
groupMode,
categoryInitializer.viewMode,
categoryInitializer.supportsNegative));
} }
} }
} }
@ -313,16 +423,18 @@ NavCategoryGroup ^ NavCategoryGroup::CreateConverterCategory()
vector<NavCategoryInitializer> NavCategoryGroup::GetInitializerCategoryGroup(CategoryGroupType groupType) vector<NavCategoryInitializer> NavCategoryGroup::GetInitializerCategoryGroup(CategoryGroupType groupType)
{ {
vector<NavCategoryInitializer> initializers{}; vector<NavCategoryInitializer> initializers{};
copy_if(begin(s_categoryManifest), end(s_categoryManifest), back_inserter(initializers), copy_if(begin(s_categoryManifest), end(s_categoryManifest), back_inserter(initializers), [groupType](const NavCategoryInitializer& initializer) {
[groupType](const NavCategoryInitializer& initializer) { return initializer.groupType == groupType; }); return initializer.groupType == groupType;
});
return initializers; return initializers;
} }
String ^ NavCategoryGroup::GetHeaderResourceKey(CategoryGroupType type) String ^ NavCategoryGroup::GetHeaderResourceKey(CategoryGroupType type)
{ {
auto iter = find_if(begin(s_categoryGroupManifest), end(s_categoryGroupManifest), auto iter = find_if(begin(s_categoryGroupManifest), end(s_categoryGroupManifest), [type](const NavCategoryGroupInitializer& initializer) {
[type](const NavCategoryGroupInitializer& initializer) { return initializer.type == type; }); return initializer.type == type;
});
return (iter != s_categoryGroupManifest.end()) ? StringReference(iter->headerResourceKey) : nullptr; return (iter != s_categoryGroupManifest.end()) ? StringReference(iter->headerResourceKey) : nullptr;
} }

View file

@ -58,8 +58,15 @@ namespace CalculatorApp
private private
struct NavCategoryInitializer struct NavCategoryInitializer
{ {
constexpr NavCategoryInitializer(ViewMode mode, int id, wchar_t const* name, wchar_t const* nameKey, wchar_t const* glyph, CategoryGroupType group, constexpr NavCategoryInitializer(
MyVirtualKey vKey, bool categorySupportsNegative) ViewMode mode,
int id,
wchar_t const* name,
wchar_t const* nameKey,
wchar_t const* glyph,
CategoryGroupType group,
MyVirtualKey vKey,
bool categorySupportsNegative)
: viewMode(mode) : viewMode(mode)
, serializationId(id) , serializationId(id)
, friendlyName(name) , friendlyName(name)
@ -85,7 +92,10 @@ namespace CalculatorApp
struct NavCategoryGroupInitializer struct NavCategoryGroupInitializer
{ {
constexpr NavCategoryGroupInitializer(CategoryGroupType t, wchar_t const* h, wchar_t const* n, wchar_t const* a) constexpr NavCategoryGroupInitializer(CategoryGroupType t, wchar_t const* h, wchar_t const* n, wchar_t const* a)
: type(t), headerResourceKey(h), modeResourceKey(n), automationResourceKey(a) : type(t)
, headerResourceKey(h)
, modeResourceKey(n)
, automationResourceKey(a)
{ {
} }
@ -161,8 +171,14 @@ namespace CalculatorApp
static ViewMode GetViewModeForVirtualKey(MyVirtualKey virtualKey); static ViewMode GetViewModeForVirtualKey(MyVirtualKey virtualKey);
internal : NavCategory(Platform::String ^ name, Platform::String ^ automationName, Platform::String ^ glyph, Platform::String ^ accessKey, internal : NavCategory(
Platform::String ^ mode, ViewMode viewMode, bool supportsNegative) Platform::String ^ name,
Platform::String ^ automationName,
Platform::String ^ glyph,
Platform::String ^ accessKey,
Platform::String ^ mode,
ViewMode viewMode,
bool supportsNegative)
: m_name(name) : m_name(name)
, m_automationName(automationName) , m_automationName(automationName)
, m_glyph(glyph) , m_glyph(glyph)

View file

@ -11,19 +11,30 @@ namespace CalculatorApp
class TraceActivity class TraceActivity
{ {
public: public:
TraceActivity() : m_channel(nullptr), m_activity(nullptr), m_fields(nullptr) TraceActivity()
: m_channel(nullptr)
, m_activity(nullptr)
, m_fields(nullptr)
{ {
} }
TraceActivity(winrt::Windows::Foundation::Diagnostics::LoggingChannel channel, std::wstring_view activityName, TraceActivity(
winrt::Windows::Foundation::Diagnostics::LoggingFields fields) winrt::Windows::Foundation::Diagnostics::LoggingChannel channel,
: m_channel(channel), m_activityName(activityName), m_fields(fields), m_activity(nullptr) std::wstring_view activityName,
winrt::Windows::Foundation::Diagnostics::LoggingFields fields)
: m_channel(channel)
, m_activityName(activityName)
, m_fields(fields)
, m_activity(nullptr)
{ {
// Write the activity's START event. Note that you must not specify keyword // Write the activity's START event. Note that you must not specify keyword
// or level for START and STOP events because they always use the activity's // or level for START and STOP events because they always use the activity's
// keyword and level. // keyword and level.
m_activity = m_channel.StartActivity(m_activityName, m_fields, winrt::Windows::Foundation::Diagnostics::LoggingLevel::Verbose, m_activity = m_channel.StartActivity(
winrt::Windows::Foundation::Diagnostics::LoggingOptions(WINEVENT_KEYWORD_RESPONSE_TIME)); m_activityName,
m_fields,
winrt::Windows::Foundation::Diagnostics::LoggingLevel::Verbose,
winrt::Windows::Foundation::Diagnostics::LoggingOptions(WINEVENT_KEYWORD_RESPONSE_TIME));
} }
~TraceActivity() ~TraceActivity()

View file

@ -607,8 +607,8 @@ namespace CalculatorApp
} }
} }
void TraceLogger::LogMemoryUsed(int windowId, unsigned int slotPosition, bool isStandard, bool isScientific, bool isProgrammer, void
unsigned int memorySize) const TraceLogger::LogMemoryUsed(int windowId, unsigned int slotPosition, bool isStandard, bool isScientific, bool isProgrammer, unsigned int memorySize) const
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;

View file

@ -96,8 +96,8 @@ namespace CalculatorApp
// Trace methods for Date Calculator usage // Trace methods for Date Calculator usage
void LogDateDifferenceModeUsed(int windowId); void LogDateDifferenceModeUsed(int windowId);
void LogDateAddSubtractModeUsed(int windowId, bool isAddMode); void LogDateAddSubtractModeUsed(int windowId, bool isAddMode);
void LogDateClippedTimeDifferenceFound(winrt::Windows::Globalization::Calendar const& today, void
winrt::Windows::Foundation::DateTime const& clippedTime) const; LogDateClippedTimeDifferenceFound(winrt::Windows::Globalization::Calendar const& today, winrt::Windows::Foundation::DateTime const& clippedTime) const;
void LogStandardException(std::wstring_view functionName, _In_ const std::exception& e) const; void LogStandardException(std::wstring_view functionName, _In_ const std::exception& e) const;
void LogWinRTException(std::wstring_view functionName, _In_ winrt::hresult_error const& e) const; void LogWinRTException(std::wstring_view functionName, _In_ winrt::hresult_error const& e) const;

View file

@ -92,8 +92,10 @@ wstring Utils::RemoveUnwantedCharsFromWstring(wstring input, wchar_t* unwantedCh
return input; return input;
} }
void Utils::SerializeCommandsAndTokens(_In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens, void Utils::SerializeCommandsAndTokens(
_In_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands, DataWriter ^ writer) _In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
_In_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands,
DataWriter ^ writer)
{ {
unsigned int commandsSize; unsigned int commandsSize;
IFTPlatformException(commands->GetSize(&commandsSize)); IFTPlatformException(commands->GetSize(&commandsSize));

View file

@ -384,9 +384,10 @@ namespace Utils
double GetDoubleFromWstring(std::wstring input); double GetDoubleFromWstring(std::wstring input);
int GetWindowId(); int GetWindowId();
void RunOnUIThreadNonblocking(std::function<void()>&& function, _In_ Windows::UI::Core::CoreDispatcher ^ currentDispatcher); void RunOnUIThreadNonblocking(std::function<void()>&& function, _In_ Windows::UI::Core::CoreDispatcher ^ currentDispatcher);
void SerializeCommandsAndTokens(_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, void SerializeCommandsAndTokens(
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands, _In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
Windows::Storage::Streams::DataWriter ^ writer); _In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands,
Windows::Storage::Streams::DataWriter ^ writer);
const std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> DeserializeCommands(Windows::Storage::Streams::DataReader ^ reader); const std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> DeserializeCommands(Windows::Storage::Streams::DataReader ^ reader);
const std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> DeserializeTokens(Windows::Storage::Streams::DataReader ^ reader); const std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> DeserializeTokens(Windows::Storage::Streams::DataReader ^ reader);
@ -394,8 +395,11 @@ namespace Utils
Windows::Foundation::DateTime GetUniversalSystemTime(); Windows::Foundation::DateTime GetUniversalSystemTime();
bool IsDateTimeOlderThan(Windows::Foundation::DateTime dateTime, const long long duration); bool IsDateTimeOlderThan(Windows::Foundation::DateTime dateTime, const long long duration);
concurrency::task<void> WriteFileToFolder(Windows::Storage::IStorageFolder ^ folder, Platform::String ^ fileName, Platform::String ^ contents, concurrency::task<void> WriteFileToFolder(
Windows::Storage::CreationCollisionOption collisionOption); Windows::Storage::IStorageFolder ^ folder,
Platform::String ^ fileName,
Platform::String ^ contents,
Windows::Storage::CreationCollisionOption collisionOption);
concurrency::task<Platform::String ^> ReadFileFromFolder(Windows::Storage::IStorageFolder ^ folder, Platform::String ^ fileName); concurrency::task<Platform::String ^> ReadFileFromFolder(Windows::Storage::IStorageFolder ^ folder, Platform::String ^ fileName);
} }

View file

@ -17,16 +17,22 @@ namespace CalculatorApp
private: private:
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ Convert(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert
{ {
// Pass through as we don't want to change the value from the source // Pass through as we don't want to change the value from the source
return value; return value;
} }
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ ConvertBack(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack
{ {
if (value) if (value)
{ {
@ -47,16 +53,22 @@ namespace CalculatorApp
private: private:
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ Convert(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert
{ {
// Pass through as we don't want to change the value from the source // Pass through as we don't want to change the value from the source
return value; return value;
} }
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ ConvertBack(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack
{ {
// The value to be valid has to be a boxed int32 value // The value to be valid has to be a boxed int32 value
// extract that value and ensure it is valid, ie >= 0 // extract that value and ensure it is valid, ie >= 0

View file

@ -46,8 +46,10 @@ static constexpr auto CACHE_LANGCODE_KEY = L"CURRENCY_CONVERTER_LANGCODE";
static constexpr auto CACHE_DELIMITER = L"%"; static constexpr auto CACHE_DELIMITER = L"%";
static constexpr auto STATIC_DATA_FILENAME = L"CURRENCY_CONVERTER_STATIC_DATA.txt"; static constexpr auto STATIC_DATA_FILENAME = L"CURRENCY_CONVERTER_STATIC_DATA.txt";
static constexpr array<wstring_view, 5> STATIC_DATA_PROPERTIES = { wstring_view{ L"CountryCode", 11 }, wstring_view{ L"CountryName", 11 }, static constexpr array<wstring_view, 5> STATIC_DATA_PROPERTIES = { wstring_view{ L"CountryCode", 11 },
wstring_view{ L"CurrencyCode", 12 }, wstring_view{ L"CurrencyName", 12 }, wstring_view{ L"CountryName", 11 },
wstring_view{ L"CurrencyCode", 12 },
wstring_view{ L"CurrencyName", 12 },
wstring_view{ L"CurrencySymbol", 14 } }; wstring_view{ L"CurrencySymbol", 14 } };
static constexpr auto ALL_RATIOS_DATA_FILENAME = L"CURRENCY_CONVERTER_ALL_RATIOS_DATA.txt"; static constexpr auto ALL_RATIOS_DATA_FILENAME = L"CURRENCY_CONVERTER_ALL_RATIOS_DATA.txt";
@ -275,8 +277,8 @@ pair<wstring, wstring> CurrencyDataLoader::GetCurrencyRatioEquality(_In_ const U
wstring digitSymbol = wstring{ LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'1') }; wstring digitSymbol = wstring{ LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'1') };
wstring roundedFormat = m_ratioFormatter->Format(rounded)->Data(); wstring roundedFormat = m_ratioFormatter->Format(rounded)->Data();
wstring ratioString = LocalizationStringUtil::GetLocalizedString(m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.abbreviation.c_str(), wstring ratioString = LocalizationStringUtil::GetLocalizedString(
roundedFormat.c_str(), unit2.abbreviation.c_str()); m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.abbreviation.c_str(), roundedFormat.c_str(), unit2.abbreviation.c_str());
wstring accessibleRatioString = LocalizationStringUtil::GetLocalizedString( wstring accessibleRatioString = LocalizationStringUtil::GetLocalizedString(
m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.accessibleName.c_str(), roundedFormat.c_str(), unit2.accessibleName.c_str()); m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.accessibleName.c_str(), roundedFormat.c_str(), unit2.accessibleName.c_str());
@ -459,8 +461,11 @@ task<bool> CurrencyDataLoader::TryLoadDataFromWebOverrideAsync()
}; };
#pragma optimize("", on) #pragma optimize("", on)
bool CurrencyDataLoader::TryParseWebResponses(_In_ String ^ staticDataJson, _In_ String ^ allRatiosJson, _Inout_ vector<UCM::CurrencyStaticData>& staticData, bool CurrencyDataLoader::TryParseWebResponses(
_Inout_ CurrencyRatioMap& allRatiosData) _In_ String ^ staticDataJson,
_In_ String ^ allRatiosJson,
_Inout_ vector<UCM::CurrencyStaticData>& staticData,
_Inout_ CurrencyRatioMap& allRatiosData)
{ {
return TryParseStaticData(staticDataJson, staticData) && TryParseAllRatiosData(allRatiosJson, allRatiosData); return TryParseStaticData(staticDataJson, staticData) && TryParseAllRatiosData(allRatiosJson, allRatiosData);
} }

View file

@ -43,7 +43,8 @@ namespace CalculatorApp
struct CurrencyUnitMetadata struct CurrencyUnitMetadata
{ {
CurrencyUnitMetadata(const std::wstring& s) : symbol(s) CurrencyUnitMetadata(const std::wstring& s)
: symbol(s)
{ {
} }
@ -71,8 +72,8 @@ namespace CalculatorApp
// ICurrencyConverterDataLoader // ICurrencyConverterDataLoader
void SetViewModelCallback(const std::shared_ptr<UCM::IViewModelCurrencyCallback>& callback) override; void SetViewModelCallback(const std::shared_ptr<UCM::IViewModelCurrencyCallback>& callback) override;
std::pair<std::wstring, std::wstring> GetCurrencySymbols(const UCM::Unit& unit1, const UCM::Unit& unit2) override; std::pair<std::wstring, std::wstring> GetCurrencySymbols(const UCM::Unit& unit1, const UCM::Unit& unit2) override;
std::pair<std::wstring, std::wstring> GetCurrencyRatioEquality(_In_ const UnitConversionManager::Unit& unit1, std::pair<std::wstring, std::wstring>
_In_ const UnitConversionManager::Unit& unit2) override; GetCurrencyRatioEquality(_In_ const UnitConversionManager::Unit& unit1, _In_ const UnitConversionManager::Unit& unit2) override;
std::wstring GetCurrencyTimestamp() override; std::wstring GetCurrencyTimestamp() override;
concurrency::task<bool> TryLoadDataFromCacheAsync() override; concurrency::task<bool> TryLoadDataFromCacheAsync() override;
@ -88,8 +89,11 @@ namespace CalculatorApp
concurrency::task<bool> TryFinishLoadFromCacheAsync(); concurrency::task<bool> TryFinishLoadFromCacheAsync();
bool TryParseWebResponses(_In_ Platform::String ^ staticDataJson, _In_ Platform::String ^ allRatiosJson, bool TryParseWebResponses(
_Inout_ std::vector<UCM::CurrencyStaticData>& staticData, _Inout_ CurrencyRatioMap& allRatiosData); _In_ Platform::String ^ staticDataJson,
_In_ Platform::String ^ allRatiosJson,
_Inout_ std::vector<UCM::CurrencyStaticData>& staticData,
_Inout_ CurrencyRatioMap& allRatiosData);
bool TryParseStaticData(_In_ Platform::String ^ rawJson, _Inout_ std::vector<UCM::CurrencyStaticData>& staticData); bool TryParseStaticData(_In_ Platform::String ^ rawJson, _Inout_ std::vector<UCM::CurrencyStaticData>& staticData);
bool TryParseAllRatiosData(_In_ Platform::String ^ rawJson, _Inout_ CurrencyRatioMap& allRatiosData); bool TryParseAllRatiosData(_In_ Platform::String ^ rawJson, _Inout_ CurrencyRatioMap& allRatiosData);
concurrency::task<void> FinalizeUnits(_In_ const std::vector<UCM::CurrencyStaticData>& staticData, _In_ const CurrencyRatioMap& ratioMap); concurrency::task<void> FinalizeUnits(_In_ const std::vector<UCM::CurrencyStaticData>& staticData, _In_ const CurrencyRatioMap& ratioMap);

View file

@ -13,7 +13,9 @@ using namespace Windows::Web::Http;
static constexpr auto sc_MetadataUriLocalizeFor = L"https://go.microsoft.com/fwlink/?linkid=2041093&localizeFor="; static constexpr auto sc_MetadataUriLocalizeFor = L"https://go.microsoft.com/fwlink/?linkid=2041093&localizeFor=";
static constexpr auto sc_RatiosUriRelativeTo = L"https://go.microsoft.com/fwlink/?linkid=2041339&localCurrency="; static constexpr auto sc_RatiosUriRelativeTo = L"https://go.microsoft.com/fwlink/?linkid=2041339&localCurrency=";
CurrencyHttpClient::CurrencyHttpClient() : m_client(ref new HttpClient()), m_responseLanguage(L"en-US") CurrencyHttpClient::CurrencyHttpClient()
: m_client(ref new HttpClient())
, m_responseLanguage(L"en-US")
{ {
} }

View file

@ -18,7 +18,8 @@ using namespace Windows::Globalization;
static constexpr bool CONVERT_WITH_OFFSET_FIRST = true; static constexpr bool CONVERT_WITH_OFFSET_FIRST = true;
UnitConverterDataLoader::UnitConverterDataLoader(GeographicRegion ^ region) : m_currentRegionCode(region->CodeTwoLetter) UnitConverterDataLoader::UnitConverterDataLoader(GeographicRegion ^ region)
: m_currentRegionCode(region->CodeTwoLetter)
{ {
m_categoryList = make_shared<vector<UCM::Category>>(); m_categoryList = make_shared<vector<UCM::Category>>();
m_categoryToUnits = make_shared<UCM::CategoryToUnitVectorMap>(); m_categoryToUnits = make_shared<UCM::CategoryToUnitVectorMap>();
@ -53,8 +54,9 @@ bool UnitConverterDataLoader::SupportsCategory(const UCM::Category& target)
} }
static int currencyId = NavCategory::Serialize(ViewMode::Currency); static int currencyId = NavCategory::Serialize(ViewMode::Currency);
auto itr = find_if(supportedCategories->begin(), supportedCategories->end(), auto itr = find_if(supportedCategories->begin(), supportedCategories->end(), [&](const UCM::Category& category) {
[&](const UCM::Category& category) { return currencyId != category.id && target.id == category.id; }); return currencyId != category.id && target.id == category.id;
});
return itr != supportedCategories->end(); return itr != supportedCategories->end();
} }
@ -182,34 +184,65 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map<ViewMode, vector<Order
OrderedUnit{ UnitConverterUnits::Area_Acre, GetLocalizedStringName(L"UnitName_Acre"), GetLocalizedStringName(L"UnitAbbreviation_Acre"), 9 }); OrderedUnit{ UnitConverterUnits::Area_Acre, GetLocalizedStringName(L"UnitName_Acre"), GetLocalizedStringName(L"UnitAbbreviation_Acre"), 9 });
areaUnits.push_back( areaUnits.push_back(
OrderedUnit{ UnitConverterUnits::Area_Hectare, GetLocalizedStringName(L"UnitName_Hectare"), GetLocalizedStringName(L"UnitAbbreviation_Hectare"), 4 }); OrderedUnit{ UnitConverterUnits::Area_Hectare, GetLocalizedStringName(L"UnitName_Hectare"), GetLocalizedStringName(L"UnitAbbreviation_Hectare"), 4 });
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareCentimeter, GetLocalizedStringName(L"UnitName_SquareCentimeter"), areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareCentimeter,
GetLocalizedStringName(L"UnitAbbreviation_SquareCentimeter"), 2 }); GetLocalizedStringName(L"UnitName_SquareCentimeter"),
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareFoot, GetLocalizedStringName(L"UnitName_SquareFoot"), GetLocalizedStringName(L"UnitAbbreviation_SquareCentimeter"),
GetLocalizedStringName(L"UnitAbbreviation_SquareFoot"), 7, useSI, useUSCustomary, false }); 2 });
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareInch, GetLocalizedStringName(L"UnitName_SquareInch"), areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareFoot,
GetLocalizedStringName(L"UnitAbbreviation_SquareInch"), 6 }); GetLocalizedStringName(L"UnitName_SquareFoot"),
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareKilometer, GetLocalizedStringName(L"UnitName_SquareKilometer"), GetLocalizedStringName(L"UnitAbbreviation_SquareFoot"),
GetLocalizedStringName(L"UnitAbbreviation_SquareKilometer"), 5 }); 7,
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareMeter, GetLocalizedStringName(L"UnitName_SquareMeter"), useSI,
GetLocalizedStringName(L"UnitAbbreviation_SquareMeter"), 3, useUSCustomary, useSI, false }); useUSCustomary,
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareMile, GetLocalizedStringName(L"UnitName_SquareMile"), false });
GetLocalizedStringName(L"UnitAbbreviation_SquareMile"), 10 }); areaUnits.push_back(OrderedUnit{
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareMillimeter, GetLocalizedStringName(L"UnitName_SquareMillimeter"), UnitConverterUnits::Area_SquareInch, GetLocalizedStringName(L"UnitName_SquareInch"), GetLocalizedStringName(L"UnitAbbreviation_SquareInch"), 6 });
GetLocalizedStringName(L"UnitAbbreviation_SquareMillimeter"), 1 }); areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareKilometer,
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareYard, GetLocalizedStringName(L"UnitName_SquareYard"), GetLocalizedStringName(L"UnitName_SquareKilometer"),
GetLocalizedStringName(L"UnitAbbreviation_SquareYard"), 8 }); GetLocalizedStringName(L"UnitAbbreviation_SquareKilometer"),
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_Hand, GetLocalizedStringName(L"UnitName_Hand"), GetLocalizedStringName(L"UnitAbbreviation_Hand"), 5 });
11, false, false, true }); areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareMeter,
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_Paper, GetLocalizedStringName(L"UnitName_Paper"), GetLocalizedStringName(L"UnitName_SquareMeter"),
GetLocalizedStringName(L"UnitAbbreviation_Paper"), 12, false, false, true }); GetLocalizedStringName(L"UnitAbbreviation_SquareMeter"),
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SoccerField, GetLocalizedStringName(L"UnitName_SoccerField"), 3,
GetLocalizedStringName(L"UnitAbbreviation_SoccerField"), 13, false, false, true }); useUSCustomary,
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_Castle, GetLocalizedStringName(L"UnitName_Castle"), useSI,
GetLocalizedStringName(L"UnitAbbreviation_Castle"), 14, false, false, true }); false });
areaUnits.push_back(OrderedUnit{
UnitConverterUnits::Area_SquareMile, GetLocalizedStringName(L"UnitName_SquareMile"), GetLocalizedStringName(L"UnitAbbreviation_SquareMile"), 10 });
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SquareMillimeter,
GetLocalizedStringName(L"UnitName_SquareMillimeter"),
GetLocalizedStringName(L"UnitAbbreviation_SquareMillimeter"),
1 });
areaUnits.push_back(OrderedUnit{
UnitConverterUnits::Area_SquareYard, GetLocalizedStringName(L"UnitName_SquareYard"), GetLocalizedStringName(L"UnitAbbreviation_SquareYard"), 8 });
areaUnits.push_back(OrderedUnit{
UnitConverterUnits::Area_Hand, GetLocalizedStringName(L"UnitName_Hand"), GetLocalizedStringName(L"UnitAbbreviation_Hand"), 11, false, false, true });
areaUnits.push_back(OrderedUnit{
UnitConverterUnits::Area_Paper, GetLocalizedStringName(L"UnitName_Paper"), GetLocalizedStringName(L"UnitAbbreviation_Paper"), 12, false, false, true });
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_SoccerField,
GetLocalizedStringName(L"UnitName_SoccerField"),
GetLocalizedStringName(L"UnitAbbreviation_SoccerField"),
13,
false,
false,
true });
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_Castle,
GetLocalizedStringName(L"UnitName_Castle"),
GetLocalizedStringName(L"UnitAbbreviation_Castle"),
14,
false,
false,
true });
if (usePyeong) if (usePyeong)
{ {
areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_Pyeong, GetLocalizedStringName(L"UnitName_Pyeong"), areaUnits.push_back(OrderedUnit{ UnitConverterUnits::Area_Pyeong,
GetLocalizedStringName(L"UnitAbbreviation_Pyeong"), 15, false, false, false }); GetLocalizedStringName(L"UnitName_Pyeong"),
GetLocalizedStringName(L"UnitAbbreviation_Pyeong"),
15,
false,
false,
false });
} }
unitMap.emplace(ViewMode::Area, areaUnits); unitMap.emplace(ViewMode::Area, areaUnits);
@ -220,169 +253,275 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map<ViewMode, vector<Order
OrderedUnit{ UnitConverterUnits::Data_Byte, GetLocalizedStringName(L"UnitName_Byte"), GetLocalizedStringName(L"UnitAbbreviation_Byte"), 2 }); OrderedUnit{ UnitConverterUnits::Data_Byte, GetLocalizedStringName(L"UnitName_Byte"), GetLocalizedStringName(L"UnitAbbreviation_Byte"), 2 });
dataUnits.push_back( dataUnits.push_back(
OrderedUnit{ UnitConverterUnits::Data_Exabits, GetLocalizedStringName(L"UnitName_Exabits"), GetLocalizedStringName(L"UnitAbbreviation_Exabits"), 23 }); OrderedUnit{ UnitConverterUnits::Data_Exabits, GetLocalizedStringName(L"UnitName_Exabits"), GetLocalizedStringName(L"UnitAbbreviation_Exabits"), 23 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Exabytes, GetLocalizedStringName(L"UnitName_Exabytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Exabytes"), 25 }); UnitConverterUnits::Data_Exabytes, GetLocalizedStringName(L"UnitName_Exabytes"), GetLocalizedStringName(L"UnitAbbreviation_Exabytes"), 25 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Exbibits, GetLocalizedStringName(L"UnitName_Exbibits"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Exbibits"), 24 }); UnitConverterUnits::Data_Exbibits, GetLocalizedStringName(L"UnitName_Exbibits"), GetLocalizedStringName(L"UnitAbbreviation_Exbibits"), 24 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Exbibytes, GetLocalizedStringName(L"UnitName_Exbibytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Exbibytes"), 26 }); UnitConverterUnits::Data_Exbibytes, GetLocalizedStringName(L"UnitName_Exbibytes"), GetLocalizedStringName(L"UnitAbbreviation_Exbibytes"), 26 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gibibits, GetLocalizedStringName(L"UnitName_Gibibits"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Gibibits"), 12 }); UnitConverterUnits::Data_Gibibits, GetLocalizedStringName(L"UnitName_Gibibits"), GetLocalizedStringName(L"UnitAbbreviation_Gibibits"), 12 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gibibytes, GetLocalizedStringName(L"UnitName_Gibibytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Gibibytes"), 14 }); UnitConverterUnits::Data_Gibibytes, GetLocalizedStringName(L"UnitName_Gibibytes"), GetLocalizedStringName(L"UnitAbbreviation_Gibibytes"), 14 });
dataUnits.push_back( dataUnits.push_back(
OrderedUnit{ UnitConverterUnits::Data_Gigabit, GetLocalizedStringName(L"UnitName_Gigabit"), GetLocalizedStringName(L"UnitAbbreviation_Gigabit"), 11 }); OrderedUnit{ UnitConverterUnits::Data_Gigabit, GetLocalizedStringName(L"UnitName_Gigabit"), GetLocalizedStringName(L"UnitAbbreviation_Gigabit"), 11 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gigabyte, GetLocalizedStringName(L"UnitName_Gigabyte"), dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gigabyte,
GetLocalizedStringName(L"UnitAbbreviation_Gigabyte"), 13, true, false, false }); GetLocalizedStringName(L"UnitName_Gigabyte"),
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Kibibits, GetLocalizedStringName(L"UnitName_Kibibits"), GetLocalizedStringName(L"UnitAbbreviation_Gigabyte"),
GetLocalizedStringName(L"UnitAbbreviation_Kibibits"), 4 }); 13,
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Kibibytes, GetLocalizedStringName(L"UnitName_Kibibytes"), true,
GetLocalizedStringName(L"UnitAbbreviation_Kibibytes"), 6 }); false,
false });
dataUnits.push_back(OrderedUnit{
UnitConverterUnits::Data_Kibibits, GetLocalizedStringName(L"UnitName_Kibibits"), GetLocalizedStringName(L"UnitAbbreviation_Kibibits"), 4 });
dataUnits.push_back(OrderedUnit{
UnitConverterUnits::Data_Kibibytes, GetLocalizedStringName(L"UnitName_Kibibytes"), GetLocalizedStringName(L"UnitAbbreviation_Kibibytes"), 6 });
dataUnits.push_back( dataUnits.push_back(
OrderedUnit{ UnitConverterUnits::Data_Kilobit, GetLocalizedStringName(L"UnitName_Kilobit"), GetLocalizedStringName(L"UnitAbbreviation_Kilobit"), 3 }); OrderedUnit{ UnitConverterUnits::Data_Kilobit, GetLocalizedStringName(L"UnitName_Kilobit"), GetLocalizedStringName(L"UnitAbbreviation_Kilobit"), 3 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Kilobyte, GetLocalizedStringName(L"UnitName_Kilobyte"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Kilobyte"), 5 }); UnitConverterUnits::Data_Kilobyte, GetLocalizedStringName(L"UnitName_Kilobyte"), GetLocalizedStringName(L"UnitAbbreviation_Kilobyte"), 5 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Mebibits, GetLocalizedStringName(L"UnitName_Mebibits"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Mebibits"), 8 }); UnitConverterUnits::Data_Mebibits, GetLocalizedStringName(L"UnitName_Mebibits"), GetLocalizedStringName(L"UnitAbbreviation_Mebibits"), 8 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Mebibytes, GetLocalizedStringName(L"UnitName_Mebibytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Mebibytes"), 10 }); UnitConverterUnits::Data_Mebibytes, GetLocalizedStringName(L"UnitName_Mebibytes"), GetLocalizedStringName(L"UnitAbbreviation_Mebibytes"), 10 });
dataUnits.push_back( dataUnits.push_back(
OrderedUnit{ UnitConverterUnits::Data_Megabit, GetLocalizedStringName(L"UnitName_Megabit"), GetLocalizedStringName(L"UnitAbbreviation_Megabit"), 7 }); OrderedUnit{ UnitConverterUnits::Data_Megabit, GetLocalizedStringName(L"UnitName_Megabit"), GetLocalizedStringName(L"UnitAbbreviation_Megabit"), 7 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Megabyte, GetLocalizedStringName(L"UnitName_Megabyte"), dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Megabyte,
GetLocalizedStringName(L"UnitAbbreviation_Megabyte"), 9, false, true, false }); GetLocalizedStringName(L"UnitName_Megabyte"),
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Pebibits, GetLocalizedStringName(L"UnitName_Pebibits"), GetLocalizedStringName(L"UnitAbbreviation_Megabyte"),
GetLocalizedStringName(L"UnitAbbreviation_Pebibits"), 20 }); 9,
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Pebibytes, GetLocalizedStringName(L"UnitName_Pebibytes"), false,
GetLocalizedStringName(L"UnitAbbreviation_Pebibytes"), 22 }); true,
false });
dataUnits.push_back(OrderedUnit{
UnitConverterUnits::Data_Pebibits, GetLocalizedStringName(L"UnitName_Pebibits"), GetLocalizedStringName(L"UnitAbbreviation_Pebibits"), 20 });
dataUnits.push_back(OrderedUnit{
UnitConverterUnits::Data_Pebibytes, GetLocalizedStringName(L"UnitName_Pebibytes"), GetLocalizedStringName(L"UnitAbbreviation_Pebibytes"), 22 });
dataUnits.push_back( dataUnits.push_back(
OrderedUnit{ UnitConverterUnits::Data_Petabit, GetLocalizedStringName(L"UnitName_Petabit"), GetLocalizedStringName(L"UnitAbbreviation_Petabit"), 19 }); OrderedUnit{ UnitConverterUnits::Data_Petabit, GetLocalizedStringName(L"UnitName_Petabit"), GetLocalizedStringName(L"UnitAbbreviation_Petabit"), 19 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Petabyte, GetLocalizedStringName(L"UnitName_Petabyte"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Petabyte"), 21 }); UnitConverterUnits::Data_Petabyte, GetLocalizedStringName(L"UnitName_Petabyte"), GetLocalizedStringName(L"UnitAbbreviation_Petabyte"), 21 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Tebibits, GetLocalizedStringName(L"UnitName_Tebibits"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Tebibits"), 16 }); UnitConverterUnits::Data_Tebibits, GetLocalizedStringName(L"UnitName_Tebibits"), GetLocalizedStringName(L"UnitAbbreviation_Tebibits"), 16 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Tebibytes, GetLocalizedStringName(L"UnitName_Tebibytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Tebibytes"), 18 }); UnitConverterUnits::Data_Tebibytes, GetLocalizedStringName(L"UnitName_Tebibytes"), GetLocalizedStringName(L"UnitAbbreviation_Tebibytes"), 18 });
dataUnits.push_back( dataUnits.push_back(
OrderedUnit{ UnitConverterUnits::Data_Terabit, GetLocalizedStringName(L"UnitName_Terabit"), GetLocalizedStringName(L"UnitAbbreviation_Terabit"), 15 }); OrderedUnit{ UnitConverterUnits::Data_Terabit, GetLocalizedStringName(L"UnitName_Terabit"), GetLocalizedStringName(L"UnitAbbreviation_Terabit"), 15 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Terabyte, GetLocalizedStringName(L"UnitName_Terabyte"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Terabyte"), 17 }); UnitConverterUnits::Data_Terabyte, GetLocalizedStringName(L"UnitName_Terabyte"), GetLocalizedStringName(L"UnitAbbreviation_Terabyte"), 17 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Yobibits, GetLocalizedStringName(L"UnitName_Yobibits"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Yobibits"), 32 }); UnitConverterUnits::Data_Yobibits, GetLocalizedStringName(L"UnitName_Yobibits"), GetLocalizedStringName(L"UnitAbbreviation_Yobibits"), 32 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Yobibytes, GetLocalizedStringName(L"UnitName_Yobibytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Yobibytes"), 34 }); UnitConverterUnits::Data_Yobibytes, GetLocalizedStringName(L"UnitName_Yobibytes"), GetLocalizedStringName(L"UnitAbbreviation_Yobibytes"), 34 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Yottabit, GetLocalizedStringName(L"UnitName_Yottabit"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Yottabit"), 31 }); UnitConverterUnits::Data_Yottabit, GetLocalizedStringName(L"UnitName_Yottabit"), GetLocalizedStringName(L"UnitAbbreviation_Yottabit"), 31 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Yottabyte, GetLocalizedStringName(L"UnitName_Yottabyte"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Yottabyte"), 33 }); UnitConverterUnits::Data_Yottabyte, GetLocalizedStringName(L"UnitName_Yottabyte"), GetLocalizedStringName(L"UnitAbbreviation_Yottabyte"), 33 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Zebibits, GetLocalizedStringName(L"UnitName_Zebibits"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Zebibits"), 28 }); UnitConverterUnits::Data_Zebibits, GetLocalizedStringName(L"UnitName_Zebibits"), GetLocalizedStringName(L"UnitAbbreviation_Zebibits"), 28 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Zebibytes, GetLocalizedStringName(L"UnitName_Zebibytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Zebibytes"), 30 }); UnitConverterUnits::Data_Zebibytes, GetLocalizedStringName(L"UnitName_Zebibytes"), GetLocalizedStringName(L"UnitAbbreviation_Zebibytes"), 30 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Zetabits, GetLocalizedStringName(L"UnitName_Zetabits"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Zetabits"), 27 }); UnitConverterUnits::Data_Zetabits, GetLocalizedStringName(L"UnitName_Zetabits"), GetLocalizedStringName(L"UnitAbbreviation_Zetabits"), 27 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Zetabytes, GetLocalizedStringName(L"UnitName_Zetabytes"), dataUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Zetabytes"), 29 }); UnitConverterUnits::Data_Zetabytes, GetLocalizedStringName(L"UnitName_Zetabytes"), GetLocalizedStringName(L"UnitAbbreviation_Zetabytes"), 29 });
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_FloppyDisk, GetLocalizedStringName(L"UnitName_FloppyDisk"), dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_FloppyDisk,
GetLocalizedStringName(L"UnitAbbreviation_FloppyDisk"), 13, false, false, true }); GetLocalizedStringName(L"UnitName_FloppyDisk"),
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_CD, GetLocalizedStringName(L"UnitName_CD"), GetLocalizedStringName(L"UnitAbbreviation_CD"), 14, GetLocalizedStringName(L"UnitAbbreviation_FloppyDisk"),
false, false, true }); 13,
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_DVD, GetLocalizedStringName(L"UnitName_DVD"), GetLocalizedStringName(L"UnitAbbreviation_DVD"), 15, false,
false, false, true }); false,
true });
dataUnits.push_back(OrderedUnit{
UnitConverterUnits::Data_CD, GetLocalizedStringName(L"UnitName_CD"), GetLocalizedStringName(L"UnitAbbreviation_CD"), 14, false, false, true });
dataUnits.push_back(OrderedUnit{
UnitConverterUnits::Data_DVD, GetLocalizedStringName(L"UnitName_DVD"), GetLocalizedStringName(L"UnitAbbreviation_DVD"), 15, false, false, true });
unitMap.emplace(ViewMode::Data, dataUnits); unitMap.emplace(ViewMode::Data, dataUnits);
vector<OrderedUnit> energyUnits; vector<OrderedUnit> energyUnits;
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_BritishThermalUnit, GetLocalizedStringName(L"UnitName_BritishThermalUnit"), energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_BritishThermalUnit,
GetLocalizedStringName(L"UnitAbbreviation_BritishThermalUnit"), 7 }); GetLocalizedStringName(L"UnitName_BritishThermalUnit"),
GetLocalizedStringName(L"UnitAbbreviation_BritishThermalUnit"),
7 });
energyUnits.push_back( energyUnits.push_back(
OrderedUnit{ UnitConverterUnits::Energy_Calorie, GetLocalizedStringName(L"UnitName_Calorie"), GetLocalizedStringName(L"UnitAbbreviation_Calorie"), 4 }); OrderedUnit{ UnitConverterUnits::Energy_Calorie, GetLocalizedStringName(L"UnitName_Calorie"), GetLocalizedStringName(L"UnitAbbreviation_Calorie"), 4 });
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_ElectronVolt, GetLocalizedStringName(L"UnitName_Electron-Volt"), energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_ElectronVolt,
GetLocalizedStringName(L"UnitAbbreviation_Electron-Volt"), 1 }); GetLocalizedStringName(L"UnitName_Electron-Volt"),
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_FootPound, GetLocalizedStringName(L"UnitName_Foot-Pound"), GetLocalizedStringName(L"UnitAbbreviation_Electron-Volt"),
GetLocalizedStringName(L"UnitAbbreviation_Foot-Pound"), 6 }); 1 });
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Joule, GetLocalizedStringName(L"UnitName_Joule"), energyUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Joule"), 2, true, false, false }); UnitConverterUnits::Energy_FootPound, GetLocalizedStringName(L"UnitName_Foot-Pound"), GetLocalizedStringName(L"UnitAbbreviation_Foot-Pound"), 6 });
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Kilocalorie, GetLocalizedStringName(L"UnitName_Kilocalorie"), energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Joule,
GetLocalizedStringName(L"UnitAbbreviation_Kilocalorie"), 5, false, true, false }); GetLocalizedStringName(L"UnitName_Joule"),
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Kilojoule, GetLocalizedStringName(L"UnitName_Kilojoule"), GetLocalizedStringName(L"UnitAbbreviation_Joule"),
GetLocalizedStringName(L"UnitAbbreviation_Kilojoule"), 3 }); 2,
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Battery, GetLocalizedStringName(L"UnitName_Battery"), true,
GetLocalizedStringName(L"UnitAbbreviation_Battery"), 8, false, false, true }); false,
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Banana, GetLocalizedStringName(L"UnitName_Banana"), false });
GetLocalizedStringName(L"UnitAbbreviation_Banana"), 9, false, false, true }); energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Kilocalorie,
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_SliceOfCake, GetLocalizedStringName(L"UnitName_SliceOfCake"), GetLocalizedStringName(L"UnitName_Kilocalorie"),
GetLocalizedStringName(L"UnitAbbreviation_SliceOfCake"), 10, false, false, true }); GetLocalizedStringName(L"UnitAbbreviation_Kilocalorie"),
5,
false,
true,
false });
energyUnits.push_back(OrderedUnit{
UnitConverterUnits::Energy_Kilojoule, GetLocalizedStringName(L"UnitName_Kilojoule"), GetLocalizedStringName(L"UnitAbbreviation_Kilojoule"), 3 });
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Battery,
GetLocalizedStringName(L"UnitName_Battery"),
GetLocalizedStringName(L"UnitAbbreviation_Battery"),
8,
false,
false,
true });
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_Banana,
GetLocalizedStringName(L"UnitName_Banana"),
GetLocalizedStringName(L"UnitAbbreviation_Banana"),
9,
false,
false,
true });
energyUnits.push_back(OrderedUnit{ UnitConverterUnits::Energy_SliceOfCake,
GetLocalizedStringName(L"UnitName_SliceOfCake"),
GetLocalizedStringName(L"UnitAbbreviation_SliceOfCake"),
10,
false,
false,
true });
unitMap.emplace(ViewMode::Energy, energyUnits); unitMap.emplace(ViewMode::Energy, energyUnits);
vector<OrderedUnit> lengthUnits; vector<OrderedUnit> lengthUnits;
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Centimeter, GetLocalizedStringName(L"UnitName_Centimeter"), lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Centimeter,
GetLocalizedStringName(L"UnitAbbreviation_Centimeter"), 4, useUSCustomary, useSI, false }); GetLocalizedStringName(L"UnitName_Centimeter"),
GetLocalizedStringName(L"UnitAbbreviation_Centimeter"),
4,
useUSCustomary,
useSI,
false });
lengthUnits.push_back( lengthUnits.push_back(
OrderedUnit{ UnitConverterUnits::Length_Foot, GetLocalizedStringName(L"UnitName_Foot"), GetLocalizedStringName(L"UnitAbbreviation_Foot"), 8 }); OrderedUnit{ UnitConverterUnits::Length_Foot, GetLocalizedStringName(L"UnitName_Foot"), GetLocalizedStringName(L"UnitAbbreviation_Foot"), 8 });
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Inch, GetLocalizedStringName(L"UnitName_Inch"), lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Inch,
GetLocalizedStringName(L"UnitAbbreviation_Inch"), 7, useSI, useUSCustomary, false }); GetLocalizedStringName(L"UnitName_Inch"),
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Kilometer, GetLocalizedStringName(L"UnitName_Kilometer"), GetLocalizedStringName(L"UnitAbbreviation_Inch"),
GetLocalizedStringName(L"UnitAbbreviation_Kilometer"), 6 }); 7,
useSI,
useUSCustomary,
false });
lengthUnits.push_back(OrderedUnit{
UnitConverterUnits::Length_Kilometer, GetLocalizedStringName(L"UnitName_Kilometer"), GetLocalizedStringName(L"UnitAbbreviation_Kilometer"), 6 });
lengthUnits.push_back( lengthUnits.push_back(
OrderedUnit{ UnitConverterUnits::Length_Meter, GetLocalizedStringName(L"UnitName_Meter"), GetLocalizedStringName(L"UnitAbbreviation_Meter"), 5 }); OrderedUnit{ UnitConverterUnits::Length_Meter, GetLocalizedStringName(L"UnitName_Meter"), GetLocalizedStringName(L"UnitAbbreviation_Meter"), 5 });
lengthUnits.push_back( lengthUnits.push_back(
OrderedUnit{ UnitConverterUnits::Length_Micron, GetLocalizedStringName(L"UnitName_Micron"), GetLocalizedStringName(L"UnitAbbreviation_Micron"), 2 }); OrderedUnit{ UnitConverterUnits::Length_Micron, GetLocalizedStringName(L"UnitName_Micron"), GetLocalizedStringName(L"UnitAbbreviation_Micron"), 2 });
lengthUnits.push_back( lengthUnits.push_back(
OrderedUnit{ UnitConverterUnits::Length_Mile, GetLocalizedStringName(L"UnitName_Mile"), GetLocalizedStringName(L"UnitAbbreviation_Mile"), 10 }); OrderedUnit{ UnitConverterUnits::Length_Mile, GetLocalizedStringName(L"UnitName_Mile"), GetLocalizedStringName(L"UnitAbbreviation_Mile"), 10 });
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Millimeter, GetLocalizedStringName(L"UnitName_Millimeter"), lengthUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Millimeter"), 3 }); UnitConverterUnits::Length_Millimeter, GetLocalizedStringName(L"UnitName_Millimeter"), GetLocalizedStringName(L"UnitAbbreviation_Millimeter"), 3 });
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Nanometer, GetLocalizedStringName(L"UnitName_Nanometer"), lengthUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Nanometer"), 1 }); UnitConverterUnits::Length_Nanometer, GetLocalizedStringName(L"UnitName_Nanometer"), GetLocalizedStringName(L"UnitAbbreviation_Nanometer"), 1 });
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_NauticalMile, GetLocalizedStringName(L"UnitName_NauticalMile"), lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_NauticalMile,
GetLocalizedStringName(L"UnitAbbreviation_NauticalMile"), 11 }); GetLocalizedStringName(L"UnitName_NauticalMile"),
GetLocalizedStringName(L"UnitAbbreviation_NauticalMile"),
11 });
lengthUnits.push_back( lengthUnits.push_back(
OrderedUnit{ UnitConverterUnits::Length_Yard, GetLocalizedStringName(L"UnitName_Yard"), GetLocalizedStringName(L"UnitAbbreviation_Yard"), 9 }); OrderedUnit{ UnitConverterUnits::Length_Yard, GetLocalizedStringName(L"UnitName_Yard"), GetLocalizedStringName(L"UnitAbbreviation_Yard"), 9 });
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Paperclip, GetLocalizedStringName(L"UnitName_Paperclip"), lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Paperclip,
GetLocalizedStringName(L"UnitAbbreviation_Paperclip"), 12, false, false, true }); GetLocalizedStringName(L"UnitName_Paperclip"),
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_Hand, GetLocalizedStringName(L"UnitName_Hand"), GetLocalizedStringName(L"UnitAbbreviation_Paperclip"),
GetLocalizedStringName(L"UnitAbbreviation_Hand"), 13, false, false, true }); 12,
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_JumboJet, GetLocalizedStringName(L"UnitName_JumboJet"), false,
GetLocalizedStringName(L"UnitAbbreviation_JumboJet"), 14, false, false, true }); false,
true });
lengthUnits.push_back(OrderedUnit{
UnitConverterUnits::Length_Hand, GetLocalizedStringName(L"UnitName_Hand"), GetLocalizedStringName(L"UnitAbbreviation_Hand"), 13, false, false, true });
lengthUnits.push_back(OrderedUnit{ UnitConverterUnits::Length_JumboJet,
GetLocalizedStringName(L"UnitName_JumboJet"),
GetLocalizedStringName(L"UnitAbbreviation_JumboJet"),
14,
false,
false,
true });
unitMap.emplace(ViewMode::Length, lengthUnits); unitMap.emplace(ViewMode::Length, lengthUnits);
vector<OrderedUnit> powerUnits; vector<OrderedUnit> powerUnits;
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_BritishThermalUnitPerMinute, GetLocalizedStringName(L"UnitName_BTUPerMinute"), powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_BritishThermalUnitPerMinute,
GetLocalizedStringName(L"UnitAbbreviation_BTUPerMinute"), 5 }); GetLocalizedStringName(L"UnitName_BTUPerMinute"),
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_FootPoundPerMinute, GetLocalizedStringName(L"UnitName_Foot-PoundPerMinute"), GetLocalizedStringName(L"UnitAbbreviation_BTUPerMinute"),
GetLocalizedStringName(L"UnitAbbreviation_Foot-PoundPerMinute"), 4 }); 5 });
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Horsepower, GetLocalizedStringName(L"UnitName_Horsepower"), powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_FootPoundPerMinute,
GetLocalizedStringName(L"UnitAbbreviation_Horsepower"), 3, false, true, false }); GetLocalizedStringName(L"UnitName_Foot-PoundPerMinute"),
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Kilowatt, GetLocalizedStringName(L"UnitName_Kilowatt"), GetLocalizedStringName(L"UnitAbbreviation_Foot-PoundPerMinute"),
GetLocalizedStringName(L"UnitAbbreviation_Kilowatt"), 2, !useWattInsteadOfKilowatt }); 4 });
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Watt, GetLocalizedStringName(L"UnitName_Watt"), powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Horsepower,
GetLocalizedStringName(L"UnitAbbreviation_Watt"), 1, useWattInsteadOfKilowatt }); GetLocalizedStringName(L"UnitName_Horsepower"),
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_LightBulb, GetLocalizedStringName(L"UnitName_LightBulb"), GetLocalizedStringName(L"UnitAbbreviation_Horsepower"),
GetLocalizedStringName(L"UnitAbbreviation_LightBulb"), 6, false, false, true }); 3,
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Horse, GetLocalizedStringName(L"UnitName_Horse"), false,
GetLocalizedStringName(L"UnitAbbreviation_Horse"), 7, false, false, true }); true,
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_TrainEngine, GetLocalizedStringName(L"UnitName_TrainEngine"), false });
GetLocalizedStringName(L"UnitAbbreviation_TrainEngine"), 8, false, false, true }); powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Kilowatt,
GetLocalizedStringName(L"UnitName_Kilowatt"),
GetLocalizedStringName(L"UnitAbbreviation_Kilowatt"),
2,
!useWattInsteadOfKilowatt });
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_Watt,
GetLocalizedStringName(L"UnitName_Watt"),
GetLocalizedStringName(L"UnitAbbreviation_Watt"),
1,
useWattInsteadOfKilowatt });
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_LightBulb,
GetLocalizedStringName(L"UnitName_LightBulb"),
GetLocalizedStringName(L"UnitAbbreviation_LightBulb"),
6,
false,
false,
true });
powerUnits.push_back(OrderedUnit{
UnitConverterUnits::Power_Horse, GetLocalizedStringName(L"UnitName_Horse"), GetLocalizedStringName(L"UnitAbbreviation_Horse"), 7, false, false, true });
powerUnits.push_back(OrderedUnit{ UnitConverterUnits::Power_TrainEngine,
GetLocalizedStringName(L"UnitName_TrainEngine"),
GetLocalizedStringName(L"UnitAbbreviation_TrainEngine"),
8,
false,
false,
true });
unitMap.emplace(ViewMode::Power, powerUnits); unitMap.emplace(ViewMode::Power, powerUnits);
vector<OrderedUnit> tempUnits; vector<OrderedUnit> tempUnits;
tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesCelsius, GetLocalizedStringName(L"UnitName_DegreesCelsius"), tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesCelsius,
GetLocalizedStringName(L"UnitAbbreviation_DegreesCelsius"), 1, useFahrenheit, !useFahrenheit, false }); GetLocalizedStringName(L"UnitName_DegreesCelsius"),
tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesFahrenheit, GetLocalizedStringName(L"UnitName_DegreesFahrenheit"), GetLocalizedStringName(L"UnitAbbreviation_DegreesCelsius"),
GetLocalizedStringName(L"UnitAbbreviation_DegreesFahrenheit"), 2, !useFahrenheit, useFahrenheit, false }); 1,
tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_Kelvin, GetLocalizedStringName(L"UnitName_Kelvin"), useFahrenheit,
GetLocalizedStringName(L"UnitAbbreviation_Kelvin"), 3 }); !useFahrenheit,
false });
tempUnits.push_back(OrderedUnit{ UnitConverterUnits::Temperature_DegreesFahrenheit,
GetLocalizedStringName(L"UnitName_DegreesFahrenheit"),
GetLocalizedStringName(L"UnitAbbreviation_DegreesFahrenheit"),
2,
!useFahrenheit,
useFahrenheit,
false });
tempUnits.push_back(OrderedUnit{
UnitConverterUnits::Temperature_Kelvin, GetLocalizedStringName(L"UnitName_Kelvin"), GetLocalizedStringName(L"UnitAbbreviation_Kelvin"), 3 });
unitMap.emplace(ViewMode::Temperature, tempUnits); unitMap.emplace(ViewMode::Temperature, tempUnits);
vector<OrderedUnit> timeUnits; vector<OrderedUnit> timeUnits;
timeUnits.push_back( timeUnits.push_back(
OrderedUnit{ UnitConverterUnits::Time_Day, GetLocalizedStringName(L"UnitName_Day"), GetLocalizedStringName(L"UnitAbbreviation_Day"), 6 }); OrderedUnit{ UnitConverterUnits::Time_Day, GetLocalizedStringName(L"UnitName_Day"), GetLocalizedStringName(L"UnitAbbreviation_Day"), 6 });
timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Hour, GetLocalizedStringName(L"UnitName_Hour"), GetLocalizedStringName(L"UnitAbbreviation_Hour"), timeUnits.push_back(OrderedUnit{
5, true, false, false }); UnitConverterUnits::Time_Hour, GetLocalizedStringName(L"UnitName_Hour"), GetLocalizedStringName(L"UnitAbbreviation_Hour"), 5, true, false, false });
timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Microsecond, GetLocalizedStringName(L"UnitName_Microsecond"), timeUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Microsecond"), 1 }); UnitConverterUnits::Time_Microsecond, GetLocalizedStringName(L"UnitName_Microsecond"), GetLocalizedStringName(L"UnitAbbreviation_Microsecond"), 1 });
timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Millisecond, GetLocalizedStringName(L"UnitName_Millisecond"), timeUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Millisecond"), 2 }); UnitConverterUnits::Time_Millisecond, GetLocalizedStringName(L"UnitName_Millisecond"), GetLocalizedStringName(L"UnitAbbreviation_Millisecond"), 2 });
timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Minute, GetLocalizedStringName(L"UnitName_Minute"), timeUnits.push_back(OrderedUnit{ UnitConverterUnits::Time_Minute,
GetLocalizedStringName(L"UnitAbbreviation_Minute"), 4, false, true, false }); GetLocalizedStringName(L"UnitName_Minute"),
GetLocalizedStringName(L"UnitAbbreviation_Minute"),
4,
false,
true,
false });
timeUnits.push_back( timeUnits.push_back(
OrderedUnit{ UnitConverterUnits::Time_Second, GetLocalizedStringName(L"UnitName_Second"), GetLocalizedStringName(L"UnitAbbreviation_Second"), 3 }); OrderedUnit{ UnitConverterUnits::Time_Second, GetLocalizedStringName(L"UnitName_Second"), GetLocalizedStringName(L"UnitAbbreviation_Second"), 3 });
timeUnits.push_back( timeUnits.push_back(
@ -392,136 +531,239 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map<ViewMode, vector<Order
unitMap.emplace(ViewMode::Time, timeUnits); unitMap.emplace(ViewMode::Time, timeUnits);
vector<OrderedUnit> speedUnits; vector<OrderedUnit> speedUnits;
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_CentimetersPerSecond, GetLocalizedStringName(L"UnitName_CentimetersPerSecond"), speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_CentimetersPerSecond,
GetLocalizedStringName(L"UnitAbbreviation_CentimetersPerSecond"), 1 }); GetLocalizedStringName(L"UnitName_CentimetersPerSecond"),
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_FeetPerSecond, GetLocalizedStringName(L"UnitName_FeetPerSecond"), GetLocalizedStringName(L"UnitAbbreviation_CentimetersPerSecond"),
GetLocalizedStringName(L"UnitAbbreviation_FeetPerSecond"), 4 }); 1 });
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_KilometersPerHour, GetLocalizedStringName(L"UnitName_KilometersPerHour"), speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_FeetPerSecond,
GetLocalizedStringName(L"UnitAbbreviation_KilometersPerHour"), 3, useUSCustomary, useSI, false }); GetLocalizedStringName(L"UnitName_FeetPerSecond"),
GetLocalizedStringName(L"UnitAbbreviation_FeetPerSecond"),
4 });
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_KilometersPerHour,
GetLocalizedStringName(L"UnitName_KilometersPerHour"),
GetLocalizedStringName(L"UnitAbbreviation_KilometersPerHour"),
3,
useUSCustomary,
useSI,
false });
speedUnits.push_back( speedUnits.push_back(
OrderedUnit{ UnitConverterUnits::Speed_Knot, GetLocalizedStringName(L"UnitName_Knot"), GetLocalizedStringName(L"UnitAbbreviation_Knot"), 6 }); OrderedUnit{ UnitConverterUnits::Speed_Knot, GetLocalizedStringName(L"UnitName_Knot"), GetLocalizedStringName(L"UnitAbbreviation_Knot"), 6 });
speedUnits.push_back( speedUnits.push_back(
OrderedUnit{ UnitConverterUnits::Speed_Mach, GetLocalizedStringName(L"UnitName_Mach"), GetLocalizedStringName(L"UnitAbbreviation_Mach"), 7 }); OrderedUnit{ UnitConverterUnits::Speed_Mach, GetLocalizedStringName(L"UnitName_Mach"), GetLocalizedStringName(L"UnitAbbreviation_Mach"), 7 });
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MetersPerSecond, GetLocalizedStringName(L"UnitName_MetersPerSecond"), speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MetersPerSecond,
GetLocalizedStringName(L"UnitAbbreviation_MetersPerSecond"), 2 }); GetLocalizedStringName(L"UnitName_MetersPerSecond"),
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MilesPerHour, GetLocalizedStringName(L"UnitName_MilesPerHour"), GetLocalizedStringName(L"UnitAbbreviation_MetersPerSecond"),
GetLocalizedStringName(L"UnitAbbreviation_MilesPerHour"), 5, useSI, useUSCustomary, false }); 2 });
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Turtle, GetLocalizedStringName(L"UnitName_Turtle"), speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_MilesPerHour,
GetLocalizedStringName(L"UnitAbbreviation_Turtle"), 8, false, false, true }); GetLocalizedStringName(L"UnitName_MilesPerHour"),
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Horse, GetLocalizedStringName(L"UnitName_Horse"), GetLocalizedStringName(L"UnitAbbreviation_MilesPerHour"),
GetLocalizedStringName(L"UnitAbbreviation_Horse"), 9, false, false, true }); 5,
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Jet, GetLocalizedStringName(L"UnitName_Jet"), GetLocalizedStringName(L"UnitAbbreviation_Jet"), useSI,
10, false, false, true }); useUSCustomary,
false });
speedUnits.push_back(OrderedUnit{ UnitConverterUnits::Speed_Turtle,
GetLocalizedStringName(L"UnitName_Turtle"),
GetLocalizedStringName(L"UnitAbbreviation_Turtle"),
8,
false,
false,
true });
speedUnits.push_back(OrderedUnit{
UnitConverterUnits::Speed_Horse, GetLocalizedStringName(L"UnitName_Horse"), GetLocalizedStringName(L"UnitAbbreviation_Horse"), 9, false, false, true });
speedUnits.push_back(OrderedUnit{
UnitConverterUnits::Speed_Jet, GetLocalizedStringName(L"UnitName_Jet"), GetLocalizedStringName(L"UnitAbbreviation_Jet"), 10, false, false, true });
unitMap.emplace(ViewMode::Speed, speedUnits); unitMap.emplace(ViewMode::Speed, speedUnits);
vector<OrderedUnit> volumeUnits; vector<OrderedUnit> volumeUnits;
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicCentimeter, GetLocalizedStringName(L"UnitName_CubicCentimeter"), volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicCentimeter,
GetLocalizedStringName(L"UnitAbbreviation_CubicCentimeter"), 2 }); GetLocalizedStringName(L"UnitName_CubicCentimeter"),
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicFoot, GetLocalizedStringName(L"UnitName_CubicFoot"), GetLocalizedStringName(L"UnitAbbreviation_CubicCentimeter"),
GetLocalizedStringName(L"UnitAbbreviation_CubicFoot"), 13 }); 2 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicInch, GetLocalizedStringName(L"UnitName_CubicInch"), volumeUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_CubicInch"), 12 }); UnitConverterUnits::Volume_CubicFoot, GetLocalizedStringName(L"UnitName_CubicFoot"), GetLocalizedStringName(L"UnitAbbreviation_CubicFoot"), 13 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicMeter, GetLocalizedStringName(L"UnitName_CubicMeter"), volumeUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_CubicMeter"), 4 }); UnitConverterUnits::Volume_CubicInch, GetLocalizedStringName(L"UnitName_CubicInch"), GetLocalizedStringName(L"UnitAbbreviation_CubicInch"), 12 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CubicYard, GetLocalizedStringName(L"UnitName_CubicYard"), volumeUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_CubicYard"), 14 }); UnitConverterUnits::Volume_CubicMeter, GetLocalizedStringName(L"UnitName_CubicMeter"), GetLocalizedStringName(L"UnitAbbreviation_CubicMeter"), 4 });
volumeUnits.push_back(OrderedUnit{
UnitConverterUnits::Volume_CubicYard, GetLocalizedStringName(L"UnitName_CubicYard"), GetLocalizedStringName(L"UnitAbbreviation_CubicYard"), 14 });
volumeUnits.push_back( volumeUnits.push_back(
OrderedUnit{ UnitConverterUnits::Volume_CupUS, GetLocalizedStringName(L"UnitName_CupUS"), GetLocalizedStringName(L"UnitAbbreviation_CupUS"), 8 }); OrderedUnit{ UnitConverterUnits::Volume_CupUS, GetLocalizedStringName(L"UnitName_CupUS"), GetLocalizedStringName(L"UnitAbbreviation_CupUS"), 8 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUK, GetLocalizedStringName(L"UnitName_FluidOunceUK"), volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUK,
GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUK"), 17 }); GetLocalizedStringName(L"UnitName_FluidOunceUK"),
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUS, GetLocalizedStringName(L"UnitName_FluidOunceUS"), GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUK"),
GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUS"), 7 }); 17 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_GallonUK, GetLocalizedStringName(L"UnitName_GallonUK"), volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_FluidOunceUS,
GetLocalizedStringName(L"UnitAbbreviation_GallonUK"), 20 }); GetLocalizedStringName(L"UnitName_FluidOunceUS"),
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_GallonUS, GetLocalizedStringName(L"UnitName_GallonUS"), GetLocalizedStringName(L"UnitAbbreviation_FluidOunceUS"),
GetLocalizedStringName(L"UnitAbbreviation_GallonUS"), 11 }); 7 });
volumeUnits.push_back(OrderedUnit{
UnitConverterUnits::Volume_GallonUK, GetLocalizedStringName(L"UnitName_GallonUK"), GetLocalizedStringName(L"UnitAbbreviation_GallonUK"), 20 });
volumeUnits.push_back(OrderedUnit{
UnitConverterUnits::Volume_GallonUS, GetLocalizedStringName(L"UnitName_GallonUS"), GetLocalizedStringName(L"UnitAbbreviation_GallonUS"), 11 });
volumeUnits.push_back( volumeUnits.push_back(
OrderedUnit{ UnitConverterUnits::Volume_Liter, GetLocalizedStringName(L"UnitName_Liter"), GetLocalizedStringName(L"UnitAbbreviation_Liter"), 3 }); OrderedUnit{ UnitConverterUnits::Volume_Liter, GetLocalizedStringName(L"UnitName_Liter"), GetLocalizedStringName(L"UnitAbbreviation_Liter"), 3 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Milliliter, GetLocalizedStringName(L"UnitName_Milliliter"), volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Milliliter,
GetLocalizedStringName(L"UnitAbbreviation_Milliliter"), 1, useUSCustomary, useSI }); GetLocalizedStringName(L"UnitName_Milliliter"),
GetLocalizedStringName(L"UnitAbbreviation_Milliliter"),
1,
useUSCustomary,
useSI });
volumeUnits.push_back( volumeUnits.push_back(
OrderedUnit{ UnitConverterUnits::Volume_PintUK, GetLocalizedStringName(L"UnitName_PintUK"), GetLocalizedStringName(L"UnitAbbreviation_PintUK"), 18 }); OrderedUnit{ UnitConverterUnits::Volume_PintUK, GetLocalizedStringName(L"UnitName_PintUK"), GetLocalizedStringName(L"UnitAbbreviation_PintUK"), 18 });
volumeUnits.push_back( volumeUnits.push_back(
OrderedUnit{ UnitConverterUnits::Volume_PintUS, GetLocalizedStringName(L"UnitName_PintUS"), GetLocalizedStringName(L"UnitAbbreviation_PintUS"), 9 }); OrderedUnit{ UnitConverterUnits::Volume_PintUS, GetLocalizedStringName(L"UnitName_PintUS"), GetLocalizedStringName(L"UnitAbbreviation_PintUS"), 9 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUS, GetLocalizedStringName(L"UnitName_TablespoonUS"), volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUS,
GetLocalizedStringName(L"UnitAbbreviation_TablespoonUS"), 6 }); GetLocalizedStringName(L"UnitName_TablespoonUS"),
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUS, GetLocalizedStringName(L"UnitName_TeaspoonUS"), GetLocalizedStringName(L"UnitAbbreviation_TablespoonUS"),
GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUS"), 5, useSI, useUSCustomary && m_currentRegionCode != "GB" }); 6 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_QuartUK, GetLocalizedStringName(L"UnitName_QuartUK"), volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUS,
GetLocalizedStringName(L"UnitAbbreviation_QuartUK"), 19 }); GetLocalizedStringName(L"UnitName_TeaspoonUS"),
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_QuartUS, GetLocalizedStringName(L"UnitName_QuartUS"), GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUS"),
GetLocalizedStringName(L"UnitAbbreviation_QuartUS"), 10 }); 5,
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUK, GetLocalizedStringName(L"UnitName_TeaspoonUK"), useSI,
GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUK"), 15, false, useUSCustomary && m_currentRegionCode == "GB" }); useUSCustomary && m_currentRegionCode != "GB" });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUK, GetLocalizedStringName(L"UnitName_TablespoonUK"), volumeUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_TablespoonUK"), 16 }); UnitConverterUnits::Volume_QuartUK, GetLocalizedStringName(L"UnitName_QuartUK"), GetLocalizedStringName(L"UnitAbbreviation_QuartUK"), 19 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CoffeeCup, GetLocalizedStringName(L"UnitName_CoffeeCup"), volumeUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_CoffeeCup"), 22, false, false, true }); UnitConverterUnits::Volume_QuartUS, GetLocalizedStringName(L"UnitName_QuartUS"), GetLocalizedStringName(L"UnitAbbreviation_QuartUS"), 10 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Bathtub, GetLocalizedStringName(L"UnitName_Bathtub"), volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TeaspoonUK,
GetLocalizedStringName(L"UnitAbbreviation_Bathtub"), 23, false, false, true }); GetLocalizedStringName(L"UnitName_TeaspoonUK"),
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_SwimmingPool, GetLocalizedStringName(L"UnitName_SwimmingPool"), GetLocalizedStringName(L"UnitAbbreviation_TeaspoonUK"),
GetLocalizedStringName(L"UnitAbbreviation_SwimmingPool"), 24, false, false, true }); 15,
false,
useUSCustomary && m_currentRegionCode == "GB" });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_TablespoonUK,
GetLocalizedStringName(L"UnitName_TablespoonUK"),
GetLocalizedStringName(L"UnitAbbreviation_TablespoonUK"),
16 });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_CoffeeCup,
GetLocalizedStringName(L"UnitName_CoffeeCup"),
GetLocalizedStringName(L"UnitAbbreviation_CoffeeCup"),
22,
false,
false,
true });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_Bathtub,
GetLocalizedStringName(L"UnitName_Bathtub"),
GetLocalizedStringName(L"UnitAbbreviation_Bathtub"),
23,
false,
false,
true });
volumeUnits.push_back(OrderedUnit{ UnitConverterUnits::Volume_SwimmingPool,
GetLocalizedStringName(L"UnitName_SwimmingPool"),
GetLocalizedStringName(L"UnitAbbreviation_SwimmingPool"),
24,
false,
false,
true });
unitMap.emplace(ViewMode::Volume, volumeUnits); unitMap.emplace(ViewMode::Volume, volumeUnits);
vector<OrderedUnit> weightUnits; vector<OrderedUnit> weightUnits;
weightUnits.push_back( weightUnits.push_back(
OrderedUnit{ UnitConverterUnits::Weight_Carat, GetLocalizedStringName(L"UnitName_Carat"), GetLocalizedStringName(L"UnitAbbreviation_Carat"), 1 }); OrderedUnit{ UnitConverterUnits::Weight_Carat, GetLocalizedStringName(L"UnitName_Carat"), GetLocalizedStringName(L"UnitAbbreviation_Carat"), 1 });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Centigram, GetLocalizedStringName(L"UnitName_Centigram"), weightUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Centigram"), 3 }); UnitConverterUnits::Weight_Centigram, GetLocalizedStringName(L"UnitName_Centigram"), GetLocalizedStringName(L"UnitAbbreviation_Centigram"), 3 });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Decigram, GetLocalizedStringName(L"UnitName_Decigram"), weightUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Decigram"), 4 }); UnitConverterUnits::Weight_Decigram, GetLocalizedStringName(L"UnitName_Decigram"), GetLocalizedStringName(L"UnitAbbreviation_Decigram"), 4 });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Decagram, GetLocalizedStringName(L"UnitName_Decagram"), weightUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Decagram"), 6 }); UnitConverterUnits::Weight_Decagram, GetLocalizedStringName(L"UnitName_Decagram"), GetLocalizedStringName(L"UnitAbbreviation_Decagram"), 6 });
weightUnits.push_back( weightUnits.push_back(
OrderedUnit{ UnitConverterUnits::Weight_Gram, GetLocalizedStringName(L"UnitName_Gram"), GetLocalizedStringName(L"UnitAbbreviation_Gram"), 5 }); OrderedUnit{ UnitConverterUnits::Weight_Gram, GetLocalizedStringName(L"UnitName_Gram"), GetLocalizedStringName(L"UnitAbbreviation_Gram"), 5 });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Hectogram, GetLocalizedStringName(L"UnitName_Hectogram"), weightUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_Hectogram"), 7 }); UnitConverterUnits::Weight_Hectogram, GetLocalizedStringName(L"UnitName_Hectogram"), GetLocalizedStringName(L"UnitAbbreviation_Hectogram"), 7 });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Kilogram, GetLocalizedStringName(L"UnitName_Kilogram"), weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Kilogram,
GetLocalizedStringName(L"UnitAbbreviation_Kilogram"), 8, useUSCustomary, useSI }); GetLocalizedStringName(L"UnitName_Kilogram"),
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_LongTon, GetLocalizedStringName(L"UnitName_LongTon"), GetLocalizedStringName(L"UnitAbbreviation_Kilogram"),
GetLocalizedStringName(L"UnitAbbreviation_LongTon"), 14 }); 8,
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Milligram, GetLocalizedStringName(L"UnitName_Milligram"), useUSCustomary,
GetLocalizedStringName(L"UnitAbbreviation_Milligram"), 2 }); useSI });
weightUnits.push_back(OrderedUnit{
UnitConverterUnits::Weight_LongTon, GetLocalizedStringName(L"UnitName_LongTon"), GetLocalizedStringName(L"UnitAbbreviation_LongTon"), 14 });
weightUnits.push_back(OrderedUnit{
UnitConverterUnits::Weight_Milligram, GetLocalizedStringName(L"UnitName_Milligram"), GetLocalizedStringName(L"UnitAbbreviation_Milligram"), 2 });
weightUnits.push_back( weightUnits.push_back(
OrderedUnit{ UnitConverterUnits::Weight_Ounce, GetLocalizedStringName(L"UnitName_Ounce"), GetLocalizedStringName(L"UnitAbbreviation_Ounce"), 10 }); OrderedUnit{ UnitConverterUnits::Weight_Ounce, GetLocalizedStringName(L"UnitName_Ounce"), GetLocalizedStringName(L"UnitAbbreviation_Ounce"), 10 });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Pound, GetLocalizedStringName(L"UnitName_Pound"), weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Pound,
GetLocalizedStringName(L"UnitAbbreviation_Pound"), 11, useSI, useUSCustomary }); GetLocalizedStringName(L"UnitName_Pound"),
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_ShortTon, GetLocalizedStringName(L"UnitName_ShortTon"), GetLocalizedStringName(L"UnitAbbreviation_Pound"),
GetLocalizedStringName(L"UnitAbbreviation_ShortTon"), 13 }); 11,
useSI,
useUSCustomary });
weightUnits.push_back(OrderedUnit{
UnitConverterUnits::Weight_ShortTon, GetLocalizedStringName(L"UnitName_ShortTon"), GetLocalizedStringName(L"UnitAbbreviation_ShortTon"), 13 });
weightUnits.push_back( weightUnits.push_back(
OrderedUnit{ UnitConverterUnits::Weight_Stone, GetLocalizedStringName(L"UnitName_Stone"), GetLocalizedStringName(L"UnitAbbreviation_Stone"), 12 }); OrderedUnit{ UnitConverterUnits::Weight_Stone, GetLocalizedStringName(L"UnitName_Stone"), GetLocalizedStringName(L"UnitAbbreviation_Stone"), 12 });
weightUnits.push_back( weightUnits.push_back(
OrderedUnit{ UnitConverterUnits::Weight_Tonne, GetLocalizedStringName(L"UnitName_Tonne"), GetLocalizedStringName(L"UnitAbbreviation_Tonne"), 9 }); OrderedUnit{ UnitConverterUnits::Weight_Tonne, GetLocalizedStringName(L"UnitName_Tonne"), GetLocalizedStringName(L"UnitAbbreviation_Tonne"), 9 });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Snowflake, GetLocalizedStringName(L"UnitName_Snowflake"), weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Snowflake,
GetLocalizedStringName(L"UnitAbbreviation_Snowflake"), 15, false, false, true }); GetLocalizedStringName(L"UnitName_Snowflake"),
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_SoccerBall, GetLocalizedStringName(L"UnitName_SoccerBall"), GetLocalizedStringName(L"UnitAbbreviation_Snowflake"),
GetLocalizedStringName(L"UnitAbbreviation_SoccerBall"), 16, false, false, true }); 15,
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Elephant, GetLocalizedStringName(L"UnitName_Elephant"), false,
GetLocalizedStringName(L"UnitAbbreviation_Elephant"), 17, false, false, true }); false,
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Whale, GetLocalizedStringName(L"UnitName_Whale"), true });
GetLocalizedStringName(L"UnitAbbreviation_Whale"), 18, false, false, true }); weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_SoccerBall,
GetLocalizedStringName(L"UnitName_SoccerBall"),
GetLocalizedStringName(L"UnitAbbreviation_SoccerBall"),
16,
false,
false,
true });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Elephant,
GetLocalizedStringName(L"UnitName_Elephant"),
GetLocalizedStringName(L"UnitAbbreviation_Elephant"),
17,
false,
false,
true });
weightUnits.push_back(OrderedUnit{ UnitConverterUnits::Weight_Whale,
GetLocalizedStringName(L"UnitName_Whale"),
GetLocalizedStringName(L"UnitAbbreviation_Whale"),
18,
false,
false,
true });
unitMap.emplace(ViewMode::Weight, weightUnits); unitMap.emplace(ViewMode::Weight, weightUnits);
vector<OrderedUnit> pressureUnits; vector<OrderedUnit> pressureUnits;
pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_Atmosphere, GetLocalizedStringName(L"UnitName_Atmosphere"), pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_Atmosphere,
GetLocalizedStringName(L"UnitAbbreviation_Atmosphere"), 1, true, false, false }); GetLocalizedStringName(L"UnitName_Atmosphere"),
pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_Bar, GetLocalizedStringName(L"UnitName_Bar"), GetLocalizedStringName(L"UnitAbbreviation_Atmosphere"),
GetLocalizedStringName(L"UnitAbbreviation_Bar"), 2, false, true, false }); 1,
pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_KiloPascal, GetLocalizedStringName(L"UnitName_KiloPascal"), true,
GetLocalizedStringName(L"UnitAbbreviation_KiloPascal"), 3 }); false,
pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_MillimeterOfMercury, GetLocalizedStringName(L"UnitName_MillimeterOfMercury "), false });
GetLocalizedStringName(L"UnitAbbreviation_MillimeterOfMercury "), 4 }); pressureUnits.push_back(OrderedUnit{
UnitConverterUnits::Pressure_Bar, GetLocalizedStringName(L"UnitName_Bar"), GetLocalizedStringName(L"UnitAbbreviation_Bar"), 2, false, true, false });
pressureUnits.push_back(OrderedUnit{
UnitConverterUnits::Pressure_KiloPascal, GetLocalizedStringName(L"UnitName_KiloPascal"), GetLocalizedStringName(L"UnitAbbreviation_KiloPascal"), 3 });
pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_MillimeterOfMercury,
GetLocalizedStringName(L"UnitName_MillimeterOfMercury "),
GetLocalizedStringName(L"UnitAbbreviation_MillimeterOfMercury "),
4 });
pressureUnits.push_back( pressureUnits.push_back(
OrderedUnit{ UnitConverterUnits::Pressure_Pascal, GetLocalizedStringName(L"UnitName_Pascal"), GetLocalizedStringName(L"UnitAbbreviation_Pascal"), 5 }); OrderedUnit{ UnitConverterUnits::Pressure_Pascal, GetLocalizedStringName(L"UnitName_Pascal"), GetLocalizedStringName(L"UnitAbbreviation_Pascal"), 5 });
pressureUnits.push_back(OrderedUnit{ UnitConverterUnits::Pressure_PSI, GetLocalizedStringName(L"UnitName_PSI"), pressureUnits.push_back(OrderedUnit{
GetLocalizedStringName(L"UnitAbbreviation_PSI"), 6, false, false, false }); UnitConverterUnits::Pressure_PSI, GetLocalizedStringName(L"UnitName_PSI"), GetLocalizedStringName(L"UnitAbbreviation_PSI"), 6, false, false, false });
unitMap.emplace(ViewMode::Pressure, pressureUnits); unitMap.emplace(ViewMode::Pressure, pressureUnits);
vector<OrderedUnit> angleUnits; vector<OrderedUnit> angleUnits;
angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Degree, GetLocalizedStringName(L"UnitName_Degree"), angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Degree,
GetLocalizedStringName(L"UnitAbbreviation_Degree"), 1, true, false, false }); GetLocalizedStringName(L"UnitName_Degree"),
angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Radian, GetLocalizedStringName(L"UnitName_Radian"), GetLocalizedStringName(L"UnitAbbreviation_Degree"),
GetLocalizedStringName(L"UnitAbbreviation_Radian"), 2, false, true, false }); 1,
true,
false,
false });
angleUnits.push_back(OrderedUnit{ UnitConverterUnits::Angle_Radian,
GetLocalizedStringName(L"UnitName_Radian"),
GetLocalizedStringName(L"UnitAbbreviation_Radian"),
2,
false,
true,
false });
angleUnits.push_back( angleUnits.push_back(
OrderedUnit{ UnitConverterUnits::Angle_Gradian, GetLocalizedStringName(L"UnitName_Gradian"), GetLocalizedStringName(L"UnitAbbreviation_Gradian"), 3 }); OrderedUnit{ UnitConverterUnits::Angle_Gradian, GetLocalizedStringName(L"UnitName_Gradian"), GetLocalizedStringName(L"UnitAbbreviation_Gradian"), 3 });
unitMap.emplace(ViewMode::Angle, angleUnits); unitMap.emplace(ViewMode::Angle, angleUnits);
@ -721,12 +963,24 @@ void UnitConverterDataLoader::GetExplicitConversionData(_In_ unordered_map<int,
{ ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesCelsius, UnitConverterUnits::Temperature_DegreesCelsius, 1, 0 }, { ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesCelsius, UnitConverterUnits::Temperature_DegreesCelsius, 1, 0 },
{ ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesCelsius, UnitConverterUnits::Temperature_DegreesFahrenheit, 1.8, 32 }, { ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesCelsius, UnitConverterUnits::Temperature_DegreesFahrenheit, 1.8, 32 },
{ ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesCelsius, UnitConverterUnits::Temperature_Kelvin, 1, 273.15 }, { ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesCelsius, UnitConverterUnits::Temperature_Kelvin, 1, 273.15 },
{ ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesFahrenheit, UnitConverterUnits::Temperature_DegreesCelsius, { ViewMode::Temperature,
0.55555555555555555555555555555556, -32, CONVERT_WITH_OFFSET_FIRST }, UnitConverterUnits::Temperature_DegreesFahrenheit,
UnitConverterUnits::Temperature_DegreesCelsius,
0.55555555555555555555555555555556,
-32,
CONVERT_WITH_OFFSET_FIRST },
{ ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesFahrenheit, UnitConverterUnits::Temperature_DegreesFahrenheit, 1, 0 }, { ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesFahrenheit, UnitConverterUnits::Temperature_DegreesFahrenheit, 1, 0 },
{ ViewMode::Temperature, UnitConverterUnits::Temperature_DegreesFahrenheit, UnitConverterUnits::Temperature_Kelvin, 0.55555555555555555555555555555556, { ViewMode::Temperature,
459.67, CONVERT_WITH_OFFSET_FIRST }, UnitConverterUnits::Temperature_DegreesFahrenheit,
{ ViewMode::Temperature, UnitConverterUnits::Temperature_Kelvin, UnitConverterUnits::Temperature_DegreesCelsius, 1, -273.15, UnitConverterUnits::Temperature_Kelvin,
0.55555555555555555555555555555556,
459.67,
CONVERT_WITH_OFFSET_FIRST },
{ ViewMode::Temperature,
UnitConverterUnits::Temperature_Kelvin,
UnitConverterUnits::Temperature_DegreesCelsius,
1,
-273.15,
CONVERT_WITH_OFFSET_FIRST }, CONVERT_WITH_OFFSET_FIRST },
{ ViewMode::Temperature, UnitConverterUnits::Temperature_Kelvin, UnitConverterUnits::Temperature_DegreesFahrenheit, 1.8, -459.67 }, { ViewMode::Temperature, UnitConverterUnits::Temperature_Kelvin, UnitConverterUnits::Temperature_DegreesFahrenheit, 1.8, -459.67 },
{ ViewMode::Temperature, UnitConverterUnits::Temperature_Kelvin, UnitConverterUnits::Temperature_Kelvin, 1, 0 } { ViewMode::Temperature, UnitConverterUnits::Temperature_Kelvin, UnitConverterUnits::Temperature_Kelvin, 1, 0 }

View file

@ -16,9 +16,16 @@ namespace CalculatorApp
{ {
} }
OrderedUnit(int id, std::wstring name, std::wstring abbreviation, int order, bool isConversionSource = false, bool isConversionTarget = false, OrderedUnit(
bool isWhimsical = false) int id,
: UnitConversionManager::Unit(id, name, abbreviation, isConversionSource, isConversionTarget, isWhimsical), order(order) std::wstring name,
std::wstring abbreviation,
int order,
bool isConversionSource = false,
bool isConversionTarget = false,
bool isWhimsical = false)
: UnitConversionManager::Unit(id, name, abbreviation, isConversionSource, isConversionTarget, isWhimsical)
, order(order)
{ {
} }
@ -37,9 +44,17 @@ namespace CalculatorApp
ExplicitUnitConversionData() ExplicitUnitConversionData()
{ {
} }
ExplicitUnitConversionData(CalculatorApp::Common::ViewMode categoryId, int parentUnitId, int unitId, double ratio, double offset, ExplicitUnitConversionData(
bool offsetFirst = false) CalculatorApp::Common::ViewMode categoryId,
: categoryId(categoryId), parentUnitId(parentUnitId), unitId(unitId), UnitConversionManager::ConversionData(ratio, offset, offsetFirst) int parentUnitId,
int unitId,
double ratio,
double offset,
bool offsetFirst = false)
: categoryId(categoryId)
, parentUnitId(parentUnitId)
, unitId(unitId)
, UnitConversionManager::ConversionData(ratio, offset, offsetFirst)
{ {
} }

View file

@ -105,8 +105,9 @@ void DateCalculatorViewModel::OnPropertyChanged(_In_ String ^ prop)
{ {
UpdateStrDateResultAutomationName(); UpdateStrDateResultAutomationName();
} }
else if (prop != StrDateDiffResultAutomationNamePropertyName && prop != StrDateDiffResultInDaysPropertyName else if (
&& prop != StrDateResultAutomationNamePropertyName && prop != IsDiffInDaysPropertyName) prop != StrDateDiffResultAutomationNamePropertyName && prop != StrDateDiffResultInDaysPropertyName && prop != StrDateResultAutomationNamePropertyName
&& prop != IsDiffInDaysPropertyName)
{ {
OnInputsChanged(); OnInputsChanged();
} }
@ -216,8 +217,10 @@ void DateCalculatorViewModel::UpdateStrDateResultAutomationName()
void DateCalculatorViewModel::InitializeDateOutputFormats(_In_ String ^ calendarIdentifier) void DateCalculatorViewModel::InitializeDateOutputFormats(_In_ String ^ calendarIdentifier)
{ {
// Format for Add/Subtract days // Format for Add/Subtract days
m_dateTimeFormatter = LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(L"longdate", calendarIdentifier, m_dateTimeFormatter = LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used L"longdate",
calendarIdentifier,
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used
// Format for Date Difference // Format for Date Difference
m_allDateUnitsOutputFormat = DateUnit::Year | DateUnit::Month | DateUnit::Week | DateUnit::Day; m_allDateUnitsOutputFormat = DateUnit::Year | DateUnit::Month | DateUnit::Week | DateUnit::Day;

View file

@ -10,9 +10,15 @@ using namespace CalculatorApp::ViewModel;
using namespace std; using namespace std;
using namespace Platform; using namespace Platform;
HistoryItemViewModel::HistoryItemViewModel(String ^ expression, String ^ result, _In_ const shared_ptr<CalculatorVector<pair<wstring, int>>>& spTokens, HistoryItemViewModel::HistoryItemViewModel(
_In_ const shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>>& spCommands) String ^ expression,
: m_expression(expression), m_result(result), m_spTokens(spTokens), m_spCommands(spCommands) String ^ result,
_In_ const shared_ptr<CalculatorVector<pair<wstring, int>>>& spTokens,
_In_ const shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>>& spCommands)
: m_expression(expression)
, m_result(result)
, m_spTokens(spTokens)
, m_spCommands(spCommands)
{ {
// updating accessibility names for expression and result // updating accessibility names for expression and result
m_accExpression = HistoryItemViewModel::GetAccessibleExpressionFromTokens(spTokens, m_expression); m_accExpression = HistoryItemViewModel::GetAccessibleExpressionFromTokens(spTokens, m_expression);
@ -20,8 +26,9 @@ HistoryItemViewModel::HistoryItemViewModel(String ^ expression, String ^ result,
} }
String String
^ HistoryItemViewModel::GetAccessibleExpressionFromTokens(_In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& spTokens, ^ HistoryItemViewModel::GetAccessibleExpressionFromTokens(
_In_ String ^ fallbackExpression) _In_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& spTokens,
_In_ String ^ fallbackExpression)
{ {
// updating accessibility names for expression and result // updating accessibility names for expression and result
wstringstream accExpression{}; wstringstream accExpression{};

View file

@ -14,9 +14,11 @@ namespace CalculatorApp
{ {
internal : internal :
HistoryItemViewModel(Platform::String ^ expression, Platform::String ^ result, HistoryItemViewModel(
_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens, Platform::String ^ expression,
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& spCommands); Platform::String ^ result,
_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens,
_In_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& spCommands);
std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& GetTokens() std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& GetTokens()
{ {
@ -59,8 +61,9 @@ namespace CalculatorApp
^ GetStringRepresentation() { return m_accExpression + " " + m_accResult; } ^ GetStringRepresentation() { return m_accExpression + " " + m_accResult; }
private : static Platform::String private : static Platform::String
^ GetAccessibleExpressionFromTokens(_In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens, ^ GetAccessibleExpressionFromTokens(
_In_ Platform::String ^ fallbackExpression); _In_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& spTokens,
_In_ Platform::String ^ fallbackExpression);
private: private:
Platform::String ^ m_expression; Platform::String ^ m_expression;

View file

@ -27,7 +27,8 @@ namespace CalculatorApp::ViewModel::HistoryResourceKeys
} }
HistoryViewModel::HistoryViewModel(_In_ CalculationManager::CalculatorManager* calculatorManager) HistoryViewModel::HistoryViewModel(_In_ CalculationManager::CalculatorManager* calculatorManager)
: m_calculatorManager(calculatorManager), m_localizedHistoryCleared(nullptr) : m_calculatorManager(calculatorManager)
, m_localizedHistoryCleared(nullptr)
{ {
AreHistoryShortcutsEnabled = true; AreHistoryShortcutsEnabled = true;
@ -69,8 +70,11 @@ void HistoryViewModel::ReloadHistory(_In_ ViewMode currentMode)
localizer.LocalizeDisplayValue(&expression); localizer.LocalizeDisplayValue(&expression);
localizer.LocalizeDisplayValue(&result); localizer.LocalizeDisplayValue(&result);
auto item = ref new HistoryItemViewModel(ref new Platform::String(expression.c_str()), ref new Platform::String(result.c_str()), auto item = ref new HistoryItemViewModel(
(*ritr)->historyItemVector.spTokens, (*ritr)->historyItemVector.spCommands); ref new Platform::String(expression.c_str()),
ref new Platform::String(result.c_str()),
(*ritr)->historyItemVector.spTokens,
(*ritr)->historyItemVector.spCommands);
historyListVM->Append(item); historyListVM->Append(item);
} }
} }
@ -87,8 +91,11 @@ void HistoryViewModel::OnHistoryItemAdded(_In_ unsigned int addedItemIndex)
wstring result = newItem->historyItemVector.result; wstring result = newItem->historyItemVector.result;
localizer.LocalizeDisplayValue(&expression); localizer.LocalizeDisplayValue(&expression);
localizer.LocalizeDisplayValue(&result); localizer.LocalizeDisplayValue(&result);
auto item = ref new HistoryItemViewModel(ref new Platform::String(expression.c_str()), ref new Platform::String(result.c_str()), auto item = ref new HistoryItemViewModel(
newItem->historyItemVector.spTokens, newItem->historyItemVector.spCommands); ref new Platform::String(expression.c_str()),
ref new Platform::String(result.c_str()),
newItem->historyItemVector.spTokens,
newItem->historyItemVector.spCommands);
// check if we have not hit the max items // check if we have not hit the max items
if (Items->Size >= m_calculatorManager->MaxHistorySize()) if (Items->Size >= m_calculatorManager->MaxHistorySize())
@ -310,8 +317,8 @@ Platform::String ^ HistoryViewModel::SerializeHistoryItem(_In_ std::shared_ptr<C
return CryptographicBuffer::EncodeToBase64String(buffer); return CryptographicBuffer::EncodeToBase64String(buffer);
} }
CalculationManager::HISTORYITEM HistoryViewModel::DeserializeHistoryItem(_In_ Platform::String ^ historyItemKey, CalculationManager::HISTORYITEM
_In_ ApplicationDataContainer ^ historyContainer) HistoryViewModel::DeserializeHistoryItem(_In_ Platform::String ^ historyItemKey, _In_ ApplicationDataContainer ^ historyContainer)
{ {
CalculationManager::HISTORYITEM historyItem; CalculationManager::HISTORYITEM historyItem;
if (historyContainer->Values->HasKey(historyItemKey)) if (historyContainer->Values->HasKey(historyItemKey))
@ -352,8 +359,9 @@ CalculationManager::HISTORYITEM HistoryViewModel::DeserializeHistoryItem(_In_ Pl
bool HistoryViewModel::IsValid(_In_ CalculationManager::HISTORYITEM item) bool HistoryViewModel::IsValid(_In_ CalculationManager::HISTORYITEM item)
{ {
return (!item.historyItemVector.expression.empty() && !item.historyItemVector.result.empty() && (bool)item.historyItemVector.spCommands return (
&& (bool)item.historyItemVector.spTokens); !item.historyItemVector.expression.empty() && !item.historyItemVector.result.empty() && (bool)item.historyItemVector.spCommands
&& (bool)item.historyItemVector.spTokens);
} }
void HistoryViewModel::UpdateItemSize() void HistoryViewModel::UpdateItemSize()

View file

@ -60,8 +60,8 @@ namespace CalculatorApp
Platform::String ^ m_localizedHistoryCleared; Platform::String ^ m_localizedHistoryCleared;
void RestoreHistory(_In_ CalculationManager::CALCULATOR_MODE cMode); void RestoreHistory(_In_ CalculationManager::CALCULATOR_MODE cMode);
CalculationManager::HISTORYITEM DeserializeHistoryItem(_In_ Platform::String ^ historyItemKey, CalculationManager::HISTORYITEM
_In_ Windows::Storage::ApplicationDataContainer ^ historyContainer); DeserializeHistoryItem(_In_ Platform::String ^ historyItemKey, _In_ Windows::Storage::ApplicationDataContainer ^ historyContainer);
Windows::Storage::ApplicationDataContainer ^ GetHistoryContainer(_In_ CalculationManager::CALCULATOR_MODE cMode); Windows::Storage::ApplicationDataContainer ^ GetHistoryContainer(_In_ CalculationManager::CALCULATOR_MODE cMode);
Platform::String ^ GetHistoryContainerKey(_In_ CalculationManager::CALCULATOR_MODE cMode); Platform::String ^ GetHistoryContainerKey(_In_ CalculationManager::CALCULATOR_MODE cMode);
void ClearHistoryContainer(_In_ CalculationManager::CALCULATOR_MODE cMode); void ClearHistoryContainer(_In_ CalculationManager::CALCULATOR_MODE cMode);

View file

@ -18,7 +18,9 @@ namespace CalculatorApp
Windows::UI::Xaml::Data::ICustomPropertyProvider Windows::UI::Xaml::Data::ICustomPropertyProvider
{ {
public: public:
MemoryItemViewModel(StandardCalculatorViewModel ^ calcVM) : m_Position(-1), m_calcVM(calcVM) MemoryItemViewModel(StandardCalculatorViewModel ^ calcVM)
: m_Position(-1)
, m_calcVM(calcVM)
{ {
} }
OBSERVABLE_OBJECT(); OBSERVABLE_OBJECT();

View file

@ -235,9 +235,10 @@ void StandardCalculatorViewModel::SetOpenParenthesisCountNarratorAnnouncement()
wstring localizedParenthesisCount = to_wstring(m_OpenParenthesisCount).c_str(); wstring localizedParenthesisCount = to_wstring(m_OpenParenthesisCount).c_str();
LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedParenthesisCount); LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedParenthesisCount);
String ^ announcement = String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
LocalizationStringUtil::GetLocalizedNarratorAnnouncement(CalculatorResourceKeys::OpenParenthesisCountAutomationFormat, CalculatorResourceKeys::OpenParenthesisCountAutomationFormat,
m_localizedOpenParenthesisCountChangedAutomationFormat, localizedParenthesisCount.c_str()); m_localizedOpenParenthesisCountChangedAutomationFormat,
localizedParenthesisCount.c_str());
Announcement = CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(announcement); Announcement = CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(announcement);
} }
@ -283,8 +284,9 @@ void StandardCalculatorViewModel::DisableButtons(CommandType selectedExpressionC
} }
} }
void StandardCalculatorViewModel::SetExpressionDisplay(_Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens, void StandardCalculatorViewModel::SetExpressionDisplay(
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands) _Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands)
{ {
m_tokens = tokens; m_tokens = tokens;
m_commands = commands; m_commands = commands;
@ -298,8 +300,9 @@ void StandardCalculatorViewModel::SetExpressionDisplay(_Inout_ shared_ptr<Calcul
AreTokensUpdated = true; AreTokensUpdated = true;
} }
void StandardCalculatorViewModel::SetHistoryExpressionDisplay(_Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens, void StandardCalculatorViewModel::SetHistoryExpressionDisplay(
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands) _Inout_ shared_ptr<CalculatorVector<pair<wstring, int>>> const& tokens,
_Inout_ shared_ptr<CalculatorVector<shared_ptr<IExpressionCommand>>> const& commands)
{ {
m_tokens = make_shared<CalculatorVector<pair<wstring, int>>>(*tokens); m_tokens = make_shared<CalculatorVector<pair<wstring, int>>>(*tokens);
m_commands = make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>(*commands); m_commands = make_shared<CalculatorVector<shared_ptr<IExpressionCommand>>>(*commands);
@ -1035,8 +1038,8 @@ void StandardCalculatorViewModel::OnMemoryButtonPressed()
int windowId = Utils::GetWindowId(); int windowId = Utils::GetWindowId();
TraceLogger::GetInstance().InsertIntoMemoryMap(windowId, IsStandard, IsScientific, IsProgrammer); TraceLogger::GetInstance().InsertIntoMemoryMap(windowId, IsStandard, IsScientific, IsProgrammer);
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(CalculatorResourceKeys::MemorySave, m_localizedMemorySavedAutomationFormat, String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
m_DisplayValue->Data()); CalculatorResourceKeys::MemorySave, m_localizedMemorySavedAutomationFormat, m_DisplayValue->Data());
Announcement = CalculatorAnnouncement::GetMemoryItemAddedAnnouncement(announcement); Announcement = CalculatorAnnouncement::GetMemoryItemAddedAnnouncement(announcement);
} }
@ -1957,9 +1960,11 @@ NarratorAnnouncement ^ StandardCalculatorViewModel::GetDisplayUpdatedNarratorAnn
} }
else else
{ {
announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(CalculatorResourceKeys::ButtonPressFeedbackFormat, announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
m_localizedButtonPressFeedbackAutomationFormat, CalculatorResourceKeys::ButtonPressFeedbackFormat,
m_CalculationResultAutomationName->Data(), m_feedbackForButtonPress->Data()); m_localizedButtonPressFeedbackAutomationFormat,
m_CalculationResultAutomationName->Data(),
m_feedbackForButtonPress->Data());
} }
// Make sure we don't accidentally repeat an announcement. // Make sure we don't accidentally repeat an announcement.

View file

@ -334,10 +334,12 @@ namespace CalculatorApp
void SetPrimaryDisplay(_In_ std::wstring const& displayString, _In_ bool isError); void SetPrimaryDisplay(_In_ std::wstring const& displayString, _In_ bool isError);
void DisplayPasteError(); void DisplayPasteError();
void SetTokens(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens); void SetTokens(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens);
void SetExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, void SetExpressionDisplay(
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands); _Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
void SetHistoryExpressionDisplay(_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens, _Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands);
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands); void SetHistoryExpressionDisplay(
_Inout_ std::shared_ptr<CalculatorVector<std::pair<std::wstring, int>>> const& tokens,
_Inout_ std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& commands);
void SetParenthesisCount(_In_ unsigned int parenthesisCount); void SetParenthesisCount(_In_ unsigned int parenthesisCount);
void SetOpenParenthesisCountNarratorAnnouncement(); void SetOpenParenthesisCountNarratorAnnouncement();
void OnNoRightParenAdded(); void OnNoRightParenAdded();

View file

@ -463,7 +463,8 @@ void UnitConverterViewModel::UpdateSupplementaryResults(const std::vector<std::t
// Schedule the timer // Schedule the timer
m_supplementaryResultsTimer = ThreadPoolTimer::CreateTimer( m_supplementaryResultsTimer = ThreadPoolTimer::CreateTimer(
ref new TimerElapsedHandler(this, &UnitConverterViewModel::SupplementaryResultsTimerTick, TIMER_CALLBACK_CONTEXT), SUPPLEMENTARY_VALUES_INTERVAL, ref new TimerElapsedHandler(this, &UnitConverterViewModel::SupplementaryResultsTimerTick, TIMER_CALLBACK_CONTEXT),
SUPPLEMENTARY_VALUES_INTERVAL,
ref new TimerDestroyedHandler(this, &UnitConverterViewModel::SupplementaryResultsTimerCancel, TIMER_CALLBACK_CONTEXT)); ref new TimerDestroyedHandler(this, &UnitConverterViewModel::SupplementaryResultsTimerCancel, TIMER_CALLBACK_CONTEXT));
} }
@ -1010,12 +1011,16 @@ String ^ UnitConverterViewModel::GetLocalizedAutomationName(_In_ String ^ displa
} }
String String
^ UnitConverterViewModel::GetLocalizedConversionResultStringFormat(_In_ String ^ fromValue, _In_ String ^ fromUnit, _In_ String ^ toValue, ^ UnitConverterViewModel::GetLocalizedConversionResultStringFormat(
_In_ String ^ toUnit) _In_ String ^ fromValue,
_In_ String ^ fromUnit,
_In_ String ^ toValue,
_In_ String ^ toUnit)
{ {
String ^ localizedString = ref new String(LocalizationStringUtil::GetLocalizedString(m_localizedConversionResultFormat->Data(), fromValue->Data(), String ^ localizedString =
fromUnit->Data(), toValue->Data(), toUnit->Data()) ref new String(LocalizationStringUtil::GetLocalizedString(
.c_str()); m_localizedConversionResultFormat->Data(), fromValue->Data(), fromUnit->Data(), toValue->Data(), toUnit->Data())
.c_str());
return localizedString; return localizedString;
} }

View file

@ -17,7 +17,8 @@ namespace CalculatorApp
{ {
[Windows::UI::Xaml::Data::Bindable] public ref class Category sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged [Windows::UI::Xaml::Data::Bindable] public ref class Category sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
internal : Category(const UnitConversionManager::Category& category) : m_original(category) internal : Category(const UnitConversionManager::Category& category)
: m_original(category)
{ {
} }
@ -46,7 +47,8 @@ namespace CalculatorApp
[Windows::UI::Xaml::Data::Bindable] public ref class Unit sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged [Windows::UI::Xaml::Data::Bindable] public ref class Unit sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
internal : Unit(const UnitConversionManager::Unit& unit) : m_original(unit) internal : Unit(const UnitConversionManager::Unit& unit)
: m_original(unit)
{ {
} }
@ -80,7 +82,9 @@ namespace CalculatorApp
[Windows::UI::Xaml::Data::Bindable] public ref class SupplementaryResult sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged [Windows::UI::Xaml::Data::Bindable] public ref class SupplementaryResult sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
internal : SupplementaryResult(Platform::String ^ value, Unit ^ unit) : m_Value(value), m_Unit(unit) internal : SupplementaryResult(Platform::String ^ value, Unit ^ unit)
: m_Value(value)
, m_Unit(unit)
{ {
} }
@ -110,7 +114,8 @@ namespace CalculatorApp
TActivatable m_activatable; TActivatable m_activatable;
public: public:
Activatable(TActivatable activatable) : m_activatable(activatable) Activatable(TActivatable activatable)
: m_activatable(activatable)
{ {
} }
@ -207,8 +212,11 @@ namespace CalculatorApp
Platform::String Platform::String
^ GetLocalizedAutomationName(_In_ Platform::String ^ displayvalue, _In_ Platform::String ^ unitname, _In_ Platform::String ^ format); ^ GetLocalizedAutomationName(_In_ Platform::String ^ displayvalue, _In_ Platform::String ^ unitname, _In_ Platform::String ^ format);
Platform::String Platform::String
^ GetLocalizedConversionResultStringFormat(_In_ Platform::String ^ fromValue, _In_ Platform::String ^ fromUnit, _In_ Platform::String ^ toValue, ^ GetLocalizedConversionResultStringFormat(
_In_ Platform::String ^ toUnit); _In_ Platform::String ^ fromValue,
_In_ Platform::String ^ fromUnit,
_In_ Platform::String ^ toValue,
_In_ Platform::String ^ toUnit);
void UpdateValue1AutomationName(); void UpdateValue1AutomationName();
void UpdateValue2AutomationName(); void UpdateValue2AutomationName();
Platform::String ^ Serialize(); Platform::String ^ Serialize();
@ -330,7 +338,8 @@ namespace CalculatorApp
class UnitConverterVMCallback : public UnitConversionManager::IUnitConverterVMCallback class UnitConverterVMCallback : public UnitConversionManager::IUnitConverterVMCallback
{ {
public: public:
UnitConverterVMCallback(UnitConverterViewModel ^ viewModel) : m_viewModel(viewModel) UnitConverterVMCallback(UnitConverterViewModel ^ viewModel)
: m_viewModel(viewModel)
{ {
} }
@ -356,7 +365,8 @@ namespace CalculatorApp
class ViewModelCurrencyCallback : public UnitConversionManager::IViewModelCurrencyCallback class ViewModelCurrencyCallback : public UnitConversionManager::IViewModelCurrencyCallback
{ {
public: public:
ViewModelCurrencyCallback(UnitConverterViewModel ^ viewModel) : m_viewModel(viewModel) ViewModelCurrencyCallback(UnitConverterViewModel ^ viewModel)
: m_viewModel(viewModel)
{ {
} }

View file

@ -9,8 +9,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CalcManager", "CalcManager\
EndProject EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A5DF651-B8A1-45CA-9135-964A6FC7F5D1}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A5DF651-B8A1-45CA-9135-964A6FC7F5D1}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
.clang-format = .clang-format ..\.clang-format = ..\.clang-format
clang-format-all.sh = clang-format-all.sh
nuget.config = nuget.config nuget.config = nuget.config
EndProjectSection EndProjectSection
EndProject EndProject

View file

@ -356,9 +356,11 @@ void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
auto activatedEventArgs = dynamic_cast<IApplicationViewActivatedEventArgs ^>(args); auto activatedEventArgs = dynamic_cast<IApplicationViewActivatedEventArgs ^>(args);
if ((activatedEventArgs != nullptr) && (activatedEventArgs->CurrentlyShownApplicationViewId != 0)) if ((activatedEventArgs != nullptr) && (activatedEventArgs->CurrentlyShownApplicationViewId != 0))
{ {
create_task(ApplicationViewSwitcher::TryShowAsStandaloneAsync(frameService->GetViewId(), ViewSizePreference::Default, create_task(ApplicationViewSwitcher::TryShowAsStandaloneAsync(
activatedEventArgs->CurrentlyShownApplicationViewId, frameService->GetViewId(),
ViewSizePreference::Default)) ViewSizePreference::Default,
activatedEventArgs->CurrentlyShownApplicationViewId,
ViewSizePreference::Default))
.then( .then(
[safeFrameServiceCreation](bool viewShown) { [safeFrameServiceCreation](bool viewShown) {
// SafeFrameServiceCreation is used to automatically remove the frame // SafeFrameServiceCreation is used to automatically remove the frame
@ -385,8 +387,8 @@ void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
if (activationViewSwitcher != nullptr) if (activationViewSwitcher != nullptr)
{ {
activationViewSwitcher->ShowAsStandaloneAsync(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), activationViewSwitcher->ShowAsStandaloneAsync(
ViewSizePreference::Default); ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), ViewSizePreference::Default);
TraceLogger::GetInstance().LogNewWindowCreationEnd(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())); TraceLogger::GetInstance().LogNewWindowCreationEnd(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
TraceLogger::GetInstance().LogPrelaunchedAppActivatedByUser(); TraceLogger::GetInstance().LogPrelaunchedAppActivatedByUser();
} }

View file

@ -47,7 +47,9 @@ namespace CalculatorApp
{ {
public: public:
SafeFrameWindowCreation(_In_ WindowFrameService ^ frameService, App ^ parent) SafeFrameWindowCreation(_In_ WindowFrameService ^ frameService, App ^ parent)
: m_frameService(frameService), m_frameOpenedInWindow(false), m_parent(parent) : m_frameService(frameService)
, m_frameOpenedInWindow(false)
, m_parent(parent)
{ {
} }

View file

@ -9,7 +9,8 @@ namespace CalculatorApp
{ {
ref class AlwaysSelectedCollectionView sealed : public Windows::UI::Xaml::DependencyObject, public Windows::UI::Xaml::Data::ICollectionView ref class AlwaysSelectedCollectionView sealed : public Windows::UI::Xaml::DependencyObject, public Windows::UI::Xaml::Data::ICollectionView
{ {
internal : AlwaysSelectedCollectionView(Windows::UI::Xaml::Interop::IBindableVector ^ source) : m_currentPosition(-1) internal : AlwaysSelectedCollectionView(Windows::UI::Xaml::Interop::IBindableVector ^ source)
: m_currentPosition(-1)
{ {
m_source = source; m_source = source;
@ -47,8 +48,8 @@ namespace CalculatorApp
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
property Windows::Foundation::Collections::IObservableVector<Platform::Object ^> ^ CollectionGroups { property Windows::Foundation::Collections::IObservableVector<Platform::Object ^> ^ CollectionGroups {
virtual Windows::Foundation::Collections::IObservableVector<Platform::Object virtual Windows::Foundation::Collections::IObservableVector<
^> ^ get() = Windows::UI::Xaml::Data::ICollectionView::CollectionGroups::get Platform::Object ^> ^ get() = Windows::UI::Xaml::Data::ICollectionView::CollectionGroups::get
{ {
return ref new Platform::Collections::Vector<Platform::Object ^>(); return ref new Platform::Collections::Vector<Platform::Object ^>();
} }
@ -80,8 +81,9 @@ namespace CalculatorApp
// restore the selection to the way we wanted it to begin with // restore the selection to the way we wanted it to begin with
if (m_currentPosition >= 0 && m_currentPosition < static_cast<int>(m_source->Size)) if (m_currentPosition >= 0 && m_currentPosition < static_cast<int>(m_source->Size))
{ {
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler([this]() {
ref new Windows::UI::Core::DispatchedHandler([this]() { m_currentChanged(this, nullptr); })); m_currentChanged(this, nullptr);
}));
} }
return false; return false;
} }
@ -167,14 +169,14 @@ namespace CalculatorApp
{ {
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
virtual unsigned int virtual unsigned int GetMany(
GetMany(unsigned int /*startIndex*/, unsigned int /*startIndex*/,
Platform::WriteOnlyArray<Platform::Object ^> ^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::GetMany Platform::WriteOnlyArray<Platform::Object ^> ^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::GetMany
{ {
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
virtual Windows::Foundation::Collections::IVectorView<Platform::Object ^> ^ GetView() = Windows::Foundation::Collections::IVector<Platform::Object virtual Windows::Foundation::Collections::IVectorView<Platform::Object ^> ^ GetView() = Windows::Foundation::Collections::IVector<
^>::GetView Platform::Object ^>::GetView
{ {
throw ref new Platform::NotImplementedException(); throw ref new Platform::NotImplementedException();
} }
@ -263,8 +265,11 @@ namespace CalculatorApp
private: private:
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ Convert(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert
{ {
auto result = dynamic_cast<Windows::UI::Xaml::Interop::IBindableVector ^>(value); auto result = dynamic_cast<Windows::UI::Xaml::Interop::IBindableVector ^>(value);
if (result) if (result)
@ -275,8 +280,11 @@ namespace CalculatorApp
} }
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ /*value*/, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/, ^ ConvertBack(
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack Platform::Object ^ /*value*/,
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
Platform::Object ^ /*parameter*/,
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack
{ {
return Windows::UI::Xaml::DependencyProperty::UnsetValue; return Windows::UI::Xaml::DependencyProperty::UnsetValue;
} }

View file

@ -58,8 +58,8 @@ namespace CalculatorApp
#pragma region Tracing methods #pragma region Tracing methods
void AppLifecycleLogger::LogAppLifecycleEvent(hstring const& eventName, LoggingFields const& fields) const void AppLifecycleLogger::LogAppLifecycleEvent(hstring const& eventName, LoggingFields const& fields) const
{ {
m_appLifecycleProvider.LogEvent(eventName, fields, LoggingLevel::Information, m_appLifecycleProvider.LogEvent(
LoggingOptions(MICROSOFT_KEYWORD_TELEMETRY | WINEVENT_KEYWORD_RESPONSE_TIME)); eventName, fields, LoggingLevel::Information, LoggingOptions(MICROSOFT_KEYWORD_TELEMETRY | WINEVENT_KEYWORD_RESPONSE_TIME));
} }
#pragma endregion #pragma endregion

View file

@ -50,7 +50,9 @@ DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, DisplayStringExpression);
StringReference CalculationResult::s_FocusedState(L"Focused"); StringReference CalculationResult::s_FocusedState(L"Focused");
StringReference CalculationResult::s_UnfocusedState(L"Unfocused"); StringReference CalculationResult::s_UnfocusedState(L"Unfocused");
CalculationResult::CalculationResult() : m_isScalingText(false), m_haveCalculatedMax(false) CalculationResult::CalculationResult()
: m_isScalingText(false)
, m_haveCalculatedMax(false)
{ {
} }

View file

@ -9,7 +9,8 @@ using namespace Windows::UI::Xaml::Automation::Peers;
namespace CalculatorApp::Controls namespace CalculatorApp::Controls
{ {
CalculationResultAutomationPeer::CalculationResultAutomationPeer(FrameworkElement ^ owner) : FrameworkElementAutomationPeer(owner) CalculationResultAutomationPeer::CalculationResultAutomationPeer(FrameworkElement ^ owner)
: FrameworkElementAutomationPeer(owner)
{ {
} }

View file

@ -155,8 +155,9 @@ void OverflowTextBlock::UpdateScrollButtons()
ShowHideScrollButtons(::Visibility::Collapsed, ::Visibility::Collapsed); ShowHideScrollButtons(::Visibility::Collapsed, ::Visibility::Collapsed);
} }
// We have more number on both side. Show both arrows // We have more number on both side. Show both arrows
else if ((m_expressionContainer->HorizontalOffset > 0) else if (
&& (m_expressionContainer->HorizontalOffset < (m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth))) (m_expressionContainer->HorizontalOffset > 0)
&& (m_expressionContainer->HorizontalOffset < (m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)))
{ {
ShowHideScrollButtons(::Visibility::Visible, ::Visibility::Visible); ShowHideScrollButtons(::Visibility::Visible, ::Visibility::Visible);
} }

View file

@ -10,7 +10,8 @@ using namespace Windows::Foundation::Collections;
namespace CalculatorApp::Controls namespace CalculatorApp::Controls
{ {
OverflowTextBlockAutomationPeer::OverflowTextBlockAutomationPeer(OverflowTextBlock ^ owner) : FrameworkElementAutomationPeer(owner) OverflowTextBlockAutomationPeer::OverflowTextBlockAutomationPeer(OverflowTextBlock ^ owner)
: FrameworkElementAutomationPeer(owner)
{ {
} }

View file

@ -14,11 +14,17 @@ namespace CalculatorApp
{ {
public: public:
virtual Platform::Object virtual Platform::Object
^ Convert(_In_ Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object ^ parameter, ^ Convert(
_In_ Platform::String ^ language); _In_ Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
_In_ Platform::Object ^ parameter,
_In_ Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(_In_ Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object ^ parameter, ^ ConvertBack(
_In_ Platform::String ^ language); _In_ Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
_In_ Platform::Object ^ parameter,
_In_ Platform::String ^ language);
}; };
} }
} }

View file

@ -16,8 +16,11 @@ namespace CalculatorApp
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language); Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language);
}; };
} }
} }

View file

@ -23,8 +23,11 @@ namespace CalculatorApp
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language); Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language);
}; };
/// <summary> /// <summary>
@ -38,8 +41,11 @@ namespace CalculatorApp
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language); Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language);
}; };
} }

View file

@ -13,8 +13,11 @@ namespace CalculatorApp
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language); Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language);
}; };
public public
@ -24,8 +27,11 @@ namespace CalculatorApp
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language); Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language);
}; };
} }
} }

View file

@ -16,8 +16,11 @@ namespace CalculatorApp
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language); Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language);
}; };
} }
} }

View file

@ -16,8 +16,11 @@ namespace CalculatorApp
virtual Platform::Object virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language); ^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language); Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language);
}; };
} }
} }

View file

@ -13,7 +13,9 @@ namespace Numbers
ref class MemorySlot sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged ref class MemorySlot sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
public: public:
MemorySlot(int slotPosition, Platform::String ^ value) : m_SlotPosition(slotPosition), m_SlotValue(value) MemorySlot(int slotPosition, Platform::String ^ value)
: m_SlotPosition(slotPosition)
, m_SlotValue(value)
{ {
} }
@ -35,7 +37,10 @@ namespace Numbers
{ {
public: public:
StandardCalculatorViewModel() StandardCalculatorViewModel()
: m_DisplayValue("1234569"), m_DisplayStringExpression("14560 x 1890"), m_DegreeButtonContent("Deg"), m_IsMemoryEmpty(false) : m_DisplayValue("1234569")
, m_DisplayStringExpression("14560 x 1890")
, m_DegreeButtonContent("Deg")
, m_IsMemoryEmpty(false)
{ {
m_MemorizedNumbers = ref new Platform::Collections::Vector<MemorySlot ^>(); m_MemorizedNumbers = ref new Platform::Collections::Vector<MemorySlot ^>();
for (int i = 1000; i < 1100; i++) for (int i = 1000; i < 1100; i++)

View file

@ -21,11 +21,15 @@ namespace Numbers
ref class CategoryViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged ref class CategoryViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
public: public:
CategoryViewModel(Platform::String ^ name) : m_Name(name), m_NegateVisibility(Windows::UI::Xaml::Visibility::Collapsed) CategoryViewModel(Platform::String ^ name)
: m_Name(name)
, m_NegateVisibility(Windows::UI::Xaml::Visibility::Collapsed)
{ {
} }
CategoryViewModel(Platform::String ^ name, Windows::UI::Xaml::Visibility negateVisibility) : m_Name(name), m_NegateVisibility(negateVisibility) CategoryViewModel(Platform::String ^ name, Windows::UI::Xaml::Visibility negateVisibility)
: m_Name(name)
, m_NegateVisibility(negateVisibility)
{ {
} }
@ -39,7 +43,9 @@ namespace Numbers
ref class UnitViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged ref class UnitViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
public: public:
UnitViewModel(Platform::String ^ unit, Platform::String ^ abbr) : m_Name(unit), m_Abbreviation(abbr) UnitViewModel(Platform::String ^ unit, Platform::String ^ abbr)
: m_Name(unit)
, m_Abbreviation(abbr)
{ {
} }
@ -53,7 +59,8 @@ namespace Numbers
ref class UnitConverterSupplementaryResultViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged ref class UnitConverterSupplementaryResultViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
public: public:
UnitConverterSupplementaryResultViewModel(Platform::String ^ value, Platform::String ^ unit, Platform::String ^ abbr) : m_Value(value) UnitConverterSupplementaryResultViewModel(Platform::String ^ value, Platform::String ^ unit, Platform::String ^ abbr)
: m_Value(value)
{ {
m_Unit = ref new UnitViewModel(unit, abbr); m_Unit = ref new UnitViewModel(unit, abbr);
} }
@ -68,7 +75,11 @@ namespace Numbers
ref class UnitConverterViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged ref class UnitConverterViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
{ {
public: public:
UnitConverterViewModel() : m_Value1("Åy24"), m_Value2("Åy183"), m_Value1Active(true), m_Value2Active(false) UnitConverterViewModel()
: m_Value1("Åy24")
, m_Value2("Åy183")
, m_Value1Active(true)
, m_Value2Active(false)
{ {
m_SupplementaryResults = ref new Platform::Collections::Vector<UnitConverterSupplementaryResultViewModel ^>(); m_SupplementaryResults = ref new Platform::Collections::Vector<UnitConverterSupplementaryResultViewModel ^>();
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("128", "Kilograms", "Kgs")); m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("128", "Kilograms", "Kgs"));

View file

@ -41,7 +41,11 @@ DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsStandard);
DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsScientific); DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsScientific);
DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsProgrammer); DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsProgrammer);
Calculator::Calculator() : m_doAnimate(false), m_isLastAnimatedInScientific(false), m_isLastAnimatedInProgrammer(false), m_resultAnimate(false) Calculator::Calculator()
: m_doAnimate(false)
, m_isLastAnimatedInScientific(false)
, m_isLastAnimatedInProgrammer(false)
, m_resultAnimate(false)
{ {
SetFontSizeResources(); SetFontSizeResources();
InitializeComponent(); InitializeComponent();

View file

@ -109,8 +109,9 @@ public
bool m_IsDigit = false; bool m_IsDigit = false;
Memory ^ m_memory; Memory ^ m_memory;
void HistoryFlyout_Opened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void HistoryFlyout_Opened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
void HistoryFlyout_Closing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender, void HistoryFlyout_Closing(
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args); _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender,
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args);
void HistoryFlyout_Closed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void HistoryFlyout_Closed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
void OnHideHistoryClicked(); void OnHideHistoryClicked();
void OnHideMemoryClicked(); void OnHideMemoryClicked();
@ -121,8 +122,9 @@ public
bool m_fIsHistoryFlyoutOpen; bool m_fIsHistoryFlyoutOpen;
bool m_fIsMemoryFlyoutOpen; bool m_fIsMemoryFlyoutOpen;
void OnMemoryFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void OnMemoryFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
void OnMemoryFlyoutClosing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender, void OnMemoryFlyoutClosing(
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args); _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender,
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args);
void OnMemoryFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args); void OnMemoryFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
void SetChildAsMemory(); void SetChildAsMemory();
void SetChildAsHistory(); void SetChildAsHistory();

View file

@ -25,7 +25,8 @@ using namespace Windows::UI::Xaml::Input;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() : m_updatingCheckedStates(false) CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel()
: m_updatingCheckedStates(false)
{ {
InitializeComponent(); InitializeComponent();
auto booleanToVisibilityConverter = ref new Converters::BooleanToVisibilityConverter; auto booleanToVisibilityConverter = ref new Converters::BooleanToVisibilityConverter;

View file

@ -34,8 +34,10 @@ namespace CalculatorApp
void AssignFlipButtons(); void AssignFlipButtons();
void SetVisibilityBinding(_In_ Windows::UI::Xaml::FrameworkElement ^ element, _In_ Platform::String ^ path, void SetVisibilityBinding(
_In_ Windows::UI::Xaml::Data::IValueConverter ^ converter); _In_ Windows::UI::Xaml::FrameworkElement ^ element,
_In_ Platform::String ^ path,
_In_ Windows::UI::Xaml::Data::IValueConverter ^ converter);
void OnBitToggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e); void OnBitToggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
void UpdateCheckedStates(); void UpdateCheckedStates();

View file

@ -20,7 +20,8 @@ using namespace Windows::UI::Xaml::Navigation;
using namespace Windows::UI::ViewManagement; using namespace Windows::UI::ViewManagement;
using namespace Windows::UI::Core; using namespace Windows::UI::Core;
CalculatorProgrammerDisplayPanel::CalculatorProgrammerDisplayPanel() : m_isErrorVisualState(false) CalculatorProgrammerDisplayPanel::CalculatorProgrammerDisplayPanel()
: m_isErrorVisualState(false)
{ {
InitializeComponent(); InitializeComponent();
} }

View file

@ -23,7 +23,8 @@ using namespace Windows::UI::Xaml::Data;
using namespace CalculatorApp::Common; using namespace CalculatorApp::Common;
using namespace Windows::UI::Xaml::Media; using namespace Windows::UI::Xaml::Media;
CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() : m_isErrorVisualState(false) CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators()
: m_isErrorVisualState(false)
{ {
InitializeComponent(); InitializeComponent();

View file

@ -29,7 +29,8 @@ using namespace Windows::UI::Core;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
CalculatorScientificAngleButtons::CalculatorScientificAngleButtons() : m_isErrorVisualState(false) CalculatorScientificAngleButtons::CalculatorScientificAngleButtons()
: m_isErrorVisualState(false)
{ {
InitializeComponent(); InitializeComponent();
} }

View file

@ -68,8 +68,9 @@ void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object ^ /*
SetOperatorRowVisibility(); SetOperatorRowVisibility();
} }
void CalculatorScientificOperators::shiftButton_IsEnabledChanged(_In_ Platform::Object ^ /*sender*/, void CalculatorScientificOperators::shiftButton_IsEnabledChanged(
_In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ /*e*/) _In_ Platform::Object ^ /*sender*/,
_In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ /*e*/)
{ {
SetOperatorRowVisibility(); SetOperatorRowVisibility();
Common::KeyboardShortcutManager::ShiftButtonChecked(ShiftButton->IsEnabled && ShiftButton->IsChecked->Value); Common::KeyboardShortcutManager::ShiftButtonChecked(ShiftButton->IsEnabled && ShiftButton->IsChecked->Value);

View file

@ -24,7 +24,8 @@ using namespace Windows::UI::Xaml::Navigation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
CalculatorStandardOperators::CalculatorStandardOperators() : m_isErrorVisualState(false) CalculatorStandardOperators::CalculatorStandardOperators()
: m_isErrorVisualState(false)
{ {
InitializeComponent(); InitializeComponent();
} }

View file

@ -79,9 +79,10 @@ DateCalculator::DateCalculator()
DateDiff_ToDate->MaxDate = maxYear; DateDiff_ToDate->MaxDate = maxYear;
// Set the PlaceHolderText for CalendarDatePicker // Set the PlaceHolderText for CalendarDatePicker
DateTimeFormatter ^ dateTimeFormatter = DateTimeFormatter ^ dateTimeFormatter = LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(
LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(L"day month year", localizationSettings.GetCalendarIdentifier(), L"day month year",
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used localizationSettings.GetCalendarIdentifier(),
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used
DateDiff_FromDate->DateFormat = L"day month year"; DateDiff_FromDate->DateFormat = L"day month year";
DateDiff_ToDate->DateFormat = L"day month year"; DateDiff_ToDate->DateFormat = L"day month year";
@ -130,8 +131,8 @@ void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker ^ sender, _
{ {
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext); auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
dateCalcViewModel->StartDate = e->NewDate->Value; dateCalcViewModel->StartDate = e->NewDate->Value;
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), TraceLogger::GetInstance().LogDateAddSubtractModeUsed(
dateCalcViewModel->IsAddMode); ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), dateCalcViewModel->IsAddMode);
} }
else else
{ {
@ -142,8 +143,8 @@ void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker ^ sender, _
void CalculatorApp::DateCalculator::OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ SelectionChangedEventArgs ^ e) void CalculatorApp::DateCalculator::OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ SelectionChangedEventArgs ^ e)
{ {
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext); auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), TraceLogger::GetInstance().LogDateAddSubtractModeUsed(
dateCalcViewModel->IsAddMode); ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), dateCalcViewModel->IsAddMode);
} }
void DateCalculator::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e) void DateCalculator::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)

View file

@ -29,12 +29,15 @@ namespace CalculatorApp
void SetDefaultFocus(); void SetDefaultFocus();
private: private:
void FromDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, void FromDate_DateChanged(
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
void ToDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); void ToDate_DateChanged(
void AddSubtract_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e); _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
void AddSubtract_DateChanged(
_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
void OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e); void OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e); void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
void OnLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e); void OnLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);

View file

@ -63,7 +63,8 @@ namespace CalculatorApp::VisualStates
} }
} }
MainPage::MainPage() : m_model(ref new ApplicationViewModel()) MainPage::MainPage()
: m_model(ref new ApplicationViewModel())
{ {
InitializeComponent(); InitializeComponent();

View file

@ -49,8 +49,9 @@ public
void OnNavPaneOpened(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args); void OnNavPaneOpened(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
void OnNavPaneClosed(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args); void OnNavPaneClosed(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
void OnNavSelectionChanged(_In_ Platform::Object ^ sender, _In_ Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs ^ e); void OnNavSelectionChanged(_In_ Platform::Object ^ sender, _In_ Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs ^ e);
void OnNavItemInvoked(Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/, void OnNavItemInvoked(
_In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e); Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/,
_In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e);
void OnAboutButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e); void OnAboutButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
void OnAboutFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e); void OnAboutFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);

View file

@ -35,7 +35,8 @@ using namespace Windows::UI::ViewManagement;
DEPENDENCY_PROPERTY_INITIALIZATION(Memory, RowHeight); DEPENDENCY_PROPERTY_INITIALIZATION(Memory, RowHeight);
Memory::Memory() : m_isErrorVisualState(false) Memory::Memory()
: m_isErrorVisualState(false)
{ {
InitializeComponent(); InitializeComponent();
m_memoryItemFlyout = safe_cast<MenuFlyout ^>(Resources->Lookup("MemoryContextMenu")); m_memoryItemFlyout = safe_cast<MenuFlyout ^>(Resources->Lookup("MemoryContextMenu"));

View file

@ -31,7 +31,8 @@ using namespace CalculatorApp::Common;
DEPENDENCY_PROPERTY_INITIALIZATION(NumberPad, ButtonStyle); DEPENDENCY_PROPERTY_INITIALIZATION(NumberPad, ButtonStyle);
NumberPad::NumberPad() : m_isErrorVisualState(false) NumberPad::NumberPad()
: m_isErrorVisualState(false)
{ {
InitializeComponent(); InitializeComponent();

View file

@ -26,11 +26,17 @@ public
} }
internal : virtual Platform::Object internal : virtual Platform::Object
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ Convert(
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::Convert; Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::Convert;
virtual Platform::Object virtual Platform::Object
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, ^ ConvertBack(
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack; Platform::Object ^ value,
Windows::UI::Xaml::Interop::TypeName targetType,
Platform::Object ^ parameter,
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack;
private: private:
Windows::UI::Xaml::ResourceDictionary ^ m_delighters; Windows::UI::Xaml::ResourceDictionary ^ m_delighters;

View file

@ -20,7 +20,8 @@ using namespace Windows::Foundation::Collections;
namespace CalculatorApp namespace CalculatorApp
{ {
TitleBar::TitleBar() : m_coreTitleBar(CoreApplication::GetCurrentView()->TitleBar) TitleBar::TitleBar()
: m_coreTitleBar(CoreApplication::GetCurrentView()->TitleBar)
{ {
m_uiSettings = ref new UISettings(); m_uiSettings = ref new UISettings();
m_accessibilitySettings = ref new AccessibilitySettings(); m_accessibilitySettings = ref new AccessibilitySettings();
@ -163,7 +164,7 @@ namespace CalculatorApp
void TitleBar::OnWindowActivated(_In_ Object ^ /*sender*/, _In_ WindowActivatedEventArgs ^ e) void TitleBar::OnWindowActivated(_In_ Object ^ /*sender*/, _In_ WindowActivatedEventArgs ^ e)
{ {
VisualStateManager::GoToState(this, e->WindowActivationState == CoreWindowActivationState::Deactivated ? WindowNotFocused->Name : WindowFocused->Name, VisualStateManager::GoToState(
false); this, e->WindowActivationState == CoreWindowActivationState::Deactivated ? WindowNotFocused->Name : WindowFocused->Name, false);
} }
} }

View file

@ -45,7 +45,9 @@ using namespace Windows::UI::ViewManagement;
// There are 10,000 intervals in 1 ms. // There are 10,000 intervals in 1 ms.
static const long long DURATION_500_MS = 10000 * 500; static const long long DURATION_500_MS = 10000 * 500;
UnitConverter::UnitConverter() : m_meteredConnectionOverride(false), m_isAnimationEnabled(false) UnitConverter::UnitConverter()
: m_meteredConnectionOverride(false)
, m_isAnimationEnabled(false)
{ {
m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection(); m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection();
m_FlowDirectionHorizontalAlignment = m_layoutDirection == ::FlowDirection::RightToLeft ? ::HorizontalAlignment::Right : ::HorizontalAlignment::Left; m_FlowDirectionHorizontalAlignment = m_layoutDirection == ::FlowDirection::RightToLeft ? ::HorizontalAlignment::Right : ::HorizontalAlignment::Left;

Some files were not shown because too many files have changed in this diff Show more