Updating comments per the C++ core guidelines and removing trailing whitespace (#194)
Fixed comments that were inconsistent with the style guidelines described in C++ core guidelines and the modern C++/WinRT language projections and removed trailing whitespace. Inserted a space after the beginning of the comment so the text wasn't touching the // on all occurrences. Removed all occurrences of trailing whitespace
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp { namespace Common
|
||||
namespace CalculatorApp { namespace Common
|
||||
{
|
||||
ref class AlwaysSelectedCollectionView sealed:
|
||||
ref class AlwaysSelectedCollectionView sealed:
|
||||
public Windows::UI::Xaml::DependencyObject,
|
||||
public Windows::UI::Xaml::Data::ICollectionView
|
||||
{
|
||||
@@ -14,11 +14,11 @@ namespace CalculatorApp { namespace Common
|
||||
m_currentPosition(-1)
|
||||
{
|
||||
m_source = source;
|
||||
|
||||
|
||||
Windows::UI::Xaml::Interop::IBindableObservableVector^ observable = dynamic_cast<Windows::UI::Xaml::Interop::IBindableObservableVector^>(source);
|
||||
if (observable)
|
||||
{
|
||||
observable->VectorChanged +=
|
||||
observable->VectorChanged +=
|
||||
ref new Windows::UI::Xaml::Interop::BindableVectorChangedEventHandler(this, &AlwaysSelectedCollectionView::OnSourceBindableVectorChanged);
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ namespace CalculatorApp { namespace Common
|
||||
return ref new Platform::Collections::Vector<Platform::Object^>();
|
||||
}
|
||||
}
|
||||
property bool HasMoreItems
|
||||
property bool HasMoreItems
|
||||
{
|
||||
virtual bool get() = Windows::UI::Xaml::Data::ICollectionView::HasMoreItems::get
|
||||
{
|
||||
@@ -77,7 +77,7 @@ namespace CalculatorApp { namespace Common
|
||||
}
|
||||
|
||||
// The item is not in the collection
|
||||
// We're going to schedule a call back later so we
|
||||
// We're going to schedule a call back later so we
|
||||
// restore the selection to the way we wanted it to begin with
|
||||
if (m_currentPosition >= 0 && m_currentPosition < static_cast<int>(m_source->Size))
|
||||
{
|
||||
@@ -161,7 +161,7 @@ namespace CalculatorApp { namespace Common
|
||||
m_currentChanging -= token;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// IVector<Object^>
|
||||
// Not implemented methods
|
||||
virtual void Append(Platform::Object^ /*item*/) = Windows::Foundation::Collections::IVector<Platform::Object^>::Append
|
||||
@@ -219,7 +219,7 @@ namespace CalculatorApp { namespace Common
|
||||
return m_source->Size;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// IObservableVector<Object^>
|
||||
event Windows::Foundation::Collections::VectorChangedEventHandler<Platform::Object^>^ VectorChanged
|
||||
{
|
||||
@@ -262,9 +262,9 @@ namespace CalculatorApp { namespace Common
|
||||
|
||||
private:
|
||||
virtual Platform::Object^ Convert(
|
||||
Platform::Object^ value,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
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);
|
||||
@@ -276,9 +276,9 @@ namespace CalculatorApp { namespace Common
|
||||
}
|
||||
|
||||
virtual Platform::Object^ ConvertBack(
|
||||
Platform::Object^ /*value*/,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
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;
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace CalculatorApp::Common::Automation
|
||||
static NarratorAnnouncement^ GetCategoryNameChangedAnnouncement(Platform::String^ announcement);
|
||||
|
||||
static NarratorAnnouncement^ GetUpdateCurrencyRatesAnnouncement(Platform::String^ announcement);
|
||||
|
||||
|
||||
static NarratorAnnouncement^ GetDisplayCopiedAnnouncement(Platform::String^ announcement);
|
||||
|
||||
static NarratorAnnouncement^ GetOpenParenthesisCountChangedAnnouncement(Platform::String^ announcement);
|
||||
|
||||
@@ -18,17 +18,17 @@ void BindableBase::OnPropertyChanged(String^ propertyName)
|
||||
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Data::ICustomProperty^ BindableBase::GetCustomProperty(Platform::String^ name)
|
||||
Windows::UI::Xaml::Data::ICustomProperty^ BindableBase::GetCustomProperty(Platform::String^ name)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Data::ICustomProperty^ BindableBase::GetIndexedProperty(Platform::String^ name, Windows::UI::Xaml::Interop::TypeName type)
|
||||
Windows::UI::Xaml::Data::ICustomProperty^ BindableBase::GetIndexedProperty(Platform::String^ name, Windows::UI::Xaml::Interop::TypeName type)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Platform::String^ BindableBase::GetStringRepresentation()
|
||||
Platform::String^ BindableBase::GetStringRepresentation()
|
||||
{
|
||||
return this->ToString();
|
||||
return this->ToString();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace CalculatorApp
|
||||
D = (int) CM::Command::CommandD,
|
||||
E = (int) CM::Command::CommandE,
|
||||
F = (int) CM::Command::CommandF,
|
||||
Memory, // This is the memory button. Doesn't have a direct mapping to the CalcEngine.
|
||||
Memory, // This is the memory button. Doesn't have a direct mapping to the CalcEngine.
|
||||
Sinh = (int) CM::Command::CommandSINH,
|
||||
Cosh = (int) CM::Command::CommandCOSH,
|
||||
Tanh = (int) CM::Command::CommandTANH,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// This class provides the concrete implementation for the ICalcDisplay interface
|
||||
// that is declared in the Calculation Manager Library.
|
||||
// that is declared in the Calculation Manager Library.
|
||||
#include "pch.h"
|
||||
#include "CalculatorDisplay.h"
|
||||
#include "StandardCalculatorViewModel.h"
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace CalculatorApp
|
||||
public:
|
||||
ConversionResultTaskHelper(unsigned int delay, const std::function<void()> functionToRun);
|
||||
~ConversionResultTaskHelper();
|
||||
|
||||
|
||||
private:
|
||||
concurrency::task<void> CompleteAfter(unsigned int timeout);
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ String^ CopyPasteManager::ValidatePasteExpression(String^ pastedText, ViewMode m
|
||||
|
||||
wstring pasteExpression = pastedText->Data();
|
||||
|
||||
// Get english translated expression
|
||||
// Get english translated expression
|
||||
String^ englishString = LocalizationSettings::GetInstance().GetEnglishValueFromLocalizedDigits(pasteExpression);
|
||||
|
||||
// Removing the spaces, comma separator from the pasteExpression to allow pasting of expressions like 1 + 2+1,333
|
||||
|
||||
@@ -15,7 +15,7 @@ DateCalculationEngine::DateCalculationEngine(_In_ String^ calendarIdentifier)
|
||||
m_calendar->ChangeCalendarSystem(calendarIdentifier);
|
||||
}
|
||||
|
||||
// Adding Duration to a Date
|
||||
// Adding Duration to a Date
|
||||
// Returns: True if function succeeds to calculate the date else returns False
|
||||
bool DateCalculationEngine::AddDuration(_In_ DateTime startDate, _In_ const DateDifference& duration, _Out_ DateTime *endDate)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ bool DateCalculationEngine::AddDuration(_In_ DateTime startDate, _In_ const Date
|
||||
bool DateCalculationEngine::SubtractDuration(_In_ DateTime startDate, _In_ const DateDifference& duration, _Out_ DateTime *endDate)
|
||||
{
|
||||
// For Subtract the Algorithm is different than Add. Here the smaller units are subtracted first
|
||||
// and then the larger units.
|
||||
// and then the larger units.
|
||||
try
|
||||
{
|
||||
m_calendar->SetDateTime(startDate);
|
||||
|
||||
@@ -21,10 +21,10 @@ namespace CalculatorApp
|
||||
|
||||
private:
|
||||
|
||||
// Explicit, and private, implementation of ICommand, this way of programming makes it so
|
||||
// Explicit, and private, implementation of ICommand, this way of programming makes it so
|
||||
// the ICommand methods will only be available if the ICommand interface is requested via a dynamic_cast
|
||||
// The ICommand interface is meant to be consumed by Xaml and not by the app, this is a defensive measure against
|
||||
// code in the app calling Execute.
|
||||
// code in the app calling Execute.
|
||||
virtual void ExecuteImpl(Platform::Object^ parameter) sealed = Windows::UI::Xaml::Input::ICommand::Execute
|
||||
{
|
||||
TTarget^ target = m_weakTarget.Resolve<TTarget>();
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace CalculatorApp
|
||||
{
|
||||
// Lights up all of the buttons in the given range
|
||||
// The range is defined by a pair of iterators
|
||||
template <typename T>
|
||||
template <typename T>
|
||||
void LightUpButtons(const T& buttons)
|
||||
{
|
||||
auto iterator = buttons.first;
|
||||
@@ -72,14 +72,14 @@ namespace CalculatorApp
|
||||
|
||||
void LightUpButton(ButtonBase^ button)
|
||||
{
|
||||
// If the button is a toggle button then we don't need
|
||||
// If the button is a toggle button then we don't need
|
||||
// to change the UI of the button
|
||||
if (dynamic_cast<ToggleButton^>(button))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// The button will go into the visual Pressed state with this call
|
||||
// The button will go into the visual Pressed state with this call
|
||||
VisualStateManager::GoToState(button, "Pressed", true);
|
||||
|
||||
// This timer will fire after lightUpTime and make the button
|
||||
@@ -89,7 +89,7 @@ namespace CalculatorApp
|
||||
TimeSpan lightUpTime{};
|
||||
lightUpTime.Duration = 500000L; // Half second (in 100-ns units)
|
||||
timer->Interval = lightUpTime;
|
||||
|
||||
|
||||
WeakReference timerWeakReference(timer);
|
||||
WeakReference buttonWeakReference(button);
|
||||
timer->Tick += ref new EventHandler<Object^>(
|
||||
@@ -206,7 +206,7 @@ void KeyboardShortcutManager::HonorEscape()
|
||||
}
|
||||
|
||||
void KeyboardShortcutManager::OnCharacterPropertyChanged(
|
||||
DependencyObject^ target,
|
||||
DependencyObject^ target,
|
||||
String^ oldValue,
|
||||
String^ newValue)
|
||||
{
|
||||
@@ -263,10 +263,10 @@ void KeyboardShortcutManager::OnVirtualKeyPropertyChanged(
|
||||
reader_writer_lock::scoped_lock lock(s_keyboardShortcutMapLock);
|
||||
|
||||
auto button = static_cast<ButtonBase^>(target);
|
||||
|
||||
|
||||
int viewId = Utils::GetWindowId();
|
||||
auto iterViewMap = s_VirtualKeysForButtons.find(viewId);
|
||||
|
||||
|
||||
// Check if the View Id has already been registered
|
||||
if (iterViewMap != s_VirtualKeysForButtons.end())
|
||||
{
|
||||
@@ -281,7 +281,7 @@ void KeyboardShortcutManager::OnVirtualKeyPropertyChanged(
|
||||
}
|
||||
|
||||
void KeyboardShortcutManager::OnVirtualKeyControlChordPropertyChanged(
|
||||
DependencyObject^ target,
|
||||
DependencyObject^ target,
|
||||
MyVirtualKey /*oldValue*/,
|
||||
MyVirtualKey newValue)
|
||||
{
|
||||
@@ -537,7 +537,7 @@ void KeyboardShortcutManager::OnKeyDownHandler(CoreWindow^ sender, KeyEventArgs^
|
||||
|
||||
// Handle Ctrl + E for DateCalculator
|
||||
if ((key == VirtualKey::E) &&
|
||||
isControlKeyPressed &&
|
||||
isControlKeyPressed &&
|
||||
!isShiftKeyPressed)
|
||||
{
|
||||
const auto& lookupMap = GetCurrentKeyDictionary(static_cast<MyVirtualKey>(key));
|
||||
@@ -710,7 +710,7 @@ void KeyboardShortcutManager::OnAcceleratorKeyActivated(CoreDispatcher^, Acceler
|
||||
{
|
||||
int viewId = Utils::GetWindowId();
|
||||
auto iterViewMap = s_AboutFlyout.find(viewId);
|
||||
|
||||
|
||||
if ((iterViewMap != s_AboutFlyout.end()) && (iterViewMap->second != nullptr))
|
||||
{
|
||||
iterViewMap->second->Hide();
|
||||
@@ -721,9 +721,9 @@ void KeyboardShortcutManager::OnAcceleratorKeyActivated(CoreDispatcher^, Acceler
|
||||
void KeyboardShortcutManager::Initialize()
|
||||
{
|
||||
auto coreWindow = Window::Current->CoreWindow;
|
||||
coreWindow->CharacterReceived +=
|
||||
coreWindow->CharacterReceived +=
|
||||
ref new TypedEventHandler<CoreWindow^, CharacterReceivedEventArgs^>(&KeyboardShortcutManager::OnCharacterReceivedHandler);
|
||||
coreWindow->KeyDown +=
|
||||
coreWindow->KeyDown +=
|
||||
ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(&KeyboardShortcutManager::OnKeyDownHandler);
|
||||
coreWindow->KeyUp +=
|
||||
ref new TypedEventHandler<CoreWindow^, KeyEventArgs^>(&KeyboardShortcutManager::OnKeyUpHandler);
|
||||
@@ -758,7 +758,7 @@ void KeyboardShortcutManager::UpdateDropDownState(bool isOpen)
|
||||
void KeyboardShortcutManager::UpdateDropDownState(Flyout^ aboutPageFlyout)
|
||||
{
|
||||
int viewId = Utils::GetWindowId();
|
||||
|
||||
|
||||
if (s_AboutFlyout.find(viewId) != s_AboutFlyout.end())
|
||||
{
|
||||
s_AboutFlyout.erase(viewId);
|
||||
@@ -803,7 +803,7 @@ void KeyboardShortcutManager::RegisterNewAppViewId()
|
||||
{
|
||||
s_CharacterForButtons.insert(std::make_pair(appViewId, std::multimap<wchar_t, WeakReference>()));
|
||||
}
|
||||
|
||||
|
||||
if (s_VirtualKeysForButtons.find(appViewId) == s_VirtualKeysForButtons.end())
|
||||
{
|
||||
s_VirtualKeysForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
||||
@@ -823,17 +823,17 @@ void KeyboardShortcutManager::RegisterNewAppViewId()
|
||||
{
|
||||
s_VirtualKeyAltChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
||||
}
|
||||
|
||||
|
||||
if (s_VirtualKeyControlShiftChordsForButtons.find(appViewId) == s_VirtualKeyControlShiftChordsForButtons.end())
|
||||
{
|
||||
s_VirtualKeyControlShiftChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
||||
}
|
||||
|
||||
|
||||
if (s_VirtualKeyInverseChordsForButtons.find(appViewId) == s_VirtualKeyInverseChordsForButtons.end())
|
||||
{
|
||||
s_VirtualKeyInverseChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
||||
}
|
||||
|
||||
|
||||
if (s_VirtualKeyControlInverseChordsForButtons.find(appViewId) == s_VirtualKeyControlInverseChordsForButtons.end())
|
||||
{
|
||||
s_VirtualKeyControlInverseChordsForButtons.insert(std::make_pair(appViewId, std::multimap<MyVirtualKey, WeakReference>()));
|
||||
|
||||
@@ -206,7 +206,7 @@ FontWeight LocalizationService::GetFontWeightOverride()
|
||||
double LocalizationService::GetFontScaleFactorOverride(LanguageFontType fontType)
|
||||
{
|
||||
assert(m_overrideFontApiValues);
|
||||
|
||||
|
||||
switch (fontType)
|
||||
{
|
||||
case LanguageFontType::UIText:
|
||||
@@ -271,12 +271,12 @@ void LocalizationService::UpdateFontFamilyAndSize(DependencyObject^ target)
|
||||
{
|
||||
control->FontSize = sizeToUse;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
control->ClearValue(Control::FontSizeProperty);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
auto textBlock = dynamic_cast<TextBlock^>(target);
|
||||
if (textBlock)
|
||||
@@ -290,7 +290,7 @@ void LocalizationService::UpdateFontFamilyAndSize(DependencyObject^ target)
|
||||
{
|
||||
textBlock->FontSize = sizeToUse;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
textBlock->ClearValue(TextBlock::FontSizeProperty);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ void LocalizationService::UpdateFontFamilyAndSize(DependencyObject^ target)
|
||||
{
|
||||
richTextBlock->FontSize = sizeToUse;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
richTextBlock->ClearValue(RichTextBlock::FontSizeProperty);
|
||||
}
|
||||
@@ -328,7 +328,7 @@ void LocalizationService::UpdateFontFamilyAndSize(DependencyObject^ target)
|
||||
{
|
||||
textElement->FontSize = sizeToUse;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
textElement->ClearValue(TextElement::FontSizeProperty);
|
||||
}
|
||||
@@ -416,7 +416,7 @@ IIterable<String^>^ LocalizationService::GetLanguageIdentifiers()
|
||||
int result = GetUserDefaultLocaleName(currentLocale, LOCALE_NAME_MAX_LENGTH);
|
||||
if (result != 0)
|
||||
{
|
||||
// GetUserDefaultLocaleName may return an invalid bcp47 language tag with trailing non-BCP47 friendly characters,
|
||||
// GetUserDefaultLocaleName may return an invalid bcp47 language tag with trailing non-BCP47 friendly characters,
|
||||
// which if present would start with an underscore, for example sort order
|
||||
// (see https://msdn.microsoft.com/en-us/library/windows/desktop/dd373814(v=vs.85).aspx).
|
||||
// Therefore, if there is an underscore in the locale name, trim all characters from the underscore onwards.
|
||||
|
||||
@@ -20,11 +20,11 @@ namespace CalculatorApp
|
||||
va_list args = NULL;
|
||||
va_start(args, pMessage);
|
||||
DWORD fmtReturnVal = FormatMessage(FORMAT_MESSAGE_FROM_STRING,
|
||||
pMessage,
|
||||
pMessage,
|
||||
0,
|
||||
0,
|
||||
spBuffer.get(),
|
||||
length,
|
||||
spBuffer.get(),
|
||||
length,
|
||||
&args);
|
||||
va_end(args);
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace CalculatorApp
|
||||
|
||||
property Platform::String^ AccessKey
|
||||
{
|
||||
Platform::String^ get()
|
||||
Platform::String^ get()
|
||||
{
|
||||
return m_accessKey;
|
||||
}
|
||||
@@ -220,11 +220,11 @@ namespace CalculatorApp
|
||||
static Windows::Foundation::Collections::IObservableVector<NavCategoryGroup^>^ CreateMenuOptions();
|
||||
|
||||
static Platform::String^ GetHeaderResourceKey(CategoryGroupType type);
|
||||
|
||||
|
||||
internal:
|
||||
static NavCategoryGroup^ CreateCalculatorCategory();
|
||||
static NavCategoryGroup^ CreateConverterCategory();
|
||||
|
||||
|
||||
private:
|
||||
NavCategoryGroup(const NavCategoryGroupInitializer& groupInitializer);
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace CalculatorApp
|
||||
g_calculatorProvider(
|
||||
L"MicrosoftCalculator",
|
||||
LoggingChannelOptions(GUID{ 0x4f50731a, 0x89cf, 0x4782, 0xb3, 0xe0, 0xdc, 0xe8, 0xc9, 0x4, 0x76, 0xba }), // Microsoft Telemetry group
|
||||
GUID{ 0x905ca09, 0x610e, 0x401e, 0xb6, 0x50, 0x2f, 0x21, 0x29, 0x80, 0xb9, 0xe0 }), //Unique providerID {0905CA09-610E-401E-B650-2F212980B9E0}
|
||||
GUID{ 0x905ca09, 0x610e, 0x401e, 0xb6, 0x50, 0x2f, 0x21, 0x29, 0x80, 0xb9, 0xe0 }), // Unique providerID {0905CA09-610E-401E-B650-2F212980B9E0}
|
||||
m_appLaunchActivity{ nullptr }
|
||||
{
|
||||
// initialize the function array
|
||||
@@ -248,7 +248,7 @@ namespace CalculatorApp
|
||||
{
|
||||
windowIdLog.insert(pair<int, bool>(windowId, false));
|
||||
}
|
||||
// if the event is not logged already for the present mode
|
||||
// if the event is not logged already for the present mode
|
||||
if (currentMode != mode)
|
||||
{
|
||||
currentMode = mode;
|
||||
@@ -271,7 +271,7 @@ namespace CalculatorApp
|
||||
{
|
||||
windowIdLog.insert(pair<int, bool>(windowId, false));
|
||||
}
|
||||
// if the event is not logged already for the present mode
|
||||
// if the event is not logged already for the present mode
|
||||
if (currentMode != mode)
|
||||
{
|
||||
currentMode = mode;
|
||||
@@ -293,7 +293,7 @@ namespace CalculatorApp
|
||||
{
|
||||
windowIdLog.insert(pair<int, bool>(windowId, false));
|
||||
}
|
||||
// if the event is not logged already for the present mode
|
||||
// if the event is not logged already for the present mode
|
||||
if (currentMode != mode)
|
||||
{
|
||||
currentMode = mode;
|
||||
@@ -482,9 +482,9 @@ namespace CalculatorApp
|
||||
LogTelemetryEvent(EVENT_NAME_MEMORY_BODY_OPENED, fields);
|
||||
}
|
||||
|
||||
//If calculator is launched in any mode other than standard then this call will come which is not intended. But there is no way to avoid it.
|
||||
//So don't use this function to analyze the count of mode change in session instead use CalculatorViewedInSession and ConverterViewedInSession to do that.
|
||||
//Use of this function is to analyze perf of mode change.
|
||||
// If calculator is launched in any mode other than standard then this call will come which is not intended. But there is no way to avoid it.
|
||||
// So don't use this function to analyze the count of mode change in session instead use CalculatorViewedInSession and ConverterViewedInSession to do that.
|
||||
// Use of this function is to analyze perf of mode change.
|
||||
void TraceLogger::LogModeChangeBegin(ViewMode fromMode, ViewMode toMode, int windowId)
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
@@ -499,7 +499,7 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
//comment: same as LogModeChangeBegin
|
||||
// comment: same as LogModeChangeBegin
|
||||
void TraceLogger::LogModeChangeEnd(ViewMode toMode, int windowId) const
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
@@ -578,7 +578,7 @@ namespace CalculatorApp
|
||||
// Writer lock for the static resources
|
||||
reader_writer_lock::scoped_lock lock(s_traceLoggerLock);
|
||||
auto iterMap = s_memoryMap.find(windowId);
|
||||
|
||||
|
||||
LoggingFields fields{};
|
||||
LogTelemetryEvent(EVENT_NAME_MEMORY_CLEAR_ALL, fields);
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
static const int maxFunctionSize = (int)CalculationManager::Command::CommandBINEDITEND;
|
||||
|
||||
// A trace logging provider can only be instantiated and registered once per module.
|
||||
// This class implements a singleton model ensure that only one instance is created.
|
||||
// A trace logging provider can only be instantiated and registered once per module.
|
||||
// This class implements a singleton model ensure that only one instance is created.
|
||||
namespace CalculatorApp
|
||||
{
|
||||
struct FuncLog
|
||||
@@ -105,7 +105,7 @@ namespace CalculatorApp
|
||||
|
||||
// Any new Log method should
|
||||
// a) decide the level of logging. This will help us in limiting recording of events only up to a certain level. See this link for guidance https://msdn.microsoft.com/en-us/library/windows/desktop/aa363742(v=vs.85).aspx
|
||||
// We're using Verbose level for events that are called frequently and needed only for debugging or capturing perf for specific scenarios
|
||||
// We're using Verbose level for events that are called frequently and needed only for debugging or capturing perf for specific scenarios
|
||||
// b) should decide whether or not to log to telemetry and pass TraceLoggingKeyword(MICROSOFT_KEYWORD_TELEMETRY) accordingly
|
||||
// c) Should accept a variable number of additional data arguments if needed
|
||||
void LogTelemetryEvent(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const;
|
||||
|
||||
@@ -54,7 +54,7 @@ double Utils::GetDoubleFromWstring(wstring input)
|
||||
return ::atof(inputString.c_str());
|
||||
}
|
||||
|
||||
//returns windowId for the current view
|
||||
// Returns windowId for the current view
|
||||
int Utils::GetWindowId()
|
||||
{
|
||||
int windowId = -1;
|
||||
@@ -80,20 +80,20 @@ void Utils::RunOnUIThreadNonblocking(std::function<void()>&& function, _In_ Core
|
||||
}
|
||||
}
|
||||
|
||||
// returns if the last character of a wstring is the target wchar_t
|
||||
// Returns if the last character of a wstring is the target wchar_t
|
||||
bool Utils::IsLastCharacterTarget(_In_ wstring const &input, _In_ wchar_t target)
|
||||
{
|
||||
return !input.empty() && input.back() == target;
|
||||
}
|
||||
|
||||
//return wstring after removing characters like space, comma, and double quotes
|
||||
// Returns wstring after removing characters like space, comma, and double quotes
|
||||
wstring Utils::RemoveUnwantedCharsFromWstring(wstring input)
|
||||
{
|
||||
wchar_t unWantedChars[] = { L' ', L',', L'"', 8234, 8235, 8236, 8237 };
|
||||
return RemoveUnwantedCharsFromWstring(input, unWantedChars, 6);
|
||||
}
|
||||
|
||||
//return wstring after removing characters specified by unwantedChars array
|
||||
// Returns wstring after removing characters specified by unwantedChars array
|
||||
wstring Utils::RemoveUnwantedCharsFromWstring(wstring input, wchar_t* unwantedChars, unsigned int size)
|
||||
{
|
||||
for (unsigned int i = 0; i < size; ++i)
|
||||
@@ -110,7 +110,7 @@ void Utils::SerializeCommandsAndTokens(_In_ shared_ptr<CalculatorVector <pair<ws
|
||||
unsigned int commandsSize;
|
||||
IFTPlatformException(commands->GetSize(&commandsSize));
|
||||
|
||||
// save the size of the commands vector
|
||||
// Save the size of the commands vector
|
||||
writer->WriteUInt32(commandsSize);
|
||||
|
||||
SerializeCommandVisitor cmdVisitor(writer);
|
||||
|
||||
@@ -54,11 +54,11 @@
|
||||
#ifndef UNIT_TESTS
|
||||
#define OBSERVABLE_OBJECT() virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged;\
|
||||
internal: void RaisePropertyChanged(Platform::String^ p) {\
|
||||
PropertyChanged(this, ref new Windows::UI::Xaml::Data::PropertyChangedEventArgs(p)); } public:
|
||||
PropertyChanged(this, ref new Windows::UI::Xaml::Data::PropertyChangedEventArgs(p)); } public:
|
||||
#else
|
||||
#define OBSERVABLE_OBJECT() virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged;\
|
||||
internal: void RaisePropertyChanged(Platform::String^ p) {\
|
||||
} public:
|
||||
} public:
|
||||
#endif
|
||||
|
||||
// The callback specified in the macro is a method in the class that will be called every time the object changes
|
||||
@@ -68,21 +68,21 @@
|
||||
internal: void RaisePropertyChanged(Platform::String^ p) {\
|
||||
PropertyChanged(this, ref new Windows::UI::Xaml::Data::PropertyChangedEventArgs(p));\
|
||||
c(p);\
|
||||
} public:
|
||||
} public:
|
||||
#else
|
||||
#define OBSERVABLE_OBJECT_CALLBACK(c) virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler^ PropertyChanged;\
|
||||
internal: void RaisePropertyChanged(Platform::String^ p) {\
|
||||
c(p);\
|
||||
} public:
|
||||
} public:
|
||||
#endif
|
||||
|
||||
// The variable member generated by this macro should not be used in the class code, use the
|
||||
// property getter instead.
|
||||
// The variable member generated by this macro should not be used in the class code, use the
|
||||
// property getter instead.
|
||||
#define COMMAND_FOR_METHOD(p, m) property Windows::UI::Xaml::Input::ICommand^ p {\
|
||||
Windows::UI::Xaml::Input::ICommand^ get() {\
|
||||
if (!donotuse_##p) {\
|
||||
donotuse_##p = CalculatorApp::Common::MakeDelegate(this, &m);\
|
||||
} return donotuse_##p; }} private: Windows::UI::Xaml::Input::ICommand^ donotuse_##p; public:
|
||||
} return donotuse_##p; }} private: Windows::UI::Xaml::Input::ICommand^ donotuse_##p; public:
|
||||
|
||||
#define DEPENDENCY_PROPERTY_DECLARATION(t, n)\
|
||||
property t n {\
|
||||
@@ -141,7 +141,7 @@ namespace Utils
|
||||
const wchar_t PDF = 0x202c; // Pop Directional Formatting
|
||||
const wchar_t LRO = 0x202d; // Left-to-Right Override
|
||||
|
||||
// Regular DependencyProperty
|
||||
// Regular DependencyProperty
|
||||
template <typename TOwner, typename TType>
|
||||
Windows::UI::Xaml::DependencyProperty^ RegisterDependencyProperty(
|
||||
_In_ const wchar_t* const name,
|
||||
@@ -205,7 +205,7 @@ namespace Utils
|
||||
ref new Windows::UI::Xaml::PropertyChangedCallback(callback)));
|
||||
}
|
||||
|
||||
// Attached DependencyProperty
|
||||
// Attached DependencyProperty
|
||||
template <typename TOwner, typename TType>
|
||||
Windows::UI::Xaml::DependencyProperty^ RegisterDependencyPropertyAttached(
|
||||
_In_ const wchar_t* const name,
|
||||
|
||||
@@ -14,9 +14,9 @@ namespace CalculatorApp { namespace Common
|
||||
private:
|
||||
|
||||
virtual Platform::Object^ Convert(
|
||||
Platform::Object^ value,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
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
|
||||
@@ -24,9 +24,9 @@ namespace CalculatorApp { namespace Common
|
||||
}
|
||||
|
||||
virtual Platform::Object^ ConvertBack(
|
||||
Platform::Object^ value,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
Platform::Object^ value,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
Platform::String^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack
|
||||
{
|
||||
if (value)
|
||||
@@ -47,9 +47,9 @@ namespace CalculatorApp { namespace Common
|
||||
private:
|
||||
|
||||
virtual Platform::Object^ Convert(
|
||||
Platform::Object^ value,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
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
|
||||
@@ -57,9 +57,9 @@ namespace CalculatorApp { namespace Common
|
||||
}
|
||||
|
||||
virtual Platform::Object^ ConvertBack(
|
||||
Platform::Object^ value,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
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
|
||||
|
||||
@@ -203,7 +203,7 @@ void CurrencyDataLoader::LoadData()
|
||||
}
|
||||
}
|
||||
|
||||
co_return didLoad;
|
||||
co_return didLoad;
|
||||
}).then([this](bool didLoad)
|
||||
{
|
||||
UpdateDisplayedTimestamp();
|
||||
@@ -329,7 +329,7 @@ task<bool> CurrencyDataLoader::TryLoadDataFromCacheAsync()
|
||||
{
|
||||
loadComplete = co_await TryLoadDataFromWebAsync();
|
||||
}
|
||||
|
||||
|
||||
if (!loadComplete)
|
||||
{
|
||||
loadComplete = co_await TryFinishLoadFromCacheAsync();
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace CalculatorApp
|
||||
|
||||
bool TryParseWebResponses(
|
||||
_In_ Platform::String^ staticDataJson,
|
||||
_In_ Platform::String^ allRatiosJson,
|
||||
_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);
|
||||
|
||||
@@ -200,7 +200,7 @@ void UnitConverterDataLoader::GetUnits(_In_ unordered_map<ViewMode, vector<Order
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Exbibits, GetLocalizedStringName(L"UnitName_Exbibits"), GetLocalizedStringName(L"UnitAbbreviation_Exbibits"), 24 });
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Exbibytes, GetLocalizedStringName(L"UnitName_Exbibytes"), GetLocalizedStringName(L"UnitAbbreviation_Exbibytes"), 26 });
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gibibits, GetLocalizedStringName(L"UnitName_Gibibits"), GetLocalizedStringName(L"UnitAbbreviation_Gibibits"), 12 });
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gibibytes, GetLocalizedStringName(L"UnitName_Gibibytes"), GetLocalizedStringName(L"UnitAbbreviation_Gibibytes"), 14 });
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gibibytes, GetLocalizedStringName(L"UnitName_Gibibytes"), GetLocalizedStringName(L"UnitAbbreviation_Gibibytes"), 14 });
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gigabit, GetLocalizedStringName(L"UnitName_Gigabit"), GetLocalizedStringName(L"UnitAbbreviation_Gigabit"), 11 });
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Gigabyte, GetLocalizedStringName(L"UnitName_Gigabyte"), GetLocalizedStringName(L"UnitAbbreviation_Gigabyte"),13, true, false, false});
|
||||
dataUnits.push_back(OrderedUnit{ UnitConverterUnits::Data_Kibibits, GetLocalizedStringName(L"UnitName_Kibibits"), GetLocalizedStringName(L"UnitAbbreviation_Kibibits"), 4 });
|
||||
|
||||
@@ -180,8 +180,8 @@ void DateCalculatorViewModel::UpdateDisplayResult()
|
||||
StrDateDiffResultInDays = L"";
|
||||
StrDateDiffResult = AppResourceProvider::GetInstance().GetResourceString(L"Date_SameDates");
|
||||
}
|
||||
else if ((m_dateDiffResult.year == 0) &&
|
||||
(m_dateDiffResult.month == 0) &&
|
||||
else if ((m_dateDiffResult.year == 0) &&
|
||||
(m_dateDiffResult.month == 0) &&
|
||||
(m_dateDiffResult.week == 0))
|
||||
{
|
||||
IsDiffInDays = true;
|
||||
|
||||
@@ -17,18 +17,18 @@ namespace CalculatorApp
|
||||
internal:
|
||||
|
||||
HistoryItemViewModel(Platform::String^ expression,
|
||||
Platform::String^ result,
|
||||
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()
|
||||
{
|
||||
return m_spTokens;
|
||||
return m_spTokens;
|
||||
}
|
||||
|
||||
std::shared_ptr<CalculatorVector<std::shared_ptr<IExpressionCommand>>> const& GetCommands()
|
||||
{
|
||||
return m_spCommands;
|
||||
{
|
||||
return m_spCommands;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -64,7 +64,7 @@ void HistoryViewModel::ReloadHistory(_In_ ViewMode currentMode)
|
||||
if (historyListModel.size() > 0)
|
||||
{
|
||||
for (auto ritr = historyListModel.rbegin(); ritr != historyListModel.rend(); ++ritr)
|
||||
{
|
||||
{
|
||||
wstring expression = (*ritr)->historyItemVector.expression;
|
||||
wstring result = (*ritr)->historyItemVector.result;
|
||||
localizer.LocalizeDisplayValue(&expression);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace CalculatorApp::ViewModel
|
||||
StringReference BinaryDisplayValue(L"BinaryDisplayValue");
|
||||
StringReference OpenParenthesisCount(L"OpenParenthesisCount");
|
||||
}
|
||||
|
||||
|
||||
namespace CalculatorResourceKeys
|
||||
{
|
||||
StringReference CalculatorExpression(L"Format_CalculatorExpression");
|
||||
@@ -516,7 +516,7 @@ void StandardCalculatorViewModel::HandleUpdatedOperandData(Command cmdenum)
|
||||
|
||||
if (IsOperandTextCompletelySelected)
|
||||
{
|
||||
//Clear older text;
|
||||
// Clear older text;
|
||||
m_selectedExpressionLastData = L"";
|
||||
if (ch == L'x')
|
||||
{
|
||||
@@ -606,7 +606,7 @@ void StandardCalculatorViewModel::OnButtonPressed(Object^ parameter)
|
||||
if (IsInError)
|
||||
{
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandCLEAR);
|
||||
|
||||
|
||||
if (!IsRecoverableCommand((int)numOpEnum))
|
||||
{
|
||||
return;
|
||||
@@ -869,8 +869,8 @@ void StandardCalculatorViewModel::OnPaste(String^ pastedString, ViewMode mode)
|
||||
Command cmdenum = ConvertToOperatorsEnum(mappedNumOp);
|
||||
m_standardCalculatorManager.SendCommand(cmdenum);
|
||||
|
||||
// The CalcEngine state machine won't allow the negate command to be sent before any
|
||||
// other digits, so instead a flag is set and the command is sent after the first appropriate
|
||||
// The CalcEngine state machine won't allow the negate command to be sent before any
|
||||
// other digits, so instead a flag is set and the command is sent after the first appropriate
|
||||
// command.
|
||||
if (sendNegate)
|
||||
{
|
||||
@@ -1196,10 +1196,10 @@ Array<unsigned char>^ StandardCalculatorViewModel::Serialize()
|
||||
writer->WriteInt32(data);
|
||||
}
|
||||
|
||||
//For ProgrammerMode
|
||||
// For ProgrammerMode
|
||||
writer->WriteUInt32(static_cast<UINT32>(CurrentRadixType));
|
||||
|
||||
//Serialize commands of calculator manager
|
||||
// Serialize commands of calculator manager
|
||||
vector<unsigned char> serializedCommand = m_standardCalculatorManager.SerializeCommands();
|
||||
writer->WriteUInt32(static_cast<UINT32>(serializedCommand.size()));
|
||||
writer->WriteBytes(ref new Array<unsigned char>(serializedCommand.data(), static_cast<unsigned int>(serializedCommand.size())));
|
||||
@@ -1209,7 +1209,7 @@ Array<unsigned char>^ StandardCalculatorViewModel::Serialize()
|
||||
Utils::SerializeCommandsAndTokens(m_tokens, m_commands, writer);
|
||||
}
|
||||
|
||||
//Convert viewmodel data in writer to bytes
|
||||
// Convert viewmodel data in writer to bytes
|
||||
IBuffer^ buffer = writer->DetachBuffer();
|
||||
DataReader^ reader = DataReader::FromBuffer(buffer);
|
||||
Platform::Array<unsigned char>^ viewModelDataAsBytes = ref new Array<unsigned char>(buffer->Length);
|
||||
@@ -1257,7 +1257,7 @@ void StandardCalculatorViewModel::Deserialize(Array<unsigned char>^ state)
|
||||
m_standardCalculatorManager.DeSerializePrimaryDisplay(serializedPrimaryDisplay);
|
||||
|
||||
CurrentRadixType = reader->ReadUInt32();
|
||||
//Read command data and Deserialize
|
||||
// Read command data and Deserialize
|
||||
UINT32 modeldatalength = reader->ReadUInt32();
|
||||
Array<unsigned char>^ modelDataAsBytes = ref new Array<unsigned char>(modeldatalength);
|
||||
reader->ReadBytes(modelDataAsBytes);
|
||||
@@ -1604,7 +1604,7 @@ void StandardCalculatorViewModel::Recalculate(bool fromHistory)
|
||||
m_standardCalculatorManager.SendCommand(static_cast<CalculationManager::Command>(currentCommands[i]));
|
||||
}
|
||||
|
||||
if (fromHistory) // This is for the cases where the expression is loaded from history
|
||||
if (fromHistory) // This is for the cases where the expression is loaded from history
|
||||
{
|
||||
// To maintain F-E state of the engine, as the last operand hasn't reached engine by now
|
||||
m_standardCalculatorManager.SendCommand(Command::CommandFE);
|
||||
@@ -1981,7 +1981,7 @@ void StandardCalculatorViewModel::UpdatecommandsInRecordingMode()
|
||||
}
|
||||
else
|
||||
{
|
||||
//reset all vars
|
||||
// Reset all vars
|
||||
isDecimal = false;
|
||||
isNegative = false;
|
||||
isExpMode = false;
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace CalculatorApp
|
||||
|
||||
NumbersAndOperatorsEnum MapCharacterToButtonId(const wchar_t ch, bool& canSendNegate);
|
||||
|
||||
//Memory feature related methods. They are internal because they need to called from the MainPage code-behind
|
||||
// Memory feature related methods. They are internal because they need to called from the MainPage code-behind
|
||||
void OnMemoryButtonPressed();
|
||||
void OnMemoryItemPressed(Platform::Object^ memoryItemPosition);
|
||||
void OnMemoryAdd(Platform::Object^ memoryItemPosition);
|
||||
|
||||
@@ -142,7 +142,7 @@ UnitConverterViewModel::UnitConverterViewModel(const shared_ptr<UCM::IUnitConver
|
||||
m_currencyFormatter->Mode = CurrencyFormatterMode::UseCurrencyCode;
|
||||
m_currencyFormatter->ApplyRoundingForCurrency(RoundingAlgorithm::RoundHalfDown);
|
||||
m_currencyMaxFractionDigits = m_currencyFormatter->FractionDigits;
|
||||
|
||||
|
||||
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||
m_localizedValueFromFormat = resourceLoader.GetResourceString(UnitConverterResourceKeys::ValueFromFormat);
|
||||
m_localizedValueToFormat = resourceLoader.GetResourceString(UnitConverterResourceKeys::ValueToFormat);
|
||||
@@ -257,7 +257,7 @@ void UnitConverterViewModel::OnUnitChanged(Object^ parameter)
|
||||
|
||||
void UnitConverterViewModel::OnSwitchActive(Platform::Object^ unused)
|
||||
{
|
||||
// this can be false if this switch occurs without the user having explicitly updated any strings
|
||||
// this can be false if this switch occurs without the user having explicitly updated any strings
|
||||
// (for example, during deserialization). We only want to try this cleanup if there's actually
|
||||
// something to clean up.
|
||||
if (m_relocalizeStringOnSwitch)
|
||||
@@ -279,7 +279,7 @@ void UnitConverterViewModel::OnSwitchActive(Platform::Object^ unused)
|
||||
|
||||
m_valueFromUnlocalized.swap(m_valueToUnlocalized);
|
||||
Utils::Swap(&m_localizedValueFromFormat, &m_localizedValueToFormat);
|
||||
|
||||
|
||||
Utils::Swap(&m_Unit1AutomationName, &m_Unit2AutomationName);
|
||||
RaisePropertyChanged(UnitConverterViewModelProperties::Unit1AutomationName);
|
||||
RaisePropertyChanged(UnitConverterViewModelProperties::Unit2AutomationName);
|
||||
@@ -324,7 +324,7 @@ String^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& str
|
||||
if (allowPartialStrings)
|
||||
{
|
||||
// allow "in progress" strings, like "3." that occur during the composition of
|
||||
// a final number. Without this, when typing the three characters in "3.2"
|
||||
// a final number. Without this, when typing the three characters in "3.2"
|
||||
// you don't see the decimal point when typing it, you only see it once you've finally
|
||||
// typed a post-decimal digit.
|
||||
|
||||
@@ -341,7 +341,7 @@ String^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& str
|
||||
{
|
||||
wstring currencyResult = m_currencyFormatter->Format(stod(stringToLocalize))->Data();
|
||||
wstring currencyCode = m_currencyFormatter->Currency->Data();
|
||||
|
||||
|
||||
// CurrencyFormatter always includes LangCode or Symbol. Make it include LangCode
|
||||
// because this includes a non-breaking space. Remove the LangCode.
|
||||
auto pos = currencyResult.find(currencyCode);
|
||||
@@ -367,7 +367,7 @@ String^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& str
|
||||
if (hasDecimal)
|
||||
{
|
||||
// Since the output from GetLocaleInfoEx() and DecimalFormatter are differing for decimal string
|
||||
// we are adding the below work-around of editing the string returned by DecimalFormatter
|
||||
// we are adding the below work-around of editing the string returned by DecimalFormatter
|
||||
// and replacing the decimal separator with the one returned by GetLocaleInfoEx()
|
||||
String^ formattedSampleString = m_decimalFormatter->Format(stod("1.1"));
|
||||
wstring formattedSampleWString = wstring(formattedSampleString->Data());
|
||||
@@ -378,7 +378,7 @@ String^ UnitConverterViewModel::ConvertToLocalizedString(const std::wstring& str
|
||||
{
|
||||
resultWithDecimal.replace(pos, 1, &m_decimalSeparator);
|
||||
}
|
||||
|
||||
|
||||
// Copy back the edited string to the result
|
||||
result = ref new String(resultWithDecimal.c_str());
|
||||
}
|
||||
@@ -479,7 +479,7 @@ void UnitConverterViewModel::OnButtonPressed(Platform::Object^ parameter)
|
||||
NumbersAndOperatorsEnum numOpEnum = CalculatorButtonPressedEventArgs::GetOperationFromCommandParameter(parameter);
|
||||
UCM::Command command = CommandFromButtonId(numOpEnum);
|
||||
|
||||
//Don't clear the display if combo box is open and escape is pressed
|
||||
// Don't clear the display if combo box is open and escape is pressed
|
||||
if (command == UCM::Command::Clear && IsDropDownOpen)
|
||||
{
|
||||
return;
|
||||
@@ -674,7 +674,7 @@ void UnitConverterViewModel::Deserialize(Platform::String^ state)
|
||||
RaisePropertyChanged(nullptr); // Update since all props have been updated.
|
||||
}
|
||||
|
||||
//Saving User Preferences of Category and Associated-Units across Sessions.
|
||||
// Saving User Preferences of Category and Associated-Units across Sessions.
|
||||
void UnitConverterViewModel::SaveUserPreferences()
|
||||
{
|
||||
if (UnitsAreValid())
|
||||
@@ -695,7 +695,7 @@ void UnitConverterViewModel::SaveUserPreferences()
|
||||
}
|
||||
}
|
||||
|
||||
//Restoring User Preferences of Category and Associated-Units.
|
||||
// Restoring User Preferences of Category and Associated-Units.
|
||||
void UnitConverterViewModel::RestoreUserPreferences()
|
||||
{
|
||||
if (!IsCurrencyCurrentCategory)
|
||||
@@ -973,7 +973,7 @@ void UnitConverterViewModel::OnPaste(String^ stringToPaste, ViewMode mode)
|
||||
{
|
||||
if (isFirstLegalChar)
|
||||
{
|
||||
// Send Clear before sending something that will actually apply
|
||||
// Send Clear before sending something that will actually apply
|
||||
// to the field.
|
||||
m_model->SendCommand(UCM::Command::Clear);
|
||||
isFirstLegalChar = false;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace CalculatorApp
|
||||
public ref class Category sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
internal:
|
||||
Category(const UnitConversionManager::Category& category) :
|
||||
Category(const UnitConversionManager::Category& category) :
|
||||
m_original(category)
|
||||
{ }
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace CalculatorApp
|
||||
public ref class Unit sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
internal:
|
||||
Unit(const UnitConversionManager::Unit& unit) :
|
||||
Unit(const UnitConversionManager::Unit& unit) :
|
||||
m_original(unit)
|
||||
{ }
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace CalculatorApp
|
||||
internal:
|
||||
UnitConverterViewModel(const std::shared_ptr<UnitConversionManager::IUnitConverter>& model);
|
||||
|
||||
public:
|
||||
public:
|
||||
OBSERVABLE_OBJECT_CALLBACK(OnPropertyChanged);
|
||||
|
||||
OBSERVABLE_PROPERTY_R(Windows::Foundation::Collections::IObservableVector<Category^>^, Categories);
|
||||
@@ -224,7 +224,7 @@ namespace CalculatorApp
|
||||
COMMAND_FOR_METHOD(PasteCommand, UnitConverterViewModel::OnPasteCommand);
|
||||
|
||||
void AnnounceConversionResult();
|
||||
|
||||
|
||||
internal:
|
||||
void ResetView();
|
||||
void PopulateData();
|
||||
@@ -242,8 +242,8 @@ namespace CalculatorApp
|
||||
void UpdateValue2AutomationName();
|
||||
Platform::String^ Serialize();
|
||||
void Deserialize(Platform::String^ state);
|
||||
|
||||
//Saving And Restoring User Preferences of Category and Associated-Units across Sessions.
|
||||
|
||||
// Saving And Restoring User Preferences of Category and Associated-Units across Sessions.
|
||||
void SaveUserPreferences();
|
||||
void RestoreUserPreferences();
|
||||
|
||||
@@ -360,9 +360,9 @@ namespace CalculatorApp
|
||||
UnitConverterVMCallback(UnitConverterViewModel^ viewModel) : m_viewModel(viewModel)
|
||||
{}
|
||||
|
||||
void DisplayCallback(const std::wstring& from, const std::wstring& to) override
|
||||
{
|
||||
m_viewModel->UpdateDisplay(from, to);
|
||||
void DisplayCallback(const std::wstring& from, const std::wstring& to) override
|
||||
{
|
||||
m_viewModel->UpdateDisplay(from, to);
|
||||
}
|
||||
|
||||
void SuggestedValueCallback(
|
||||
|
||||
Reference in New Issue
Block a user