mirror of
https://github.com/Microsoft/calculator.git
synced 2025-07-07 05:31:09 -07:00
Initial PR for the feature/GraphingCalculator feature branch, part of #338. The feature incorporates a proprietary Microsoft-owned graphing engine to drive graphing experiences in the Windows Calculator app. Due to the private nature of the graphing engine, the source available in the public repo will make use of a mock graphing engine. See README.md for more details. This PR simply serves as a base for future feature development. As such, the PR will be immediately merged. Feedback on the content of this PR, and on the feature in general, is encouraged. If there is feedback related to the content of this specific PR, please leave comments on the PR page. We will address the comments in future PRs to the feature branch.
95 lines
3.6 KiB
C++
95 lines
3.6 KiB
C++
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
// Licensed under the MIT License.
|
|
|
|
#pragma once
|
|
|
|
#include "StandardCalculatorViewModel.h"
|
|
#include "DateCalculatorViewModel.h"
|
|
#include "GraphingCalculator/GraphingCalculatorViewModel.h"
|
|
#include "UnitConverterViewModel.h"
|
|
|
|
namespace CalculatorApp
|
|
{
|
|
namespace ViewModel
|
|
{
|
|
[Windows::UI::Xaml::Data::Bindable]
|
|
public ref class ApplicationViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
|
{
|
|
public:
|
|
ApplicationViewModel();
|
|
|
|
void Initialize(CalculatorApp::Common::ViewMode mode); // Use for first init, use deserialize for rehydration
|
|
|
|
OBSERVABLE_OBJECT();
|
|
OBSERVABLE_PROPERTY_RW(StandardCalculatorViewModel^, CalculatorViewModel);
|
|
OBSERVABLE_PROPERTY_RW(DateCalculatorViewModel^, DateCalcViewModel);
|
|
OBSERVABLE_PROPERTY_RW(GraphingCalculatorViewModel^, GraphingCalcViewModel);
|
|
OBSERVABLE_PROPERTY_RW(UnitConverterViewModel^, ConverterViewModel);
|
|
OBSERVABLE_PROPERTY_RW(CalculatorApp::Common::ViewMode, PreviousMode);
|
|
OBSERVABLE_NAMED_PROPERTY_RW(Platform::String^, CategoryName);
|
|
|
|
COMMAND_FOR_METHOD(CopyCommand, ApplicationViewModel::OnCopyCommand);
|
|
COMMAND_FOR_METHOD(PasteCommand, ApplicationViewModel::OnPasteCommand);
|
|
|
|
property CalculatorApp::Common::ViewMode Mode
|
|
{
|
|
CalculatorApp::Common::ViewMode get()
|
|
{
|
|
return m_mode;
|
|
}
|
|
|
|
void set(CalculatorApp::Common::ViewMode value);
|
|
}
|
|
static property Platform::String^ ModePropertyName
|
|
{
|
|
Platform::String^ get()
|
|
{
|
|
return Platform::StringReference(L"Mode");
|
|
}
|
|
}
|
|
|
|
property Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup^>^ Categories
|
|
{
|
|
Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup^>^ get()
|
|
{
|
|
return m_categories;
|
|
}
|
|
|
|
void set(Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup^>^ value);
|
|
}
|
|
|
|
property Windows::UI::Xaml::Visibility ClearMemoryVisibility
|
|
{
|
|
Windows::UI::Xaml::Visibility get()
|
|
{
|
|
return CalculatorApp::Common::NavCategory::IsCalculatorViewMode(Mode)
|
|
? Windows::UI::Xaml::Visibility::Visible
|
|
: Windows::UI::Xaml::Visibility::Collapsed;
|
|
}
|
|
}
|
|
|
|
property Windows::UI::Xaml::Visibility AppBarVisibility
|
|
{
|
|
Windows::UI::Xaml::Visibility get()
|
|
{
|
|
return CalculatorApp::Common::NavCategory::IsCalculatorViewMode(Mode)
|
|
? Windows::UI::Xaml::Visibility::Visible
|
|
: Windows::UI::Xaml::Visibility::Collapsed;
|
|
}
|
|
}
|
|
|
|
private:
|
|
bool TryRecoverFromNavigationModeFailure();
|
|
|
|
void OnModeChanged();
|
|
|
|
void OnCopyCommand(Platform::Object^ parameter);
|
|
void OnPasteCommand(Platform::Object^ parameter);
|
|
|
|
void SetMenuCategories();
|
|
|
|
CalculatorApp::Common::ViewMode m_mode;
|
|
Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup^>^ m_categories;
|
|
};
|
|
}
|
|
}
|