Replace wstring used in public methods by Platform::String in CalcViewModel (#768)
This commit is contained in:
@@ -152,7 +152,7 @@ void ApplicationViewModel::OnModeChanged()
|
||||
}
|
||||
|
||||
auto resProvider = AppResourceProvider::GetInstance();
|
||||
CategoryName = resProvider.GetResourceString(NavCategory::GetNameResourceKey(m_mode));
|
||||
CategoryName = resProvider->GetResourceString(NavCategory::GetNameResourceKey(m_mode));
|
||||
|
||||
// Cast mode to an int in order to save it to app data.
|
||||
// Save the changed mode, so that the new window launches in this mode.
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
@@ -14,9 +14,9 @@ AppResourceProvider::AppResourceProvider()
|
||||
m_cEngineStringResLoader = ResourceLoader::GetForViewIndependentUse(L"CEngineStrings");
|
||||
}
|
||||
|
||||
AppResourceProvider& AppResourceProvider::GetInstance()
|
||||
AppResourceProvider ^ AppResourceProvider::GetInstance()
|
||||
{
|
||||
static AppResourceProvider s_instance;
|
||||
static AppResourceProvider ^ s_instance = ref new AppResourceProvider();
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
class AppResourceProvider
|
||||
public ref class AppResourceProvider sealed
|
||||
{
|
||||
public:
|
||||
static AppResourceProvider& GetInstance();
|
||||
static AppResourceProvider ^ GetInstance();
|
||||
Platform::String ^ GetResourceString(_In_ Platform::String ^ key);
|
||||
Platform::String ^ GetCEngineString(_In_ Platform::String ^ key);
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
using namespace CalculatorApp;
|
||||
using namespace CalculationManager;
|
||||
using namespace Platform;
|
||||
using namespace std;
|
||||
|
||||
CalculatorDisplay::CalculatorDisplay()
|
||||
@@ -31,7 +32,7 @@ void CalculatorDisplay::SetPrimaryDisplay(_In_ const wstring& displayStringValue
|
||||
{
|
||||
if (auto calcVM = m_callbackReference.Resolve<ViewModel::StandardCalculatorViewModel>())
|
||||
{
|
||||
calcVM->SetPrimaryDisplay(displayStringValue, isError);
|
||||
calcVM->SetPrimaryDisplay(StringReference(displayStringValue.c_str()), isError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ using namespace Windows::Foundation;
|
||||
using namespace Windows::System;
|
||||
using namespace Windows::ApplicationModel::DataTransfer;
|
||||
|
||||
String ^ CopyPasteManager::supportedFormats[] = { StandardDataFormats::Text };
|
||||
StringReference PasteErrorString(L"NoOp");
|
||||
|
||||
static const wstring c_validBasicCharacterSet = L"0123456789+-.e";
|
||||
static const wstring c_validStandardCharacterSet = c_validBasicCharacterSet + L"*/";
|
||||
@@ -66,7 +66,7 @@ void CopyPasteManager::CopyToClipboard(String ^ stringToCopy)
|
||||
Clipboard::SetContent(dataPackage);
|
||||
}
|
||||
|
||||
task<String ^> CopyPasteManager::GetStringToPaste(ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, BitLength bitLengthType)
|
||||
IAsyncOperation<String ^> ^ CopyPasteManager::GetStringToPaste(ViewMode mode, CategoryGroupType modeType, int programmerNumberBase, BitLength bitLengthType)
|
||||
{
|
||||
// Retrieve the text in the clipboard
|
||||
auto dataPackageView = Clipboard::GetContent();
|
||||
@@ -76,36 +76,29 @@ task<String ^> CopyPasteManager::GetStringToPaste(ViewMode mode, CategoryGroupTy
|
||||
//-- add support to allow pasting for expressions like .2 , -.2
|
||||
//-- 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)))
|
||||
.then(
|
||||
[mode, modeType, programmerNumberBase, bitLengthType](String ^ pastedText) {
|
||||
return ValidatePasteExpression(pastedText, mode, modeType, programmerNumberBase, bitLengthType);
|
||||
},
|
||||
task_continuation_context::use_arbitrary());
|
||||
return create_async([dataPackageView, mode, modeType, programmerNumberBase, bitLengthType] {
|
||||
return create_task(dataPackageView->GetTextAsync(::StandardDataFormats::Text))
|
||||
.then(
|
||||
[mode, modeType, programmerNumberBase, bitLengthType](String ^ pastedText) {
|
||||
return ValidatePasteExpression(pastedText, mode, modeType, programmerNumberBase, bitLengthType);
|
||||
},
|
||||
task_continuation_context::use_arbitrary());
|
||||
});
|
||||
}
|
||||
|
||||
int CopyPasteManager::ClipboardTextFormat()
|
||||
bool CopyPasteManager::HasStringToPaste()
|
||||
{
|
||||
const auto dataPackageView = Clipboard::GetContent();
|
||||
|
||||
for (int i = 0; i < RTL_NUMBER_OF(supportedFormats); i++)
|
||||
{
|
||||
if (dataPackageView->Contains(supportedFormats[i]))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
return Clipboard::GetContent()->Contains(StandardDataFormats::Text);
|
||||
}
|
||||
|
||||
String ^ CopyPasteManager::ValidatePasteExpression(String ^ pastedText, ViewMode mode, int programmerNumberBase, BitLength bitLengthType)
|
||||
{
|
||||
return CopyPasteManager::ValidatePasteExpression(pastedText, mode, NavCategory::GetGroupType(mode), programmerNumberBase, bitLengthType);
|
||||
return ValidatePasteExpression(pastedText, mode, NavCategory::GetGroupType(mode), programmerNumberBase, bitLengthType);
|
||||
}
|
||||
|
||||
// return "NoOp" if pastedText is invalid else return pastedText
|
||||
|
||||
String ^ CopyPasteManager::ValidatePasteExpression(
|
||||
String
|
||||
^ CopyPasteManager::ValidatePasteExpression(
|
||||
String ^ pastedText,
|
||||
ViewMode mode,
|
||||
CategoryGroupType modeType,
|
||||
@@ -116,16 +109,14 @@ String ^ CopyPasteManager::ValidatePasteExpression(
|
||||
{
|
||||
// return NoOp to indicate don't paste anything.
|
||||
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"PastedExpressionSizeGreaterThanMaxAllowed");
|
||||
return StringReference(PasteErrorString);
|
||||
return PasteErrorString;
|
||||
}
|
||||
|
||||
wstring pasteExpression = pastedText->Data();
|
||||
|
||||
// Get english translated expression
|
||||
String ^ englishString = LocalizationSettings::GetInstance().GetEnglishValueFromLocalizedDigits(pasteExpression);
|
||||
String ^ englishString = LocalizationSettings::GetInstance().GetEnglishValueFromLocalizedDigits(pastedText);
|
||||
|
||||
// Removing the spaces, comma separator from the pasteExpression to allow pasting of expressions like 1 + 2+1,333
|
||||
pasteExpression = RemoveUnwantedCharsFromWstring(englishString->Data());
|
||||
wstring pasteExpression = RemoveUnwantedCharsFromWstring(englishString->Data());
|
||||
|
||||
// If the last character is an = sign, remove it from the pasteExpression to allow evaluating the result on paste.
|
||||
if (!pasteExpression.empty() && pasteExpression.back() == L'=')
|
||||
@@ -139,7 +130,7 @@ String ^ CopyPasteManager::ValidatePasteExpression(
|
||||
if (operands.empty())
|
||||
{
|
||||
// return NoOp to indicate don't paste anything.
|
||||
return StringReference(PasteErrorString);
|
||||
return PasteErrorString;
|
||||
}
|
||||
|
||||
if (modeType == CategoryGroupType::Converter)
|
||||
@@ -151,10 +142,10 @@ String ^ CopyPasteManager::ValidatePasteExpression(
|
||||
if (!ExpressionRegExMatch(operands, mode, modeType, programmerNumberBase, bitLengthType))
|
||||
{
|
||||
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"InvalidExpressionForPresentMode");
|
||||
return StringReference(PasteErrorString);
|
||||
return PasteErrorString;
|
||||
}
|
||||
|
||||
return ref new String(pastedText->Data());
|
||||
return pastedText;
|
||||
}
|
||||
|
||||
vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression, ViewMode mode)
|
||||
@@ -593,3 +584,8 @@ wstring CopyPasteManager::RemoveUnwantedCharsFromWstring(const wstring& input)
|
||||
wchar_t unWantedChars[] = { L' ', L',', L'"', 165, 164, 8373, 36, 8353, 8361, 8362, 8358, 8377, 163, 8364, 8234, 8235, 8236, 8237 };
|
||||
return Utils::RemoveUnwantedCharsFromWstring(input, unWantedChars, 18);
|
||||
}
|
||||
|
||||
bool CopyPasteManager::IsErrorMessage(Platform::String ^ message)
|
||||
{
|
||||
return message == PasteErrorString;
|
||||
}
|
||||
|
@@ -19,24 +19,19 @@ namespace CalculatorApp
|
||||
inline constexpr auto OctBase = 7;
|
||||
inline constexpr auto BinBase = 8;
|
||||
|
||||
class CopyPasteManager
|
||||
public ref class CopyPasteManager sealed
|
||||
{
|
||||
public:
|
||||
static void CopyToClipboard(Platform::String ^ stringToCopy);
|
||||
static concurrency::task<Platform::String ^> GetStringToPaste(
|
||||
static Windows::Foundation::IAsyncOperation<Platform::String ^>^ GetStringToPaste(
|
||||
CalculatorApp::Common::ViewMode mode,
|
||||
CalculatorApp::Common::CategoryGroupType modeType,
|
||||
int programmerNumberBase = -1,
|
||||
CalculatorApp::Common::BitLength bitLengthType = CalculatorApp::Common::BitLength::BitLengthUnknown);
|
||||
static bool HasStringToPaste()
|
||||
{
|
||||
return ClipboardTextFormat() >= 0;
|
||||
}
|
||||
|
||||
static constexpr auto PasteErrorString = L"NoOp";
|
||||
int programmerNumberBase,
|
||||
CalculatorApp::Common::BitLength bitLengthType);
|
||||
static bool HasStringToPaste();
|
||||
static bool IsErrorMessage(Platform::String ^ message);
|
||||
|
||||
private:
|
||||
static int ClipboardTextFormat();
|
||||
static Platform::String
|
||||
^ ValidatePasteExpression(
|
||||
Platform::String ^ pastedText,
|
||||
@@ -84,8 +79,6 @@ namespace CalculatorApp
|
||||
static constexpr size_t MaxExponentLength = 4;
|
||||
static constexpr size_t MaxProgrammerBitLength = 64;
|
||||
|
||||
static Platform::String ^ supportedFormats[];
|
||||
|
||||
friend class CalculatorUnitTests::CopyPasteManagerTest;
|
||||
};
|
||||
}
|
||||
|
@@ -519,7 +519,7 @@ void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow ^ sender, KeyEventArgs
|
||||
auto navView = buttons.first->second.Resolve<MUXC::NavigationView>();
|
||||
auto appViewModel = safe_cast<ApplicationViewModel ^>(navView->DataContext);
|
||||
appViewModel->Mode = ViewMode::Date;
|
||||
auto categoryName = AppResourceProvider::GetInstance().GetResourceString(L"DateCalculationModeText");
|
||||
auto categoryName = AppResourceProvider::GetInstance()->GetResourceString(L"DateCalculationModeText");
|
||||
appViewModel->CategoryName = categoryName;
|
||||
|
||||
auto menuItems = static_cast<IObservableVector<Object ^> ^>(navView->MenuItemsSource);
|
||||
|
@@ -94,16 +94,16 @@ LocalizationService::LocalizationService(_In_ const wchar_t * const overridedLan
|
||||
m_locale = locale("");
|
||||
}
|
||||
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||
m_fontFamilyOverride = resourceLoader.GetResourceString(L"LocalizedFontFamilyOverride");
|
||||
m_fontFamilyOverride = resourceLoader->GetResourceString(L"LocalizedFontFamilyOverride");
|
||||
|
||||
String ^ reserved = L"RESERVED_FOR_FONTLOC";
|
||||
|
||||
m_overrideFontApiValues = ((m_fontFamilyOverride != nullptr) && (m_fontFamilyOverride != reserved));
|
||||
if (m_overrideFontApiValues)
|
||||
{
|
||||
String ^ localizedUICaptionFontSizeFactorOverride = resourceLoader.GetResourceString(L"LocalizedUICaptionFontSizeFactorOverride");
|
||||
String ^ localizedUITextFontSizeFactorOverride = resourceLoader.GetResourceString(L"LocalizedUITextFontSizeFactorOverride");
|
||||
String ^ localizedFontWeightOverride = resourceLoader.GetResourceString(L"LocalizedFontWeightOverride");
|
||||
String ^ localizedUICaptionFontSizeFactorOverride = resourceLoader->GetResourceString(L"LocalizedUICaptionFontSizeFactorOverride");
|
||||
String ^ localizedUITextFontSizeFactorOverride = resourceLoader->GetResourceString(L"LocalizedUITextFontSizeFactorOverride");
|
||||
String ^ localizedFontWeightOverride = resourceLoader->GetResourceString(L"LocalizedFontWeightOverride");
|
||||
|
||||
// If any of the font overrides are modified then all of them need to be modified
|
||||
assert(localizedFontWeightOverride != reserved);
|
||||
@@ -554,12 +554,12 @@ unordered_map<wstring, wstring> LocalizationService::GetTokenToReadableNameMap()
|
||||
unordered_map<wstring, wstring> tokenToReadableNameMap{};
|
||||
auto resProvider = AppResourceProvider::GetInstance();
|
||||
|
||||
static const wstring openParen = resProvider.GetCEngineString(StringReference(s_openParenResourceKey))->Data();
|
||||
static const wstring openParen = resProvider->GetCEngineString(StringReference(s_openParenResourceKey))->Data();
|
||||
|
||||
for (const auto& keyPair : s_parenEngineKeyResourceMap)
|
||||
{
|
||||
wstring engineStr = resProvider.GetCEngineString(StringReference(keyPair.first.c_str()))->Data();
|
||||
wstring automationName = resProvider.GetResourceString(StringReference(keyPair.second.c_str()))->Data();
|
||||
wstring engineStr = resProvider->GetCEngineString(StringReference(keyPair.first.c_str()))->Data();
|
||||
wstring automationName = resProvider->GetResourceString(StringReference(keyPair.second.c_str()))->Data();
|
||||
|
||||
tokenToReadableNameMap.emplace(engineStr + openParen, automationName);
|
||||
}
|
||||
@@ -567,15 +567,15 @@ unordered_map<wstring, wstring> LocalizationService::GetTokenToReadableNameMap()
|
||||
|
||||
for (const auto& keyPair : s_noParenEngineKeyResourceMap)
|
||||
{
|
||||
wstring engineStr = resProvider.GetCEngineString(StringReference(keyPair.first.c_str()))->Data();
|
||||
wstring automationName = resProvider.GetResourceString(StringReference(keyPair.second.c_str()))->Data();
|
||||
wstring engineStr = resProvider->GetCEngineString(StringReference(keyPair.first.c_str()))->Data();
|
||||
wstring automationName = resProvider->GetResourceString(StringReference(keyPair.second.c_str()))->Data();
|
||||
|
||||
tokenToReadableNameMap.emplace(engineStr, automationName);
|
||||
}
|
||||
s_noParenEngineKeyResourceMap.clear();
|
||||
|
||||
// Also replace hyphens with "minus"
|
||||
wstring minusText = resProvider.GetResourceString(L"minus")->Data();
|
||||
wstring minusText = resProvider->GetResourceString(L"minus")->Data();
|
||||
tokenToReadableNameMap.emplace(L"-", minusText);
|
||||
|
||||
return tokenToReadableNameMap;
|
||||
@@ -592,7 +592,7 @@ String ^ LocalizationService::GetNarratorReadableToken(String ^ rawToken)
|
||||
}
|
||||
else
|
||||
{
|
||||
static const String ^ openParen = AppResourceProvider::GetInstance().GetCEngineString(StringReference(s_openParenResourceKey));
|
||||
static const String ^ openParen = AppResourceProvider::GetInstance()->GetCEngineString(StringReference(s_openParenResourceKey));
|
||||
return ref new String(itr->second.c_str()) + L" " + openParen;
|
||||
}
|
||||
}
|
||||
|
@@ -58,10 +58,11 @@ namespace CalculatorApp
|
||||
|
||||
Windows::Globalization::NumberFormatting::DecimalFormatter ^ GetRegionalSettingsAwareDecimalFormatter() const;
|
||||
Windows::Globalization::DateTimeFormatting::DateTimeFormatter ^ GetRegionalSettingsAwareDateTimeFormatter(_In_ Platform::String ^ format) const;
|
||||
Windows::Globalization::DateTimeFormatting::DateTimeFormatter ^ GetRegionalSettingsAwareDateTimeFormatter(
|
||||
_In_ Platform::String ^ format,
|
||||
_In_ Platform::String ^ calendarIdentifier,
|
||||
_In_ Platform::String ^ clockIdentifier) const;
|
||||
Windows::Globalization::DateTimeFormatting::DateTimeFormatter
|
||||
^ GetRegionalSettingsAwareDateTimeFormatter(
|
||||
_In_ Platform::String ^ format,
|
||||
_In_ Platform::String ^ calendarIdentifier,
|
||||
_In_ Platform::String ^ clockIdentifier) const;
|
||||
|
||||
Windows::Globalization::NumberFormatting::CurrencyFormatter ^ GetRegionalSettingsAwareCurrencyFormatter() const;
|
||||
|
||||
|
@@ -169,20 +169,21 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
Platform::String ^ GetEnglishValueFromLocalizedDigits(const std::wstring& localizedString) const
|
||||
Platform::String ^ GetEnglishValueFromLocalizedDigits(Platform::String ^ localizedString) const
|
||||
{
|
||||
if (m_resolvedName == L"en-US")
|
||||
{
|
||||
return ref new Platform::String(localizedString.c_str());
|
||||
return localizedString;
|
||||
}
|
||||
|
||||
size_t i = 0;
|
||||
size_t length = localizedString.size();
|
||||
auto localizedStringData = localizedString->Data();
|
||||
size_t length = localizedString->Length();
|
||||
std::unique_ptr<wchar_t[]> englishString(new wchar_t[length + 1]); // +1 for the null termination
|
||||
|
||||
for (; i < length; ++i)
|
||||
{
|
||||
wchar_t ch = localizedString[i];
|
||||
wchar_t ch = localizedStringData[i];
|
||||
if (!IsEnUsDigit(ch))
|
||||
{
|
||||
for (int j = 0; j < 10; ++j)
|
||||
@@ -281,18 +282,17 @@ namespace CalculatorApp
|
||||
return m_numberGrouping;
|
||||
}
|
||||
|
||||
void RemoveGroupSeparators(const wchar_t* value, const size_t length, std::wstring* rawValue) const
|
||||
Platform::String ^ RemoveGroupSeparators(Platform::String ^ source) const
|
||||
{
|
||||
rawValue->clear();
|
||||
rawValue->reserve(length);
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
std::wstringstream stream;
|
||||
for (auto c = source->Begin(); c < source->End(); ++c)
|
||||
{
|
||||
if (value[i] != L' ' && value[i] != m_numberGroupSeparator)
|
||||
if (*c != L' ' && *c != m_numberGroupSeparator)
|
||||
{
|
||||
rawValue->append(1, value[i]);
|
||||
stream << *c;
|
||||
}
|
||||
}
|
||||
return ref new Platform::String(stream.str().c_str());
|
||||
}
|
||||
|
||||
Platform::String ^ GetCalendarIdentifier() const
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
@@ -9,50 +9,78 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Common
|
||||
{
|
||||
class LocalizationStringUtil
|
||||
class LocalizationStringUtilInternal
|
||||
{
|
||||
public:
|
||||
static std::wstring GetLocalizedString(const wchar_t* pMessage, ...)
|
||||
static Platform::String ^ GetLocalizedString(Platform::String ^ pMessage, ...)
|
||||
{
|
||||
std::wstring returnString = L"";
|
||||
const UINT32 length = 1024;
|
||||
std::unique_ptr<wchar_t[]> spBuffer = std::unique_ptr<wchar_t[]>(new wchar_t[length]);
|
||||
va_list args = NULL;
|
||||
va_start(args, pMessage);
|
||||
DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage, 0, 0, spBuffer.get(), length, &args);
|
||||
DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING, pMessage->Data(), 0, 0, spBuffer.get(), length, &args);
|
||||
va_end(args);
|
||||
|
||||
if (fmtReturnVal != 0)
|
||||
{
|
||||
returnString = spBuffer.get();
|
||||
return ref new Platform::String(spBuffer.get());
|
||||
}
|
||||
|
||||
return returnString;
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
static Platform::String^ GetLocalizedNarratorAnnouncement(Platform::String^ resourceKey, Platform::String^& formatVariable, T*... params)
|
||||
{
|
||||
EnsureInitialization(resourceKey, formatVariable);
|
||||
return StringReference(GetLocalizedString(formatVariable->Data(), params...).c_str());
|
||||
}
|
||||
|
||||
private:
|
||||
static void EnsureInitialization(Platform::String^ resourceKey, Platform::String^& formatVariable)
|
||||
{
|
||||
if (resourceKey == nullptr || resourceKey->IsEmpty())
|
||||
else
|
||||
{
|
||||
return;
|
||||
return ref new Platform::String();
|
||||
}
|
||||
|
||||
// If the formatVariable already has a value, we don't need to set it again. Simply return.
|
||||
if (formatVariable != nullptr && !formatVariable->IsEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
formatVariable = AppResourceProvider::GetInstance().GetResourceString(resourceKey);
|
||||
}
|
||||
};
|
||||
|
||||
public
|
||||
ref class LocalizationStringUtil sealed
|
||||
{
|
||||
public:
|
||||
static Platform::String
|
||||
^ GetLocalizedString(Platform::String ^ pMessage)
|
||||
{
|
||||
return LocalizationStringUtilInternal::GetLocalizedString(pMessage);
|
||||
}
|
||||
|
||||
static Platform::String
|
||||
^ GetLocalizedString(
|
||||
Platform::String ^ pMessage,
|
||||
Platform::String ^ param1)
|
||||
{
|
||||
return LocalizationStringUtilInternal::GetLocalizedString(pMessage, param1->Data());
|
||||
}
|
||||
|
||||
static Platform::String
|
||||
^ GetLocalizedString(
|
||||
Platform::String ^ pMessage,
|
||||
Platform::String ^ param1,
|
||||
Platform::String ^ param2)
|
||||
{
|
||||
return LocalizationStringUtilInternal::GetLocalizedString(pMessage, param1->Data(), param2->Data());
|
||||
}
|
||||
|
||||
static Platform::String
|
||||
^ GetLocalizedString(
|
||||
Platform::String ^ pMessage,
|
||||
Platform::String ^ param1,
|
||||
Platform::String ^ param2,
|
||||
Platform::String
|
||||
^ param3)
|
||||
{
|
||||
return LocalizationStringUtilInternal::GetLocalizedString(pMessage, param1->Data(), param2->Data(), param3->Data());
|
||||
}
|
||||
|
||||
static Platform::String
|
||||
^ GetLocalizedString(
|
||||
Platform::String ^ pMessage,
|
||||
Platform::String ^ param1,
|
||||
Platform::String ^ param2,
|
||||
Platform::String ^ param3,
|
||||
Platform::String ^ param4)
|
||||
{
|
||||
return LocalizationStringUtilInternal::GetLocalizedString(pMessage, param1->Data(), param2->Data(), param3->Data(), param4->Data());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -368,33 +368,28 @@ NavCategoryGroup::NavCategoryGroup(const NavCategoryGroupInitializer& groupIniti
|
||||
m_GroupType = groupInitializer.type;
|
||||
|
||||
auto resProvider = AppResourceProvider::GetInstance();
|
||||
String ^ headerResourceKey = StringReference(groupInitializer.headerResourceKey);
|
||||
String ^ modeResourceKey = StringReference(groupInitializer.modeResourceKey);
|
||||
String ^ automationResourceKey = StringReference(groupInitializer.automationResourceKey);
|
||||
m_Name = resProvider.GetResourceString(headerResourceKey);
|
||||
String ^ groupMode = resProvider.GetResourceString(modeResourceKey);
|
||||
String ^ automationName = resProvider.GetResourceString(automationResourceKey);
|
||||
m_Name = resProvider->GetResourceString(StringReference(groupInitializer.headerResourceKey));
|
||||
String ^ groupMode = resProvider->GetResourceString(StringReference(groupInitializer.modeResourceKey));
|
||||
String ^ automationName = resProvider->GetResourceString(StringReference(groupInitializer.automationResourceKey));
|
||||
|
||||
String ^ navCategoryHeaderAutomationNameFormat = resProvider.GetResourceString(L"NavCategoryHeader_AutomationNameFormat");
|
||||
m_AutomationName =
|
||||
ref new String(LocalizationStringUtil::GetLocalizedString(navCategoryHeaderAutomationNameFormat->Data(), automationName->Data()).c_str());
|
||||
String ^ navCategoryHeaderAutomationNameFormat = resProvider->GetResourceString(L"NavCategoryHeader_AutomationNameFormat");
|
||||
m_AutomationName = LocalizationStringUtil::GetLocalizedString(navCategoryHeaderAutomationNameFormat, automationName);
|
||||
|
||||
String ^ navCategoryItemAutomationNameFormat = resProvider.GetResourceString(L"NavCategoryItem_AutomationNameFormat");
|
||||
String ^ navCategoryItemAutomationNameFormat = resProvider->GetResourceString(L"NavCategoryItem_AutomationNameFormat");
|
||||
|
||||
for (const NavCategoryInitializer& categoryInitializer : s_categoryManifest)
|
||||
{
|
||||
if (categoryInitializer.groupType == groupInitializer.type)
|
||||
{
|
||||
String ^ nameResourceKey = StringReference(categoryInitializer.nameResourceKey);
|
||||
String ^ categoryName = resProvider.GetResourceString(nameResourceKey + "Text");
|
||||
String ^ categoryAutomationName = ref new String(
|
||||
LocalizationStringUtil::GetLocalizedString(navCategoryItemAutomationNameFormat->Data(), categoryName->Data(), m_Name->Data()).c_str());
|
||||
String ^ categoryName = resProvider->GetResourceString(nameResourceKey + "Text");
|
||||
String ^ categoryAutomationName = LocalizationStringUtil::GetLocalizedString(navCategoryItemAutomationNameFormat, categoryName, m_Name);
|
||||
|
||||
m_Categories->Append(ref new NavCategory(
|
||||
categoryName,
|
||||
categoryAutomationName,
|
||||
StringReference(categoryInitializer.glyph),
|
||||
resProvider.GetResourceString(nameResourceKey + "AccessKey"),
|
||||
resProvider->GetResourceString(nameResourceKey + "AccessKey"),
|
||||
groupMode,
|
||||
categoryInitializer.viewMode,
|
||||
categoryInitializer.supportsNegative));
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#include "pch.h"
|
||||
@@ -132,8 +132,8 @@ CurrencyDataLoader::CurrencyDataLoader(_In_ unique_ptr<ICurrencyHttpClient> clie
|
||||
m_ratioFormatter->IsDecimalPointAlwaysDisplayed = true;
|
||||
m_ratioFormatter->FractionDigits = FORMATTER_RATE_FRACTION_PADDING;
|
||||
|
||||
m_ratioFormat = AppResourceProvider::GetInstance().GetResourceString(L"CurrencyFromToRatioFormat")->Data();
|
||||
m_timestampFormat = AppResourceProvider::GetInstance().GetResourceString(L"CurrencyTimestampFormat")->Data();
|
||||
m_ratioFormat = AppResourceProvider::GetInstance()->GetResourceString(L"CurrencyFromToRatioFormat");
|
||||
m_timestampFormat = AppResourceProvider::GetInstance()->GetResourceString(L"CurrencyTimestampFormat");
|
||||
}
|
||||
|
||||
CurrencyDataLoader::~CurrencyDataLoader()
|
||||
@@ -300,16 +300,18 @@ pair<wstring, wstring> CurrencyDataLoader::GetCurrencyRatioEquality(_In_ const U
|
||||
double ratio = (iter2->second).ratio;
|
||||
double rounded = RoundCurrencyRatio(ratio);
|
||||
|
||||
wstring digitSymbol = wstring{ LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'1') };
|
||||
wstring roundedFormat = m_ratioFormatter->Format(rounded)->Data();
|
||||
auto digit = LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'1');
|
||||
auto digitSymbol = ref new String(&digit, 1);
|
||||
auto roundedFormat = m_ratioFormatter->Format(rounded);
|
||||
|
||||
wstring ratioString = LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.abbreviation.c_str(), roundedFormat.c_str(), unit2.abbreviation.c_str());
|
||||
auto ratioString = LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat, digitSymbol, StringReference(unit1.abbreviation.c_str()), roundedFormat, StringReference(unit2.abbreviation.c_str()));
|
||||
|
||||
wstring accessibleRatioString = LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat.c_str(), digitSymbol.c_str(), unit1.accessibleName.c_str(), roundedFormat.c_str(), unit2.accessibleName.c_str());
|
||||
auto accessibleRatioString =
|
||||
LocalizationStringUtil::GetLocalizedString(
|
||||
m_ratioFormat, digitSymbol, StringReference(unit1.accessibleName.c_str()), roundedFormat, StringReference(unit2.accessibleName.c_str()));
|
||||
|
||||
return make_pair(ratioString, accessibleRatioString);
|
||||
return make_pair(ratioString->Data(), accessibleRatioString->Data());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -747,21 +749,19 @@ void CurrencyDataLoader::UpdateDisplayedTimestamp()
|
||||
}
|
||||
wstring CurrencyDataLoader::GetCurrencyTimestamp()
|
||||
{
|
||||
wstring timestamp = L"";
|
||||
|
||||
DateTime epoch{};
|
||||
if (m_cacheTimestamp.UniversalTime != epoch.UniversalTime)
|
||||
{
|
||||
DateTimeFormatter ^ dateFormatter = ref new DateTimeFormatter(L"shortdate");
|
||||
wstring date = dateFormatter->Format(m_cacheTimestamp)->Data();
|
||||
auto date = dateFormatter->Format(m_cacheTimestamp);
|
||||
|
||||
DateTimeFormatter ^ timeFormatter = ref new DateTimeFormatter(L"shorttime");
|
||||
wstring time = timeFormatter->Format(m_cacheTimestamp)->Data();
|
||||
auto time = timeFormatter->Format(m_cacheTimestamp);
|
||||
|
||||
timestamp = LocalizationStringUtil::GetLocalizedString(m_timestampFormat.c_str(), date.c_str(), time.c_str());
|
||||
return LocalizationStringUtil::GetLocalizedString(m_timestampFormat, date, time)->Data();
|
||||
}
|
||||
|
||||
return timestamp;
|
||||
return L"";
|
||||
}
|
||||
|
||||
#pragma optimize("", off) // Turn off optimizations to work around DevDiv 393321
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
#pragma once
|
||||
@@ -124,9 +124,9 @@ namespace CalculatorApp
|
||||
std::shared_ptr<UCM::IViewModelCurrencyCallback> m_vmCallback;
|
||||
|
||||
Windows::Globalization::NumberFormatting::DecimalFormatter ^ m_ratioFormatter;
|
||||
std::wstring m_ratioFormat;
|
||||
Platform::String ^ m_ratioFormat;
|
||||
Windows::Foundation::DateTime m_cacheTimestamp;
|
||||
std::wstring m_timestampFormat;
|
||||
Platform::String ^ m_timestampFormat;
|
||||
|
||||
CurrencyLoadStatus m_loadStatus;
|
||||
|
||||
|
@@ -953,7 +953,7 @@ void UnitConverterDataLoader::GetConversionData(_In_ unordered_map<ViewMode, uno
|
||||
|
||||
wstring UnitConverterDataLoader::GetLocalizedStringName(String ^ stringId)
|
||||
{
|
||||
return AppResourceProvider::GetInstance().GetResourceString(stringId)->Data();
|
||||
return AppResourceProvider::GetInstance()->GetResourceString(stringId)->Data();
|
||||
}
|
||||
|
||||
void UnitConverterDataLoader::GetExplicitConversionData(_In_ unordered_map<int, unordered_map<int, UCM::ConversionData>>& unitToUnitConversionList)
|
||||
|
@@ -172,14 +172,14 @@ void DateCalculatorViewModel::UpdateDisplayResult()
|
||||
{
|
||||
IsDiffInDays = false;
|
||||
StrDateDiffResultInDays = L"";
|
||||
StrDateDiffResult = AppResourceProvider::GetInstance().GetResourceString(L"CalculationFailed");
|
||||
StrDateDiffResult = AppResourceProvider::GetInstance()->GetResourceString(L"CalculationFailed");
|
||||
}
|
||||
else if (m_dateDiffResultInDays.day == 0)
|
||||
{
|
||||
// to and from dates the same
|
||||
IsDiffInDays = true;
|
||||
StrDateDiffResultInDays = L"";
|
||||
StrDateDiffResult = AppResourceProvider::GetInstance().GetResourceString(L"Date_SameDates");
|
||||
StrDateDiffResult = AppResourceProvider::GetInstance()->GetResourceString(L"Date_SameDates");
|
||||
}
|
||||
else if (m_dateDiffResult == DateDifferenceUnknown ||
|
||||
(m_dateDiffResult.year == 0 && m_dateDiffResult.month == 0 && m_dateDiffResult.week == 0))
|
||||
@@ -206,7 +206,7 @@ void DateCalculatorViewModel::UpdateDisplayResult()
|
||||
if (m_isOutOfBound)
|
||||
{
|
||||
// Display Date out of bound message
|
||||
StrDateResult = AppResourceProvider::GetInstance().GetResourceString(L"Date_OutOfBoundMessage");
|
||||
StrDateResult = AppResourceProvider::GetInstance()->GetResourceString(L"Date_OutOfBoundMessage");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -218,16 +218,14 @@ void DateCalculatorViewModel::UpdateDisplayResult()
|
||||
|
||||
void DateCalculatorViewModel::UpdateStrDateDiffResultAutomationName()
|
||||
{
|
||||
String ^ automationFormat = AppResourceProvider::GetInstance().GetResourceString(L"Date_DifferenceResultAutomationName");
|
||||
wstring localizedAutomationName = LocalizationStringUtil::GetLocalizedString(automationFormat->Data(), StrDateDiffResult->Data());
|
||||
StrDateDiffResultAutomationName = ref new String(localizedAutomationName.c_str());
|
||||
String ^ automationFormat = AppResourceProvider::GetInstance()->GetResourceString(L"Date_DifferenceResultAutomationName");
|
||||
StrDateDiffResultAutomationName = LocalizationStringUtil::GetLocalizedString(automationFormat, StrDateDiffResult);
|
||||
}
|
||||
|
||||
void DateCalculatorViewModel::UpdateStrDateResultAutomationName()
|
||||
{
|
||||
String ^ automationFormat = AppResourceProvider::GetInstance().GetResourceString(L"Date_ResultingDateAutomationName");
|
||||
wstring localizedAutomationName = LocalizationStringUtil::GetLocalizedString(automationFormat->Data(), StrDateResult->Data());
|
||||
StrDateResultAutomationName = ref new String(localizedAutomationName.c_str());
|
||||
String ^ automationFormat = AppResourceProvider::GetInstance()->GetResourceString(L"Date_ResultingDateAutomationName");
|
||||
StrDateResultAutomationName = LocalizationStringUtil::GetLocalizedString(automationFormat, StrDateResult);
|
||||
}
|
||||
|
||||
void DateCalculatorViewModel::InitializeDateOutputFormats(_In_ String ^ calendarIdentifier)
|
||||
@@ -247,7 +245,7 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
|
||||
{
|
||||
wstring result;
|
||||
bool addDelimiter = false;
|
||||
AppResourceProvider resourceLoader = AppResourceProvider::GetInstance();
|
||||
AppResourceProvider ^ resourceLoader = AppResourceProvider::GetInstance();
|
||||
|
||||
auto yearCount = m_dateDiffResult.year;
|
||||
if (yearCount > 0)
|
||||
@@ -257,11 +255,11 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
|
||||
|
||||
if (yearCount > 1)
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Years")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Years")->Data();
|
||||
}
|
||||
else
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Year")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Year")->Data();
|
||||
}
|
||||
|
||||
// set the flags to add a delimiter whenever the next unit is added
|
||||
@@ -285,11 +283,11 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
|
||||
|
||||
if (monthCount > 1)
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Months")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Months")->Data();
|
||||
}
|
||||
else
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Month")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Month")->Data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,11 +308,11 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
|
||||
|
||||
if (weekCount > 1)
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Weeks")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Weeks")->Data();
|
||||
}
|
||||
else
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Week")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Week")->Data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,11 +333,11 @@ String ^ DateCalculatorViewModel::GetDateDiffString() const
|
||||
|
||||
if (dayCount > 1)
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Days")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Days")->Data();
|
||||
}
|
||||
else
|
||||
{
|
||||
result += resourceLoader.GetResourceString(L"Date_Day")->Data();
|
||||
result += resourceLoader->GetResourceString(L"Date_Day")->Data();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -354,11 +352,11 @@ String ^ DateCalculatorViewModel::GetDateDiffStringInDays() const
|
||||
// Display the result as '1 day' or 'N days'
|
||||
if (m_dateDiffResultInDays.day > 1)
|
||||
{
|
||||
result += AppResourceProvider::GetInstance().GetResourceString(L"Date_Days")->Data();
|
||||
result += AppResourceProvider::GetInstance()->GetResourceString(L"Date_Days")->Data();
|
||||
}
|
||||
else
|
||||
{
|
||||
result += AppResourceProvider::GetInstance().GetResourceString(L"Date_Day")->Data();
|
||||
result += AppResourceProvider::GetInstance()->GetResourceString(L"Date_Day")->Data();
|
||||
}
|
||||
|
||||
return ref new String(result.data());
|
||||
|
@@ -164,7 +164,11 @@ void HistoryViewModel::OnClearCommand(_In_ Platform::Object ^ e)
|
||||
UpdateItemSize();
|
||||
}
|
||||
|
||||
MakeHistoryClearedNarratorAnnouncement(HistoryResourceKeys::HistoryCleared, m_localizedHistoryCleared);
|
||||
if (m_localizedHistoryCleared == nullptr)
|
||||
{
|
||||
m_localizedHistoryCleared = AppResourceProvider::GetInstance()->GetResourceString(HistoryResourceKeys::HistoryCleared);
|
||||
}
|
||||
HistoryAnnouncement = CalculatorAnnouncement::GetHistoryClearedAnnouncement(m_localizedHistoryCleared);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,10 +374,3 @@ void HistoryViewModel::UpdateItemSize()
|
||||
{
|
||||
ItemSize = Items->Size;
|
||||
}
|
||||
|
||||
void HistoryViewModel::MakeHistoryClearedNarratorAnnouncement(String ^ resourceKey, String ^ &formatVariable)
|
||||
{
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(resourceKey, formatVariable);
|
||||
|
||||
HistoryAnnouncement = CalculatorAnnouncement::GetHistoryClearedAnnouncement(announcement);
|
||||
}
|
||||
|
@@ -68,8 +68,6 @@ namespace CalculatorApp
|
||||
void UpdateHistoryVectorLength(_In_ int newValue, _In_ CalculationManager::CALCULATOR_MODE cMode);
|
||||
bool IsValid(_In_ CalculationManager::HISTORYITEM item);
|
||||
|
||||
void MakeHistoryClearedNarratorAnnouncement(Platform::String ^ resourceKey, Platform::String ^ &formatVariable);
|
||||
|
||||
friend class CalculatorDisplay;
|
||||
void UpdateItemSize();
|
||||
};
|
||||
|
@@ -25,6 +25,7 @@ using namespace Windows::UI::Popups;
|
||||
using namespace Windows::Storage::Streams;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
using namespace Utils;
|
||||
using namespace concurrency;
|
||||
|
||||
constexpr int StandardModePrecision = 16;
|
||||
constexpr int ScientificModePrecision = 32;
|
||||
@@ -93,15 +94,16 @@ StandardCalculatorViewModel::StandardCalculatorViewModel()
|
||||
, m_localizedNoRightParenthesisAddedFormat(nullptr)
|
||||
{
|
||||
WeakReference calculatorViewModel(this);
|
||||
auto appResourceProvider = AppResourceProvider::GetInstance();
|
||||
m_calculatorDisplay.SetCallback(calculatorViewModel);
|
||||
m_expressionAutomationNameFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::CalculatorExpression);
|
||||
m_localizedCalculationResultAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::CalculatorResults);
|
||||
m_expressionAutomationNameFormat = appResourceProvider->GetResourceString(CalculatorResourceKeys::CalculatorExpression);
|
||||
m_localizedCalculationResultAutomationFormat = appResourceProvider->GetResourceString(CalculatorResourceKeys::CalculatorResults);
|
||||
m_localizedCalculationResultDecimalAutomationFormat =
|
||||
AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::CalculatorResults_DecimalSeparator_Announced);
|
||||
m_localizedHexaDecimalAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::HexButton);
|
||||
m_localizedDecimalAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::DecButton);
|
||||
m_localizedOctalAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::OctButton);
|
||||
m_localizedBinaryAutomationFormat = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::BinButton);
|
||||
appResourceProvider->GetResourceString(CalculatorResourceKeys::CalculatorResults_DecimalSeparator_Announced);
|
||||
m_localizedHexaDecimalAutomationFormat = appResourceProvider->GetResourceString(CalculatorResourceKeys::HexButton);
|
||||
m_localizedDecimalAutomationFormat = appResourceProvider->GetResourceString(CalculatorResourceKeys::DecButton);
|
||||
m_localizedOctalAutomationFormat = appResourceProvider->GetResourceString(CalculatorResourceKeys::OctButton);
|
||||
m_localizedBinaryAutomationFormat = appResourceProvider->GetResourceString(CalculatorResourceKeys::BinButton);
|
||||
|
||||
// Initialize the Automation Name
|
||||
CalculationResultAutomationName = GetLocalizedStringFormat(m_localizedCalculationResultAutomationFormat, m_DisplayValue);
|
||||
@@ -192,13 +194,13 @@ String ^ StandardCalculatorViewModel::GetNarratorStringReadRawNumbers(_In_ Strin
|
||||
return ref new String(wss.str().c_str());
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::SetPrimaryDisplay(_In_ wstring const& displayStringValue, _In_ bool isError)
|
||||
void StandardCalculatorViewModel::SetPrimaryDisplay(_In_ String ^ displayStringValue, _In_ bool isError)
|
||||
{
|
||||
String ^ localizedDisplayStringValue = LocalizeDisplayValue(displayStringValue, isError);
|
||||
String ^ localizedDisplayStringValue = LocalizeDisplayValue(displayStringValue->Data(), isError);
|
||||
|
||||
// Set this variable before the DisplayValue is modified, Otherwise the DisplayValue will
|
||||
// not match what the narrator is saying
|
||||
m_CalculationResultAutomationName = CalculateNarratorDisplayValue(displayStringValue, localizedDisplayStringValue, isError);
|
||||
m_CalculationResultAutomationName = CalculateNarratorDisplayValue(displayStringValue->Data(), localizedDisplayStringValue, isError);
|
||||
|
||||
AreAlwaysOnTopResultsUpdated = false;
|
||||
if (DisplayValue != localizedDisplayStringValue)
|
||||
@@ -239,10 +241,13 @@ void StandardCalculatorViewModel::SetOpenParenthesisCountNarratorAnnouncement()
|
||||
wstring localizedParenthesisCount = to_wstring(m_OpenParenthesisCount).c_str();
|
||||
LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedParenthesisCount);
|
||||
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||
CalculatorResourceKeys::OpenParenthesisCountAutomationFormat,
|
||||
m_localizedOpenParenthesisCountChangedAutomationFormat,
|
||||
localizedParenthesisCount.c_str());
|
||||
if (m_localizedOpenParenthesisCountChangedAutomationFormat == nullptr)
|
||||
{
|
||||
m_localizedOpenParenthesisCountChangedAutomationFormat =
|
||||
AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::OpenParenthesisCountAutomationFormat);
|
||||
}
|
||||
String ^ announcement =
|
||||
LocalizationStringUtil::GetLocalizedString(m_localizedOpenParenthesisCountChangedAutomationFormat, StringReference(localizedParenthesisCount.c_str()));
|
||||
|
||||
Announcement = CalculatorAnnouncement::GetOpenParenthesisCountChangedAnnouncement(announcement);
|
||||
}
|
||||
@@ -254,10 +259,13 @@ void StandardCalculatorViewModel::OnNoRightParenAdded()
|
||||
|
||||
void StandardCalculatorViewModel::SetNoParenAddedNarratorAnnouncement()
|
||||
{
|
||||
String ^ announcement =
|
||||
LocalizationStringUtil::GetLocalizedNarratorAnnouncement(CalculatorResourceKeys::NoParenthesisAdded, m_localizedNoRightParenthesisAddedFormat);
|
||||
if (m_localizedNoRightParenthesisAddedFormat == nullptr)
|
||||
{
|
||||
m_localizedNoRightParenthesisAddedFormat =
|
||||
AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::NoParenthesisAdded);
|
||||
}
|
||||
|
||||
Announcement = CalculatorAnnouncement::GetNoRightParenthesisAddedAnnouncement(announcement);
|
||||
Announcement = CalculatorAnnouncement::GetNoRightParenthesisAddedAnnouncement(m_localizedNoRightParenthesisAddedFormat);
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::DisableButtons(CommandType selectedExpressionCommandType)
|
||||
@@ -337,7 +345,7 @@ void StandardCalculatorViewModel::SetTokens(_Inout_ shared_ptr<vector<pair<wstri
|
||||
for (unsigned int i = 0; i < nTokens; ++i)
|
||||
{
|
||||
auto currentToken = (*tokens)[i];
|
||||
|
||||
|
||||
Common::TokenType type;
|
||||
bool isEditable = currentToken.second != -1;
|
||||
localizer.LocalizeDisplayValue(&(currentToken.first));
|
||||
@@ -352,7 +360,7 @@ void StandardCalculatorViewModel::SetTokens(_Inout_ shared_ptr<vector<pair<wstri
|
||||
type = command->GetCommandType() == CommandType::OperandCommand ? TokenType::Operand : TokenType::Operator;
|
||||
}
|
||||
|
||||
auto currentTokenString = ref new String(currentToken.first.c_str());
|
||||
auto currentTokenString = StringReference(currentToken.first.c_str());
|
||||
if (i < m_ExpressionTokens->Size)
|
||||
{
|
||||
auto existingItem = m_ExpressionTokens->GetAt(i);
|
||||
@@ -696,7 +704,7 @@ void StandardCalculatorViewModel::OnCopyCommand(Object ^ parameter)
|
||||
{
|
||||
CopyPasteManager::CopyToClipboard(GetRawDisplayValue());
|
||||
|
||||
String ^ announcement = AppResourceProvider::GetInstance().GetResourceString(CalculatorResourceKeys::DisplayCopied);
|
||||
String ^ announcement = AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::DisplayCopied);
|
||||
Announcement = CalculatorAnnouncement::GetDisplayCopiedAnnouncement(announcement);
|
||||
}
|
||||
|
||||
@@ -727,7 +735,7 @@ void StandardCalculatorViewModel::OnPasteCommand(Object ^ parameter)
|
||||
}
|
||||
|
||||
// Ensure that the paste happens on the UI thread
|
||||
CopyPasteManager::GetStringToPaste(mode, NavCategory::GetGroupType(mode), NumberBase, bitLengthType)
|
||||
create_task(CopyPasteManager::GetStringToPaste(mode, NavCategory::GetGroupType(mode), NumberBase, bitLengthType))
|
||||
.then([that, mode](String ^ pastedString) { that->OnPaste(pastedString); }, concurrency::task_continuation_context::use_current());
|
||||
}
|
||||
|
||||
@@ -739,7 +747,7 @@ CalculationManager::Command StandardCalculatorViewModel::ConvertToOperatorsEnum(
|
||||
void StandardCalculatorViewModel::OnPaste(String ^ pastedString)
|
||||
{
|
||||
// If pastedString is invalid("NoOp") then display pasteError else process the string
|
||||
if (pastedString == StringReference(CopyPasteManager::PasteErrorString))
|
||||
if (CopyPasteManager::IsErrorMessage(pastedString))
|
||||
{
|
||||
this->DisplayPasteError();
|
||||
return;
|
||||
@@ -893,8 +901,11 @@ void StandardCalculatorViewModel::OnClearMemoryCommand(Object ^ parameter)
|
||||
|
||||
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::MemoryClear, GetCalculatorMode());
|
||||
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(CalculatorResourceKeys::MemoryCleared, m_localizedMemoryCleared);
|
||||
Announcement = CalculatorAnnouncement::GetMemoryClearedAnnouncement(announcement);
|
||||
if (m_localizedMemoryCleared == nullptr)
|
||||
{
|
||||
m_localizedMemoryCleared = AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::MemoryCleared);
|
||||
}
|
||||
Announcement = CalculatorAnnouncement::GetMemoryClearedAnnouncement(m_localizedMemoryCleared);
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::OnPinUnpinCommand(Object ^ parameter)
|
||||
@@ -1046,9 +1057,11 @@ void StandardCalculatorViewModel::OnMemoryButtonPressed()
|
||||
|
||||
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::Memory, GetCalculatorMode());
|
||||
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||
CalculatorResourceKeys::MemorySave, m_localizedMemorySavedAutomationFormat, m_DisplayValue->Data());
|
||||
|
||||
if (m_localizedMemorySavedAutomationFormat == nullptr)
|
||||
{
|
||||
m_localizedMemorySavedAutomationFormat = AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::MemorySave);
|
||||
}
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedString(m_localizedMemorySavedAutomationFormat, m_DisplayValue);
|
||||
Announcement = CalculatorAnnouncement::GetMemoryItemAddedAnnouncement(announcement);
|
||||
}
|
||||
|
||||
@@ -1062,9 +1075,12 @@ void StandardCalculatorViewModel::OnMemoryItemChanged(unsigned int indexOfMemory
|
||||
wstring localizedIndex = to_wstring(indexOfMemory + 1);
|
||||
LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedIndex);
|
||||
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||
CalculatorResourceKeys::MemoryItemChanged, m_localizedMemoryItemChangedAutomationFormat, localizedIndex.c_str(), localizedValue->Data());
|
||||
|
||||
if (m_localizedMemoryItemChangedAutomationFormat == nullptr)
|
||||
{
|
||||
m_localizedMemoryItemChangedAutomationFormat = AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::MemoryItemChanged);
|
||||
}
|
||||
String ^ announcement =
|
||||
LocalizationStringUtil::GetLocalizedString(m_localizedMemoryItemChangedAutomationFormat, StringReference(localizedIndex.c_str()), localizedValue);
|
||||
Announcement = CalculatorAnnouncement::GetMemoryItemChangedAnnouncement(announcement);
|
||||
}
|
||||
}
|
||||
@@ -1131,8 +1147,12 @@ void StandardCalculatorViewModel::OnMemoryClear(_In_ Object ^ memoryItemPosition
|
||||
wstring localizedIndex = to_wstring(boxedPosition->Value + 1);
|
||||
LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedIndex);
|
||||
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||
CalculatorResourceKeys::MemoryItemCleared, m_localizedMemoryItemClearedAutomationFormat, localizedIndex.c_str());
|
||||
if (m_localizedMemoryItemClearedAutomationFormat == nullptr)
|
||||
{
|
||||
m_localizedMemoryItemClearedAutomationFormat = AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::MemoryItemCleared);
|
||||
}
|
||||
String ^ announcement =
|
||||
LocalizationStringUtil::GetLocalizedString(m_localizedMemoryItemClearedAutomationFormat, StringReference(localizedIndex.c_str()));
|
||||
|
||||
Announcement = CalculatorAnnouncement::GetMemoryClearedAnnouncement(announcement);
|
||||
}
|
||||
@@ -1212,9 +1232,7 @@ String ^ StandardCalculatorViewModel::GetRawDisplayValue()
|
||||
}
|
||||
else
|
||||
{
|
||||
wstring rawValue;
|
||||
LocalizationSettings::GetInstance().RemoveGroupSeparators(DisplayValue->Data(), DisplayValue->Length(), &rawValue);
|
||||
return ref new String(rawValue.c_str());
|
||||
return LocalizationSettings::GetInstance().RemoveGroupSeparators(DisplayValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,8 +1241,7 @@ String ^ StandardCalculatorViewModel::GetRawDisplayValue()
|
||||
// 'displayValue' is a localized string containing a numerical value to be displayed to the user.
|
||||
String ^ StandardCalculatorViewModel::GetLocalizedStringFormat(String ^ format, String ^ displayValue)
|
||||
{
|
||||
String ^ localizedString = ref new String(LocalizationStringUtil::GetLocalizedString(format->Data(), displayValue->Data()).c_str());
|
||||
return localizedString;
|
||||
return LocalizationStringUtil::GetLocalizedString(format, displayValue);
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::ResetDisplay()
|
||||
@@ -1585,7 +1602,7 @@ size_t StandardCalculatorViewModel::LengthWithoutPadding(wstring str)
|
||||
|
||||
wstring StandardCalculatorViewModel::AddPadding(wstring binaryString)
|
||||
{
|
||||
if (LocalizationSettings::GetInstance().GetEnglishValueFromLocalizedDigits(binaryString) == L"0")
|
||||
if (LocalizationSettings::GetInstance().GetEnglishValueFromLocalizedDigits(StringReference(binaryString.c_str())) == L"0")
|
||||
{
|
||||
return binaryString;
|
||||
}
|
||||
@@ -1684,7 +1701,7 @@ void StandardCalculatorViewModel::UpdateOperand(int pos, String ^ text)
|
||||
{
|
||||
pair<wstring, int> p = m_tokens->at(pos);
|
||||
|
||||
String ^ englishString = LocalizationSettings::GetInstance().GetEnglishValueFromLocalizedDigits(text->Data());
|
||||
String ^ englishString = LocalizationSettings::GetInstance().GetEnglishValueFromLocalizedDigits(text);
|
||||
p.first = englishString->Data();
|
||||
|
||||
int commandPos = p.second;
|
||||
@@ -1808,9 +1825,11 @@ void StandardCalculatorViewModel::UpdatecommandsInRecordingMode()
|
||||
|
||||
void StandardCalculatorViewModel::OnMaxDigitsReached()
|
||||
{
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||
CalculatorResourceKeys::MaxDigitsReachedFormat, m_localizedMaxDigitsReachedAutomationFormat, m_CalculationResultAutomationName->Data());
|
||||
|
||||
if (m_localizedMaxDigitsReachedAutomationFormat == nullptr)
|
||||
{
|
||||
m_localizedMaxDigitsReachedAutomationFormat = AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::MaxDigitsReachedFormat);
|
||||
}
|
||||
String ^ announcement = LocalizationStringUtil::GetLocalizedString(m_localizedMaxDigitsReachedAutomationFormat, m_CalculationResultAutomationName);
|
||||
Announcement = CalculatorAnnouncement::GetMaxDigitsReachedAnnouncement(announcement);
|
||||
}
|
||||
|
||||
@@ -1828,11 +1847,14 @@ NarratorAnnouncement ^ StandardCalculatorViewModel::GetDisplayUpdatedNarratorAnn
|
||||
}
|
||||
else
|
||||
{
|
||||
announcement = LocalizationStringUtil::GetLocalizedNarratorAnnouncement(
|
||||
CalculatorResourceKeys::ButtonPressFeedbackFormat,
|
||||
if (m_localizedButtonPressFeedbackAutomationFormat == nullptr)
|
||||
{
|
||||
m_localizedButtonPressFeedbackAutomationFormat = AppResourceProvider::GetInstance()->GetResourceString(CalculatorResourceKeys::ButtonPressFeedbackFormat);
|
||||
}
|
||||
announcement = LocalizationStringUtil::GetLocalizedString(
|
||||
m_localizedButtonPressFeedbackAutomationFormat,
|
||||
m_CalculationResultAutomationName->Data(),
|
||||
m_feedbackForButtonPress->Data());
|
||||
m_CalculationResultAutomationName,
|
||||
m_feedbackForButtonPress);
|
||||
}
|
||||
|
||||
// Make sure we don't accidentally repeat an announcement.
|
||||
|
@@ -340,7 +340,7 @@ namespace CalculatorApp
|
||||
void OnPinUnpinCommand(Platform::Object ^ parameter);
|
||||
|
||||
void OnInputChanged();
|
||||
void SetPrimaryDisplay(_In_ std::wstring const& displayString, _In_ bool isError);
|
||||
void SetPrimaryDisplay(Platform::String ^ displayString, _In_ bool isError);
|
||||
void DisplayPasteError();
|
||||
void SetTokens(_Inout_ std::shared_ptr<std::vector<std::pair<std::wstring, int>>> const& tokens);
|
||||
void SetExpressionDisplay(
|
||||
|
@@ -137,12 +137,12 @@ UnitConverterViewModel::UnitConverterViewModel(const shared_ptr<UCM::IUnitConver
|
||||
m_currencyMaxFractionDigits = m_currencyFormatter->FractionDigits;
|
||||
|
||||
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||
m_localizedValueFromFormat = resourceLoader.GetResourceString(UnitConverterResourceKeys::ValueFromFormat);
|
||||
m_localizedValueToFormat = resourceLoader.GetResourceString(UnitConverterResourceKeys::ValueToFormat);
|
||||
m_localizedConversionResultFormat = resourceLoader.GetResourceString(UnitConverterResourceKeys::ConversionResultFormat);
|
||||
m_localizedValueFromDecimalFormat = resourceLoader.GetResourceString(UnitConverterResourceKeys::ValueFromDecimalFormat);
|
||||
m_localizedInputUnitName = resourceLoader.GetResourceString(UnitConverterResourceKeys::InputUnit_Name);
|
||||
m_localizedOutputUnitName = resourceLoader.GetResourceString(UnitConverterResourceKeys::OutputUnit_Name);
|
||||
m_localizedValueFromFormat = resourceLoader->GetResourceString(UnitConverterResourceKeys::ValueFromFormat);
|
||||
m_localizedValueToFormat = resourceLoader->GetResourceString(UnitConverterResourceKeys::ValueToFormat);
|
||||
m_localizedConversionResultFormat = resourceLoader->GetResourceString(UnitConverterResourceKeys::ConversionResultFormat);
|
||||
m_localizedValueFromDecimalFormat = resourceLoader->GetResourceString(UnitConverterResourceKeys::ValueFromDecimalFormat);
|
||||
m_localizedInputUnitName = resourceLoader->GetResourceString(UnitConverterResourceKeys::InputUnit_Name);
|
||||
m_localizedOutputUnitName = resourceLoader->GetResourceString(UnitConverterResourceKeys::OutputUnit_Name);
|
||||
|
||||
Unit1AutomationName = m_localizedInputUnitName;
|
||||
Unit2AutomationName = m_localizedOutputUnitName;
|
||||
@@ -390,7 +390,7 @@ String ^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& st
|
||||
|
||||
void UnitConverterViewModel::DisplayPasteError()
|
||||
{
|
||||
String ^ errorMsg = AppResourceProvider::GetInstance().GetCEngineString(StringReference(SIDS_DOMAIN)); /*SIDS_DOMAIN is for "invalid input"*/
|
||||
String ^ errorMsg = AppResourceProvider::GetInstance()->GetCEngineString(StringReference(SIDS_DOMAIN)); /*SIDS_DOMAIN is for "invalid input"*/
|
||||
Value1 = errorMsg;
|
||||
Value2 = errorMsg;
|
||||
m_relocalizeStringOnSwitch = false;
|
||||
@@ -515,8 +515,10 @@ void UnitConverterViewModel::OnPasteCommand(Platform::Object ^ parameter)
|
||||
// Ensure that the paste happens on the UI thread
|
||||
// EventWriteClipboardPaste_Start();
|
||||
// Any converter ViewMode is fine here.
|
||||
CopyPasteManager::GetStringToPaste(m_Mode, NavCategory::GetGroupType(m_Mode))
|
||||
.then([this](String ^ pastedString) { OnPaste(pastedString); }, concurrency::task_continuation_context::use_current());
|
||||
|
||||
auto that(this);
|
||||
create_task(CopyPasteManager::GetStringToPaste(m_Mode, NavCategory::GetGroupType(m_Mode), -1, BitLength::BitLengthUnknown))
|
||||
.then([that](String ^ pastedString) { that->OnPaste(pastedString); }, concurrency::task_continuation_context::use_current());
|
||||
}
|
||||
|
||||
void UnitConverterViewModel::InitializeView()
|
||||
@@ -650,7 +652,7 @@ void UnitConverterViewModel::OnCurrencyDataLoadFinished(bool didLoad)
|
||||
ResetCategory();
|
||||
|
||||
StringReference key = didLoad ? UnitConverterResourceKeys::CurrencyRatesUpdated : UnitConverterResourceKeys::CurrencyRatesUpdateFailed;
|
||||
String ^ announcement = AppResourceProvider::GetInstance().GetResourceString(key);
|
||||
String ^ announcement = AppResourceProvider::GetInstance()->GetResourceString(key);
|
||||
Announcement = CalculatorAnnouncement::GetUpdateCurrencyRatesAnnouncement(announcement);
|
||||
}
|
||||
|
||||
@@ -665,17 +667,18 @@ void UnitConverterViewModel::RefreshCurrencyRatios()
|
||||
m_isCurrencyDataLoaded = false;
|
||||
IsCurrencyLoadingVisible = true;
|
||||
|
||||
String ^ announcement = AppResourceProvider::GetInstance().GetResourceString(UnitConverterResourceKeys::UpdatingCurrencyRates);
|
||||
String ^ announcement = AppResourceProvider::GetInstance()->GetResourceString(UnitConverterResourceKeys::UpdatingCurrencyRates);
|
||||
Announcement = CalculatorAnnouncement::GetUpdateCurrencyRatesAnnouncement(announcement);
|
||||
|
||||
auto refreshTask = create_task([this] { return m_model->RefreshCurrencyRatios().get(); });
|
||||
auto that(this);
|
||||
auto refreshTask = create_task([that] { return that->m_model->RefreshCurrencyRatios().get(); });
|
||||
refreshTask.then(
|
||||
[this](const pair<bool, wstring>& refreshResult) {
|
||||
[that](const pair<bool, wstring>& refreshResult) {
|
||||
bool didLoad = refreshResult.first;
|
||||
wstring timestamp = refreshResult.second;
|
||||
|
||||
OnCurrencyTimestampUpdated(timestamp, false /*isWeekOldData*/);
|
||||
OnCurrencyDataLoadFinished(didLoad);
|
||||
that->OnCurrencyTimestampUpdated(timestamp, false /*isWeekOldData*/);
|
||||
that->OnCurrencyDataLoadFinished(didLoad);
|
||||
},
|
||||
task_continuation_context::use_current());
|
||||
}
|
||||
@@ -878,7 +881,7 @@ NumbersAndOperatorsEnum UnitConverterViewModel::MapCharacterToButtonId(const wch
|
||||
void UnitConverterViewModel::OnPaste(String ^ stringToPaste)
|
||||
{
|
||||
// If pastedString is invalid("NoOp") then display pasteError else process the string
|
||||
if (stringToPaste == StringReference(CopyPasteManager::PasteErrorString))
|
||||
if (CopyPasteManager::IsErrorMessage(stringToPaste))
|
||||
{
|
||||
this->DisplayPasteError();
|
||||
return;
|
||||
@@ -954,8 +957,7 @@ String ^ UnitConverterViewModel::GetLocalizedAutomationName(_In_ String ^ displa
|
||||
format = m_localizedValueFromDecimalFormat;
|
||||
}
|
||||
|
||||
wstring localizedResult = LocalizationStringUtil::GetLocalizedString(format->Data(), displayvalue->Data(), unitname->Data());
|
||||
return ref new String(localizedResult.c_str());
|
||||
return LocalizationStringUtil::GetLocalizedString(format, displayvalue, unitname);
|
||||
}
|
||||
|
||||
String
|
||||
@@ -965,11 +967,7 @@ String
|
||||
_In_ String ^ toValue,
|
||||
_In_ String ^ toUnit)
|
||||
{
|
||||
String ^ localizedString =
|
||||
ref new String(LocalizationStringUtil::GetLocalizedString(
|
||||
m_localizedConversionResultFormat->Data(), fromValue->Data(), fromUnit->Data(), toValue->Data(), toUnit->Data())
|
||||
.c_str());
|
||||
return localizedString;
|
||||
return LocalizationStringUtil::GetLocalizedString(m_localizedConversionResultFormat, fromValue, fromUnit, toValue, toUnit);
|
||||
}
|
||||
|
||||
void UnitConverterViewModel::UpdateValue1AutomationName()
|
||||
@@ -990,9 +988,9 @@ void UnitConverterViewModel::UpdateValue2AutomationName()
|
||||
|
||||
void UnitConverterViewModel::OnMaxDigitsReached()
|
||||
{
|
||||
String ^ format = AppResourceProvider::GetInstance().GetResourceString(UnitConverterResourceKeys::MaxDigitsReachedFormat);
|
||||
const wstring& announcement = LocalizationStringUtil::GetLocalizedString(format->Data(), m_lastAnnouncedConversionResult->Data());
|
||||
Announcement = CalculatorAnnouncement::GetMaxDigitsReachedAnnouncement(StringReference(announcement.c_str()));
|
||||
String ^ format = AppResourceProvider::GetInstance()->GetResourceString(UnitConverterResourceKeys::MaxDigitsReachedFormat);
|
||||
auto announcement = LocalizationStringUtil::GetLocalizedString(format, m_lastAnnouncedConversionResult);
|
||||
Announcement = CalculatorAnnouncement::GetMaxDigitsReachedAnnouncement(announcement);
|
||||
}
|
||||
|
||||
bool UnitConverterViewModel::UnitsAreValid()
|
||||
@@ -1002,17 +1000,18 @@ bool UnitConverterViewModel::UnitsAreValid()
|
||||
|
||||
void UnitConverterViewModel::StartConversionResultTimer()
|
||||
{
|
||||
m_conversionResultTaskHelper = make_unique<ConversionResultTaskHelper>(CONVERSION_FINALIZED_DELAY_IN_MS, [this]() {
|
||||
if (UnitsAreValid())
|
||||
auto that(this);
|
||||
m_conversionResultTaskHelper = make_unique<ConversionResultTaskHelper>(CONVERSION_FINALIZED_DELAY_IN_MS, [that]() {
|
||||
if (that->UnitsAreValid())
|
||||
{
|
||||
String ^ valueFrom = m_Value1Active ? m_Value1 : m_Value2;
|
||||
String ^ valueTo = m_Value1Active ? m_Value2 : m_Value1;
|
||||
String ^ valueFrom = that->m_Value1Active ? that->m_Value1 : that->m_Value2;
|
||||
String ^ valueTo = that->m_Value1Active ? that->m_Value2 : that->m_Value1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
String ^ SupplementaryResult::GetLocalizedAutomationName()
|
||||
{
|
||||
auto format = AppResourceProvider::GetInstance().GetResourceString("SupplementaryUnit_AutomationName");
|
||||
return ref new String(LocalizationStringUtil::GetLocalizedString(format->Data(), this->Value->Data(), this->Unit->Name->Data()).c_str());
|
||||
auto format = AppResourceProvider::GetInstance()->GetResourceString("SupplementaryUnit_AutomationName");
|
||||
return LocalizationStringUtil::GetLocalizedString(format, this->Value, this->Unit->Name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user