mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-16 02:02:51 -07:00
CalcViewModel code cleaning (#754)
* move KeyboardShortcutManager, ValidationConverter and ViewState to Calculator * remove dead code listed in #753 * remove Microsoft.UI.Xaml nuget package from CalcViewModel
This commit is contained in:
parent
712bdb1b7c
commit
2d177e5160
31 changed files with 77 additions and 378 deletions
|
@ -313,16 +313,13 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="ApplicationViewModel.h" />
|
<ClInclude Include="ApplicationViewModel.h" />
|
||||||
<ClInclude Include="Common\AlwaysSelectedCollectionView.h" />
|
|
||||||
<ClInclude Include="Common\AppResourceProvider.h" />
|
<ClInclude Include="Common\AppResourceProvider.h" />
|
||||||
<ClInclude Include="Common\Automation\NarratorAnnouncement.h" />
|
<ClInclude Include="Common\Automation\NarratorAnnouncement.h" />
|
||||||
<ClInclude Include="Common\Automation\NarratorNotifier.h" />
|
<ClInclude Include="Common\Automation\NarratorNotifier.h" />
|
||||||
<ClInclude Include="Common\BindableBase.h" />
|
|
||||||
<ClInclude Include="Common\BitLength.h" />
|
<ClInclude Include="Common\BitLength.h" />
|
||||||
<ClInclude Include="Common\CalculatorButtonPressedEventArgs.h" />
|
<ClInclude Include="Common\CalculatorButtonPressedEventArgs.h" />
|
||||||
<ClInclude Include="Common\CalculatorButtonUser.h" />
|
<ClInclude Include="Common\CalculatorButtonUser.h" />
|
||||||
<ClInclude Include="Common\CalculatorDisplay.h" />
|
<ClInclude Include="Common\CalculatorDisplay.h" />
|
||||||
<ClInclude Include="Common\ConversionResultTaskHelper.h" />
|
|
||||||
<ClInclude Include="Common\CopyPasteManager.h" />
|
<ClInclude Include="Common\CopyPasteManager.h" />
|
||||||
<ClInclude Include="Common\DateCalculator.h" />
|
<ClInclude Include="Common\DateCalculator.h" />
|
||||||
<ClInclude Include="Common\DelegateCommand.h" />
|
<ClInclude Include="Common\DelegateCommand.h" />
|
||||||
|
@ -330,7 +327,6 @@
|
||||||
<ClInclude Include="Common\EngineResourceProvider.h" />
|
<ClInclude Include="Common\EngineResourceProvider.h" />
|
||||||
<ClInclude Include="Common\ExpressionCommandDeserializer.h" />
|
<ClInclude Include="Common\ExpressionCommandDeserializer.h" />
|
||||||
<ClInclude Include="Common\ExpressionCommandSerializer.h" />
|
<ClInclude Include="Common\ExpressionCommandSerializer.h" />
|
||||||
<ClInclude Include="Common\KeyboardShortcutManager.h" />
|
|
||||||
<ClInclude Include="Common\LocalizationService.h" />
|
<ClInclude Include="Common\LocalizationService.h" />
|
||||||
<ClInclude Include="Common\LocalizationSettings.h" />
|
<ClInclude Include="Common\LocalizationSettings.h" />
|
||||||
<ClInclude Include="Common\LocalizationStringUtil.h" />
|
<ClInclude Include="Common\LocalizationStringUtil.h" />
|
||||||
|
@ -341,7 +337,6 @@
|
||||||
<ClInclude Include="Common\TraceActivity.h" />
|
<ClInclude Include="Common\TraceActivity.h" />
|
||||||
<ClInclude Include="Common\TraceLogger.h" />
|
<ClInclude Include="Common\TraceLogger.h" />
|
||||||
<ClInclude Include="Common\Utils.h" />
|
<ClInclude Include="Common\Utils.h" />
|
||||||
<ClInclude Include="Common\ValidatingConverters.h" />
|
|
||||||
<ClInclude Include="DataLoaders\CurrencyDataLoader.h" />
|
<ClInclude Include="DataLoaders\CurrencyDataLoader.h" />
|
||||||
<ClInclude Include="DataLoaders\CurrencyHttpClient.h" />
|
<ClInclude Include="DataLoaders\CurrencyHttpClient.h" />
|
||||||
<ClInclude Include="DataLoaders\ICurrencyHttpClient.h" />
|
<ClInclude Include="DataLoaders\ICurrencyHttpClient.h" />
|
||||||
|
@ -361,16 +356,13 @@
|
||||||
<ClCompile Include="Common\AppResourceProvider.cpp" />
|
<ClCompile Include="Common\AppResourceProvider.cpp" />
|
||||||
<ClCompile Include="Common\Automation\NarratorAnnouncement.cpp" />
|
<ClCompile Include="Common\Automation\NarratorAnnouncement.cpp" />
|
||||||
<ClCompile Include="Common\Automation\NarratorNotifier.cpp" />
|
<ClCompile Include="Common\Automation\NarratorNotifier.cpp" />
|
||||||
<ClCompile Include="Common\BindableBase.cpp" />
|
|
||||||
<ClCompile Include="Common\CalculatorButtonPressedEventArgs.cpp" />
|
<ClCompile Include="Common\CalculatorButtonPressedEventArgs.cpp" />
|
||||||
<ClCompile Include="Common\CalculatorDisplay.cpp" />
|
<ClCompile Include="Common\CalculatorDisplay.cpp" />
|
||||||
<ClCompile Include="Common\ConversionResultTaskHelper.cpp" />
|
|
||||||
<ClCompile Include="Common\CopyPasteManager.cpp" />
|
<ClCompile Include="Common\CopyPasteManager.cpp" />
|
||||||
<ClCompile Include="Common\DateCalculator.cpp" />
|
<ClCompile Include="Common\DateCalculator.cpp" />
|
||||||
<ClCompile Include="Common\EngineResourceProvider.cpp" />
|
<ClCompile Include="Common\EngineResourceProvider.cpp" />
|
||||||
<ClCompile Include="Common\ExpressionCommandDeserializer.cpp" />
|
<ClCompile Include="Common\ExpressionCommandDeserializer.cpp" />
|
||||||
<ClCompile Include="Common\ExpressionCommandSerializer.cpp" />
|
<ClCompile Include="Common\ExpressionCommandSerializer.cpp" />
|
||||||
<ClCompile Include="Common\KeyboardShortcutManager.cpp" />
|
|
||||||
<ClCompile Include="Common\LocalizationService.cpp" />
|
<ClCompile Include="Common\LocalizationService.cpp" />
|
||||||
<ClCompile Include="Common\NavCategory.cpp" />
|
<ClCompile Include="Common\NavCategory.cpp" />
|
||||||
<ClCompile Include="Common\NetworkManager.cpp" />
|
<ClCompile Include="Common\NetworkManager.cpp" />
|
||||||
|
@ -420,16 +412,7 @@
|
||||||
</Choose>
|
</Choose>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="DataLoaders\DefaultFromToCurrency.json" />
|
<None Include="DataLoaders\DefaultFromToCurrency.json" />
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets" />
|
||||||
<Import Project="..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets" Condition="Exists('..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets')" />
|
|
||||||
</ImportGroup>
|
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Error Condition="!Exists('..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.UI.Xaml.2.2.190830001\build\native\Microsoft.UI.Xaml.targets'))" />
|
|
||||||
</Target>
|
|
||||||
</Project>
|
</Project>
|
|
@ -23,18 +23,12 @@
|
||||||
<ClCompile Include="Common\AppResourceProvider.cpp">
|
<ClCompile Include="Common\AppResourceProvider.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Common\BindableBase.cpp">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Common\CalculatorButtonPressedEventArgs.cpp">
|
<ClCompile Include="Common\CalculatorButtonPressedEventArgs.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Common\CalculatorDisplay.cpp">
|
<ClCompile Include="Common\CalculatorDisplay.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Common\ConversionResultTaskHelper.cpp">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Common\CopyPasteManager.cpp">
|
<ClCompile Include="Common\CopyPasteManager.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -50,9 +44,6 @@
|
||||||
<ClCompile Include="Common\ExpressionCommandSerializer.cpp">
|
<ClCompile Include="Common\ExpressionCommandSerializer.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Common\KeyboardShortcutManager.cpp">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Common\LocalizationService.cpp">
|
<ClCompile Include="Common\LocalizationService.cpp">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -94,15 +85,9 @@
|
||||||
<ClInclude Include="MemoryItemViewModel.h" />
|
<ClInclude Include="MemoryItemViewModel.h" />
|
||||||
<ClInclude Include="StandardCalculatorViewModel.h" />
|
<ClInclude Include="StandardCalculatorViewModel.h" />
|
||||||
<ClInclude Include="UnitConverterViewModel.h" />
|
<ClInclude Include="UnitConverterViewModel.h" />
|
||||||
<ClInclude Include="Common\AlwaysSelectedCollectionView.h">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common\AppResourceProvider.h">
|
<ClInclude Include="Common\AppResourceProvider.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\BindableBase.h">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common\CalculatorButtonPressedEventArgs.h">
|
<ClInclude Include="Common\CalculatorButtonPressedEventArgs.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -112,18 +97,12 @@
|
||||||
<ClInclude Include="Common\CalculatorDisplay.h">
|
<ClInclude Include="Common\CalculatorDisplay.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\ConversionResultTaskHelper.h">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common\CopyPasteManager.h">
|
<ClInclude Include="Common\CopyPasteManager.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\DateCalculator.h">
|
<ClInclude Include="Common\DateCalculator.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\DelegateCommand.h">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common\DisplayExpressionToken.h">
|
<ClInclude Include="Common\DisplayExpressionToken.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -136,9 +115,6 @@
|
||||||
<ClInclude Include="Common\ExpressionCommandSerializer.h">
|
<ClInclude Include="Common\ExpressionCommandSerializer.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\KeyboardShortcutManager.h">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common\LocalizationService.h">
|
<ClInclude Include="Common\LocalizationService.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -163,9 +139,6 @@
|
||||||
<ClInclude Include="Common\Utils.h">
|
<ClInclude Include="Common\Utils.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\ValidatingConverters.h">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Common\Automation\NarratorNotifier.h">
|
<ClInclude Include="Common\Automation\NarratorNotifier.h">
|
||||||
<Filter>Common\Automation</Filter>
|
<Filter>Common\Automation</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -199,14 +172,13 @@
|
||||||
<ClInclude Include="Common\NumberBase.h">
|
<ClInclude Include="Common\NumberBase.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common\DelegateCommand.h">
|
||||||
|
<Filter>Common</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="DataLoaders\DefaultFromToCurrency.json">
|
<None Include="DataLoaders\DefaultFromToCurrency.json">
|
||||||
<Filter>DataLoaders</Filter>
|
<Filter>DataLoaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<Page Include="$(MSBuildThisFileDirectory)DensityStyles\Compact.xaml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,34 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "BindableBase.h"
|
|
||||||
|
|
||||||
using namespace CalculatorApp::Common;
|
|
||||||
|
|
||||||
using namespace Platform;
|
|
||||||
using namespace Windows::UI::Xaml::Data;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Notifies listeners that a property value has changed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="propertyName">Name of the property used to notify listeners.</param>
|
|
||||||
void BindableBase::OnPropertyChanged(String ^ propertyName)
|
|
||||||
{
|
|
||||||
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform::String ^ BindableBase::GetStringRepresentation()
|
|
||||||
{
|
|
||||||
return this->ToString();
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace CalculatorApp
|
|
||||||
{
|
|
||||||
namespace Common
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Implementation of <see cref="INotifyPropertyChanged"/> to simplify models.
|
|
||||||
/// </summary>
|
|
||||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class BindableBase : Windows::UI::Xaml::DependencyObject,
|
|
||||||
Windows::UI::Xaml::Data::INotifyPropertyChanged,
|
|
||||||
Windows::UI::Xaml::Data::ICustomPropertyProvider
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// ICustomPropertyProvider
|
|
||||||
virtual Windows::UI::Xaml::Data::ICustomProperty ^ GetCustomProperty(Platform::String ^ name);
|
|
||||||
virtual Windows::UI::Xaml::Data::ICustomProperty ^ GetIndexedProperty(Platform::String ^ name, Windows::UI::Xaml::Interop::TypeName type);
|
|
||||||
virtual Platform::String ^ GetStringRepresentation();
|
|
||||||
|
|
||||||
property Windows::UI::Xaml::Interop::TypeName Type
|
|
||||||
{
|
|
||||||
virtual Windows::UI::Xaml::Interop::TypeName get()
|
|
||||||
{
|
|
||||||
return this->GetType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void OnPropertyChanged(Platform::String ^ propertyName);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "ConversionResultTaskHelper.h"
|
|
||||||
|
|
||||||
using namespace CalculatorApp::Common;
|
|
||||||
using namespace concurrency;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
ConversionResultTaskHelper::ConversionResultTaskHelper(unsigned int delay, const function<void()> functionToRun)
|
|
||||||
: m_delay{ delay }
|
|
||||||
, m_storedFunction{ functionToRun }
|
|
||||||
{
|
|
||||||
auto token = m_cts.get_token();
|
|
||||||
auto delayTask = CompleteAfter(delay);
|
|
||||||
delayTask.then(
|
|
||||||
[this, token]() {
|
|
||||||
if (!token.is_canceled())
|
|
||||||
{
|
|
||||||
m_storedFunction();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
task_continuation_context::use_current());
|
|
||||||
}
|
|
||||||
|
|
||||||
ConversionResultTaskHelper::~ConversionResultTaskHelper()
|
|
||||||
{
|
|
||||||
m_cts.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma optimize("", off)
|
|
||||||
// Creates a task that completes after the specified delay.
|
|
||||||
//
|
|
||||||
// Taken from: How to: Create a Task that Completes After a Delay
|
|
||||||
// https://msdn.microsoft.com/en-us/library/hh873170.aspx
|
|
||||||
task<void> ConversionResultTaskHelper::CompleteAfter(unsigned int timeout)
|
|
||||||
{
|
|
||||||
co_await winrt::resume_after(winrt::Windows::Foundation::TimeSpan{ std::chrono::duration<uint32_t, std::milli>(timeout) });
|
|
||||||
};
|
|
||||||
#pragma optimize("", on)
|
|
|
@ -1,24 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace CalculatorApp
|
|
||||||
{
|
|
||||||
namespace Common
|
|
||||||
{
|
|
||||||
class ConversionResultTaskHelper
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ConversionResultTaskHelper(unsigned int delay, const std::function<void()> functionToRun);
|
|
||||||
~ConversionResultTaskHelper();
|
|
||||||
|
|
||||||
private:
|
|
||||||
concurrency::task<void> CompleteAfter(unsigned int timeout);
|
|
||||||
|
|
||||||
unsigned int m_delay;
|
|
||||||
concurrency::cancellation_token_source m_cts;
|
|
||||||
const std::function<void()> m_storedFunction;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,12 +1,11 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
// Licensed under the MIT License.
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <winmeta.h>
|
||||||
|
|
||||||
namespace CalculatorApp
|
namespace CalculatorApp
|
||||||
{
|
{
|
||||||
constexpr int64_t WINEVENT_KEYWORD_RESPONSE_TIME = 0x1000000000000;
|
|
||||||
|
|
||||||
// RAII wrapper that automatically sends the Stop event when the class gets destructed.
|
// RAII wrapper that automatically sends the Stop event when the class gets destructed.
|
||||||
class TraceActivity
|
class TraceActivity
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,12 +36,6 @@ HistoryViewModel::HistoryViewModel(_In_ CalculationManager::CalculatorManager* c
|
||||||
ItemSize = 0;
|
ItemSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryViewModel::RestoreCompleteHistory()
|
|
||||||
{
|
|
||||||
RestoreHistory(CalculationManager::CALCULATOR_MODE::CM_STD);
|
|
||||||
RestoreHistory(CalculationManager::CALCULATOR_MODE::CM_SCI);
|
|
||||||
}
|
|
||||||
|
|
||||||
// this will reload Items with the history list based on current mode
|
// this will reload Items with the history list based on current mode
|
||||||
void HistoryViewModel::ReloadHistory(_In_ ViewMode currentMode)
|
void HistoryViewModel::ReloadHistory(_In_ ViewMode currentMode)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,7 +41,6 @@ namespace CalculatorApp
|
||||||
event HistoryItemClickedHandler ^ HistoryItemClicked;
|
event HistoryItemClickedHandler ^ HistoryItemClicked;
|
||||||
void ShowItem(_In_ CalculatorApp::ViewModel::HistoryItemViewModel ^ e);
|
void ShowItem(_In_ CalculatorApp::ViewModel::HistoryItemViewModel ^ e);
|
||||||
void ClearHistory();
|
void ClearHistory();
|
||||||
void RestoreCompleteHistory();
|
|
||||||
|
|
||||||
internal : HistoryViewModel(_In_ CalculationManager::CalculatorManager* calculatorManager);
|
internal : HistoryViewModel(_In_ CalculationManager::CalculatorManager* calculatorManager);
|
||||||
void SetCalculatorDisplay(CalculatorDisplay& calculatorDisplay);
|
void SetCalculatorDisplay(CalculatorDisplay& calculatorDisplay);
|
||||||
|
|
|
@ -903,21 +903,6 @@ void StandardCalculatorViewModel::OnClearMemoryCommand(Object ^ parameter)
|
||||||
Announcement = CalculatorAnnouncement::GetMemoryClearedAnnouncement(m_localizedMemoryCleared);
|
Announcement = CalculatorAnnouncement::GetMemoryClearedAnnouncement(m_localizedMemoryCleared);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StandardCalculatorViewModel::OnPinUnpinCommand(Object ^ parameter)
|
|
||||||
{
|
|
||||||
SetViewPinnedState(!IsViewPinned());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StandardCalculatorViewModel::IsViewPinned()
|
|
||||||
{
|
|
||||||
return m_IsCurrentViewPinned;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StandardCalculatorViewModel::SetViewPinnedState(bool pinned)
|
|
||||||
{
|
|
||||||
IsCurrentViewPinned = pinned;
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonInfo StandardCalculatorViewModel::MapCharacterToButtonId(char16 ch)
|
ButtonInfo StandardCalculatorViewModel::MapCharacterToButtonId(char16 ch)
|
||||||
{
|
{
|
||||||
ButtonInfo result;
|
ButtonInfo result;
|
||||||
|
@ -1476,15 +1461,6 @@ void StandardCalculatorViewModel::Recalculate(bool fromHistory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandType StandardCalculatorViewModel::GetSelectedTokenType(_In_ unsigned int tokenPosition)
|
|
||||||
{
|
|
||||||
const pair<wstring, int>& token = m_tokens->at(tokenPosition);
|
|
||||||
unsigned int tokenCommandIndex = token.second;
|
|
||||||
const shared_ptr<IExpressionCommand>& tokenCommand = m_commands->at(tokenCommandIndex);
|
|
||||||
|
|
||||||
return tokenCommand->GetCommandType();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool StandardCalculatorViewModel::IsOpnd(Command command)
|
bool StandardCalculatorViewModel::IsOpnd(Command command)
|
||||||
{
|
{
|
||||||
static constexpr Command opnd[] = { Command::Command0, Command::Command1, Command::Command2, Command::Command3, Command::Command4, Command::Command5,
|
static constexpr Command opnd[] = { Command::Command0, Command::Command1, Command::Command2, Command::Command3, Command::Command4, Command::Command5,
|
||||||
|
@ -1626,26 +1602,6 @@ void StandardCalculatorViewModel::SwitchAngleType(NumbersAndOperatorsEnum num)
|
||||||
OnButtonPressed(num);
|
OnButtonPressed(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumbersAndOperatorsEnum StandardCalculatorViewModel::ConvertIntegerToNumbersAndOperatorsEnum(unsigned int parameter)
|
|
||||||
{
|
|
||||||
NumbersAndOperatorsEnum angletype;
|
|
||||||
switch (parameter)
|
|
||||||
{
|
|
||||||
case 321:
|
|
||||||
angletype = NumbersAndOperatorsEnum::Degree;
|
|
||||||
break;
|
|
||||||
case 322:
|
|
||||||
angletype = NumbersAndOperatorsEnum::Radians;
|
|
||||||
break;
|
|
||||||
case 323:
|
|
||||||
angletype = NumbersAndOperatorsEnum::Grads;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
angletype = NumbersAndOperatorsEnum::Degree;
|
|
||||||
};
|
|
||||||
return angletype;
|
|
||||||
}
|
|
||||||
|
|
||||||
void StandardCalculatorViewModel::UpdateOperand(int pos, String ^ text)
|
void StandardCalculatorViewModel::UpdateOperand(int pos, String ^ text)
|
||||||
{
|
{
|
||||||
pair<wstring, int> p = m_tokens->at(pos);
|
pair<wstring, int> p = m_tokens->at(pos);
|
||||||
|
|
|
@ -71,7 +71,6 @@ namespace CalculatorApp
|
||||||
OBSERVABLE_PROPERTY_R(bool, IsUnaryOperatorEnabled);
|
OBSERVABLE_PROPERTY_R(bool, IsUnaryOperatorEnabled);
|
||||||
OBSERVABLE_PROPERTY_R(bool, IsNegateEnabled);
|
OBSERVABLE_PROPERTY_R(bool, IsNegateEnabled);
|
||||||
OBSERVABLE_PROPERTY_RW(bool, IsDecimalEnabled);
|
OBSERVABLE_PROPERTY_RW(bool, IsDecimalEnabled);
|
||||||
OBSERVABLE_PROPERTY_R(bool, IsCurrentViewPinned);
|
|
||||||
OBSERVABLE_PROPERTY_R(Windows::Foundation::Collections::IVector<MemoryItemViewModel ^> ^, MemorizedNumbers);
|
OBSERVABLE_PROPERTY_R(Windows::Foundation::Collections::IVector<MemoryItemViewModel ^> ^, MemorizedNumbers);
|
||||||
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsMemoryEmpty);
|
OBSERVABLE_NAMED_PROPERTY_RW(bool, IsMemoryEmpty);
|
||||||
OBSERVABLE_PROPERTY_R(bool, IsFToEChecked);
|
OBSERVABLE_PROPERTY_R(bool, IsFToEChecked);
|
||||||
|
@ -209,7 +208,6 @@ namespace CalculatorApp
|
||||||
{
|
{
|
||||||
if (m_isEditingEnabled != value)
|
if (m_isEditingEnabled != value)
|
||||||
{
|
{
|
||||||
// Numbers::Common::KeyboardShortcutManager::IsCalculatorInEditingMode = value;
|
|
||||||
m_isEditingEnabled = value;
|
m_isEditingEnabled = value;
|
||||||
bool currentEditToggleValue = !m_isEditingEnabled;
|
bool currentEditToggleValue = !m_isEditingEnabled;
|
||||||
IsBinaryOperatorEnabled = currentEditToggleValue;
|
IsBinaryOperatorEnabled = currentEditToggleValue;
|
||||||
|
@ -262,7 +260,6 @@ namespace CalculatorApp
|
||||||
void OnMemoryAdd(Platform::Object ^ memoryItemPosition);
|
void OnMemoryAdd(Platform::Object ^ memoryItemPosition);
|
||||||
void OnMemorySubtract(Platform::Object ^ memoryItemPosition);
|
void OnMemorySubtract(Platform::Object ^ memoryItemPosition);
|
||||||
void OnMemoryClear(_In_ Platform::Object ^ memoryItemPosition);
|
void OnMemoryClear(_In_ Platform::Object ^ memoryItemPosition);
|
||||||
void OnPinUnpinCommand(Platform::Object ^ parameter);
|
|
||||||
|
|
||||||
void OnInputChanged();
|
void OnInputChanged();
|
||||||
void DisplayPasteError();
|
void DisplayPasteError();
|
||||||
|
@ -332,7 +329,6 @@ namespace CalculatorApp
|
||||||
Platform::String ^ m_localizedOpenParenthesisCountChangedAutomationFormat;
|
Platform::String ^ m_localizedOpenParenthesisCountChangedAutomationFormat;
|
||||||
Platform::String ^ m_localizedNoRightParenthesisAddedFormat;
|
Platform::String ^ m_localizedNoRightParenthesisAddedFormat;
|
||||||
|
|
||||||
bool m_pinned;
|
|
||||||
bool m_isOperandEnabled;
|
bool m_isOperandEnabled;
|
||||||
bool m_isEditingEnabled;
|
bool m_isEditingEnabled;
|
||||||
bool m_isStandard;
|
bool m_isStandard;
|
||||||
|
@ -372,12 +368,8 @@ namespace CalculatorApp
|
||||||
bool IsOpnd(CalculationManager::Command command);
|
bool IsOpnd(CalculationManager::Command command);
|
||||||
bool IsRecoverableCommand(CalculationManager::Command command);
|
bool IsRecoverableCommand(CalculationManager::Command command);
|
||||||
|
|
||||||
CalculationManager::CommandType GetSelectedTokenType(_In_ unsigned int);
|
|
||||||
void SaveEditedCommand(_In_ unsigned int index, _In_ CalculationManager::Command command);
|
void SaveEditedCommand(_In_ unsigned int index, _In_ CalculationManager::Command command);
|
||||||
|
|
||||||
bool IsViewPinned();
|
|
||||||
void SetViewPinnedState(bool pinned);
|
|
||||||
|
|
||||||
CalculatorApp::Common::ViewMode GetCalculatorMode();
|
CalculatorApp::Common::ViewMode GetCalculatorMode();
|
||||||
|
|
||||||
friend class CalculatorDisplay;
|
friend class CalculatorDisplay;
|
||||||
|
|
|
@ -478,21 +478,11 @@ void UnitConverterViewModel::OnButtonPressed(Platform::Object ^ parameter)
|
||||||
|
|
||||||
static constexpr UCM::Command OPERANDS[] = { UCM::Command::Zero, UCM::Command::One, UCM::Command::Two, UCM::Command::Three, UCM::Command::Four,
|
static constexpr UCM::Command OPERANDS[] = { UCM::Command::Zero, UCM::Command::One, UCM::Command::Two, UCM::Command::Three, UCM::Command::Four,
|
||||||
UCM::Command::Five, UCM::Command::Six, UCM::Command::Seven, UCM::Command::Eight, UCM::Command::Nine };
|
UCM::Command::Five, UCM::Command::Six, UCM::Command::Seven, UCM::Command::Eight, UCM::Command::Nine };
|
||||||
|
if (m_isInputBlocked)
|
||||||
if (find(begin(OPERANDS), end(OPERANDS), command) != end(OPERANDS))
|
{
|
||||||
{
|
return;
|
||||||
if (m_isInputBlocked)
|
}
|
||||||
{
|
m_model->SendCommand(command);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_IsCurrencyCurrentCategory)
|
|
||||||
{
|
|
||||||
StartConversionResultTimer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_model->SendCommand(command);
|
|
||||||
|
|
||||||
TraceLogger::GetInstance()->LogConverterInputReceived(Mode);
|
TraceLogger::GetInstance()->LogConverterInputReceived(Mode);
|
||||||
}
|
}
|
||||||
|
@ -998,18 +988,6 @@ bool UnitConverterViewModel::UnitsAreValid()
|
||||||
return UnitFrom != nullptr && !UnitFrom->Abbreviation->IsEmpty() && UnitTo != nullptr && !UnitTo->Abbreviation->IsEmpty();
|
return UnitFrom != nullptr && !UnitFrom->Abbreviation->IsEmpty() && UnitTo != nullptr && !UnitTo->Abbreviation->IsEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UnitConverterViewModel::StartConversionResultTimer()
|
|
||||||
{
|
|
||||||
auto that(this);
|
|
||||||
m_conversionResultTaskHelper = make_unique<ConversionResultTaskHelper>(CONVERSION_FINALIZED_DELAY_IN_MS, [that]() {
|
|
||||||
if (that->UnitsAreValid())
|
|
||||||
{
|
|
||||||
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()
|
String ^ SupplementaryResult::GetLocalizedAutomationName()
|
||||||
{
|
{
|
||||||
auto format = AppResourceProvider::GetInstance()->GetResourceString("SupplementaryUnit_AutomationName");
|
auto format = AppResourceProvider::GetInstance()->GetResourceString("SupplementaryUnit_AutomationName");
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include "Common/Utils.h"
|
#include "Common/Utils.h"
|
||||||
#include "Common/NetworkManager.h"
|
#include "Common/NetworkManager.h"
|
||||||
#include "Common/Automation/NarratorAnnouncement.h"
|
#include "Common/Automation/NarratorAnnouncement.h"
|
||||||
#include "Common/ConversionResultTaskHelper.h"
|
|
||||||
#include "Common/CalculatorButtonUser.h"
|
#include "Common/CalculatorButtonUser.h"
|
||||||
#include "Common/NavCategory.h"
|
#include "Common/NavCategory.h"
|
||||||
|
|
||||||
|
@ -264,8 +263,6 @@ namespace CalculatorApp
|
||||||
void OnButtonPressed(Platform::Object ^ parameter);
|
void OnButtonPressed(Platform::Object ^ parameter);
|
||||||
Platform::String ^ ConvertToLocalizedString(const std::wstring& stringToLocalize, bool allowPartialStrings);
|
Platform::String ^ ConvertToLocalizedString(const std::wstring& stringToLocalize, bool allowPartialStrings);
|
||||||
|
|
||||||
void StartConversionResultTimer();
|
|
||||||
|
|
||||||
std::shared_ptr<UnitConversionManager::IUnitConverter> m_model;
|
std::shared_ptr<UnitConversionManager::IUnitConverter> m_model;
|
||||||
wchar_t m_decimalSeparator;
|
wchar_t m_decimalSeparator;
|
||||||
|
|
||||||
|
@ -326,8 +323,6 @@ namespace CalculatorApp
|
||||||
Platform::String ^ m_lastAnnouncedConversionResult;
|
Platform::String ^ m_lastAnnouncedConversionResult;
|
||||||
|
|
||||||
bool m_isCurrencyDataLoaded;
|
bool m_isCurrencyDataLoaded;
|
||||||
|
|
||||||
std::unique_ptr<CalculatorApp::Common::ConversionResultTaskHelper> m_conversionResultTaskHelper;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class UnitConverterVMCallback : public UnitConversionManager::IUnitConverterVMCallback
|
class UnitConverterVMCallback : public UnitConversionManager::IUnitConverterVMCallback
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<packages>
|
|
||||||
<package id="Microsoft.UI.Xaml" version="2.2.190830001" targetFramework="native" />
|
|
||||||
</packages>
|
|
|
@ -230,10 +230,12 @@
|
||||||
<DependentUpon>AboutFlyout.xaml</DependentUpon>
|
<DependentUpon>AboutFlyout.xaml</DependentUpon>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\AppLifecycleLogger.h" />
|
<ClInclude Include="Common\AppLifecycleLogger.h" />
|
||||||
|
<ClInclude Include="Common\KeyboardShortcutManager.h" />
|
||||||
|
<ClInclude Include="Common\ValidatingConverters.h" />
|
||||||
|
<ClInclude Include="Common\ViewState.h" />
|
||||||
<ClInclude Include="Controls\CalculationResultAutomationPeer.h" />
|
<ClInclude Include="Controls\CalculationResultAutomationPeer.h" />
|
||||||
<ClInclude Include="Controls\OverflowTextBlockAutomationPeer.h" />
|
<ClInclude Include="Controls\OverflowTextBlockAutomationPeer.h" />
|
||||||
<ClInclude Include="Common\AlwaysSelectedCollectionView.h" />
|
<ClInclude Include="Common\AlwaysSelectedCollectionView.h" />
|
||||||
<ClInclude Include="Common\BindableBase.h" />
|
|
||||||
<ClInclude Include="Controls\CalculationResult.h" />
|
<ClInclude Include="Controls\CalculationResult.h" />
|
||||||
<ClInclude Include="Controls\CalculatorButton.h" />
|
<ClInclude Include="Controls\CalculatorButton.h" />
|
||||||
<ClInclude Include="Controls\FlipButtons.h" />
|
<ClInclude Include="Controls\FlipButtons.h" />
|
||||||
|
@ -363,9 +365,10 @@
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="Common\AppLifecycleLogger.cpp" />
|
<ClCompile Include="Common\AppLifecycleLogger.cpp" />
|
||||||
|
<ClCompile Include="Common\KeyboardShortcutManager.cpp" />
|
||||||
|
<ClCompile Include="Common\ViewState.cpp" />
|
||||||
<ClCompile Include="Controls\CalculationResultAutomationPeer.cpp" />
|
<ClCompile Include="Controls\CalculationResultAutomationPeer.cpp" />
|
||||||
<ClCompile Include="Controls\OverflowTextBlockAutomationPeer.cpp" />
|
<ClCompile Include="Controls\OverflowTextBlockAutomationPeer.cpp" />
|
||||||
<ClCompile Include="Common\BindableBase.cpp" />
|
|
||||||
<ClCompile Include="Controls\CalculationResult.cpp" />
|
<ClCompile Include="Controls\CalculationResult.cpp" />
|
||||||
<ClCompile Include="Controls\CalculatorButton.cpp" />
|
<ClCompile Include="Controls\CalculatorButton.cpp" />
|
||||||
<ClCompile Include="Controls\FlipButtons.cpp" />
|
<ClCompile Include="Controls\FlipButtons.cpp" />
|
||||||
|
|
|
@ -225,9 +225,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="App.xaml.cpp" />
|
<ClCompile Include="App.xaml.cpp" />
|
||||||
<ClCompile Include="pch.cpp" />
|
<ClCompile Include="pch.cpp" />
|
||||||
<ClCompile Include="Common\BindableBase.cpp">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Controls\CalculationResult.cpp">
|
<ClCompile Include="Controls\CalculationResult.cpp">
|
||||||
<Filter>Controls</Filter>
|
<Filter>Controls</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -308,6 +305,10 @@
|
||||||
<ClCompile Include="Controls\OperatorPanelButton.cpp">
|
<ClCompile Include="Controls\OperatorPanelButton.cpp">
|
||||||
<Filter>Controls</Filter>
|
<Filter>Controls</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Common\KeyboardShortcutManager.cpp">
|
||||||
|
<Filter>Common</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="Common\ViewState.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="pch.h" />
|
<ClInclude Include="pch.h" />
|
||||||
|
@ -315,9 +316,6 @@
|
||||||
<ClInclude Include="Common\AlwaysSelectedCollectionView.h">
|
<ClInclude Include="Common\AlwaysSelectedCollectionView.h">
|
||||||
<Filter>Common</Filter>
|
<Filter>Common</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Common\BindableBase.h">
|
|
||||||
<Filter>Common</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Controls\CalculationResult.h">
|
<ClInclude Include="Controls\CalculationResult.h">
|
||||||
<Filter>Controls</Filter>
|
<Filter>Controls</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -398,6 +396,13 @@
|
||||||
<ClInclude Include="Controls\OperatorPanelButton.h">
|
<ClInclude Include="Controls\OperatorPanelButton.h">
|
||||||
<Filter>Controls</Filter>
|
<Filter>Controls</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common\KeyboardShortcutManager.h">
|
||||||
|
<Filter>Common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common\ValidatingConverters.h">
|
||||||
|
<Filter>Common</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="Common\ViewState.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AppxManifest Include="Package.appxmanifest" />
|
<AppxManifest Include="Package.appxmanifest" />
|
||||||
|
@ -465,6 +470,7 @@
|
||||||
<Page Include="Views\TitleBar.xaml">
|
<Page Include="Views\TitleBar.xaml">
|
||||||
<Filter>Views</Filter>
|
<Filter>Views</Filter>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="$(MSBuildThisFileDirectory)DensityStyles\Compact.xaml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PRIResource Include="Resources\en-US\CEngineStrings.resw">
|
<PRIResource Include="Resources\en-US\CEngineStrings.resw">
|
||||||
|
@ -1510,4 +1516,4 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="Calculator.rc" />
|
<ResourceCompile Include="Calculator.rc" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "AppLifecycleLogger.h"
|
#include "AppLifecycleLogger.h"
|
||||||
#include "CalcViewModel/Common/TraceActivity.h"
|
#include <winmeta.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace winrt;
|
using namespace winrt;
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "BindableBase.h"
|
|
||||||
|
|
||||||
using namespace CalculatorApp::Common;
|
|
||||||
|
|
||||||
using namespace Platform;
|
|
||||||
using namespace Windows::UI::Xaml::Data;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Notifies listeners that a property value has changed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="propertyName">Name of the property used to notify listeners.</param>
|
|
||||||
void BindableBase::OnPropertyChanged(String ^ propertyName)
|
|
||||||
{
|
|
||||||
PropertyChanged(this, ref new PropertyChangedEventArgs(propertyName));
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Platform::String ^ BindableBase::GetStringRepresentation()
|
|
||||||
{
|
|
||||||
return this->ToString();
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
// Licensed under the MIT License.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
namespace CalculatorApp
|
|
||||||
{
|
|
||||||
namespace Common
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Implementation of <see cref="INotifyPropertyChanged"/> to simplify models.
|
|
||||||
/// </summary>
|
|
||||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class BindableBase : Windows::UI::Xaml::DependencyObject,
|
|
||||||
Windows::UI::Xaml::Data::INotifyPropertyChanged,
|
|
||||||
Windows::UI::Xaml::Data::ICustomPropertyProvider
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual event Windows::UI::Xaml::Data::PropertyChangedEventHandler ^ PropertyChanged;
|
|
||||||
|
|
||||||
public:
|
|
||||||
// ICustomPropertyProvider
|
|
||||||
virtual Windows::UI::Xaml::Data::ICustomProperty ^ GetCustomProperty(Platform::String ^ name);
|
|
||||||
virtual Windows::UI::Xaml::Data::ICustomProperty ^ GetIndexedProperty(Platform::String ^ name, Windows::UI::Xaml::Interop::TypeName type);
|
|
||||||
virtual Platform::String ^ GetStringRepresentation();
|
|
||||||
|
|
||||||
property Windows::UI::Xaml::Interop::TypeName Type
|
|
||||||
{
|
|
||||||
virtual Windows::UI::Xaml::Interop::TypeName get()
|
|
||||||
{
|
|
||||||
return this->GetType();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void OnPropertyChanged(Platform::String ^ propertyName);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "KeyboardShortcutManager.h"
|
#include "KeyboardShortcutManager.h"
|
||||||
#include "AppResourceProvider.h"
|
#include "CalcViewModel/Common/AppResourceProvider.h"
|
||||||
#include "ApplicationViewModel.h"
|
#include "CalcViewModel/ApplicationViewModel.h"
|
||||||
#include "LocalizationSettings.h"
|
#include "CalcViewModel/Common/LocalizationSettings.h"
|
||||||
|
|
||||||
using namespace Concurrency;
|
using namespace Concurrency;
|
||||||
using namespace Platform;
|
using namespace Platform;
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "CalcViewModel/Common/Utils.h"
|
||||||
#include "MyVirtualKey.h"
|
#include "CalcViewModel/Common/MyVirtualKey.h"
|
||||||
|
|
||||||
namespace CalculatorApp
|
namespace CalculatorApp
|
||||||
{
|
{
|
19
src/Calculator/Common/ViewState.cpp
Normal file
19
src/Calculator/Common/ViewState.cpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#include "pch.h"
|
||||||
|
#include "ViewState.h"
|
||||||
|
|
||||||
|
namespace CalculatorApp
|
||||||
|
{
|
||||||
|
namespace ViewState
|
||||||
|
{
|
||||||
|
Platform::StringReference Snap(L"Snap");
|
||||||
|
Platform::StringReference DockedView(L"DockedView");
|
||||||
|
|
||||||
|
bool IsValidViewState(Platform::String ^ viewState)
|
||||||
|
{
|
||||||
|
return viewState->Equals(ViewState::Snap) || viewState->Equals(ViewState::DockedView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
src/Calculator/Common/ViewState.h
Normal file
15
src/Calculator/Common/ViewState.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
// Licensed under the MIT License.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace CalculatorApp
|
||||||
|
{
|
||||||
|
namespace ViewState
|
||||||
|
{
|
||||||
|
extern Platform::StringReference Snap;
|
||||||
|
extern Platform::StringReference DockedView;
|
||||||
|
|
||||||
|
bool IsValidViewState(Platform::String ^ viewState);
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "CalculatorScientificOperators.xaml.h"
|
#include "CalculatorScientificOperators.xaml.h"
|
||||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
#include "Common/KeyboardShortcutManager.h"
|
||||||
#include "CalcViewModel/Common/TraceLogger.h"
|
#include "CalcViewModel/Common/TraceLogger.h"
|
||||||
#include "Controls/CalculatorButton.h"
|
#include "Controls/CalculatorButton.h"
|
||||||
#include "CalcViewModel/StandardCalculatorViewModel.h"
|
#include "CalcViewModel/StandardCalculatorViewModel.h"
|
||||||
|
|
|
@ -403,7 +403,7 @@
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Visibility="{Binding IsDateDiffMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
Visibility="{Binding IsDateDiffMode, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="1*" MaxHeight="17"/>
|
<RowDefinition Height="1*" MaxHeight="17"/>
|
||||||
<RowDefinition Height="Auto" MinHeight="32"/>
|
<RowDefinition Height="Auto" MinHeight="32"/>
|
||||||
<RowDefinition Height="1*" MaxHeight="24"/>
|
<RowDefinition Height="1*" MaxHeight="24"/>
|
||||||
<RowDefinition Height="Auto" MinHeight="32"/>
|
<RowDefinition Height="Auto" MinHeight="32"/>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "MainPage.xaml.h"
|
#include "MainPage.xaml.h"
|
||||||
#include "CalcViewModel/Common/TraceLogger.h"
|
#include "CalcViewModel/Common/TraceLogger.h"
|
||||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
|
||||||
#include "CalcViewModel/Common/LocalizationService.h"
|
#include "CalcViewModel/Common/LocalizationService.h"
|
||||||
#include "CalcViewModel/Common/Automation/NarratorNotifier.h"
|
#include "CalcViewModel/Common/Automation/NarratorNotifier.h"
|
||||||
#include "CalcViewModel/Common/AppResourceProvider.h"
|
#include "CalcViewModel/Common/AppResourceProvider.h"
|
||||||
|
@ -12,6 +11,8 @@
|
||||||
#include "Converters/BooleanToVisibilityConverter.h"
|
#include "Converters/BooleanToVisibilityConverter.h"
|
||||||
#include "CalcViewModel/Common/LocalizationStringUtil.h"
|
#include "CalcViewModel/Common/LocalizationStringUtil.h"
|
||||||
#include "Common/AppLifecycleLogger.h"
|
#include "Common/AppLifecycleLogger.h"
|
||||||
|
#include "Common/KeyboardShortcutManager.h"
|
||||||
|
|
||||||
using namespace CalculatorApp;
|
using namespace CalculatorApp;
|
||||||
using namespace CalculatorApp::Common;
|
using namespace CalculatorApp::Common;
|
||||||
using namespace CalculatorApp::Common::Automation;
|
using namespace CalculatorApp::Common::Automation;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Views/NumberPad.g.h"
|
#include "Views/NumberPad.g.h"
|
||||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
#include "Common/KeyboardShortcutManager.h"
|
||||||
#include "CalcViewModel/Common/NumberBase.h"
|
#include "CalcViewModel/Common/NumberBase.h"
|
||||||
#include "CalcManager/Header Files/RadixType.h"
|
#include "CalcManager/Header Files/RadixType.h"
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
#include "Controls/CalculationResult.h"
|
#include "Controls/CalculationResult.h"
|
||||||
#include "Controls/CalculatorButton.h"
|
#include "Controls/CalculatorButton.h"
|
||||||
#include "CalcViewModel/Common/CopyPasteManager.h"
|
#include "CalcViewModel/Common/CopyPasteManager.h"
|
||||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
|
||||||
#include "CalcViewModel/Common/LocalizationService.h"
|
#include "CalcViewModel/Common/LocalizationService.h"
|
||||||
#include "CalcViewModel/Common/LocalizationSettings.h"
|
#include "CalcViewModel/Common/LocalizationSettings.h"
|
||||||
|
#include "Common/KeyboardShortcutManager.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace CalculatorApp;
|
using namespace CalculatorApp;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include "Views/UnitConverter.g.h"
|
#include "Views/UnitConverter.g.h"
|
||||||
#include "Common/AlwaysSelectedCollectionView.h"
|
#include "Common/AlwaysSelectedCollectionView.h"
|
||||||
#include "CalcViewModel/Common/ValidatingConverters.h"
|
#include "Common/ValidatingConverters.h"
|
||||||
#include "Converters/BooleanToVisibilityConverter.h"
|
#include "Converters/BooleanToVisibilityConverter.h"
|
||||||
#include "Converters/VisibilityNegationConverter.h"
|
#include "Converters/VisibilityNegationConverter.h"
|
||||||
#include "CalcViewModel/UnitConverterViewModel.h"
|
#include "CalcViewModel/UnitConverterViewModel.h"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "WindowFrameService.h"
|
#include "WindowFrameService.h"
|
||||||
#include "CalcViewModel/Common/KeyboardShortcutManager.h"
|
#include "Common/KeyboardShortcutManager.h"
|
||||||
#include "CalcViewModel/Common/TraceLogger.h"
|
#include "CalcViewModel/Common/TraceLogger.h"
|
||||||
|
|
||||||
using namespace concurrency;
|
using namespace concurrency;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue