Fix the project code style, as it is not consistent. (#236)
Fixes #202 This PR fixes code style for the project files. The Problem Different files in the project use different code style. That is not consistent and leads to harder maintenance of the project. Description of the changes: Have investigated and determined the most used code style across the given codebase Have configured IDE and applied code style to all project files. Have crafted clang-formatter config. see https://clang.llvm.org/docs/ClangFormat.html https://clang.llvm.org/docs/ClangFormatStyleOptions.html Some cases were fixed manually How changes were validated: manual/ad-hoc testing, automated testing All tests pass as before because these are only code style changes. Additional Please review, and let me know if I have any mistake in the code style. In case of any mistake, I will change the configuration and re-apply it to the project.
This commit is contained in:
committed by
Daniel Belcher
parent
c77f1de84c
commit
2826d37056
@@ -37,15 +37,15 @@ AboutFlyout::AboutFlyout()
|
||||
|
||||
Header->Text = resourceLoader.GetResourceString("AboutButton/Content");
|
||||
|
||||
auto copyrightText = LocalizationStringUtil::GetLocalizedString(resourceLoader.GetResourceString("AboutControlCopyright")->Data(), to_wstring(BUILD_YEAR).c_str());
|
||||
auto copyrightText =
|
||||
LocalizationStringUtil::GetLocalizedString(resourceLoader.GetResourceString("AboutControlCopyright")->Data(), to_wstring(BUILD_YEAR).c_str());
|
||||
AboutControlCopyrightRun->Text = ref new String(copyrightText.c_str());
|
||||
|
||||
}
|
||||
|
||||
void AboutFlyout::FeedbackButton_Click(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void AboutFlyout::FeedbackButton_Click(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
PackageVersion version = Package::Current->Id->Version;
|
||||
String^ versionNumber = ref new String(L"Version ");
|
||||
String ^ versionNumber = ref new String(L"Version ");
|
||||
versionNumber = versionNumber + version.Major + "." + version.Minor + "." + version.Build + "." + version.Revision;
|
||||
Launcher::LaunchUriAsync(ref new Uri("windows-feedback:?contextid=130&metadata=%7B%22Metadata%22:[%7B%22AppBuild%22:%22" + versionNumber + "%22%7D]%7D"));
|
||||
}
|
||||
@@ -53,7 +53,7 @@ void AboutFlyout::FeedbackButton_Click(_In_ Object^ sender, _In_ RoutedEventArgs
|
||||
void AboutFlyout::SetVersionString()
|
||||
{
|
||||
PackageVersion version = Package::Current->Id->Version;
|
||||
String^ appName = AppResourceProvider::GetInstance().GetResourceString(L"AppName");
|
||||
String ^ appName = AppResourceProvider::GetInstance().GetResourceString(L"AppName");
|
||||
AboutFlyoutVersion->Text = appName + L" " + version.Major + L"." + version.Minor + L"." + version.Build + L"." + version.Revision;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ void AboutFlyout::SetDefaultFocus()
|
||||
AboutFlyoutEULA->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void CalculatorApp::AboutFlyout::UserControl_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void CalculatorApp::AboutFlyout::UserControl_Loaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogAboutFlyoutOpened();
|
||||
}
|
||||
|
@@ -7,7 +7,8 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
public ref class AboutFlyout sealed
|
||||
public
|
||||
ref class AboutFlyout sealed
|
||||
{
|
||||
public:
|
||||
AboutFlyout();
|
||||
@@ -15,8 +16,8 @@ namespace CalculatorApp
|
||||
void SetDefaultFocus();
|
||||
|
||||
private:
|
||||
void FeedbackButton_Click(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void FeedbackButton_Click(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void SetVersionString();
|
||||
void UserControl_Loaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void UserControl_Loaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
};
|
||||
} /* namespace CalculatorApp */
|
||||
|
@@ -73,11 +73,10 @@ App::App()
|
||||
|
||||
#if _DEBUG
|
||||
this->DebugSettings->IsBindingTracingEnabled = true;
|
||||
this->DebugSettings->BindingFailed += ref new BindingFailedEventHandler([](_In_ Object^ /*sender*/, _In_ BindingFailedEventArgs^ e)
|
||||
{
|
||||
this->DebugSettings->BindingFailed += ref new BindingFailedEventHandler([](_In_ Object ^ /*sender*/, _In_ BindingFailedEventArgs ^ e) {
|
||||
if (IsDebuggerPresent())
|
||||
{
|
||||
::Platform::String^ errorMessage = e->Message;
|
||||
::Platform::String ^ errorMessage = e->Message;
|
||||
__debugbreak();
|
||||
}
|
||||
});
|
||||
@@ -87,7 +86,7 @@ App::App()
|
||||
bool App::m_isAnimationEnabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// Return True if animation is enabled by user setting.
|
||||
/// Return True if animation is enabled by user setting.
|
||||
/// </summary>
|
||||
bool App::IsAnimationEnabled()
|
||||
{
|
||||
@@ -96,12 +95,12 @@ bool App::IsAnimationEnabled()
|
||||
|
||||
/// <summary>
|
||||
/// Return the current application view state. The value
|
||||
/// will match one of the constants in the ViewState namespace.
|
||||
/// will match one of the constants in the ViewState namespace.
|
||||
/// </summary>
|
||||
String^ App::GetAppViewState()
|
||||
String ^ App::GetAppViewState()
|
||||
{
|
||||
String^ newViewState;
|
||||
CoreWindow^ window = CoreWindow::GetForCurrentThread();
|
||||
String ^ newViewState;
|
||||
CoreWindow ^ window = CoreWindow::GetForCurrentThread();
|
||||
if ((window->Bounds.Width >= 560) && (window->Bounds.Height >= 356))
|
||||
{
|
||||
newViewState = ViewState::DockedView;
|
||||
@@ -114,14 +113,14 @@ String^ App::GetAppViewState()
|
||||
return newViewState;
|
||||
}
|
||||
|
||||
void App::AddWindowToMap(_In_ WindowFrameService^ frameService)
|
||||
void App::AddWindowToMap(_In_ WindowFrameService ^ frameService)
|
||||
{
|
||||
reader_writer_lock::scoped_lock lock(m_windowsMapLock);
|
||||
m_secondaryWindows[frameService->GetViewId()] = frameService;
|
||||
TraceLogger::GetInstance().UpdateWindowCount(m_secondaryWindows.size());
|
||||
}
|
||||
|
||||
WindowFrameService^ App::GetWindowFromMap(int viewId)
|
||||
WindowFrameService ^ App::GetWindowFromMap(int viewId)
|
||||
{
|
||||
reader_writer_lock::scoped_lock_read lock(m_windowsMapLock);
|
||||
auto windowMapEntry = m_secondaryWindows.find(viewId);
|
||||
@@ -140,30 +139,30 @@ void App::RemoveWindowFromMap(int viewId)
|
||||
m_secondaryWindows.erase(viewId);
|
||||
}
|
||||
|
||||
void App::RemoveWindow(_In_ WindowFrameService^ frameService)
|
||||
void App::RemoveWindow(_In_ WindowFrameService ^ frameService)
|
||||
{
|
||||
// Shell does not allow killing the main window.
|
||||
// Shell does not allow killing the main window.
|
||||
if (m_mainViewId != frameService->GetViewId())
|
||||
{
|
||||
HandleViewReleaseAndRemoveWindowFromMap(frameService);
|
||||
}
|
||||
}
|
||||
|
||||
task<void> App::HandleViewReleaseAndRemoveWindowFromMap(_In_ WindowFrameService^ frameService)
|
||||
task<void> App::HandleViewReleaseAndRemoveWindowFromMap(_In_ WindowFrameService ^ frameService)
|
||||
{
|
||||
WeakReference weak(this);
|
||||
|
||||
// Unregister the event handler of the Main Page
|
||||
auto frame = safe_cast<Frame^>(Window::Current->Content);
|
||||
auto mainPage = safe_cast<MainPage^>(frame->Content);
|
||||
auto frame = safe_cast<Frame ^>(Window::Current->Content);
|
||||
auto mainPage = safe_cast<MainPage ^>(frame->Content);
|
||||
mainPage->UnregisterEventHandlers();
|
||||
|
||||
return frameService->HandleViewRelease()
|
||||
.then([weak, frameService]()
|
||||
{
|
||||
auto that = weak.Resolve<App>();
|
||||
that->RemoveWindowFromMap(frameService->GetViewId());
|
||||
}, task_continuation_context::use_arbitrary());
|
||||
return frameService->HandleViewRelease().then(
|
||||
[weak, frameService]() {
|
||||
auto that = weak.Resolve<App>();
|
||||
that->RemoveWindowFromMap(frameService->GetViewId());
|
||||
},
|
||||
task_continuation_context::use_arbitrary());
|
||||
}
|
||||
|
||||
task<void> App::SetupJumpList()
|
||||
@@ -176,10 +175,10 @@ task<void> App::SetupJumpList()
|
||||
jumpList->SystemGroupKind = JumpListSystemGroupKind::None;
|
||||
jumpList->Items->Clear();
|
||||
|
||||
for (NavCategory^ option : calculatorOptions->Categories)
|
||||
for (NavCategory ^ option : calculatorOptions->Categories)
|
||||
{
|
||||
ViewMode mode = option->Mode;
|
||||
auto item = JumpListItem::CreateWithArguments(((int)mode).ToString(), L"ms-resource:///Resources/"+ NavCategory::GetNameResourceKey(mode));
|
||||
auto item = JumpListItem::CreateWithArguments(((int)mode).ToString(), L"ms-resource:///Resources/" + NavCategory::GetNameResourceKey(mode));
|
||||
item->Description = L"ms-resource:///Resources/" + NavCategory::GetNameResourceKey(mode);
|
||||
item->GroupName = L"ms-resource:///Resources/" + NavCategoryGroup::GetHeaderResourceKey(calculatorOptions->GroupType);
|
||||
item->Logo = ref new Uri("ms-appx:///Assets/" + mode.ToString() + ".png");
|
||||
@@ -189,10 +188,12 @@ task<void> App::SetupJumpList()
|
||||
|
||||
co_await jumpList->SaveAsync();
|
||||
}
|
||||
catch(...) {}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void App::RemoveSecondaryWindow(_In_ WindowFrameService^ frameService)
|
||||
void App::RemoveSecondaryWindow(_In_ WindowFrameService ^ frameService)
|
||||
{
|
||||
// Shell does not allow killing the main window.
|
||||
if (m_mainViewId != frameService->GetViewId())
|
||||
@@ -201,7 +202,7 @@ void App::RemoveSecondaryWindow(_In_ WindowFrameService^ frameService)
|
||||
}
|
||||
}
|
||||
|
||||
Frame^ App::CreateFrame()
|
||||
Frame ^ App::CreateFrame()
|
||||
{
|
||||
auto frame = ref new Frame();
|
||||
frame->FlowDirection = LocalizationService::GetInstance()->GetFlowDirection();
|
||||
@@ -215,7 +216,7 @@ Frame^ App::CreateFrame()
|
||||
/// search results, and so forth.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
void App::OnLaunched(LaunchActivatedEventArgs^ args)
|
||||
void App::OnLaunched(LaunchActivatedEventArgs ^ args)
|
||||
{
|
||||
TraceLogger::GetInstance().LogWindowLaunched();
|
||||
if (args->PrelaunchActivated)
|
||||
@@ -227,7 +228,7 @@ void App::OnLaunched(LaunchActivatedEventArgs^ args)
|
||||
OnAppLaunch(args, args->Arguments);
|
||||
}
|
||||
|
||||
void App::OnAppLaunch(IActivatedEventArgs^ args, String^ argument)
|
||||
void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
|
||||
{
|
||||
auto previousExecutionState = args->PreviousExecutionState;
|
||||
|
||||
@@ -244,17 +245,17 @@ void App::OnAppLaunch(IActivatedEventArgs^ args, String^ argument)
|
||||
auto userSettings = ref new Windows::UI::ViewManagement::UISettings();
|
||||
m_isAnimationEnabled = userSettings->AnimationsEnabled;
|
||||
|
||||
args->SplashScreen->Dismissed += ref new TypedEventHandler<SplashScreen^, Object^>(this, &App::DismissedEventHandler);
|
||||
args->SplashScreen->Dismissed += ref new TypedEventHandler<SplashScreen ^, Object ^>(this, &App::DismissedEventHandler);
|
||||
|
||||
auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
|
||||
auto rootFrame = dynamic_cast<Frame ^>(Window::Current->Content);
|
||||
WeakReference weak(this);
|
||||
|
||||
float minWindowWidth = static_cast<float>(static_cast<double>(this->Resources->Lookup(ApplicationResourceKeys::AppMinWindowWidth)));
|
||||
float minWindowHeight = static_cast<float>(static_cast<double>(this->Resources->Lookup(ApplicationResourceKeys::AppMinWindowHeight)));
|
||||
Size minWindowSize = SizeHelper::FromDimensions(minWindowWidth, minWindowHeight);
|
||||
|
||||
ApplicationView^ appView = ApplicationView::GetForCurrentView();
|
||||
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
|
||||
ApplicationView ^ appView = ApplicationView::GetForCurrentView();
|
||||
ApplicationDataContainer ^ localSettings = ApplicationData::Current->LocalSettings;
|
||||
// For very first launch, set the size of the calc as size of the default standard mode
|
||||
if (!localSettings->Values->HasKey(L"VeryFirstLaunch"))
|
||||
{
|
||||
@@ -271,17 +272,17 @@ void App::OnAppLaunch(IActivatedEventArgs^ args, String^ argument)
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == nullptr)
|
||||
{
|
||||
if (!Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) // PC Family
|
||||
if (!Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")) // PC Family
|
||||
{
|
||||
// Disable the system view activation policy during the first launch of the app
|
||||
// Disable the system view activation policy during the first launch of the app
|
||||
// only for PC family devices and not for phone family devices
|
||||
try
|
||||
{
|
||||
ApplicationViewSwitcher::DisableSystemViewActivationPolicy();
|
||||
}
|
||||
catch (Exception^ e)
|
||||
catch (Exception ^ e)
|
||||
{
|
||||
// Log that DisableSystemViewActionPolicy didn't work
|
||||
// Log that DisableSystemViewActionPolicy didn't work
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,76 +309,75 @@ void App::OnAppLaunch(IActivatedEventArgs^ args, String^ argument)
|
||||
TraceLogger::GetInstance().LogAppLaunchStart();
|
||||
|
||||
// !Phone check is required because even in continuum mode user interaction mode is Mouse not Touch
|
||||
if ((UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Mouse) && (!Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
|
||||
if ((UIViewSettings::GetForCurrentView()->UserInteractionMode == UserInteractionMode::Mouse)
|
||||
&& (!Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
|
||||
{
|
||||
// If the pre-launch hasn't happened then allow for the new window/view creation
|
||||
if (!m_preLaunched)
|
||||
{
|
||||
auto newCoreAppView = CoreApplication::CreateNewView();
|
||||
newCoreAppView->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([args, argument, minWindowSize, weak]()
|
||||
{
|
||||
TraceLogger::GetInstance().LogNewWindowCreationBegin(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
auto that = weak.Resolve<App>();
|
||||
if (that != nullptr)
|
||||
{
|
||||
auto rootFrame = App::CreateFrame();
|
||||
SetMinWindowSizeAndActivate(rootFrame, minWindowSize);
|
||||
|
||||
if (!rootFrame->Navigate(MainPage::typeid, argument))
|
||||
newCoreAppView->Dispatcher->RunAsync(
|
||||
CoreDispatcherPriority::Normal, ref new DispatchedHandler([args, argument, minWindowSize, weak]() {
|
||||
TraceLogger::GetInstance().LogNewWindowCreationBegin(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
auto that = weak.Resolve<App>();
|
||||
if (that != nullptr)
|
||||
{
|
||||
// We couldn't navigate to the main page, kill the app so we have a good
|
||||
// stack to debug
|
||||
throw std::bad_exception();
|
||||
}
|
||||
auto rootFrame = App::CreateFrame();
|
||||
SetMinWindowSizeAndActivate(rootFrame, minWindowSize);
|
||||
|
||||
auto frameService = WindowFrameService::CreateNewWindowFrameService(rootFrame, true, weak);
|
||||
that->AddWindowToMap(frameService);
|
||||
|
||||
auto dispatcher = CoreWindow::GetForCurrentThread()->Dispatcher;
|
||||
auto safeFrameServiceCreation = std::make_shared<SafeFrameWindowCreation>(frameService, that);
|
||||
int newWindowId = ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread());
|
||||
|
||||
ActivationViewSwitcher^ activationViewSwitcher;
|
||||
auto activateEventArgs = dynamic_cast<IViewSwitcherProvider^>(args);
|
||||
if (activateEventArgs != nullptr)
|
||||
{
|
||||
activationViewSwitcher = activateEventArgs->ViewSwitcher;
|
||||
}
|
||||
|
||||
if (activationViewSwitcher != nullptr)
|
||||
{
|
||||
activationViewSwitcher->ShowAsStandaloneAsync(newWindowId, ViewSizePreference::Default);
|
||||
safeFrameServiceCreation->SetOperationSuccess(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto activatedEventArgs = dynamic_cast<IApplicationViewActivatedEventArgs^>(args);
|
||||
if ((activatedEventArgs != nullptr) && (activatedEventArgs->CurrentlyShownApplicationViewId != 0))
|
||||
if (!rootFrame->Navigate(MainPage::typeid, argument))
|
||||
{
|
||||
create_task(ApplicationViewSwitcher::TryShowAsStandaloneAsync(
|
||||
frameService->GetViewId(),
|
||||
ViewSizePreference::Default,
|
||||
activatedEventArgs->CurrentlyShownApplicationViewId,
|
||||
ViewSizePreference::Default
|
||||
))
|
||||
.then([safeFrameServiceCreation](bool viewShown)
|
||||
// We couldn't navigate to the main page, kill the app so we have a good
|
||||
// stack to debug
|
||||
throw std::bad_exception();
|
||||
}
|
||||
|
||||
auto frameService = WindowFrameService::CreateNewWindowFrameService(rootFrame, true, weak);
|
||||
that->AddWindowToMap(frameService);
|
||||
|
||||
auto dispatcher = CoreWindow::GetForCurrentThread()->Dispatcher;
|
||||
auto safeFrameServiceCreation = std::make_shared<SafeFrameWindowCreation>(frameService, that);
|
||||
int newWindowId = ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread());
|
||||
|
||||
ActivationViewSwitcher ^ activationViewSwitcher;
|
||||
auto activateEventArgs = dynamic_cast<IViewSwitcherProvider ^>(args);
|
||||
if (activateEventArgs != nullptr)
|
||||
{
|
||||
activationViewSwitcher = activateEventArgs->ViewSwitcher;
|
||||
}
|
||||
|
||||
if (activationViewSwitcher != nullptr)
|
||||
{
|
||||
activationViewSwitcher->ShowAsStandaloneAsync(newWindowId, ViewSizePreference::Default);
|
||||
safeFrameServiceCreation->SetOperationSuccess(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto activatedEventArgs = dynamic_cast<IApplicationViewActivatedEventArgs ^>(args);
|
||||
if ((activatedEventArgs != nullptr) && (activatedEventArgs->CurrentlyShownApplicationViewId != 0))
|
||||
{
|
||||
// SafeFrameServiceCreation is used to automatically remove the frame
|
||||
// from the list of frames if something goes bad.
|
||||
safeFrameServiceCreation->SetOperationSuccess(viewShown);
|
||||
}, task_continuation_context::use_current());
|
||||
create_task(ApplicationViewSwitcher::TryShowAsStandaloneAsync(frameService->GetViewId(), ViewSizePreference::Default,
|
||||
activatedEventArgs->CurrentlyShownApplicationViewId,
|
||||
ViewSizePreference::Default))
|
||||
.then(
|
||||
[safeFrameServiceCreation](bool viewShown) {
|
||||
// SafeFrameServiceCreation is used to automatically remove the frame
|
||||
// from the list of frames if something goes bad.
|
||||
safeFrameServiceCreation->SetOperationSuccess(viewShown);
|
||||
},
|
||||
task_continuation_context::use_current());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TraceLogger::GetInstance().LogNewWindowCreationEnd(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}));
|
||||
TraceLogger::GetInstance().LogNewWindowCreationEnd(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
TraceLogger::GetInstance().LogNewWindowCreationBegin(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
|
||||
ActivationViewSwitcher^ activationViewSwitcher;
|
||||
auto activateEventArgs = dynamic_cast<IViewSwitcherProvider^>(args);
|
||||
ActivationViewSwitcher ^ activationViewSwitcher;
|
||||
auto activateEventArgs = dynamic_cast<IViewSwitcherProvider ^>(args);
|
||||
if (activateEventArgs != nullptr)
|
||||
{
|
||||
activationViewSwitcher = activateEventArgs->ViewSwitcher;
|
||||
@@ -385,7 +385,8 @@ void App::OnAppLaunch(IActivatedEventArgs^ args, String^ argument)
|
||||
|
||||
if (activationViewSwitcher != nullptr)
|
||||
{
|
||||
activationViewSwitcher->ShowAsStandaloneAsync(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), ViewSizePreference::Default);
|
||||
activationViewSwitcher->ShowAsStandaloneAsync(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()),
|
||||
ViewSizePreference::Default);
|
||||
TraceLogger::GetInstance().LogNewWindowCreationEnd(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
TraceLogger::GetInstance().LogPrelaunchedAppActivatedByUser();
|
||||
}
|
||||
@@ -406,23 +407,24 @@ void App::OnAppLaunch(IActivatedEventArgs^ args, String^ argument)
|
||||
// parameter
|
||||
if (!rootFrame->Navigate(MainPage::typeid, argument))
|
||||
{
|
||||
// We couldn't navigate to the main page,
|
||||
// We couldn't navigate to the main page,
|
||||
// kill the app so we have a good stack to debug
|
||||
throw std::bad_exception();
|
||||
}
|
||||
}
|
||||
if (!Windows::Foundation::Metadata::ApiInformation::IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
|
||||
{
|
||||
// for tablet mode: since system view activation policy is disabled so do ShowAsStandaloneAsync if activationViewSwitcher exists in activationArgs
|
||||
ActivationViewSwitcher^ activationViewSwitcher;
|
||||
auto activateEventArgs = dynamic_cast<IViewSwitcherProvider^>(args);
|
||||
// for tablet mode: since system view activation policy is disabled so do ShowAsStandaloneAsync if activationViewSwitcher exists in
|
||||
// activationArgs
|
||||
ActivationViewSwitcher ^ activationViewSwitcher;
|
||||
auto activateEventArgs = dynamic_cast<IViewSwitcherProvider ^>(args);
|
||||
if (activateEventArgs != nullptr)
|
||||
{
|
||||
activationViewSwitcher = activateEventArgs->ViewSwitcher;
|
||||
}
|
||||
if (activationViewSwitcher != nullptr)
|
||||
{
|
||||
auto viewId = safe_cast<IApplicationViewActivatedEventArgs^>(args)->CurrentlyShownApplicationViewId;
|
||||
auto viewId = safe_cast<IApplicationViewActivatedEventArgs ^>(args)->CurrentlyShownApplicationViewId;
|
||||
if (viewId != 0)
|
||||
{
|
||||
activationViewSwitcher->ShowAsStandaloneAsync(viewId);
|
||||
@@ -435,10 +437,10 @@ void App::OnAppLaunch(IActivatedEventArgs^ args, String^ argument)
|
||||
}
|
||||
}
|
||||
|
||||
void App::SetMinWindowSizeAndActivate(Frame^ rootFrame, Size minWindowSize)
|
||||
void App::SetMinWindowSizeAndActivate(Frame ^ rootFrame, Size minWindowSize)
|
||||
{
|
||||
// SetPreferredMinSize should always be called before Window::Activate
|
||||
ApplicationView^ appView = ApplicationView::GetForCurrentView();
|
||||
ApplicationView ^ appView = ApplicationView::GetForCurrentView();
|
||||
appView->SetPreferredMinSize(minWindowSize);
|
||||
|
||||
// Place the frame in the current Window
|
||||
@@ -451,7 +453,7 @@ void App::RegisterDependencyProperties()
|
||||
NarratorNotifier::RegisterDependencyProperties();
|
||||
}
|
||||
|
||||
void App::OnActivated(IActivatedEventArgs^ args)
|
||||
void App::OnActivated(IActivatedEventArgs ^ args)
|
||||
{
|
||||
if (args->Kind == ActivationKind::Protocol)
|
||||
{
|
||||
@@ -462,14 +464,13 @@ void App::OnActivated(IActivatedEventArgs^ args)
|
||||
}
|
||||
}
|
||||
|
||||
void App::DismissedEventHandler(SplashScreen^ sender, Object^ e)
|
||||
void App::DismissedEventHandler(SplashScreen ^ sender, Object ^ e)
|
||||
{
|
||||
SetupJumpList();
|
||||
}
|
||||
|
||||
float App::GetAppWindowHeight()
|
||||
{
|
||||
CoreWindow^ window = CoreWindow::GetForCurrentThread();
|
||||
CoreWindow ^ window = CoreWindow::GetForCurrentThread();
|
||||
return window->Bounds.Height;
|
||||
}
|
||||
|
||||
|
@@ -26,31 +26,28 @@ namespace CalculatorApp
|
||||
{
|
||||
public:
|
||||
App();
|
||||
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ args) override;
|
||||
virtual void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs^ args) override;
|
||||
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ args) override;
|
||||
virtual void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args) override;
|
||||
|
||||
internal:
|
||||
static bool IsAnimationEnabled();
|
||||
static Platform::String^ GetAppViewState();
|
||||
internal : static bool IsAnimationEnabled();
|
||||
static Platform::String ^ GetAppViewState();
|
||||
static float GetAppWindowHeight();
|
||||
void RemoveWindow(_In_ WindowFrameService^ frameService);
|
||||
void RemoveSecondaryWindow(_In_ WindowFrameService^ frameService);
|
||||
void RemoveWindow(_In_ WindowFrameService ^ frameService);
|
||||
void RemoveSecondaryWindow(_In_ WindowFrameService ^ frameService);
|
||||
|
||||
private:
|
||||
static Windows::UI::Xaml::Controls::Frame^ CreateFrame();
|
||||
static void SetMinWindowSizeAndActivate(Windows::UI::Xaml::Controls::Frame^ rootFrame, Windows::Foundation::Size minWindowSize);
|
||||
static Windows::UI::Xaml::Controls::Frame ^ CreateFrame();
|
||||
static void SetMinWindowSizeAndActivate(Windows::UI::Xaml::Controls::Frame ^ rootFrame, Windows::Foundation::Size minWindowSize);
|
||||
|
||||
void OnAppLaunch(Windows::ApplicationModel::Activation::IActivatedEventArgs^ args, Platform::String^ argument);
|
||||
void DismissedEventHandler(Windows::ApplicationModel::Activation::SplashScreen^ sender, Platform::Object^ e);
|
||||
void OnAppLaunch(Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args, Platform::String ^ argument);
|
||||
void DismissedEventHandler(Windows::ApplicationModel::Activation::SplashScreen ^ sender, Platform::Object ^ e);
|
||||
void RegisterDependencyProperties();
|
||||
|
||||
class SafeFrameWindowCreation final
|
||||
{
|
||||
public:
|
||||
SafeFrameWindowCreation(_In_ WindowFrameService^ frameService, App^ parent)
|
||||
: m_frameService(frameService)
|
||||
, m_frameOpenedInWindow(false)
|
||||
, m_parent(parent)
|
||||
SafeFrameWindowCreation(_In_ WindowFrameService ^ frameService, App ^ parent)
|
||||
: m_frameService(frameService), m_frameOpenedInWindow(false), m_parent(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -70,24 +67,24 @@ namespace CalculatorApp
|
||||
}
|
||||
|
||||
private:
|
||||
WindowFrameService^ m_frameService;
|
||||
WindowFrameService ^ m_frameService;
|
||||
bool m_frameOpenedInWindow;
|
||||
App^ m_parent;
|
||||
App ^ m_parent;
|
||||
};
|
||||
|
||||
private:
|
||||
concurrency::reader_writer_lock m_windowsMapLock;
|
||||
std::unordered_map<int, WindowFrameService^> m_secondaryWindows;
|
||||
std::unordered_map<int, WindowFrameService ^> m_secondaryWindows;
|
||||
|
||||
concurrency::task<void> SetupJumpList();
|
||||
concurrency::task<void> HandleViewReleaseAndRemoveWindowFromMap(_In_ WindowFrameService^ frameService);
|
||||
void AddWindowToMap(_In_ WindowFrameService^ frameService);
|
||||
WindowFrameService^ GetWindowFromMap(int viewId);
|
||||
concurrency::task<void> HandleViewReleaseAndRemoveWindowFromMap(_In_ WindowFrameService ^ frameService);
|
||||
void AddWindowToMap(_In_ WindowFrameService ^ frameService);
|
||||
WindowFrameService ^ GetWindowFromMap(int viewId);
|
||||
void RemoveWindowFromMap(int viewId);
|
||||
int m_mainViewId;
|
||||
bool m_preLaunched;
|
||||
|
||||
Windows::UI::Xaml::Controls::Primitives::Popup^ m_aboutPopup;
|
||||
Windows::UI::Xaml::Controls::Primitives::Popup ^ m_aboutPopup;
|
||||
|
||||
static bool m_isAnimationEnabled;
|
||||
};
|
||||
|
@@ -3,107 +3,102 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp { namespace Common
|
||||
namespace CalculatorApp
|
||||
{
|
||||
ref class AlwaysSelectedCollectionView sealed:
|
||||
public Windows::UI::Xaml::DependencyObject,
|
||||
public Windows::UI::Xaml::Data::ICollectionView
|
||||
namespace Common
|
||||
{
|
||||
internal:
|
||||
AlwaysSelectedCollectionView(Windows::UI::Xaml::Interop::IBindableVector^ source):
|
||||
m_currentPosition(-1)
|
||||
ref class AlwaysSelectedCollectionView sealed : public Windows::UI::Xaml::DependencyObject, public Windows::UI::Xaml::Data::ICollectionView
|
||||
{
|
||||
m_source = source;
|
||||
internal : AlwaysSelectedCollectionView(Windows::UI::Xaml::Interop::IBindableVector ^ source) : m_currentPosition(-1)
|
||||
{
|
||||
m_source = source;
|
||||
|
||||
Windows::UI::Xaml::Interop::IBindableObservableVector^ observable = dynamic_cast<Windows::UI::Xaml::Interop::IBindableObservableVector^>(source);
|
||||
if (observable)
|
||||
{
|
||||
observable->VectorChanged +=
|
||||
ref new Windows::UI::Xaml::Interop::BindableVectorChangedEventHandler(this, &AlwaysSelectedCollectionView::OnSourceBindableVectorChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
// ICollectionView
|
||||
// Not implemented methods
|
||||
virtual Windows::Foundation::IAsyncOperation<Windows::UI::Xaml::Data::LoadMoreItemsResult>^ LoadMoreItemsAsync(unsigned int) = Windows::UI::Xaml::Data::ICollectionView::LoadMoreItemsAsync
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual bool MoveCurrentToFirst() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToFirst
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual bool MoveCurrentToLast() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToLast
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual bool MoveCurrentToNext() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToNext
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual bool MoveCurrentToPrevious() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToPrevious
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
property Windows::Foundation::Collections::IObservableVector<Platform::Object^>^ CollectionGroups
|
||||
{
|
||||
virtual Windows::Foundation::Collections::IObservableVector<Platform::Object^>^ get() = Windows::UI::Xaml::Data::ICollectionView::CollectionGroups::get
|
||||
{
|
||||
return ref new Platform::Collections::Vector<Platform::Object^>();
|
||||
}
|
||||
}
|
||||
property bool HasMoreItems
|
||||
{
|
||||
virtual bool get() = Windows::UI::Xaml::Data::ICollectionView::HasMoreItems::get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Implementented methods
|
||||
virtual bool MoveCurrentTo(Platform::Object^ item) = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentTo
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
unsigned int newCurrentPosition = 0;
|
||||
bool result = m_source->IndexOf(item, &newCurrentPosition);
|
||||
if (result)
|
||||
Windows::UI::Xaml::Interop::IBindableObservableVector ^ observable =
|
||||
dynamic_cast<Windows::UI::Xaml::Interop::IBindableObservableVector ^>(source);
|
||||
if (observable)
|
||||
{
|
||||
m_currentPosition = newCurrentPosition;
|
||||
m_currentChanged(this, nullptr);
|
||||
return true;
|
||||
observable->VectorChanged += ref new Windows::UI::Xaml::Interop::BindableVectorChangedEventHandler(
|
||||
this, &AlwaysSelectedCollectionView::OnSourceBindableVectorChanged);
|
||||
}
|
||||
}
|
||||
|
||||
// The item is not in the collection
|
||||
// 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))
|
||||
private:
|
||||
// ICollectionView
|
||||
// Not implemented methods
|
||||
virtual Windows::Foundation::IAsyncOperation<
|
||||
Windows::UI::Xaml::Data::LoadMoreItemsResult> ^ LoadMoreItemsAsync(unsigned int) = Windows::UI::Xaml::Data::ICollectionView::LoadMoreItemsAsync
|
||||
{
|
||||
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal,
|
||||
ref new Windows::UI::Core::DispatchedHandler(
|
||||
[this]()
|
||||
{
|
||||
m_currentChanged(this, nullptr);
|
||||
}));
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool MoveCurrentToPosition(int index) = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToPosition
|
||||
{
|
||||
if (index < 0 || index >= static_cast<int>(m_source->Size))
|
||||
virtual bool MoveCurrentToFirst() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToFirst
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual bool MoveCurrentToLast() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToLast
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual bool MoveCurrentToNext() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToNext
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual bool MoveCurrentToPrevious() = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToPrevious
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
property Windows::Foundation::Collections::IObservableVector<Platform::Object ^> ^ CollectionGroups {
|
||||
virtual Windows::Foundation::Collections::IObservableVector<Platform::Object
|
||||
^> ^ get() = Windows::UI::Xaml::Data::ICollectionView::CollectionGroups::get
|
||||
{
|
||||
return ref new Platform::Collections::Vector<Platform::Object ^>();
|
||||
}
|
||||
} property bool HasMoreItems
|
||||
{
|
||||
virtual bool get() = Windows::UI::Xaml::Data::ICollectionView::HasMoreItems::get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Implementented methods
|
||||
virtual bool MoveCurrentTo(Platform::Object ^ item) = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentTo
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
unsigned int newCurrentPosition = 0;
|
||||
bool result = m_source->IndexOf(item, &newCurrentPosition);
|
||||
if (result)
|
||||
{
|
||||
m_currentPosition = newCurrentPosition;
|
||||
m_currentChanged(this, nullptr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// The item is not in the collection
|
||||
// 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))
|
||||
{
|
||||
this->Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal,
|
||||
ref new Windows::UI::Core::DispatchedHandler([this]() { m_currentChanged(this, nullptr); }));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
m_currentPosition = index;
|
||||
m_currentChanged(this, nullptr);
|
||||
return true;
|
||||
}
|
||||
virtual bool MoveCurrentToPosition(int index) = Windows::UI::Xaml::Data::ICollectionView::MoveCurrentToPosition
|
||||
{
|
||||
if (index < 0 || index >= static_cast<int>(m_source->Size))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
property Platform::Object^ CurrentItem
|
||||
m_currentPosition = index;
|
||||
m_currentChanged(this, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
property Platform::Object^ CurrentItem
|
||||
{
|
||||
virtual Platform::Object^ get() = Windows::UI::Xaml::Data::ICollectionView::CurrentItem::get
|
||||
{
|
||||
@@ -116,30 +111,30 @@ namespace CalculatorApp { namespace Common
|
||||
}
|
||||
|
||||
property int CurrentPosition
|
||||
{
|
||||
virtual int get() = Windows::UI::Xaml::Data::ICollectionView::CurrentPosition::get
|
||||
{
|
||||
return m_currentPosition;
|
||||
virtual int get() = Windows::UI::Xaml::Data::ICollectionView::CurrentPosition::get
|
||||
{
|
||||
return m_currentPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property bool IsCurrentAfterLast
|
||||
{
|
||||
virtual bool get() = Windows::UI::Xaml::Data::ICollectionView::IsCurrentAfterLast::get
|
||||
property bool IsCurrentAfterLast
|
||||
{
|
||||
return m_currentPosition >= static_cast<int>(m_source->Size);
|
||||
virtual bool get() = Windows::UI::Xaml::Data::ICollectionView::IsCurrentAfterLast::get
|
||||
{
|
||||
return m_currentPosition >= static_cast<int>(m_source->Size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
property bool IsCurrentBeforeFirst
|
||||
{
|
||||
virtual bool get() = Windows::UI::Xaml::Data::ICollectionView::IsCurrentBeforeFirst::get
|
||||
property bool IsCurrentBeforeFirst
|
||||
{
|
||||
return m_currentPosition < 0;
|
||||
virtual bool get() = Windows::UI::Xaml::Data::ICollectionView::IsCurrentBeforeFirst::get
|
||||
{
|
||||
return m_currentPosition < 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
event Windows::Foundation::EventHandler<Platform::Object^>^ CurrentChanged
|
||||
event Windows::Foundation::EventHandler<Platform::Object^>^ CurrentChanged
|
||||
{
|
||||
virtual Windows::Foundation::EventRegistrationToken add(Windows::Foundation::EventHandler<Platform::Object^>^ handler) = Windows::UI::Xaml::Data::ICollectionView::CurrentChanged::add
|
||||
{
|
||||
@@ -165,63 +160,67 @@ namespace CalculatorApp { namespace Common
|
||||
// IVector<Object^>
|
||||
// Not implemented methods
|
||||
virtual void Append(Platform::Object^ /*item*/) = Windows::Foundation::Collections::IVector<Platform::Object^>::Append
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void Clear() = Windows::Foundation::Collections::IVector<Platform::Object^>::Clear
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual unsigned int GetMany(unsigned int /*startIndex*/, Platform::WriteOnlyArray<Platform::Object^>^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object^>::GetMany
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual Windows::Foundation::Collections::IVectorView<Platform::Object^>^ GetView() = Windows::Foundation::Collections::IVector<Platform::Object^>::GetView
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void InsertAt(unsigned int /*index*/, Platform::Object^ /*item*/) = Windows::Foundation::Collections::IVector<Platform::Object^>::InsertAt
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void RemoveAt(unsigned int /*index*/) = Windows::Foundation::Collections::IVector<Platform::Object^>::RemoveAt
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void RemoveAtEnd() = Windows::Foundation::Collections::IVector<Platform::Object^>::RemoveAtEnd
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void ReplaceAll(const Platform::Array<Platform::Object^>^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object^>::ReplaceAll
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void SetAt(unsigned int /*index*/, Platform::Object^ /*item*/) = Windows::Foundation::Collections::IVector<Platform::Object^>::SetAt
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
|
||||
// Implemented methods
|
||||
virtual Platform::Object^ GetAt(unsigned int index) = Windows::Foundation::Collections::IVector<Platform::Object^>::GetAt
|
||||
{
|
||||
return m_source->GetAt(index);
|
||||
}
|
||||
|
||||
virtual bool IndexOf(Platform::Object^ item, unsigned int* index) = Windows::Foundation::Collections::IVector<Platform::Object^>::IndexOf
|
||||
{
|
||||
return m_source->IndexOf(item, index);
|
||||
}
|
||||
|
||||
property unsigned int Size
|
||||
{
|
||||
virtual unsigned int get() = Windows::Foundation::Collections::IVector<Platform::Object^>::Size::get
|
||||
{
|
||||
return m_source->Size;
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void Clear() = Windows::Foundation::Collections::IVector<Platform::Object ^>::Clear
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual unsigned int
|
||||
GetMany(unsigned int /*startIndex*/,
|
||||
Platform::WriteOnlyArray<Platform::Object ^> ^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::GetMany
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual Windows::Foundation::Collections::IVectorView<Platform::Object ^> ^ GetView() = Windows::Foundation::Collections::IVector<Platform::Object
|
||||
^>::GetView
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void InsertAt(unsigned int /*index*/, Platform::Object ^ /*item*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::InsertAt
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void RemoveAt(unsigned int /*index*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::RemoveAt
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void RemoveAtEnd() = Windows::Foundation::Collections::IVector<Platform::Object ^>::RemoveAtEnd
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void
|
||||
ReplaceAll(const Platform::Array<Platform::Object ^> ^ /*items*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::ReplaceAll
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
virtual void SetAt(unsigned int /*index*/, Platform::Object ^ /*item*/) = Windows::Foundation::Collections::IVector<Platform::Object ^>::SetAt
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
// IObservableVector<Object^>
|
||||
event Windows::Foundation::Collections::VectorChangedEventHandler<Platform::Object^>^ VectorChanged
|
||||
// Implemented methods
|
||||
virtual Platform::Object ^ GetAt(unsigned int index) = Windows::Foundation::Collections::IVector<Platform::Object ^>::GetAt
|
||||
{
|
||||
return m_source->GetAt(index);
|
||||
}
|
||||
|
||||
virtual bool IndexOf(Platform::Object ^ item, unsigned int* index) = Windows::Foundation::Collections::IVector<Platform::Object ^>::IndexOf
|
||||
{
|
||||
return m_source->IndexOf(item, index);
|
||||
}
|
||||
|
||||
property unsigned int Size
|
||||
{
|
||||
virtual unsigned int get() = Windows::Foundation::Collections::IVector<Platform::Object ^>::Size::get
|
||||
{
|
||||
return m_source->Size;
|
||||
}
|
||||
}
|
||||
|
||||
// IObservableVector<Object^>
|
||||
event Windows::Foundation::Collections::VectorChangedEventHandler<Platform::Object^>^ VectorChanged
|
||||
{
|
||||
virtual Windows::Foundation::EventRegistrationToken add(Windows::Foundation::Collections::VectorChangedEventHandler<Platform::Object^>^ handler) = Windows::Foundation::Collections::IObservableVector<Platform::Object^>::VectorChanged::add
|
||||
{
|
||||
@@ -236,52 +235,51 @@ namespace CalculatorApp { namespace Common
|
||||
// IIterable<Object^>
|
||||
// Not implemented
|
||||
virtual Windows::Foundation::Collections::IIterator<Platform::Object^>^ First() = Windows::Foundation::Collections::IIterable<Platform::Object^>::First
|
||||
{
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
|
||||
// Event handlers
|
||||
void OnSourceBindableVectorChanged(Windows::UI::Xaml::Interop::IBindableObservableVector^ source, Platform::Object^ e)
|
||||
{
|
||||
Windows::Foundation::Collections::IVectorChangedEventArgs^ args = safe_cast<Windows::Foundation::Collections::IVectorChangedEventArgs^>(e);
|
||||
m_vectorChanged(this, args);
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Interop::IBindableVector^ m_source;
|
||||
int m_currentPosition;
|
||||
event Windows::Foundation::EventHandler<Platform::Object^>^ m_currentChanged;
|
||||
event Windows::UI::Xaml::Data::CurrentChangingEventHandler^ m_currentChanging;
|
||||
event Windows::Foundation::Collections::VectorChangedEventHandler<Platform::Object^>^ m_vectorChanged;
|
||||
};
|
||||
|
||||
public ref class AlwaysSelectedCollectionViewConverter sealed: public Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
AlwaysSelectedCollectionViewConverter()
|
||||
{ }
|
||||
|
||||
private:
|
||||
virtual Platform::Object^ Convert(
|
||||
Platform::Object^ value,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
Platform::String^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert
|
||||
{
|
||||
auto result = dynamic_cast<Windows::UI::Xaml::Interop::IBindableVector^>(value);
|
||||
if (result)
|
||||
{
|
||||
return ref new AlwaysSelectedCollectionView(result);
|
||||
throw ref new Platform::NotImplementedException();
|
||||
}
|
||||
return Windows::UI::Xaml::DependencyProperty::UnsetValue; // Can't convert
|
||||
}
|
||||
|
||||
virtual Platform::Object^ ConvertBack(
|
||||
Platform::Object^ /*value*/,
|
||||
Windows::UI::Xaml::Interop::TypeName /*targetType*/,
|
||||
Platform::Object^ /*parameter*/,
|
||||
Platform::String^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack
|
||||
// Event handlers
|
||||
void OnSourceBindableVectorChanged(Windows::UI::Xaml::Interop::IBindableObservableVector ^ source, Platform::Object ^ e)
|
||||
{
|
||||
Windows::Foundation::Collections::IVectorChangedEventArgs ^ args = safe_cast<Windows::Foundation::Collections::IVectorChangedEventArgs ^>(e);
|
||||
m_vectorChanged(this, args);
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::Interop::IBindableVector ^ m_source;
|
||||
int m_currentPosition;
|
||||
event Windows::Foundation::EventHandler<Platform::Object ^> ^ m_currentChanged;
|
||||
event Windows::UI::Xaml::Data::CurrentChangingEventHandler ^ m_currentChanging;
|
||||
event Windows::Foundation::Collections::VectorChangedEventHandler<Platform::Object ^> ^ m_vectorChanged;
|
||||
};
|
||||
|
||||
public
|
||||
ref class AlwaysSelectedCollectionViewConverter sealed : public Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
return Windows::UI::Xaml::DependencyProperty::UnsetValue;
|
||||
}
|
||||
};
|
||||
}}
|
||||
public:
|
||||
AlwaysSelectedCollectionViewConverter()
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/,
|
||||
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::Convert
|
||||
{
|
||||
auto result = dynamic_cast<Windows::UI::Xaml::Interop::IBindableVector ^>(value);
|
||||
if (result)
|
||||
{
|
||||
return ref new AlwaysSelectedCollectionView(result);
|
||||
}
|
||||
return Windows::UI::Xaml::DependencyProperty::UnsetValue; // Can't convert
|
||||
}
|
||||
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ /*value*/, Windows::UI::Xaml::Interop::TypeName /*targetType*/, Platform::Object ^ /*parameter*/,
|
||||
Platform::String ^ /*language*/) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack
|
||||
{
|
||||
return Windows::UI::Xaml::DependencyProperty::UnsetValue;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,13 @@ using namespace winrt::Windows::UI::ViewManagement;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
||||
#ifdef SEND_TELEMETRY
|
||||
// c.f. WINEVENT_KEYWORD_RESERVED_63-56 0xFF00000000000000 // Bits 63-56 - channel keywords
|
||||
// c.f. WINEVENT_KEYWORD_* 0x00FF000000000000 // Bits 55-48 - system-reserved keywords
|
||||
constexpr int64_t MICROSOFT_KEYWORD_CRITICAL_DATA = 0x0000800000000000; // Bit 47
|
||||
constexpr int64_t MICROSOFT_KEYWORD_MEASURES = 0x0000400000000000; // Bit 46
|
||||
constexpr int64_t MICROSOFT_KEYWORD_TELEMETRY = 0x0000200000000000; // Bit 45
|
||||
constexpr int64_t MICROSOFT_KEYWORD_RESERVED_44 = 0x0000100000000000; // Bit 44 (reserved for future assignment)
|
||||
constexpr int64_t MICROSOFT_KEYWORD_MEASURES = 0x0000400000000000; // Bit 46
|
||||
constexpr int64_t MICROSOFT_KEYWORD_TELEMETRY = 0x0000200000000000; // Bit 45
|
||||
constexpr int64_t MICROSOFT_KEYWORD_RESERVED_44 = 0x0000100000000000; // Bit 44 (reserved for future assignment)
|
||||
#else
|
||||
// define all Keyword options as 0 when we do not want to upload app telemetry
|
||||
constexpr int64_t MICROSOFT_KEYWORD_CRITICAL_DATA = 0;
|
||||
@@ -33,8 +32,8 @@ namespace CalculatorApp
|
||||
|
||||
#pragma region TraceLogger setup and cleanup
|
||||
|
||||
AppLifecycleLogger::AppLifecycleLogger() :
|
||||
m_appLifecycleProvider(
|
||||
AppLifecycleLogger::AppLifecycleLogger()
|
||||
: m_appLifecycleProvider(
|
||||
L"Microsoft.Windows.AppLifeCycle",
|
||||
LoggingChannelOptions(GUID{ 0x4f50731a, 0x89cf, 0x4782, 0xb3, 0xe0, 0xdc, 0xe8, 0xc9, 0x4, 0x76, 0xba }), // Microsoft Telemetry group
|
||||
GUID{ 0xef00584a, 0x2655, 0x462c, 0xbc, 0x24, 0xe7, 0xde, 0x63, 0xe, 0x7f, 0xbf }) // Unique provider ID {EF00584A-2655-462C-BC24-E7DE630E7FBF}
|
||||
@@ -59,13 +58,15 @@ namespace CalculatorApp
|
||||
#pragma region Tracing methods
|
||||
void AppLifecycleLogger::LogAppLifecycleEvent(hstring const& eventName, LoggingFields const& fields) const
|
||||
{
|
||||
m_appLifecycleProvider.LogEvent(eventName, fields, LoggingLevel::Information, LoggingOptions(MICROSOFT_KEYWORD_TELEMETRY | WINEVENT_KEYWORD_RESPONSE_TIME));
|
||||
m_appLifecycleProvider.LogEvent(eventName, fields, LoggingLevel::Information,
|
||||
LoggingOptions(MICROSOFT_KEYWORD_TELEMETRY | WINEVENT_KEYWORD_RESPONSE_TIME));
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
void AppLifecycleLogger::LaunchUIResponsive() const
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
if (!GetTraceLoggingProviderEnabled())
|
||||
return;
|
||||
|
||||
LoggingFields fields{};
|
||||
PopulateAppInfo(fields);
|
||||
@@ -74,7 +75,8 @@ namespace CalculatorApp
|
||||
|
||||
void AppLifecycleLogger::LaunchVisibleComplete() const
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
if (!GetTraceLoggingProviderEnabled())
|
||||
return;
|
||||
|
||||
LoggingFields fields{};
|
||||
PopulateAppInfo(fields);
|
||||
@@ -83,7 +85,8 @@ namespace CalculatorApp
|
||||
|
||||
void AppLifecycleLogger::ResumeUIResponsive() const
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
if (!GetTraceLoggingProviderEnabled())
|
||||
return;
|
||||
|
||||
LoggingFields fields{};
|
||||
PopulateAppInfo(fields);
|
||||
@@ -92,7 +95,8 @@ namespace CalculatorApp
|
||||
|
||||
void AppLifecycleLogger::ResumeVisibleComplete() const
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
if (!GetTraceLoggingProviderEnabled())
|
||||
return;
|
||||
|
||||
LoggingFields fields{};
|
||||
PopulateAppInfo(fields);
|
||||
@@ -106,7 +110,8 @@ namespace CalculatorApp
|
||||
|
||||
void AppLifecycleLogger::ResizeUIResponsive(int32_t viewId) const
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
if (!GetTraceLoggingProviderEnabled())
|
||||
return;
|
||||
|
||||
LoggingFields fields{};
|
||||
PopulateAppInfo(fields);
|
||||
@@ -121,7 +126,8 @@ namespace CalculatorApp
|
||||
|
||||
void AppLifecycleLogger::ResizeVisibleComplete(int32_t viewId) const
|
||||
{
|
||||
if (!GetTraceLoggingProviderEnabled()) return;
|
||||
if (!GetTraceLoggingProviderEnabled())
|
||||
return;
|
||||
|
||||
LoggingFields fields{};
|
||||
PopulateAppInfo(fields);
|
||||
@@ -141,6 +147,3 @@ namespace CalculatorApp
|
||||
fields.AddString(L"PsmKey", psmKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@@ -9,7 +9,7 @@ namespace CalculatorApp
|
||||
{
|
||||
public:
|
||||
AppLifecycleLogger(AppLifecycleLogger const&) = delete;
|
||||
AppLifecycleLogger const & operator= (AppLifecycleLogger const&) = delete;
|
||||
AppLifecycleLogger const& operator=(AppLifecycleLogger const&) = delete;
|
||||
~AppLifecycleLogger();
|
||||
static AppLifecycleLogger& GetInstance();
|
||||
bool GetTraceLoggingProviderEnabled() const;
|
||||
@@ -29,10 +29,10 @@ namespace CalculatorApp
|
||||
AppLifecycleLogger();
|
||||
|
||||
// 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
|
||||
// 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
|
||||
// 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 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 LogAppLifecycleEvent(winrt::hstring const& eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields const& fields) const;
|
||||
void PopulateAppInfo(winrt::Windows::Foundation::Diagnostics::LoggingFields& fields) const;
|
||||
|
||||
|
@@ -13,22 +13,22 @@ using namespace Windows::UI::Xaml::Data;
|
||||
/// 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)
|
||||
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();
|
||||
}
|
||||
|
@@ -10,26 +10,29 @@ namespace CalculatorApp
|
||||
/// <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
|
||||
[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;
|
||||
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();
|
||||
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(); }
|
||||
virtual Windows::UI::Xaml::Interop::TypeName get()
|
||||
{
|
||||
return this->GetType();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
virtual void OnPropertyChanged(Platform::String^ propertyName);
|
||||
virtual void OnPropertyChanged(Platform::String ^ propertyName);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -50,13 +50,11 @@ DEPENDENCY_PROPERTY_INITIALIZATION(CalculationResult, DisplayStringExpression);
|
||||
StringReference CalculationResult::s_FocusedState(L"Focused");
|
||||
StringReference CalculationResult::s_UnfocusedState(L"Unfocused");
|
||||
|
||||
CalculationResult::CalculationResult():
|
||||
m_isScalingText(false),
|
||||
m_haveCalculatedMax(false)
|
||||
CalculationResult::CalculationResult() : m_isScalingText(false), m_haveCalculatedMax(false)
|
||||
{
|
||||
}
|
||||
|
||||
Platform::String^ CalculationResult::GetRawDisplayValue()
|
||||
Platform::String ^ CalculationResult::GetRawDisplayValue()
|
||||
{
|
||||
std::wstring rawValue;
|
||||
|
||||
@@ -72,18 +70,19 @@ void CalculationResult::OnApplyTemplate()
|
||||
{
|
||||
m_textContainer->LayoutUpdated -= m_textContainerLayoutChangedToken;
|
||||
}
|
||||
m_textContainer = dynamic_cast<ScrollViewer^>(GetTemplateChild("TextContainer"));
|
||||
m_textContainer = dynamic_cast<ScrollViewer ^>(GetTemplateChild("TextContainer"));
|
||||
if (m_textContainer)
|
||||
{
|
||||
m_textContainer->SizeChanged += ref new SizeChangedEventHandler(this, &CalculationResult::TextContainerSizeChanged);
|
||||
// We want to know when the size of the container changes so
|
||||
// we can rescale the textbox
|
||||
m_textContainerLayoutChangedToken = m_textContainer->LayoutUpdated += ref new EventHandler<Object^>(this, &CalculationResult::OnTextContainerLayoutUpdated);
|
||||
m_textContainerLayoutChangedToken = m_textContainer->LayoutUpdated +=
|
||||
ref new EventHandler<Object ^>(this, &CalculationResult::OnTextContainerLayoutUpdated);
|
||||
|
||||
m_textContainer->ChangeView(m_textContainer->ExtentWidth - m_textContainer->ViewportWidth,nullptr,nullptr);
|
||||
m_scrollLeft = dynamic_cast<HyperlinkButton^>(GetTemplateChild("ScrollLeft"));
|
||||
m_scrollRight = dynamic_cast<HyperlinkButton^>(GetTemplateChild("ScrollRight"));
|
||||
auto borderContainer = dynamic_cast<UIElement^>(GetTemplateChild("Border"));
|
||||
m_textContainer->ChangeView(m_textContainer->ExtentWidth - m_textContainer->ViewportWidth, nullptr, nullptr);
|
||||
m_scrollLeft = dynamic_cast<HyperlinkButton ^>(GetTemplateChild("ScrollLeft"));
|
||||
m_scrollRight = dynamic_cast<HyperlinkButton ^>(GetTemplateChild("ScrollRight"));
|
||||
auto borderContainer = dynamic_cast<UIElement ^>(GetTemplateChild("Border"));
|
||||
if (m_scrollLeft && m_scrollRight)
|
||||
{
|
||||
m_scrollLeft->Click += ref new RoutedEventHandler(this, &CalculationResult::OnScrollClick);
|
||||
@@ -91,7 +90,7 @@ void CalculationResult::OnApplyTemplate()
|
||||
borderContainer->PointerEntered += ref new PointerEventHandler(this, &CalculationResult::OnPointerEntered);
|
||||
borderContainer->PointerExited += ref new PointerEventHandler(this, &CalculationResult::OnPointerExited);
|
||||
}
|
||||
m_textBlock = dynamic_cast<TextBlock^>(m_textContainer->FindName("NormalOutput"));
|
||||
m_textBlock = dynamic_cast<TextBlock ^>(m_textContainer->FindName("NormalOutput"));
|
||||
if (m_textBlock)
|
||||
{
|
||||
m_textBlock->Visibility = ::Visibility::Visible;
|
||||
@@ -101,7 +100,7 @@ void CalculationResult::OnApplyTemplate()
|
||||
VisualStateManager::GoToState(this, s_UnfocusedState, false);
|
||||
}
|
||||
|
||||
void CalculationResult::OnPointerPressed(PointerRoutedEventArgs^ e)
|
||||
void CalculationResult::OnPointerPressed(PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_scrollLeft && m_scrollRight && e->Pointer->PointerDeviceType == PointerDeviceType::Touch)
|
||||
{
|
||||
@@ -109,7 +108,7 @@ void CalculationResult::OnPointerPressed(PointerRoutedEventArgs^ e)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnTextContainerLayoutUpdated(Object^ /*sender*/, Object^ /*e*/)
|
||||
void CalculationResult::OnTextContainerLayoutUpdated(Object ^ /*sender*/, Object ^ /*e*/)
|
||||
{
|
||||
if (m_isScalingText)
|
||||
{
|
||||
@@ -117,7 +116,7 @@ void CalculationResult::OnTextContainerLayoutUpdated(Object^ /*sender*/, Object^
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::TextContainerSizeChanged(Object^ /*sender*/, SizeChangedEventArgs^ /*e*/)
|
||||
void CalculationResult::TextContainerSizeChanged(Object ^ /*sender*/, SizeChangedEventArgs ^ /*e*/)
|
||||
{
|
||||
UpdateTextState();
|
||||
}
|
||||
@@ -127,7 +126,7 @@ void CalculationResult::OnIsActivePropertyChanged(bool /*oldValue*/, bool /*newV
|
||||
UpdateVisualState();
|
||||
}
|
||||
|
||||
void CalculationResult::OnAccentColorPropertyChanged(Brush^ /*oldValue*/, Brush^ /*newValue*/)
|
||||
void CalculationResult::OnAccentColorPropertyChanged(Brush ^ /*oldValue*/, Brush ^ /*newValue*/)
|
||||
{
|
||||
// Force the "Active" transition to happen again
|
||||
if (IsActive)
|
||||
@@ -137,7 +136,7 @@ void CalculationResult::OnAccentColorPropertyChanged(Brush^ /*oldValue*/, Brush^
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnDisplayValuePropertyChanged(String^ /*oldValue*/, String^ /*newValue*/)
|
||||
void CalculationResult::OnDisplayValuePropertyChanged(String ^ /*oldValue*/, String ^ /*newValue*/)
|
||||
{
|
||||
UpdateTextState();
|
||||
}
|
||||
@@ -198,8 +197,8 @@ void CalculationResult::UpdateTextState()
|
||||
}
|
||||
|
||||
auto containerSize = m_textContainer->ActualWidth;
|
||||
String^ oldText = m_textBlock->Text;
|
||||
String^ newText = Utils::LRO + DisplayValue + Utils::PDF;
|
||||
String ^ oldText = m_textBlock->Text;
|
||||
String ^ newText = Utils::LRO + DisplayValue + Utils::PDF;
|
||||
|
||||
// Initiate the scaling operation
|
||||
// UpdateLayout will keep calling us until we make it through the below 2 if-statements
|
||||
@@ -241,11 +240,11 @@ void CalculationResult::UpdateTextState()
|
||||
m_isScalingText = false;
|
||||
if (IsOperatorCommand)
|
||||
{
|
||||
m_textContainer->ChangeView(0.0,nullptr,nullptr);
|
||||
m_textContainer->ChangeView(0.0, nullptr, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_textContainer->ChangeView(m_textContainer->ExtentWidth - m_textContainer->ViewportWidth,nullptr,nullptr);
|
||||
m_textContainer->ChangeView(m_textContainer->ExtentWidth - m_textContainer->ViewportWidth, nullptr, nullptr);
|
||||
}
|
||||
|
||||
if (m_scrollLeft && m_scrollRight)
|
||||
@@ -292,7 +291,7 @@ void CalculationResult::ScrollRight()
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnKeyDown(KeyRoutedEventArgs^ e)
|
||||
void CalculationResult::OnKeyDown(KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_scrollLeft != nullptr && m_scrollRight != nullptr)
|
||||
{
|
||||
@@ -308,9 +307,9 @@ void CalculationResult::OnKeyDown(KeyRoutedEventArgs^ e)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnScrollClick(Object^ sender, RoutedEventArgs^ /*e*/)
|
||||
void CalculationResult::OnScrollClick(Object ^ sender, RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
auto clicked = dynamic_cast<HyperlinkButton^>(sender);
|
||||
auto clicked = dynamic_cast<HyperlinkButton ^>(sender);
|
||||
if (clicked == m_scrollLeft)
|
||||
{
|
||||
this->ScrollLeft();
|
||||
@@ -321,7 +320,7 @@ void CalculationResult::OnScrollClick(Object^ sender, RoutedEventArgs^ /*e*/)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnPointerEntered(Platform::Object^ sender, PointerRoutedEventArgs^ e)
|
||||
void CalculationResult::OnPointerEntered(Platform::Object ^ sender, PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse && m_textBlock->ActualWidth >= m_textContainer->ActualWidth)
|
||||
{
|
||||
@@ -358,7 +357,7 @@ void CalculationResult::UpdateScrollButtons()
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnPointerExited(Platform::Object^ sender, PointerRoutedEventArgs^ e)
|
||||
void CalculationResult::OnPointerExited(Platform::Object ^ sender, PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
if (e->Pointer->PointerDeviceType == PointerDeviceType::Mouse)
|
||||
{
|
||||
@@ -366,7 +365,7 @@ void CalculationResult::OnPointerExited(Platform::Object^ sender, PointerRoutedE
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::ModifyFontAndMargin(TextBlock^ textBox, double fontChange)
|
||||
void CalculationResult::ModifyFontAndMargin(TextBlock ^ textBox, double fontChange)
|
||||
{
|
||||
double cur = textBox->FontSize;
|
||||
double newFontSize = 0.0;
|
||||
@@ -387,18 +386,18 @@ void CalculationResult::UpdateAllState()
|
||||
UpdateTextState();
|
||||
}
|
||||
|
||||
void CalculationResult::OnTapped(TappedRoutedEventArgs^ e)
|
||||
void CalculationResult::OnTapped(TappedRoutedEventArgs ^ e)
|
||||
{
|
||||
this->Focus(::FocusState::Programmatic);
|
||||
RaiseSelectedEvent();
|
||||
}
|
||||
|
||||
void CalculationResult::OnRightTapped(RightTappedRoutedEventArgs^ e)
|
||||
void CalculationResult::OnRightTapped(RightTappedRoutedEventArgs ^ e)
|
||||
{
|
||||
this->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void CalculationResult::OnGotFocus(RoutedEventArgs^ e)
|
||||
void CalculationResult::OnGotFocus(RoutedEventArgs ^ e)
|
||||
{
|
||||
if (this->FocusState == ::FocusState::Keyboard)
|
||||
{
|
||||
@@ -406,12 +405,12 @@ void CalculationResult::OnGotFocus(RoutedEventArgs^ e)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculationResult::OnLostFocus(RoutedEventArgs^ e)
|
||||
void CalculationResult::OnLostFocus(RoutedEventArgs ^ e)
|
||||
{
|
||||
VisualStateManager::GoToState(this, s_UnfocusedState, true);
|
||||
}
|
||||
|
||||
AutomationPeer^ CalculationResult::OnCreateAutomationPeer()
|
||||
AutomationPeer ^ CalculationResult::OnCreateAutomationPeer()
|
||||
{
|
||||
return ref new CalculationResultAutomationPeer(this);
|
||||
}
|
||||
|
@@ -9,9 +9,11 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public delegate void SelectedEventHandler(Platform::Object^ sender);
|
||||
public
|
||||
delegate void SelectedEventHandler(Platform::Object ^ sender);
|
||||
|
||||
public ref class CalculationResult sealed: public Windows::UI::Xaml::Controls::Control
|
||||
public
|
||||
ref class CalculationResult sealed : public Windows::UI::Xaml::Controls::Control
|
||||
{
|
||||
public:
|
||||
CalculationResult();
|
||||
@@ -24,45 +26,44 @@ namespace CalculatorApp
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Thickness, DisplayMargin);
|
||||
DEPENDENCY_PROPERTY(int, MaxExpressionHistoryCharacters);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsActive);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::Media::Brush^, AccentColor);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String^, DisplayValue);
|
||||
DEPENDENCY_PROPERTY(Platform::String^, DisplayStringExpression);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::Media::Brush ^, AccentColor);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String ^, DisplayValue);
|
||||
DEPENDENCY_PROPERTY(Platform::String ^, DisplayStringExpression);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsInError);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsOperatorCommand, false);
|
||||
|
||||
event SelectedEventHandler^ Selected;
|
||||
event SelectedEventHandler ^ Selected;
|
||||
void ProgrammaticSelect();
|
||||
|
||||
internal:
|
||||
void UpdateTextState();
|
||||
Platform::String^ GetRawDisplayValue();
|
||||
internal : void UpdateTextState();
|
||||
Platform::String ^ GetRawDisplayValue();
|
||||
|
||||
protected:
|
||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
|
||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
|
||||
virtual void OnApplyTemplate() override;
|
||||
virtual void OnTapped(Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e) override;
|
||||
virtual void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
||||
virtual void OnRightTapped(Windows::UI::Xaml::Input::RightTappedRoutedEventArgs^ e) override;
|
||||
virtual void OnGotFocus(Windows::UI::Xaml::RoutedEventArgs^ e) override;
|
||||
virtual void OnLostFocus(Windows::UI::Xaml::RoutedEventArgs^ e) override;
|
||||
virtual void OnTapped(Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e) override;
|
||||
virtual void OnPointerPressed(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||
virtual void OnRightTapped(Windows::UI::Xaml::Input::RightTappedRoutedEventArgs ^ e) override;
|
||||
virtual void OnGotFocus(Windows::UI::Xaml::RoutedEventArgs ^ e) override;
|
||||
virtual void OnLostFocus(Windows::UI::Xaml::RoutedEventArgs ^ e) override;
|
||||
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer^ OnCreateAutomationPeer() override;
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer ^ OnCreateAutomationPeer() override;
|
||||
|
||||
private:
|
||||
void OnIsActivePropertyChanged(bool oldValue, bool newValue);
|
||||
void OnAccentColorPropertyChanged(Windows::UI::Xaml::Media::Brush^ oldValue, Windows::UI::Xaml::Media::Brush^ newValue);
|
||||
void OnDisplayValuePropertyChanged(Platform::String^ oldValue, Platform::String^ newValue);
|
||||
void OnAccentColorPropertyChanged(Windows::UI::Xaml::Media::Brush ^ oldValue, Windows::UI::Xaml::Media::Brush ^ newValue);
|
||||
void OnDisplayValuePropertyChanged(Platform::String ^ oldValue, Platform::String ^ newValue);
|
||||
void OnIsInErrorPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnMinFontSizePropertyChanged(double oldValue, double newValue);
|
||||
void OnMaxFontSizePropertyChanged(double oldValue, double newValue);
|
||||
void TextContainerSizeChanged(Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
|
||||
void OnTextContainerLayoutUpdated(Object^ sender, Object^ e);
|
||||
void TextContainerSizeChanged(Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||
void OnTextContainerLayoutUpdated(Object ^ sender, Object ^ e);
|
||||
void UpdateVisualState();
|
||||
void UpdateAllState();
|
||||
void OnScrollClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnPointerEntered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
|
||||
void OnPointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
|
||||
void ModifyFontAndMargin(Windows::UI::Xaml::Controls::TextBlock^ textBlock, double fontChange);
|
||||
void OnScrollClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnPointerEntered(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
|
||||
void OnPointerExited(Platform::Object ^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
|
||||
void ModifyFontAndMargin(Windows::UI::Xaml::Controls::TextBlock ^ textBlock, double fontChange);
|
||||
void ShowHideScrollButtons(Windows::UI::Xaml::Visibility vLeft, Windows::UI::Xaml::Visibility vRight);
|
||||
void UpdateScrollButtons();
|
||||
void ScrollLeft();
|
||||
@@ -73,10 +74,10 @@ namespace CalculatorApp
|
||||
static Platform::StringReference s_FocusedState;
|
||||
static Platform::StringReference s_UnfocusedState;
|
||||
|
||||
Windows::UI::Xaml::Controls::ScrollViewer^ m_textContainer;
|
||||
Windows::UI::Xaml::Controls::TextBlock^ m_textBlock;
|
||||
Windows::UI::Xaml::Controls::HyperlinkButton^ m_scrollLeft;
|
||||
Windows::UI::Xaml::Controls::HyperlinkButton^ m_scrollRight;
|
||||
Windows::UI::Xaml::Controls::ScrollViewer ^ m_textContainer;
|
||||
Windows::UI::Xaml::Controls::TextBlock ^ m_textBlock;
|
||||
Windows::UI::Xaml::Controls::HyperlinkButton ^ m_scrollLeft;
|
||||
Windows::UI::Xaml::Controls::HyperlinkButton ^ m_scrollRight;
|
||||
double scrollRatio = 0.7;
|
||||
bool m_isScalingText;
|
||||
bool m_haveCalculatedMax;
|
||||
|
@@ -9,16 +9,16 @@ using namespace Windows::UI::Xaml::Automation::Peers;
|
||||
|
||||
namespace CalculatorApp::Controls
|
||||
{
|
||||
CalculationResultAutomationPeer::CalculationResultAutomationPeer(FrameworkElement^ owner) :
|
||||
FrameworkElementAutomationPeer(owner)
|
||||
{ }
|
||||
CalculationResultAutomationPeer::CalculationResultAutomationPeer(FrameworkElement ^ owner) : FrameworkElementAutomationPeer(owner)
|
||||
{
|
||||
}
|
||||
|
||||
AutomationControlType CalculationResultAutomationPeer::GetAutomationControlTypeCore()
|
||||
{
|
||||
return AutomationControlType::Text;
|
||||
}
|
||||
|
||||
Platform::Object^ CalculationResultAutomationPeer::GetPatternCore(PatternInterface pattern)
|
||||
Platform::Object ^ CalculationResultAutomationPeer::GetPatternCore(PatternInterface pattern)
|
||||
{
|
||||
if (pattern == PatternInterface::Invoke)
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace CalculatorApp::Controls
|
||||
|
||||
void CalculationResultAutomationPeer::Invoke()
|
||||
{
|
||||
auto owner = static_cast<CalculationResult^>(this->Owner);
|
||||
auto owner = static_cast<CalculationResult ^>(this->Owner);
|
||||
owner->ProgrammaticSelect();
|
||||
}
|
||||
}
|
||||
|
@@ -9,14 +9,15 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public ref class CalculationResultAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer,
|
||||
Windows::UI::Xaml::Automation::Provider::IInvokeProvider
|
||||
public
|
||||
ref class CalculationResultAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer,
|
||||
Windows::UI::Xaml::Automation::Provider::IInvokeProvider
|
||||
{
|
||||
public:
|
||||
CalculationResultAutomationPeer(Windows::UI::Xaml::FrameworkElement^ owner);
|
||||
CalculationResultAutomationPeer(Windows::UI::Xaml::FrameworkElement ^ owner);
|
||||
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override;
|
||||
virtual Platform::Object^ GetPatternCore(Windows::UI::Xaml::Automation::Peers::PatternInterface pattern) override;
|
||||
virtual Platform::Object ^ GetPatternCore(Windows::UI::Xaml::Automation::Peers::PatternInterface pattern) override;
|
||||
virtual void Invoke();
|
||||
};
|
||||
}
|
||||
|
@@ -26,12 +26,12 @@ CalculatorButton::CalculatorButton()
|
||||
{
|
||||
// Set the default bindings for this button, these can be overwritten by Xaml if needed
|
||||
// These are a replacement for binding in styles
|
||||
Binding^ commandBinding = ref new Binding();
|
||||
Binding ^ commandBinding = ref new Binding();
|
||||
commandBinding->Path = ref new PropertyPath("ButtonPressed");
|
||||
this->SetBinding(Button::CommandProperty, commandBinding);
|
||||
}
|
||||
|
||||
void CalculatorButton::OnKeyDown(KeyRoutedEventArgs^ e)
|
||||
void CalculatorButton::OnKeyDown(KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
// Ignore the Enter key
|
||||
if (e->Key == VirtualKey::Enter)
|
||||
@@ -42,7 +42,7 @@ void CalculatorButton::OnKeyDown(KeyRoutedEventArgs^ e)
|
||||
Button::OnKeyDown(e);
|
||||
}
|
||||
|
||||
void CalculatorButton::OnKeyUp(KeyRoutedEventArgs^ e)
|
||||
void CalculatorButton::OnKeyUp(KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
// Ignore the Enter key
|
||||
if (e->Key == VirtualKey::Enter)
|
||||
@@ -53,16 +53,12 @@ void CalculatorButton::OnKeyUp(KeyRoutedEventArgs^ e)
|
||||
Button::OnKeyUp(e);
|
||||
}
|
||||
|
||||
void CalculatorButton::OnButtonIdPropertyChanged(
|
||||
NumbersAndOperatorsEnum /*oldValue*/,
|
||||
NumbersAndOperatorsEnum newValue)
|
||||
void CalculatorButton::OnButtonIdPropertyChanged(NumbersAndOperatorsEnum /*oldValue*/, NumbersAndOperatorsEnum newValue)
|
||||
{
|
||||
this->CommandParameter = ref new CalculatorButtonPressedEventArgs(AuditoryFeedback, newValue);
|
||||
}
|
||||
|
||||
void CalculatorButton::OnAuditoryFeedbackPropertyChanged(
|
||||
String^ /*oldValue*/,
|
||||
String^ newValue)
|
||||
void CalculatorButton::OnAuditoryFeedbackPropertyChanged(String ^ /*oldValue*/, String ^ newValue)
|
||||
{
|
||||
this->CommandParameter = ref new CalculatorButtonPressedEventArgs(newValue, ButtonId);
|
||||
}
|
||||
|
@@ -10,29 +10,27 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public ref class CalculatorButton sealed: Windows::UI::Xaml::Controls::Button
|
||||
public
|
||||
ref class CalculatorButton sealed : Windows::UI::Xaml::Controls::Button
|
||||
{
|
||||
public:
|
||||
|
||||
CalculatorButton();
|
||||
DEPENDENCY_PROPERTY_OWNER(CalculatorButton);
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(NumbersAndOperatorsEnum, ButtonId);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String^, AuditoryFeedback);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverForeground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressForeground);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Platform::String ^, AuditoryFeedback);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverForeground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressForeground);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
|
||||
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
|
||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
|
||||
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
|
||||
|
||||
private:
|
||||
|
||||
void OnButtonIdPropertyChanged(NumbersAndOperatorsEnum oldValue, NumbersAndOperatorsEnum newValue);
|
||||
void OnAuditoryFeedbackPropertyChanged(Platform::String^ oldValue, Platform::String^ newValue);
|
||||
void OnAuditoryFeedbackPropertyChanged(Platform::String ^ oldValue, Platform::String ^ newValue);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -19,8 +19,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(FlipButtons, HoverForeground);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(FlipButtons, PressBackground);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(FlipButtons, PressForeground);
|
||||
|
||||
|
||||
void FlipButtons::OnKeyDown(KeyRoutedEventArgs^ e)
|
||||
void FlipButtons::OnKeyDown(KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
// Ignore the Enter key
|
||||
if (e->Key == VirtualKey::Enter)
|
||||
@@ -31,7 +30,7 @@ void FlipButtons::OnKeyDown(KeyRoutedEventArgs^ e)
|
||||
ToggleButton::OnKeyDown(e);
|
||||
}
|
||||
|
||||
void FlipButtons::OnKeyUp(KeyRoutedEventArgs^ e)
|
||||
void FlipButtons::OnKeyUp(KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
// Ignore the Enter key
|
||||
if (e->Key == VirtualKey::Enter)
|
||||
@@ -42,10 +41,7 @@ void FlipButtons::OnKeyUp(KeyRoutedEventArgs^ e)
|
||||
ToggleButton::OnKeyUp(e);
|
||||
}
|
||||
|
||||
void FlipButtons::OnButtonIdPropertyChanged(
|
||||
NumbersAndOperatorsEnum /*oldValue*/,
|
||||
NumbersAndOperatorsEnum newValue)
|
||||
void FlipButtons::OnButtonIdPropertyChanged(NumbersAndOperatorsEnum /*oldValue*/, NumbersAndOperatorsEnum newValue)
|
||||
{
|
||||
this->CommandParameter = newValue;
|
||||
}
|
||||
|
||||
|
@@ -10,27 +10,24 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public ref class FlipButtons sealed: Windows::UI::Xaml::Controls::Primitives::ToggleButton
|
||||
public
|
||||
ref class FlipButtons sealed : Windows::UI::Xaml::Controls::Primitives::ToggleButton
|
||||
{
|
||||
public:
|
||||
DEPENDENCY_PROPERTY_OWNER(FlipButtons);
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(NumbersAndOperatorsEnum, ButtonId);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, HoverForeground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush^, PressForeground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, HoverForeground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressBackground);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Media::Brush ^, PressForeground);
|
||||
|
||||
protected:
|
||||
|
||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
|
||||
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e) override;
|
||||
virtual void OnKeyDown(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
|
||||
virtual void OnKeyUp(Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e) override;
|
||||
|
||||
private:
|
||||
|
||||
void OnButtonIdPropertyChanged(
|
||||
NumbersAndOperatorsEnum oldValue,
|
||||
NumbersAndOperatorsEnum newValue);
|
||||
void OnButtonIdPropertyChanged(NumbersAndOperatorsEnum oldValue, NumbersAndOperatorsEnum newValue);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -55,16 +55,15 @@ Size HorizontalNoOverflowStackPanel::ArrangeOverride(Size finalSize)
|
||||
float itemWidth = item->DesiredSize.Width;
|
||||
if (widthAvailable > 0 && itemWidth <= widthAvailable)
|
||||
{
|
||||
//stack the items horizontally (left to right)
|
||||
// stack the items horizontally (left to right)
|
||||
item->Arrange(Rect(posX, 0, itemWidth, finalSize.Height));
|
||||
posX += item->RenderSize.Width;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Not display the item
|
||||
// Not display the item
|
||||
item->Arrange(Rect(0, 0, 0, 0));
|
||||
}
|
||||
}
|
||||
return finalSize;
|
||||
}
|
||||
|
||||
|
@@ -13,12 +13,15 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public ref class HorizontalNoOverflowStackPanel : public Windows::UI::Xaml::Controls::Panel
|
||||
public
|
||||
ref class HorizontalNoOverflowStackPanel : public Windows::UI::Xaml::Controls::Panel
|
||||
{
|
||||
DEPENDENCY_PROPERTY_OWNER(HorizontalNoOverflowStackPanel);
|
||||
//Prioritize the last item over all other items (except the first one)
|
||||
internal:
|
||||
HorizontalNoOverflowStackPanel() {}
|
||||
// Prioritize the last item over all other items (except the first one)
|
||||
internal : HorizontalNoOverflowStackPanel()
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual Windows::Foundation::Size MeasureOverride(Windows::Foundation::Size availableSize) override;
|
||||
virtual Windows::Foundation::Size ArrangeOverride(Windows::Foundation::Size finalSize) override;
|
||||
|
@@ -35,22 +35,23 @@ void OverflowTextBlock::OnApplyTemplate()
|
||||
auto uiElement = GetTemplateChild("ExpressionContainer");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_expressionContainer = safe_cast<ScrollViewer^>(uiElement);
|
||||
m_expressionContainer = safe_cast<ScrollViewer ^>(uiElement);
|
||||
m_expressionContainer->ChangeView(m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth, nullptr, nullptr);
|
||||
m_containerViewChangedToken = m_expressionContainer->ViewChanged += ref new EventHandler<ScrollViewerViewChangedEventArgs ^>(this, &OverflowTextBlock::OnViewChanged);
|
||||
m_containerViewChangedToken = m_expressionContainer->ViewChanged +=
|
||||
ref new EventHandler<ScrollViewerViewChangedEventArgs ^>(this, &OverflowTextBlock::OnViewChanged);
|
||||
}
|
||||
|
||||
uiElement = GetTemplateChild("ScrollLeft");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_scrollLeft = safe_cast<Button^>(uiElement);
|
||||
m_scrollLeft = safe_cast<Button ^>(uiElement);
|
||||
m_scrollLeftClickEventToken = m_scrollLeft->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
|
||||
}
|
||||
|
||||
uiElement = GetTemplateChild("ScrollRight");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_scrollRight = safe_cast<Button^>(uiElement);
|
||||
m_scrollRight = safe_cast<Button ^>(uiElement);
|
||||
m_scrollRightClickEventToken = m_scrollRight->Click += ref new RoutedEventHandler(this, &OverflowTextBlock::OnScrollClick);
|
||||
}
|
||||
|
||||
@@ -60,13 +61,13 @@ void OverflowTextBlock::OnApplyTemplate()
|
||||
uiElement = GetTemplateChild("TokenList");
|
||||
if (uiElement != nullptr)
|
||||
{
|
||||
m_itemsControl = safe_cast<ItemsControl^>(uiElement);
|
||||
m_itemsControl = safe_cast<ItemsControl ^>(uiElement);
|
||||
}
|
||||
|
||||
UpdateAllState();
|
||||
}
|
||||
|
||||
AutomationPeer^ OverflowTextBlock::OnCreateAutomationPeer()
|
||||
AutomationPeer ^ OverflowTextBlock::OnCreateAutomationPeer()
|
||||
{
|
||||
return ref new OverflowTextBlockAutomationPeer(this);
|
||||
}
|
||||
@@ -82,8 +83,7 @@ void OverflowTextBlock::OnTokensUpdatedPropertyChanged(bool /*oldValue*/, bool n
|
||||
if (m_isAccessibilityViewControl != newIsAccessibilityViewControl)
|
||||
{
|
||||
m_isAccessibilityViewControl = newIsAccessibilityViewControl;
|
||||
AutomationProperties::SetAccessibilityView(this,
|
||||
newIsAccessibilityViewControl ? AccessibilityView::Control : AccessibilityView::Raw);
|
||||
AutomationProperties::SetAccessibilityView(this, newIsAccessibilityViewControl ? AccessibilityView::Control : AccessibilityView::Raw);
|
||||
}
|
||||
UpdateScrollButtons();
|
||||
}
|
||||
@@ -129,9 +129,9 @@ void OverflowTextBlock::ScrollRight()
|
||||
}
|
||||
}
|
||||
|
||||
void OverflowTextBlock::OnScrollClick(_In_ Object^ sender, _In_ RoutedEventArgs^)
|
||||
void OverflowTextBlock::OnScrollClick(_In_ Object ^ sender, _In_ RoutedEventArgs ^)
|
||||
{
|
||||
auto clicked = safe_cast<Button^>(sender);
|
||||
auto clicked = safe_cast<Button ^>(sender);
|
||||
if (clicked == m_scrollLeft)
|
||||
{
|
||||
ScrollLeft();
|
||||
@@ -155,7 +155,8 @@ void OverflowTextBlock::UpdateScrollButtons()
|
||||
ShowHideScrollButtons(::Visibility::Collapsed, ::Visibility::Collapsed);
|
||||
}
|
||||
// We have more number on both side. Show both arrows
|
||||
else if ((m_expressionContainer->HorizontalOffset > 0) && (m_expressionContainer->HorizontalOffset < (m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)))
|
||||
else if ((m_expressionContainer->HorizontalOffset > 0)
|
||||
&& (m_expressionContainer->HorizontalOffset < (m_expressionContainer->ExtentWidth - m_expressionContainer->ViewportWidth)))
|
||||
{
|
||||
ShowHideScrollButtons(::Visibility::Visible, ::Visibility::Visible);
|
||||
}
|
||||
@@ -214,7 +215,7 @@ void OverflowTextBlock::UnregisterEventHandlers()
|
||||
}
|
||||
}
|
||||
|
||||
void OverflowTextBlock::OnViewChanged(_In_opt_ Object^ /*sender*/, _In_opt_ ScrollViewerViewChangedEventArgs^ /*args*/)
|
||||
void OverflowTextBlock::OnViewChanged(_In_opt_ Object ^ /*sender*/, _In_opt_ ScrollViewerViewChangedEventArgs ^ /*args*/)
|
||||
{
|
||||
UpdateScrollButtons();
|
||||
}
|
||||
|
@@ -9,7 +9,8 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public ref class OverflowTextBlock sealed : public Windows::UI::Xaml::Controls::Control
|
||||
public
|
||||
ref class OverflowTextBlock sealed : public Windows::UI::Xaml::Controls::Control
|
||||
{
|
||||
public:
|
||||
OverflowTextBlock()
|
||||
@@ -20,21 +21,21 @@ namespace CalculatorApp
|
||||
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, TokensUpdated);
|
||||
DEPENDENCY_PROPERTY(bool, IsActive);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style^, TextStyle);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style ^, TextStyle);
|
||||
void UpdateScrollButtons();
|
||||
void UnregisterEventHandlers();
|
||||
|
||||
protected:
|
||||
virtual void OnApplyTemplate() override;
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer^ OnCreateAutomationPeer() override;
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer ^ OnCreateAutomationPeer() override;
|
||||
|
||||
private:
|
||||
void OnScrollClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnPointerEntered(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
|
||||
void OnPointerExited(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
|
||||
void OnScrollClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnPointerEntered(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
|
||||
void OnPointerExited(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e);
|
||||
void ShowHideScrollButtons(Windows::UI::Xaml::Visibility vLeft, Windows::UI::Xaml::Visibility vRight);
|
||||
void OnTokensUpdatedPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnViewChanged(_In_opt_ Platform::Object ^sender, _In_opt_ Windows::UI::Xaml::Controls::ScrollViewerViewChangedEventArgs ^args);
|
||||
void OnViewChanged(_In_opt_ Platform::Object ^ sender, _In_opt_ Windows::UI::Xaml::Controls::ScrollViewerViewChangedEventArgs ^ args);
|
||||
|
||||
void UpdateVisualState();
|
||||
void UpdateExpressionState();
|
||||
@@ -46,10 +47,10 @@ namespace CalculatorApp
|
||||
bool m_scrollingLeft;
|
||||
bool m_scrollingRight;
|
||||
bool m_isAccessibilityViewControl;
|
||||
Windows::UI::Xaml::Controls::ItemsControl^ m_itemsControl;
|
||||
Windows::UI::Xaml::Controls::ScrollViewer^ m_expressionContainer;
|
||||
Windows::UI::Xaml::Controls::Button^ m_scrollLeft;
|
||||
Windows::UI::Xaml::Controls::Button^ m_scrollRight;
|
||||
Windows::UI::Xaml::Controls::ItemsControl ^ m_itemsControl;
|
||||
Windows::UI::Xaml::Controls::ScrollViewer ^ m_expressionContainer;
|
||||
Windows::UI::Xaml::Controls::Button ^ m_scrollLeft;
|
||||
Windows::UI::Xaml::Controls::Button ^ m_scrollRight;
|
||||
|
||||
Windows::Foundation::EventRegistrationToken m_scrollLeftClickEventToken;
|
||||
Windows::Foundation::EventRegistrationToken m_scrollRightClickEventToken;
|
||||
|
@@ -10,16 +10,16 @@ using namespace Windows::Foundation::Collections;
|
||||
|
||||
namespace CalculatorApp::Controls
|
||||
{
|
||||
OverflowTextBlockAutomationPeer::OverflowTextBlockAutomationPeer(OverflowTextBlock^ owner) :
|
||||
FrameworkElementAutomationPeer(owner)
|
||||
{ }
|
||||
OverflowTextBlockAutomationPeer::OverflowTextBlockAutomationPeer(OverflowTextBlock ^ owner) : FrameworkElementAutomationPeer(owner)
|
||||
{
|
||||
}
|
||||
|
||||
AutomationControlType OverflowTextBlockAutomationPeer::GetAutomationControlTypeCore()
|
||||
{
|
||||
return AutomationControlType::Text;
|
||||
}
|
||||
|
||||
IVector<AutomationPeer^>^ OverflowTextBlockAutomationPeer::GetChildrenCore()
|
||||
IVector<AutomationPeer ^> ^ OverflowTextBlockAutomationPeer::GetChildrenCore()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@@ -9,13 +9,14 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public ref class OverflowTextBlockAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
|
||||
public
|
||||
ref class OverflowTextBlockAutomationPeer sealed : Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
|
||||
{
|
||||
public:
|
||||
OverflowTextBlockAutomationPeer(OverflowTextBlock^ owner);
|
||||
OverflowTextBlockAutomationPeer(OverflowTextBlock ^ owner);
|
||||
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override;
|
||||
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer^>^ GetChildrenCore() override;
|
||||
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer ^> ^ GetChildrenCore() override;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -16,10 +16,10 @@ using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Input;
|
||||
using namespace Windows::UI::Xaml::Data;
|
||||
|
||||
String^ RadixButton::GetRawDisplayValue()
|
||||
String ^ RadixButton::GetRawDisplayValue()
|
||||
{
|
||||
wstring rawValue;
|
||||
String^ radixContent = Content->ToString();
|
||||
String ^ radixContent = Content->ToString();
|
||||
LocalizationSettings::GetInstance().RemoveGroupSeparators(radixContent->Data(), radixContent->Length(), &rawValue);
|
||||
return ref new String(rawValue.c_str());
|
||||
}
|
||||
|
@@ -7,12 +7,12 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public ref class RadixButton sealed : public Windows::UI::Xaml::Controls::RadioButton
|
||||
public
|
||||
ref class RadixButton sealed : public Windows::UI::Xaml::Controls::RadioButton
|
||||
{
|
||||
public:
|
||||
RadixButton() {};
|
||||
internal:
|
||||
Platform::String^ GetRawDisplayValue();
|
||||
RadixButton(){};
|
||||
internal : Platform::String ^ GetRawDisplayValue();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -18,23 +18,23 @@ using namespace Platform;
|
||||
using namespace Windows::Foundation::Collections;
|
||||
using namespace std;
|
||||
|
||||
DependencyObject^ SupplementaryItemsControl::GetContainerForItemOverride()
|
||||
DependencyObject ^ SupplementaryItemsControl::GetContainerForItemOverride()
|
||||
{
|
||||
return ref new SupplementaryContentPresenter();
|
||||
}
|
||||
|
||||
void SupplementaryItemsControl::PrepareContainerForItemOverride(DependencyObject^ element, Object^ item)
|
||||
void SupplementaryItemsControl::PrepareContainerForItemOverride(DependencyObject ^ element, Object ^ item)
|
||||
{
|
||||
ItemsControl::PrepareContainerForItemOverride(element, item);
|
||||
|
||||
auto supplementaryResult = dynamic_cast<SupplementaryResult^>(item);
|
||||
auto supplementaryResult = dynamic_cast<SupplementaryResult ^>(item);
|
||||
if (supplementaryResult)
|
||||
{
|
||||
AutomationProperties::SetName(element, supplementaryResult->GetLocalizedAutomationName());
|
||||
}
|
||||
}
|
||||
|
||||
AutomationPeer^ SupplementaryContentPresenter::OnCreateAutomationPeer()
|
||||
{
|
||||
return ref new SupplementaryContentPresenterAP(this);
|
||||
}
|
||||
AutomationPeer ^ SupplementaryContentPresenter::OnCreateAutomationPeer()
|
||||
{
|
||||
return ref new SupplementaryContentPresenterAP(this);
|
||||
}
|
||||
|
@@ -3,45 +3,52 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace CalculatorApp { namespace Controls {
|
||||
|
||||
public ref class SupplementaryItemsControl sealed: public Windows::UI::Xaml::Controls::ItemsControl
|
||||
namespace CalculatorApp
|
||||
{
|
||||
namespace Controls
|
||||
{
|
||||
public:
|
||||
SupplementaryItemsControl()
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual Windows::UI::Xaml::DependencyObject^ GetContainerForItemOverride() override;
|
||||
virtual void PrepareContainerForItemOverride(Windows::UI::Xaml::DependencyObject^ element, Platform::Object^ item) override;
|
||||
};
|
||||
|
||||
public ref class SupplementaryContentPresenter sealed: public Windows::UI::Xaml::Controls::ContentPresenter
|
||||
{
|
||||
public:
|
||||
SupplementaryContentPresenter()
|
||||
{ }
|
||||
|
||||
protected:
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer^ OnCreateAutomationPeer() override;
|
||||
};
|
||||
|
||||
ref class SupplementaryContentPresenterAP sealed: public Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
|
||||
{
|
||||
protected:
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override
|
||||
public
|
||||
ref class SupplementaryItemsControl sealed : public Windows::UI::Xaml::Controls::ItemsControl
|
||||
{
|
||||
return Windows::UI::Xaml::Automation::Peers::AutomationControlType::Text;
|
||||
}
|
||||
public:
|
||||
SupplementaryItemsControl()
|
||||
{
|
||||
}
|
||||
|
||||
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer^>^ GetChildrenCore() override
|
||||
protected:
|
||||
virtual Windows::UI::Xaml::DependencyObject ^ GetContainerForItemOverride() override;
|
||||
virtual void PrepareContainerForItemOverride(Windows::UI::Xaml::DependencyObject ^ element, Platform::Object ^ item) override;
|
||||
};
|
||||
|
||||
public
|
||||
ref class SupplementaryContentPresenter sealed : public Windows::UI::Xaml::Controls::ContentPresenter
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
public:
|
||||
SupplementaryContentPresenter()
|
||||
{
|
||||
}
|
||||
|
||||
internal:
|
||||
SupplementaryContentPresenterAP(SupplementaryContentPresenter^ owner):
|
||||
Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer(owner)
|
||||
{ }
|
||||
};
|
||||
}}
|
||||
protected:
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationPeer ^ OnCreateAutomationPeer() override;
|
||||
};
|
||||
|
||||
ref class SupplementaryContentPresenterAP sealed : public Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer
|
||||
{
|
||||
protected:
|
||||
virtual Windows::UI::Xaml::Automation::Peers::AutomationControlType GetAutomationControlTypeCore() override
|
||||
{
|
||||
return Windows::UI::Xaml::Automation::Peers::AutomationControlType::Text;
|
||||
}
|
||||
|
||||
virtual Windows::Foundation::Collections::IVector<Windows::UI::Xaml::Automation::Peers::AutomationPeer ^> ^ GetChildrenCore() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
internal : SupplementaryContentPresenterAP(SupplementaryContentPresenter ^ owner)
|
||||
: Windows::UI::Xaml::Automation::Peers::FrameworkElementAutomationPeer(owner)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Xaml::Interop;
|
||||
|
||||
// returns automationName in form "Nth bit Value zero/one" depending if bit is set/unset at corresponding index of binary display
|
||||
Object^ BitFlipAutomationNameConverter::Convert(_In_ Object^ value, TypeName targetType, _In_ Object^ parameter, _In_ String^ language)
|
||||
Object ^ BitFlipAutomationNameConverter::Convert(_In_ Object ^ value, TypeName targetType, _In_ Object ^ parameter, _In_ String ^ language)
|
||||
{
|
||||
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||
|
||||
@@ -26,15 +26,15 @@ Object^ BitFlipAutomationNameConverter::Convert(_In_ Object^ value, TypeName tar
|
||||
wchar_t ch0 = localizationSettings.GetDigitSymbolFromEnUsDigit('0');
|
||||
wchar_t ch1 = localizationSettings.GetDigitSymbolFromEnUsDigit('1');
|
||||
|
||||
String^ indexName = resourceLoader.GetResourceString(static_cast<String^>(parameter));
|
||||
String^ bitName = resourceLoader.GetResourceString(L"BitAutomationName");
|
||||
String^ valueName = resourceLoader.GetResourceString(L"ValueAutomationName");
|
||||
String^ zero = resourceLoader.GetResourceString(L"BinaryZeroValueAutomationName");
|
||||
String^ one = resourceLoader.GetResourceString(L"BinaryOneValueAutomationName");
|
||||
String ^ indexName = resourceLoader.GetResourceString(static_cast<String ^>(parameter));
|
||||
String ^ bitName = resourceLoader.GetResourceString(L"BitAutomationName");
|
||||
String ^ valueName = resourceLoader.GetResourceString(L"ValueAutomationName");
|
||||
String ^ zero = resourceLoader.GetResourceString(L"BinaryZeroValueAutomationName");
|
||||
String ^ one = resourceLoader.GetResourceString(L"BinaryOneValueAutomationName");
|
||||
if ((value != nullptr) && (parameter != nullptr))
|
||||
{
|
||||
wstring binaryDisplay = (static_cast<String^>(value))->Data();
|
||||
wstring indexString = (static_cast<String^>(parameter))->Data();
|
||||
wstring binaryDisplay = (static_cast<String ^>(value))->Data();
|
||||
wstring indexString = (static_cast<String ^>(parameter))->Data();
|
||||
wstringstream converter;
|
||||
converter << indexString;
|
||||
unsigned int index;
|
||||
@@ -42,7 +42,7 @@ Object^ BitFlipAutomationNameConverter::Convert(_In_ Object^ value, TypeName tar
|
||||
unsigned int binaryLength = 0;
|
||||
|
||||
// remove all the characters except 0 and 1 from the array.
|
||||
for each (wchar_t bit in binaryDisplay)
|
||||
for (wchar_t bit : binaryDisplay)
|
||||
{
|
||||
if ((bit == ch1) || (bit == ch0))
|
||||
{
|
||||
@@ -74,7 +74,7 @@ Object^ BitFlipAutomationNameConverter::Convert(_In_ Object^ value, TypeName tar
|
||||
return (indexName + bitName + valueName + zero);
|
||||
}
|
||||
|
||||
Object^ BitFlipAutomationNameConverter::ConvertBack(_In_ Object^ value, TypeName targetType, _In_ Object^ parameter, _In_ String^ language)
|
||||
Object ^ BitFlipAutomationNameConverter::ConvertBack(_In_ Object ^ value, TypeName targetType, _In_ Object ^ parameter, _In_ String ^ language)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
@@ -10,13 +10,15 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// Value converter that translates binary value to automation name for a bit.
|
||||
/// </summary>
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class BitFlipAutomationNameConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class BitFlipAutomationNameConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
virtual Platform::Object^ Convert(_In_ Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object^ parameter, _In_ Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(_In_ Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object^ parameter, _In_ Platform::String^ language);
|
||||
|
||||
virtual Platform::Object
|
||||
^ Convert(_In_ Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object ^ parameter,
|
||||
_In_ Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(_In_ Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, _In_ Platform::Object ^ parameter,
|
||||
_In_ Platform::String ^ language);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -10,24 +10,24 @@ using namespace Platform;
|
||||
using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Xaml::Interop;
|
||||
|
||||
Object^ BooleanNegationConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ BooleanNegationConverter::Convert(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto boxedBool = dynamic_cast<Box<bool>^>(value);
|
||||
auto boxedBool = dynamic_cast<Box<bool> ^>(value);
|
||||
auto boolValue = (boxedBool != nullptr && boxedBool->Value);
|
||||
return !boolValue;
|
||||
}
|
||||
|
||||
Object^ BooleanNegationConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ BooleanNegationConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto boxedBool = dynamic_cast<Box<bool>^>(value);
|
||||
auto boxedBool = dynamic_cast<Box<bool> ^>(value);
|
||||
auto boolValue = (boxedBool != nullptr && boxedBool->Value);
|
||||
return !boolValue;
|
||||
}
|
||||
|
@@ -10,12 +10,14 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// Value converter that translates true to false and vice versa.
|
||||
/// </summary>
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class BooleanNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class BooleanNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -15,45 +15,45 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
Object^ BooleanToVisibilityConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ BooleanToVisibilityConverter::Convert(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto boxedBool = dynamic_cast<Box<bool>^>(value);
|
||||
auto boxedBool = dynamic_cast<Box<bool> ^>(value);
|
||||
auto boolValue = (boxedBool != nullptr && boxedBool->Value);
|
||||
return BooleanToVisibilityConverter::Convert(boolValue);
|
||||
}
|
||||
|
||||
Object^ BooleanToVisibilityConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ BooleanToVisibilityConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto visibility = dynamic_cast<Box<Visibility>^>(value);
|
||||
auto visibility = dynamic_cast<Box<Visibility> ^>(value);
|
||||
return (visibility != nullptr && visibility->Value == Visibility::Visible);
|
||||
}
|
||||
|
||||
Object^ BooleanToVisibilityNegationConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ BooleanToVisibilityNegationConverter::Convert(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto boxedBool = dynamic_cast<Box<bool>^>(value);
|
||||
auto boxedBool = dynamic_cast<Box<bool> ^>(value);
|
||||
auto boolValue = (boxedBool != nullptr && boxedBool->Value);
|
||||
return BooleanToVisibilityConverter::Convert(!boolValue);
|
||||
}
|
||||
|
||||
Object^ BooleanToVisibilityNegationConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ BooleanToVisibilityNegationConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto visibility = dynamic_cast<Box<Visibility>^>(value);
|
||||
auto visibility = dynamic_cast<Box<Visibility> ^>(value);
|
||||
return (visibility != nullptr && visibility->Value != Visibility::Visible);
|
||||
}
|
||||
|
||||
|
@@ -11,29 +11,35 @@ namespace CalculatorApp
|
||||
/// Value converter that translates true to <see cref="Visibility::Visible"/> and false
|
||||
/// to <see cref="Visibility::Collapsed"/>.
|
||||
/// </summary>
|
||||
public ref class BooleanToVisibilityConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
public
|
||||
ref class BooleanToVisibilityConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
static constexpr Windows::UI::Xaml::Visibility Convert(bool visibility)
|
||||
{
|
||||
return visibility
|
||||
? Windows::UI::Xaml::Visibility::Visible
|
||||
: Windows::UI::Xaml::Visibility::Collapsed;
|
||||
return visibility ? Windows::UI::Xaml::Visibility::Visible : Windows::UI::Xaml::Visibility::Collapsed;
|
||||
}
|
||||
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language);
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Value converter that translates false to <see cref="Visibility::Visible"/> and true
|
||||
/// to <see cref="Visibility::Collapsed"/>.
|
||||
/// </summary>
|
||||
public ref class BooleanToVisibilityNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
public
|
||||
ref class BooleanToVisibilityNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language);
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -11,9 +11,10 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
Windows::UI::Xaml::DataTemplate^ ExpressionItemTemplateSelector::SelectTemplateCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container)
|
||||
Windows::UI::Xaml::DataTemplate
|
||||
^ ExpressionItemTemplateSelector::SelectTemplateCore(Platform::Object ^ item, Windows::UI::Xaml::DependencyObject ^ container)
|
||||
{
|
||||
DisplayExpressionToken^ token = dynamic_cast<DisplayExpressionToken^>(item);
|
||||
DisplayExpressionToken ^ token = dynamic_cast<DisplayExpressionToken ^>(item);
|
||||
if (token != nullptr)
|
||||
{
|
||||
Common::TokenType type = token->Type;
|
||||
|
@@ -7,11 +7,10 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
[Windows::UI::Xaml::Data::Bindable]
|
||||
public ref class ExpressionItemTemplateSelector sealed : public Windows::UI::Xaml::Controls::DataTemplateSelector
|
||||
[Windows::UI::Xaml::Data::Bindable] public ref class ExpressionItemTemplateSelector sealed : public Windows::UI::Xaml::Controls::DataTemplateSelector
|
||||
{
|
||||
public:
|
||||
virtual Windows::UI::Xaml::DataTemplate^ SelectTemplateCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container) override;
|
||||
virtual Windows::UI::Xaml::DataTemplate ^ SelectTemplateCore(Platform::Object ^ item, Windows::UI::Xaml::DependencyObject ^ container) override;
|
||||
|
||||
property Windows::UI::Xaml::DataTemplate^ OperatorTemplate
|
||||
{
|
||||
@@ -51,8 +50,8 @@ namespace CalculatorApp
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::DataTemplate^ m_operatorTemplate;
|
||||
Windows::UI::Xaml::DataTemplate^ m_operandTemplate;
|
||||
Windows::UI::Xaml::DataTemplate^ m_separatorTemplate;
|
||||
Windows::UI::Xaml::DataTemplate ^ m_operandTemplate;
|
||||
Windows::UI::Xaml::DataTemplate ^ m_separatorTemplate;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -11,34 +11,34 @@ using namespace Windows::Foundation;
|
||||
using namespace Windows::UI::Xaml;
|
||||
using namespace Windows::UI::Xaml::Interop;
|
||||
|
||||
Object^ ItemSizeToVisibilityConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ ItemSizeToVisibilityConverter::Convert(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto items = dynamic_cast<Box<int>^>(value);
|
||||
auto items = dynamic_cast<Box<int> ^>(value);
|
||||
auto boolValue = (items != nullptr && (items->Value == 0));
|
||||
return BooleanToVisibilityConverter::Convert(boolValue);
|
||||
}
|
||||
|
||||
Object^ ItemSizeToVisibilityConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ ItemSizeToVisibilityConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
throw ref new NotImplementedException();
|
||||
}
|
||||
|
||||
Object^ ItemSizeToVisibilityNegationConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ ItemSizeToVisibilityNegationConverter::Convert(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void) targetType; // Unused parameter
|
||||
(void) parameter; // Unused parameter
|
||||
(void) language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto items = dynamic_cast<Box<int>^>(value);
|
||||
auto items = dynamic_cast<Box<int> ^>(value);
|
||||
auto boolValue = (items != nullptr && (items->Value > 0));
|
||||
return BooleanToVisibilityConverter::Convert(boolValue);
|
||||
}
|
||||
|
||||
Object^ ItemSizeToVisibilityNegationConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ ItemSizeToVisibilityNegationConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
throw ref new NotImplementedException();
|
||||
}
|
||||
|
@@ -7,19 +7,25 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class ItemSizeToVisibilityConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class ItemSizeToVisibilityConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language);
|
||||
};
|
||||
|
||||
public ref class ItemSizeToVisibilityNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
public
|
||||
ref class ItemSizeToVisibilityNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -15,14 +15,14 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Converters
|
||||
{
|
||||
Object^ RadixToStringConverter::Convert(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ RadixToStringConverter::Convert(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
(void)targetType; // Unused parameter
|
||||
(void)parameter; // Unused parameter
|
||||
(void)language; // Unused parameter
|
||||
|
||||
auto boxedInt = dynamic_cast<Box<int>^>(value);
|
||||
Platform::String^ convertedValue;
|
||||
auto boxedInt = dynamic_cast<Box<int> ^>(value);
|
||||
Platform::String ^ convertedValue;
|
||||
auto resourceLoader = AppResourceProvider::GetInstance();
|
||||
switch (boxedInt->Value)
|
||||
{
|
||||
@@ -48,14 +48,11 @@ namespace CalculatorApp
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
||||
};
|
||||
return convertedValue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
Object^ RadixToStringConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ RadixToStringConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
throw ref new NotImplementedException();
|
||||
}
|
||||
|
@@ -10,12 +10,14 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// Value converter that translates true to false and vice versa.
|
||||
/// </summary>
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class RadixToStringConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class RadixToStringConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -13,9 +13,9 @@ namespace CalculatorApp
|
||||
{
|
||||
namespace Common
|
||||
{
|
||||
Object^ VisibilityNegationConverter::Convert(Object^ value, TypeName /*targetType*/, Object^ /*parameter*/, String^ /*language*/)
|
||||
Object ^ VisibilityNegationConverter::Convert(Object ^ value, TypeName /*targetType*/, Object ^ /*parameter*/, String ^ /*language*/)
|
||||
{
|
||||
auto boxedVisibility = dynamic_cast<Box<Visibility>^>(value);
|
||||
auto boxedVisibility = dynamic_cast<Box<Visibility> ^>(value);
|
||||
Visibility visibility = Visibility::Collapsed;
|
||||
if (boxedVisibility != nullptr && boxedVisibility->Value == Visibility::Collapsed)
|
||||
{
|
||||
@@ -24,7 +24,7 @@ namespace CalculatorApp
|
||||
return visibility;
|
||||
}
|
||||
|
||||
Object^ VisibilityNegationConverter::ConvertBack(Object^ value, TypeName targetType, Object^ parameter, String^ language)
|
||||
Object ^ VisibilityNegationConverter::ConvertBack(Object ^ value, TypeName targetType, Object ^ parameter, String ^ language)
|
||||
{
|
||||
return Convert(value, targetType, parameter, language);
|
||||
}
|
||||
|
@@ -10,12 +10,14 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// Value converter that translates Visible to Collapsed and vice versa
|
||||
/// </summary>
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class VisibilityNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class VisibilityNegationConverter sealed : Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language);
|
||||
virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter, Platform::String ^ language);
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -13,30 +13,30 @@ namespace Numbers
|
||||
#ifdef _DEBUG
|
||||
// These class are to be consumed exclusively by Blend and the VS designer
|
||||
// with these classes Blend will be able to populate the controls
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with semi-realistic data.
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// so it does not need to be tested. It will have to be kept in sync with UnitConverterViewModel though
|
||||
// to ensure that the design experience is correct.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
|
||||
|
||||
public ref class AppViewModel sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
public
|
||||
ref class AppViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
AppViewModel() :
|
||||
m_IsStandardMode(true),
|
||||
m_IsScientificMode(false),
|
||||
m_IsConverterMode(false),
|
||||
m_CalculatorViewModel(ref new StandardCalculatorViewModel()),
|
||||
m_ConverterViewModel(ref new UnitConverterViewModel())
|
||||
{}
|
||||
|
||||
AppViewModel()
|
||||
: m_IsStandardMode(true)
|
||||
, m_IsScientificMode(false)
|
||||
, m_IsConverterMode(false)
|
||||
, m_CalculatorViewModel(ref new StandardCalculatorViewModel())
|
||||
, m_ConverterViewModel(ref new UnitConverterViewModel())
|
||||
{
|
||||
}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(StandardCalculatorViewModel^, CalculatorViewModel);
|
||||
OBSERVABLE_PROPERTY_RW(UnitConverterViewModel^, ConverterViewModel);
|
||||
OBSERVABLE_PROPERTY_RW(StandardCalculatorViewModel ^, CalculatorViewModel);
|
||||
OBSERVABLE_PROPERTY_RW(UnitConverterViewModel ^, ConverterViewModel);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsStandardMode);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsScientificMode);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsConverterMode);
|
||||
|
@@ -9,38 +9,35 @@ namespace Numbers
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
|
||||
public ref class MemorySlot sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
public
|
||||
ref class MemorySlot sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
MemorySlot(int slotPosition, Platform::String^ value) :
|
||||
m_SlotPosition(slotPosition),
|
||||
m_SlotValue(value)
|
||||
{}
|
||||
MemorySlot(int slotPosition, Platform::String ^ value) : m_SlotPosition(slotPosition), m_SlotValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
OBSERVABLE_PROPERTY_RW(int, SlotPosition);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, SlotValue);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, SlotValue);
|
||||
};
|
||||
|
||||
// This class is to be consumed exclusively by Blend and the VS designer
|
||||
// with this class Blend will be able to populate the controls, the CalculationResults control for example,
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with semi-realistic data.
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// so it does not need to be tested. It will have to be kept in sync with StandardCalculatorViewModel though
|
||||
// to ensure that the design experience is correct.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
public ref class StandardCalculatorViewModel sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
public
|
||||
ref class StandardCalculatorViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
|
||||
StandardCalculatorViewModel():
|
||||
m_DisplayValue("1234569"),
|
||||
m_DisplayStringExpression("14560 x 1890"),
|
||||
m_DegreeButtonContent("Deg"),
|
||||
m_IsMemoryEmpty(false)
|
||||
StandardCalculatorViewModel()
|
||||
: m_DisplayValue("1234569"), m_DisplayStringExpression("14560 x 1890"), m_DegreeButtonContent("Deg"), m_IsMemoryEmpty(false)
|
||||
{
|
||||
m_MemorizedNumbers = ref new Platform::Collections::Vector<MemorySlot^>();
|
||||
m_MemorizedNumbers = ref new Platform::Collections::Vector<MemorySlot ^>();
|
||||
for (int i = 1000; i < 1100; i++)
|
||||
{
|
||||
wchar_t wzi[5];
|
||||
@@ -53,24 +50,22 @@ namespace Numbers
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DisplayValue);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DisplayStringExpression);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, DegreeButtonContent);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::Foundation::Collections::IVector<MemorySlot^>^, MemorizedNumbers);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, DisplayValue);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, DisplayStringExpression);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, DegreeButtonContent);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::Foundation::Collections::IVector<MemorySlot ^> ^, MemorizedNumbers);
|
||||
OBSERVABLE_PROPERTY_RW(bool, IsMemoryEmpty);
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(KeyboardButtonStates^, PressedButtons);
|
||||
OBSERVABLE_PROPERTY_RW(KeyboardButtonStates ^, PressedButtons);
|
||||
|
||||
COMMAND_FOR_METHOD(ButtonPressed, StandardCalculatorViewModel::OnButtonPressed);
|
||||
|
||||
private:
|
||||
|
||||
void OnButtonPressed(Platform::Object^ parameter)
|
||||
{ }
|
||||
|
||||
void OnButtonPressed(Platform::Object ^ parameter)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,86 +10,80 @@ namespace Numbers
|
||||
#ifdef _DEBUG
|
||||
// These class are to be consumed exclusively by Blend and the VS designer
|
||||
// with these classes Blend will be able to populate the controls
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with the hardcoded strings so whoever is working on the UI can actually see how the app would look like
|
||||
// with semi-realistic data.
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// This data is to only be compiled in the debug build and it will not affect app functionality at all
|
||||
// so it does not need to be tested. It will have to be kept in sync with UnitConverterViewModel though
|
||||
// to ensure that the design experience is correct.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
// This class's code is run in the designer process so the less code it has the better.
|
||||
|
||||
|
||||
public ref class CategoryViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
public
|
||||
ref class CategoryViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
CategoryViewModel(Platform::String^ name) :
|
||||
m_Name(name),
|
||||
m_NegateVisibility(Windows::UI::Xaml::Visibility::Collapsed)
|
||||
{}
|
||||
CategoryViewModel(Platform::String ^ name) : m_Name(name), m_NegateVisibility(Windows::UI::Xaml::Visibility::Collapsed)
|
||||
{
|
||||
}
|
||||
|
||||
CategoryViewModel(Platform::String^ name, Windows::UI::Xaml::Visibility negateVisibility) :
|
||||
m_Name(name),
|
||||
m_NegateVisibility(negateVisibility)
|
||||
{}
|
||||
CategoryViewModel(Platform::String ^ name, Windows::UI::Xaml::Visibility negateVisibility) : m_Name(name), m_NegateVisibility(negateVisibility)
|
||||
{
|
||||
}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Name);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, Name);
|
||||
OBSERVABLE_PROPERTY_RW(Windows::UI::Xaml::Visibility, NegateVisibility);
|
||||
};
|
||||
|
||||
public ref class UnitViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
public
|
||||
ref class UnitViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
UnitViewModel(Platform::String^ unit, Platform::String^ abbr) :
|
||||
m_Name(unit),
|
||||
m_Abbreviation(abbr)
|
||||
{}
|
||||
UnitViewModel(Platform::String ^ unit, Platform::String ^ abbr) : m_Name(unit), m_Abbreviation(abbr)
|
||||
{
|
||||
}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Name);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Abbreviation);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, Name);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, Abbreviation);
|
||||
};
|
||||
|
||||
public ref class UnitConverterSupplementaryResultViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
public
|
||||
ref class UnitConverterSupplementaryResultViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
UnitConverterSupplementaryResultViewModel(Platform::String^ value, Platform::String^ unit, Platform::String^ abbr) :
|
||||
m_Value(value)
|
||||
UnitConverterSupplementaryResultViewModel(Platform::String ^ value, Platform::String ^ unit, Platform::String ^ abbr) : m_Value(value)
|
||||
{
|
||||
m_Unit = ref new UnitViewModel(unit, abbr);
|
||||
}
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Value);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel^, Unit);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, Value);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel ^, Unit);
|
||||
};
|
||||
|
||||
public ref class UnitConverterViewModel sealed: public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
public
|
||||
ref class UnitConverterViewModel sealed : public Windows::UI::Xaml::Data::INotifyPropertyChanged
|
||||
{
|
||||
public:
|
||||
|
||||
UnitConverterViewModel():
|
||||
m_Value1("Åy24"),
|
||||
m_Value2("Åy183"),
|
||||
m_Value1Active(true),
|
||||
m_Value2Active(false)
|
||||
UnitConverterViewModel() : m_Value1("Åy24"), m_Value2("Åy183"), m_Value1Active(true), m_Value2Active(false)
|
||||
{
|
||||
m_SupplementaryResults = ref new Platform::Collections::Vector<UnitConverterSupplementaryResultViewModel^>();
|
||||
m_SupplementaryResults = ref new Platform::Collections::Vector<UnitConverterSupplementaryResultViewModel ^>();
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("128", "Kilograms", "Kgs"));
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("42.55", "Liters", "ÅyL"));
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("1.5e3", "Gallons", "G"));
|
||||
m_SupplementaryResults->Append(ref new UnitConverterSupplementaryResultViewModel("1929", "Gigabyte", "GB"));
|
||||
|
||||
m_Categories = ref new Platform::Collections::Vector<CategoryViewModel^>();
|
||||
m_Categories = ref new Platform::Collections::Vector<CategoryViewModel ^>();
|
||||
m_Categories->Append(ref new CategoryViewModel("Volume"));
|
||||
m_Categories->Append(ref new CategoryViewModel("Temperature", Windows::UI::Xaml::Visibility::Visible));
|
||||
m_CurrentCategory = ref new CategoryViewModel("ÅyTime");
|
||||
m_Categories->Append(m_CurrentCategory);
|
||||
m_Categories->Append(ref new CategoryViewModel("Speed"));
|
||||
|
||||
m_Units = ref new Platform::Collections::Vector<UnitViewModel^>();
|
||||
m_Units = ref new Platform::Collections::Vector<UnitViewModel ^>();
|
||||
m_Unit1 = ref new UnitViewModel("ÅySeconds", "S");
|
||||
m_Unit2 = ref new UnitViewModel("ÅyMinutes", "M");
|
||||
m_Units->Append(ref new UnitViewModel("Miliseconds", "MS"));
|
||||
@@ -100,19 +94,18 @@ namespace Numbers
|
||||
|
||||
OBSERVABLE_OBJECT();
|
||||
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Value1);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String^, Value2);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector^, Categories);
|
||||
OBSERVABLE_PROPERTY_RW(CategoryViewModel^, CurrentCategory);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector^, Units);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel^, Unit1);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel^, Unit2);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, Value1);
|
||||
OBSERVABLE_PROPERTY_RW(Platform::String ^, Value2);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector ^, Categories);
|
||||
OBSERVABLE_PROPERTY_RW(CategoryViewModel ^, CurrentCategory);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector ^, Units);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel ^, Unit1);
|
||||
OBSERVABLE_PROPERTY_RW(UnitViewModel ^, Unit2);
|
||||
OBSERVABLE_PROPERTY_RW(bool, Value1Active);
|
||||
OBSERVABLE_PROPERTY_RW(bool, Value2Active);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector^, SupplementaryResults);
|
||||
OBSERVABLE_PROPERTY_R(Windows::UI::Xaml::Interop::IBindableObservableVector ^, SupplementaryResults);
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -41,11 +41,7 @@ DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsStandard);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsScientific);
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Calculator, IsProgrammer);
|
||||
|
||||
Calculator::Calculator() :
|
||||
m_doAnimate(false),
|
||||
m_isLastAnimatedInScientific(false),
|
||||
m_isLastAnimatedInProgrammer(false),
|
||||
m_resultAnimate(false)
|
||||
Calculator::Calculator() : m_doAnimate(false), m_isLastAnimatedInScientific(false), m_isLastAnimatedInProgrammer(false), m_resultAnimate(false)
|
||||
{
|
||||
SetFontSizeResources();
|
||||
InitializeComponent();
|
||||
@@ -56,7 +52,7 @@ m_resultAnimate(false)
|
||||
HistoryButton->HorizontalAlignment = ::HorizontalAlignment::Left;
|
||||
}
|
||||
|
||||
m_displayFlyout = static_cast<MenuFlyout^>(Resources->Lookup(L"DisplayContextMenu"));
|
||||
m_displayFlyout = static_cast<MenuFlyout ^>(Resources->Lookup(L"DisplayContextMenu"));
|
||||
auto resLoader = AppResourceProvider::GetInstance();
|
||||
CopyMenuItem->Text = resLoader.GetResourceString(L"copyMenuItem");
|
||||
PasteMenuItem->Text = resLoader.GetResourceString(L"pasteMenuItem");
|
||||
@@ -73,7 +69,7 @@ void Calculator::LoadResourceStrings()
|
||||
AutomationProperties::SetName(HistoryButton, m_openHistoryFlyoutAutomationName);
|
||||
}
|
||||
|
||||
void Calculator::InitializeHistoryView(_In_ HistoryViewModel^ historyVM)
|
||||
void Calculator::InitializeHistoryView(_In_ HistoryViewModel ^ historyVM)
|
||||
{
|
||||
if (m_historyList == nullptr)
|
||||
{
|
||||
@@ -89,30 +85,18 @@ void Calculator::SetFontSizeResources()
|
||||
// Since we need different font sizes for different numeric system,
|
||||
// we use a table of optimal font sizes for each numeric system.
|
||||
static const FontTable fontTables[] = {
|
||||
{ L"Arab", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"ArabExt", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"Beng", 104, 26, 17, 40, 56, 40, 56 },
|
||||
{ L"Deva", 104, 29.333, 20.5, 40, 56, 40, 56 },
|
||||
{ L"Gujr", 104, 29.333, 18.5, 40, 56, 40, 56 },
|
||||
{ L"Khmr", 104, 29.333, 19.5, 40, 56, 40, 56 },
|
||||
{ L"Knda", 104, 25, 17, 40, 56, 40, 56 },
|
||||
{ L"Laoo", 104, 28, 18, 40, 56, 40, 56 },
|
||||
{ L"Latn", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"Mlym", 80, 22, 15.5, 30, 56, 35, 48 },
|
||||
{ L"Mymr", 104, 29.333, 20, 35, 48, 36, 48 },
|
||||
{ L"Orya", 88, 26, 20, 40, 56, 40, 56 },
|
||||
{ L"TamlDec", 77, 25, 16, 28, 48, 34, 48 },
|
||||
{ L"Telu", 104, 25, 16.5, 40, 56, 40, 56 },
|
||||
{ L"Thai", 104, 28, 18, 40, 56, 40, 56 },
|
||||
{ L"Tibt", 104, 29.333, 20, 40, 56, 40, 56 },
|
||||
{ L"Default", 104, 29.333, 23, 40, 56, 40, 56 }
|
||||
{ L"Arab", 104, 29.333, 23, 40, 56, 40, 56 }, { L"ArabExt", 104, 29.333, 23, 40, 56, 40, 56 }, { L"Beng", 104, 26, 17, 40, 56, 40, 56 },
|
||||
{ L"Deva", 104, 29.333, 20.5, 40, 56, 40, 56 }, { L"Gujr", 104, 29.333, 18.5, 40, 56, 40, 56 }, { L"Khmr", 104, 29.333, 19.5, 40, 56, 40, 56 },
|
||||
{ L"Knda", 104, 25, 17, 40, 56, 40, 56 }, { L"Laoo", 104, 28, 18, 40, 56, 40, 56 }, { L"Latn", 104, 29.333, 23, 40, 56, 40, 56 },
|
||||
{ L"Mlym", 80, 22, 15.5, 30, 56, 35, 48 }, { L"Mymr", 104, 29.333, 20, 35, 48, 36, 48 }, { L"Orya", 88, 26, 20, 40, 56, 40, 56 },
|
||||
{ L"TamlDec", 77, 25, 16, 28, 48, 34, 48 }, { L"Telu", 104, 25, 16.5, 40, 56, 40, 56 }, { L"Thai", 104, 28, 18, 40, 56, 40, 56 },
|
||||
{ L"Tibt", 104, 29.333, 20, 40, 56, 40, 56 }, { L"Default", 104, 29.333, 23, 40, 56, 40, 56 }
|
||||
};
|
||||
|
||||
DecimalFormatter^ formatter = LocalizationService::GetRegionalSettingsAwareDecimalFormatter();
|
||||
DecimalFormatter ^ formatter = LocalizationService::GetRegionalSettingsAwareDecimalFormatter();
|
||||
|
||||
const FontTable* currentItem = fontTables;
|
||||
while (currentItem->numericSystem.compare(std::wstring(L"Default")) != 0 &&
|
||||
currentItem->numericSystem.compare(formatter->NumeralSystem->Data()) != 0)
|
||||
while (currentItem->numericSystem.compare(std::wstring(L"Default")) != 0 && currentItem->numericSystem.compare(formatter->NumeralSystem->Data()) != 0)
|
||||
{
|
||||
currentItem++;
|
||||
}
|
||||
@@ -126,36 +110,36 @@ void Calculator::SetFontSizeResources()
|
||||
this->Resources->Insert(StringReference(L"CalcButtonScientificPortraitCaptionSizeOverride"), currentItem->portraitScientificNumPadFont);
|
||||
}
|
||||
|
||||
void Calculator::OnLoaded(_In_ Object^, _In_ RoutedEventArgs^)
|
||||
void Calculator::OnLoaded(_In_ Object ^, _In_ RoutedEventArgs ^)
|
||||
{
|
||||
Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &Calculator::OnCalcPropertyChanged);
|
||||
Model->HideMemoryClicked += ref new HideMemoryClickedHandler(this, &Calculator::OnHideMemoryClicked);
|
||||
|
||||
InitializeHistoryView(Model->HistoryVM);
|
||||
String^ historyPaneName = AppResourceProvider::GetInstance().GetResourceString(L"HistoryPane");
|
||||
String ^ historyPaneName = AppResourceProvider::GetInstance().GetResourceString(L"HistoryPane");
|
||||
HistoryFlyout->FlyoutPresenterStyle->Setters->Append(ref new Setter(AutomationProperties::NameProperty, historyPaneName));
|
||||
String^ memoryPaneName = AppResourceProvider::GetInstance().GetResourceString(L"MemoryPane");
|
||||
String ^ memoryPaneName = AppResourceProvider::GetInstance().GetResourceString(L"MemoryPane");
|
||||
MemoryFlyout->FlyoutPresenterStyle->Setters->Append(ref new Setter(AutomationProperties::NameProperty, memoryPaneName));
|
||||
|
||||
if (Windows::Foundation::Metadata::ApiInformation::IsEventPresent(L"Windows.UI.Xaml.Controls.Primitives.FlyoutBase", L"Closing"))
|
||||
{
|
||||
HistoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase^, FlyoutBaseClosingEventArgs^>(this, &Calculator::HistoryFlyout_Closing);
|
||||
MemoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase^, FlyoutBaseClosingEventArgs^>(this, &Calculator::OnMemoryFlyoutClosing);
|
||||
HistoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase ^, FlyoutBaseClosingEventArgs ^>(this, &Calculator::HistoryFlyout_Closing);
|
||||
MemoryFlyout->Closing += ref new TypedEventHandler<FlyoutBase ^, FlyoutBaseClosingEventArgs ^>(this, &Calculator::OnMemoryFlyoutClosing);
|
||||
}
|
||||
|
||||
// Delay load things later when we get a chance.
|
||||
WeakReference weakThis(this);
|
||||
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([weakThis]()
|
||||
{
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
auto refThis = weakThis.Resolve<Calculator>();
|
||||
if (refThis != nullptr)
|
||||
this->Dispatcher->RunAsync(
|
||||
CoreDispatcherPriority::Normal, ref new DispatchedHandler([weakThis]() {
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
refThis->GetMemory();
|
||||
auto refThis = weakThis.Resolve<Calculator>();
|
||||
if (refThis != nullptr)
|
||||
{
|
||||
refThis->GetMemory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
}));
|
||||
}
|
||||
|
||||
std::wstring Calculator::GetCurrentLayoutState()
|
||||
@@ -203,17 +187,17 @@ void Calculator::UpdateViewState()
|
||||
CloseHistoryFlyout();
|
||||
CloseMemoryFlyout();
|
||||
|
||||
VisualStateManager::GoToState(this, ref new String(state.c_str()), true/*useTransitions*/);
|
||||
VisualStateManager::GoToState(this, ref new String(state.c_str()), true /*useTransitions*/);
|
||||
}
|
||||
|
||||
|
||||
void Calculator::AnimateCalculator(bool resultAnimate)
|
||||
{
|
||||
if (App::IsAnimationEnabled())
|
||||
{
|
||||
m_doAnimate = true;
|
||||
m_resultAnimate = resultAnimate;
|
||||
if (((m_isLastAnimatedInScientific && IsScientific) || (!m_isLastAnimatedInScientific && !IsScientific)) && ((m_isLastAnimatedInProgrammer && IsProgrammer) || (!m_isLastAnimatedInProgrammer && !IsProgrammer)))
|
||||
if (((m_isLastAnimatedInScientific && IsScientific) || (!m_isLastAnimatedInScientific && !IsScientific))
|
||||
&& ((m_isLastAnimatedInProgrammer && IsProgrammer) || (!m_isLastAnimatedInProgrammer && !IsProgrammer)))
|
||||
{
|
||||
// We are forcing the animation here
|
||||
// It's because if last animation was in standard, then go to unit converter, then comes back to standard
|
||||
@@ -223,9 +207,9 @@ void Calculator::AnimateCalculator(bool resultAnimate)
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::OnContextRequested(UIElement^ sender, ContextRequestedEventArgs^ e)
|
||||
void Calculator::OnContextRequested(UIElement ^ sender, ContextRequestedEventArgs ^ e)
|
||||
{
|
||||
auto requestedElement = safe_cast<FrameworkElement^>(e->OriginalSource);
|
||||
auto requestedElement = safe_cast<FrameworkElement ^>(e->OriginalSource);
|
||||
|
||||
PasteMenuItem->IsEnabled = CopyPasteManager::HasStringToPaste();
|
||||
|
||||
@@ -243,12 +227,12 @@ void Calculator::OnContextRequested(UIElement^ sender, ContextRequestedEventArgs
|
||||
e->Handled = true;
|
||||
}
|
||||
|
||||
void Calculator::OnContextCanceled(UIElement^ sender, RoutedEventArgs^ e)
|
||||
void Calculator::OnContextCanceled(UIElement ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
m_displayFlyout->Hide();
|
||||
}
|
||||
|
||||
void Calculator::OnLayoutStateChanged(_In_ Object^ sender, _In_ Object^ e)
|
||||
void Calculator::OnLayoutStateChanged(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
UpdatePanelViewState();
|
||||
}
|
||||
@@ -275,7 +259,7 @@ void Calculator::OnIsProgrammerPropertyChanged(bool /*oldValue*/, bool newValue)
|
||||
if (newValue)
|
||||
{
|
||||
EnsureProgrammer();
|
||||
m_pivotItem = static_cast<Windows::UI::Xaml::Controls::PivotItem^>(DockPivot->Items->GetAt(0));
|
||||
m_pivotItem = static_cast<Windows::UI::Xaml::Controls::PivotItem ^>(DockPivot->Items->GetAt(0));
|
||||
DockPivot->Items->RemoveAt(0);
|
||||
}
|
||||
else
|
||||
@@ -295,7 +279,7 @@ void Calculator::OnIsInErrorPropertyChanged()
|
||||
{
|
||||
bool isError = Model->IsInError;
|
||||
|
||||
String^ newState = isError ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = isError ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
|
||||
if (m_memory != nullptr)
|
||||
@@ -316,7 +300,7 @@ void Calculator::OnIsInErrorPropertyChanged()
|
||||
|
||||
// Once the storyboard that rearranges the buttons completed,
|
||||
// We do the animation based on the Mode or Orientation change.
|
||||
void Calculator::OnStoryboardCompleted(_In_ Object^ sender, _In_ Object^ e)
|
||||
void Calculator::OnStoryboardCompleted(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
m_isLastAnimatedInScientific = IsScientific;
|
||||
m_isLastAnimatedInProgrammer = IsProgrammer;
|
||||
@@ -361,9 +345,9 @@ void Calculator::EnsureProgrammer()
|
||||
ProgrammerOperators->SetRadixButton(Model->GetCurrentRadixType());
|
||||
}
|
||||
|
||||
void Calculator::OnCalcPropertyChanged(_In_ Object^ sender, _In_ PropertyChangedEventArgs^ e)
|
||||
void Calculator::OnCalcPropertyChanged(_In_ Object ^ sender, _In_ PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
String^ prop = e->PropertyName;
|
||||
String ^ prop = e->PropertyName;
|
||||
if (prop == StandardCalculatorViewModel::IsMemoryEmptyPropertyName)
|
||||
{
|
||||
UpdateMemoryState();
|
||||
@@ -382,7 +366,7 @@ void Calculator::UpdatePanelViewState()
|
||||
|
||||
void Calculator::UpdateHistoryState()
|
||||
{
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState == ViewState::DockedView)
|
||||
{
|
||||
// docked view
|
||||
@@ -396,7 +380,7 @@ void Calculator::UpdateHistoryState()
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // flyout view
|
||||
{ // flyout view
|
||||
DockHistoryHolder->Child = nullptr;
|
||||
if (!IsProgrammer)
|
||||
{
|
||||
@@ -418,7 +402,7 @@ void Calculator::UpdateMemoryState()
|
||||
ClearMemoryButton->IsEnabled = false;
|
||||
}
|
||||
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState == ViewState::DockedView)
|
||||
{
|
||||
CloseMemoryFlyout();
|
||||
@@ -457,7 +441,7 @@ void Calculator::OnHideHistoryClicked()
|
||||
ToggleHistoryFlyout(nullptr);
|
||||
}
|
||||
|
||||
void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel^ e)
|
||||
void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel ^ e)
|
||||
{
|
||||
unsigned int tokenSize;
|
||||
assert(e->GetTokens() != nullptr);
|
||||
@@ -473,7 +457,7 @@ void Calculator::OnHistoryItemClicked(_In_ HistoryItemViewModel^ e)
|
||||
this->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void Calculator::HistoryFlyout_Opened(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::HistoryFlyout_Opened(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
m_fIsHistoryFlyoutOpen = true;
|
||||
m_IsLastFlyoutMemory = false;
|
||||
@@ -484,13 +468,13 @@ void Calculator::HistoryFlyout_Opened(_In_ Object ^sender, _In_ Object ^args)
|
||||
TraceLogger::GetInstance().LogHistoryBodyOpened();
|
||||
}
|
||||
|
||||
void Calculator::HistoryFlyout_Closing(_In_ FlyoutBase^ sender, _In_ FlyoutBaseClosingEventArgs^ args)
|
||||
void Calculator::HistoryFlyout_Closing(_In_ FlyoutBase ^ sender, _In_ FlyoutBaseClosingEventArgs ^ args)
|
||||
{
|
||||
// Set in the Closing event so the new name is available when the Flyout has Closed.
|
||||
AutomationProperties::SetName(HistoryButton, m_openHistoryFlyoutAutomationName);
|
||||
}
|
||||
|
||||
void Calculator::HistoryFlyout_Closed(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::HistoryFlyout_Closed(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
|
||||
// Closing is not available until RS1+ so we set the name again here for TH2 support.
|
||||
@@ -526,9 +510,9 @@ void Calculator::SetDefaultFocus()
|
||||
Results->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void Calculator::ToggleHistoryFlyout(Object^ /*parameter*/)
|
||||
void Calculator::ToggleHistoryFlyout(Object ^ /*parameter*/)
|
||||
{
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
// If app starts correctly in snap mode and shortcut is used for history then we need to load history if not yet initialized.
|
||||
if (viewState != ViewState::DockedView)
|
||||
{
|
||||
@@ -548,7 +532,7 @@ void Calculator::ToggleHistoryFlyout(Object^ /*parameter*/)
|
||||
|
||||
void Calculator::ToggleMemoryFlyout()
|
||||
{
|
||||
String^ viewState = App::GetAppViewState();
|
||||
String ^ viewState = App::GetAppViewState();
|
||||
if (viewState != ViewState::DockedView)
|
||||
{
|
||||
if (m_fIsMemoryFlyoutOpen)
|
||||
@@ -565,7 +549,7 @@ void Calculator::ToggleMemoryFlyout()
|
||||
}
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyoutOpened(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::OnMemoryFlyoutOpened(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
TraceLogger::GetInstance().LogMemoryFlyoutOpenEnd(Model->MemorizedNumbers->Size);
|
||||
m_IsLastFlyoutMemory = true;
|
||||
@@ -576,13 +560,13 @@ void Calculator::OnMemoryFlyoutOpened(_In_ Object ^sender, _In_ Object ^args)
|
||||
TraceLogger::GetInstance().LogMemoryBodyOpened();
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyoutClosing(_In_ FlyoutBase^ sender, _In_ FlyoutBaseClosingEventArgs^ args)
|
||||
void Calculator::OnMemoryFlyoutClosing(_In_ FlyoutBase ^ sender, _In_ FlyoutBaseClosingEventArgs ^ args)
|
||||
{
|
||||
// Set in the Closing event so the new name is available when the Flyout has Closed.
|
||||
AutomationProperties::SetName(MemoryButton, m_openMemoryFlyoutAutomationName);
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyoutClosed(_In_ Object ^sender, _In_ Object ^args)
|
||||
void Calculator::OnMemoryFlyoutClosed(_In_ Object ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
// Ideally, this would be renamed in the Closing event because the Closed event is too late.
|
||||
// Closing is not available until RS1+ so we set the name again here for TH2 support.
|
||||
@@ -597,12 +581,12 @@ void Calculator::OnMemoryFlyoutClosed(_In_ Object ^sender, _In_ Object ^args)
|
||||
FullscreenFlyoutClosed();
|
||||
}
|
||||
|
||||
Memory^ Calculator::GetMemory()
|
||||
Memory ^ Calculator::GetMemory()
|
||||
{
|
||||
if (m_memory == nullptr)
|
||||
{
|
||||
m_memory = ref new Memory();
|
||||
VisualStateManager::GoToState(m_memory, ref new String(GetCurrentLayoutState().c_str()), true/*useTransitions*/);
|
||||
VisualStateManager::GoToState(m_memory, ref new String(GetCurrentLayoutState().c_str()), true /*useTransitions*/);
|
||||
}
|
||||
|
||||
return m_memory;
|
||||
@@ -636,9 +620,9 @@ void Calculator::EnableControls(bool enable)
|
||||
EnableMemoryControls(enable);
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEventArgs^ e)
|
||||
void Calculator::OnMemoryFlyOutTapped(_In_ Object ^ sender, _In_ TappedRoutedEventArgs ^ e)
|
||||
{
|
||||
Grid^ grid = safe_cast<Grid^> (sender);
|
||||
Grid ^ grid = safe_cast<Grid ^>(sender);
|
||||
Point point = e->GetPosition(nullptr);
|
||||
|
||||
if (point.Y < (grid->ActualHeight - NumpadPanel->ActualHeight))
|
||||
@@ -647,10 +631,9 @@ void Calculator::OnMemoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEven
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Calculator::OnHistoryFlyOutTapped(_In_ Object^ sender, _In_ TappedRoutedEventArgs^ e)
|
||||
void Calculator::OnHistoryFlyOutTapped(_In_ Object ^ sender, _In_ TappedRoutedEventArgs ^ e)
|
||||
{
|
||||
Grid^ grid = safe_cast<Grid^> (sender);
|
||||
Grid ^ grid = safe_cast<Grid ^>(sender);
|
||||
Point point = e->GetPosition(nullptr);
|
||||
|
||||
if (point.Y < (grid->ActualHeight - NumpadPanel->ActualHeight))
|
||||
@@ -668,7 +651,7 @@ bool Calculator::IsValidRegularExpression(std::wstring str)
|
||||
regexPatterns[2] = L"[-]{0,1}[0-9]{0,}[.]{0,1}[0-9]{0,}[e]{1}[-]{1}[0-9]{1,}";
|
||||
|
||||
const auto& localizer = LocalizationSettings::GetInstance();
|
||||
String^ englishString = localizer.GetEnglishValueFromLocalizedDigits(str);
|
||||
String ^ englishString = localizer.GetEnglishValueFromLocalizedDigits(str);
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
@@ -681,7 +664,7 @@ bool Calculator::IsValidRegularExpression(std::wstring str)
|
||||
return result;
|
||||
}
|
||||
|
||||
void Calculator::DockPanelTapped(_In_ TappedRoutedEventArgs^ e)
|
||||
void Calculator::DockPanelTapped(_In_ TappedRoutedEventArgs ^ e)
|
||||
{
|
||||
int index = DockPivot->SelectedIndex;
|
||||
if (index == 1 && !IsProgrammer)
|
||||
@@ -698,23 +681,22 @@ void Calculator::UnregisterEventHandlers()
|
||||
ExpressionText->UnregisterEventHandlers();
|
||||
}
|
||||
|
||||
void Calculator::OnErrorLayoutCompleted(_In_ Object^ sender, _In_ Object^ e)
|
||||
void Calculator::OnErrorLayoutCompleted(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
SetDefaultFocus();
|
||||
}
|
||||
|
||||
void Calculator::OnHistoryAccessKeyInvoked(_In_ UIElement^ sender, _In_ AccessKeyInvokedEventArgs^ args)
|
||||
void Calculator::OnHistoryAccessKeyInvoked(_In_ UIElement ^ sender, _In_ AccessKeyInvokedEventArgs ^ args)
|
||||
{
|
||||
DockPivot->SelectedItem = HistoryPivotItem;
|
||||
}
|
||||
|
||||
void Calculator::OnMemoryAccessKeyInvoked(_In_ UIElement^ sender, _In_ AccessKeyInvokedEventArgs^ args)
|
||||
void Calculator::OnMemoryAccessKeyInvoked(_In_ UIElement ^ sender, _In_ AccessKeyInvokedEventArgs ^ args)
|
||||
{
|
||||
DockPivot->SelectedItem = MemoryPivotItem;
|
||||
}
|
||||
|
||||
|
||||
void CalculatorApp::Calculator::DockPivot_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
|
||||
void CalculatorApp::Calculator::DockPivot_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e)
|
||||
{
|
||||
if (DockPivot->SelectedIndex == 0)
|
||||
{
|
||||
|
@@ -33,13 +33,13 @@ namespace CalculatorApp
|
||||
double portraitScientificNumPadFont;
|
||||
};
|
||||
|
||||
public delegate void FullscreenFlyoutClosedEventHandler();
|
||||
public
|
||||
delegate void FullscreenFlyoutClosedEventHandler();
|
||||
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class Calculator sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class Calculator sealed
|
||||
{
|
||||
public:
|
||||
event FullscreenFlyoutClosedEventHandler^ FullscreenFlyoutClosed;
|
||||
event FullscreenFlyoutClosedEventHandler ^ FullscreenFlyoutClosed;
|
||||
|
||||
Calculator();
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel^ Model
|
||||
@@ -57,7 +57,7 @@ namespace CalculatorApp
|
||||
COMMAND_FOR_METHOD(HistoryButtonPressed, Calculator::ToggleHistoryFlyout);
|
||||
|
||||
void AnimateCalculator(bool resultAnimate);
|
||||
void InitializeHistoryView(CalculatorApp::ViewModel::HistoryViewModel^ historyVM);
|
||||
void InitializeHistoryView(CalculatorApp::ViewModel::HistoryViewModel ^ historyVM);
|
||||
void UpdatePanelViewState();
|
||||
void UnregisterEventHandlers();
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace CalculatorApp
|
||||
void SetDefaultFocus();
|
||||
|
||||
private:
|
||||
void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void LoadResourceStrings();
|
||||
|
||||
@@ -75,24 +75,24 @@ namespace CalculatorApp
|
||||
void UpdateMemoryState();
|
||||
void UpdateHistoryState();
|
||||
|
||||
void CalculationResultsOnSelected(_In_ Platform::Object^ sender);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void CalculationResultsOnSelected(_In_ Platform::Object ^ sender);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnIsScientificPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnIsProgrammerPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnIsStandardPropertyChanged(bool oldValue, bool newValue);
|
||||
void OnIsInErrorPropertyChanged();
|
||||
void OnCalcPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void OnStoryboardCompleted(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnLayoutStateChanged(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnCalcPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
void OnStoryboardCompleted(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnLayoutStateChanged(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void EnsureScientific();
|
||||
void EnsureProgrammer();
|
||||
void SetFontSizeResources();
|
||||
std::wstring GetCurrentLayoutState();
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Controls::ListView^ m_tokenList;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout^ m_displayFlyout;
|
||||
Windows::UI::Xaml::Controls::ListView ^ m_tokenList;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout ^ m_displayFlyout;
|
||||
bool m_doAnimate;
|
||||
bool m_resultAnimate;
|
||||
bool m_isLastAnimatedInScientific;
|
||||
@@ -100,40 +100,42 @@ namespace CalculatorApp
|
||||
bool m_IsLastFlyoutMemory = false;
|
||||
bool m_IsLastFlyoutHistory = false;
|
||||
|
||||
Platform::String^ m_openMemoryFlyoutAutomationName;
|
||||
Platform::String^ m_closeMemoryFlyoutAutomationName;
|
||||
Platform::String^ m_openHistoryFlyoutAutomationName;
|
||||
Platform::String^ m_closeHistoryFlyoutAutomationName;
|
||||
Platform::String ^ m_openMemoryFlyoutAutomationName;
|
||||
Platform::String ^ m_closeMemoryFlyoutAutomationName;
|
||||
Platform::String ^ m_openHistoryFlyoutAutomationName;
|
||||
Platform::String ^ m_closeHistoryFlyoutAutomationName;
|
||||
|
||||
Windows::UI::Xaml::Controls::PivotItem^ m_pivotItem;
|
||||
Windows::UI::Xaml::Controls::PivotItem ^ m_pivotItem;
|
||||
bool m_IsDigit = false;
|
||||
Memory^ m_memory;
|
||||
void HistoryFlyout_Opened(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
void HistoryFlyout_Closing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase^ sender, _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs^ args);
|
||||
void HistoryFlyout_Closed(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
Memory ^ m_memory;
|
||||
void HistoryFlyout_Opened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void HistoryFlyout_Closing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args);
|
||||
void HistoryFlyout_Closed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnHideHistoryClicked();
|
||||
void OnHideMemoryClicked();
|
||||
void OnHistoryItemClicked(_In_ CalculatorApp::ViewModel::HistoryItemViewModel^ e);
|
||||
void ToggleHistoryFlyout(Platform::Object^ parameter);
|
||||
void OnHistoryItemClicked(_In_ CalculatorApp::ViewModel::HistoryItemViewModel ^ e);
|
||||
void ToggleHistoryFlyout(Platform::Object ^ parameter);
|
||||
void ToggleMemoryFlyout();
|
||||
CalculatorApp::HistoryList^ m_historyList;
|
||||
CalculatorApp::HistoryList ^ m_historyList;
|
||||
bool m_fIsHistoryFlyoutOpen;
|
||||
bool m_fIsMemoryFlyoutOpen;
|
||||
void OnMemoryFlyoutOpened(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
void OnMemoryFlyoutClosing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase^ sender, _In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs^ args);
|
||||
void OnMemoryFlyoutClosed(_In_ Platform::Object ^sender, _In_ Platform::Object ^args);
|
||||
void OnMemoryFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnMemoryFlyoutClosing(_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBase ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::Primitives::FlyoutBaseClosingEventArgs ^ args);
|
||||
void OnMemoryFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ args);
|
||||
void SetChildAsMemory();
|
||||
void SetChildAsHistory();
|
||||
Memory^ GetMemory();
|
||||
Memory ^ GetMemory();
|
||||
void EnableControls(bool enable);
|
||||
void EnableMemoryControls(bool enable);
|
||||
void OnMemoryFlyOutTapped(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnHistoryFlyOutTapped(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnMemoryFlyOutTapped(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e);
|
||||
void OnHistoryFlyOutTapped(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e);
|
||||
bool IsValidRegularExpression(std::wstring str);
|
||||
void DockPanelTapped(_In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
|
||||
void OnErrorLayoutCompleted(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnHistoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs^ args);
|
||||
void OnMemoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs^ args);
|
||||
void DockPivot_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
|
||||
};
|
||||
void DockPanelTapped(_In_ Windows::UI::Xaml::Input::TappedRoutedEventArgs ^ e);
|
||||
void OnErrorLayoutCompleted(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnHistoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
||||
void OnMemoryAccessKeyInvoked(_In_ Windows::UI::Xaml::UIElement ^ sender, _In_ Windows::UI::Xaml::Input::AccessKeyInvokedEventArgs ^ args);
|
||||
void DockPivot_SelectionChanged(Platform::Object ^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -25,8 +25,7 @@ using namespace Windows::UI::Xaml::Input;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() :
|
||||
m_updatingCheckedStates(false)
|
||||
CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() : m_updatingCheckedStates(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
auto booleanToVisibilityConverter = ref new Converters::BooleanToVisibilityConverter;
|
||||
@@ -35,13 +34,13 @@ CalculatorProgrammerBitFlipPanel::CalculatorProgrammerBitFlipPanel() :
|
||||
AssignFlipButtons();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::OnLoaded(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerBitFlipPanel::OnLoaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
UnsubscribePropertyChanged();
|
||||
SubscribePropertyChanged();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::OnUnloaded(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerBitFlipPanel::OnUnloaded(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
UnsubscribePropertyChanged();
|
||||
}
|
||||
@@ -50,8 +49,7 @@ void CalculatorProgrammerBitFlipPanel::SubscribePropertyChanged()
|
||||
{
|
||||
if (Model != nullptr)
|
||||
{
|
||||
m_propertyChangedToken =
|
||||
Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorProgrammerBitFlipPanel::OnPropertyChanged);
|
||||
m_propertyChangedToken = Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &CalculatorProgrammerBitFlipPanel::OnPropertyChanged);
|
||||
|
||||
UpdateCheckedStates();
|
||||
}
|
||||
@@ -66,7 +64,7 @@ void CalculatorProgrammerBitFlipPanel::UnsubscribePropertyChanged()
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object^ sender, PropertyChangedEventArgs^ e)
|
||||
void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object ^ sender, PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->PropertyName == StandardCalculatorViewModel::BinaryDisplayValuePropertyName)
|
||||
{
|
||||
@@ -74,25 +72,25 @@ void CalculatorProgrammerBitFlipPanel::OnPropertyChanged(Object^ sender, Propert
|
||||
}
|
||||
}
|
||||
|
||||
StandardCalculatorViewModel^ CalculatorProgrammerBitFlipPanel::Model::get()
|
||||
StandardCalculatorViewModel ^ CalculatorProgrammerBitFlipPanel::Model::get()
|
||||
{
|
||||
return static_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
return static_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::AssignFlipButtons()
|
||||
{
|
||||
assert(m_flipButtons.size() == 64);
|
||||
|
||||
m_flipButtons[0] = this->Bit0;
|
||||
m_flipButtons[1] = this->Bit1;
|
||||
m_flipButtons[2] = this->Bit2;
|
||||
m_flipButtons[3] = this->Bit3;
|
||||
m_flipButtons[4] = this->Bit4;
|
||||
m_flipButtons[5] = this->Bit5;
|
||||
m_flipButtons[6] = this->Bit6;
|
||||
m_flipButtons[7] = this->Bit7;
|
||||
m_flipButtons[8] = this->Bit8;
|
||||
m_flipButtons[9] = this->Bit9;
|
||||
m_flipButtons[0] = this->Bit0;
|
||||
m_flipButtons[1] = this->Bit1;
|
||||
m_flipButtons[2] = this->Bit2;
|
||||
m_flipButtons[3] = this->Bit3;
|
||||
m_flipButtons[4] = this->Bit4;
|
||||
m_flipButtons[5] = this->Bit5;
|
||||
m_flipButtons[6] = this->Bit6;
|
||||
m_flipButtons[7] = this->Bit7;
|
||||
m_flipButtons[8] = this->Bit8;
|
||||
m_flipButtons[9] = this->Bit9;
|
||||
m_flipButtons[10] = this->Bit10;
|
||||
m_flipButtons[11] = this->Bit11;
|
||||
m_flipButtons[12] = this->Bit12;
|
||||
@@ -149,29 +147,31 @@ void CalculatorProgrammerBitFlipPanel::AssignFlipButtons()
|
||||
m_flipButtons[63] = this->Bit63;
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::SetVisibilityBinding(_In_ FrameworkElement^ element, _In_ String^ path, _In_ IValueConverter^ converter)
|
||||
void CalculatorProgrammerBitFlipPanel::SetVisibilityBinding(_In_ FrameworkElement ^ element, _In_ String ^ path, _In_ IValueConverter ^ converter)
|
||||
{
|
||||
Binding^ commandBinding = ref new Binding();
|
||||
Binding ^ commandBinding = ref new Binding();
|
||||
commandBinding->Path = ref new PropertyPath(path);
|
||||
commandBinding->Converter = converter;
|
||||
element->SetBinding(VisibilityProperty, commandBinding);
|
||||
}
|
||||
|
||||
void CalculatorProgrammerBitFlipPanel::OnBitToggled(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerBitFlipPanel::OnBitToggled(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
if (m_updatingCheckedStates) { return; }
|
||||
if (m_updatingCheckedStates)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle this the bit toggled event only if it is coming from BitFlip mode.
|
||||
// Any input from the Numpad may also result in toggling the bit as their state is bound to the BinaryDisplayValue.
|
||||
// Also, if the mode is switched to other Calculator modes when the BitFlip panel is open,
|
||||
// a race condition exists in which the IsProgrammerMode property is still true and the UpdatePrimaryResult() is called,
|
||||
// which continuously alters the Display Value and the state of the Bit Flip buttons.
|
||||
if ((Model->IsBitFlipChecked)
|
||||
&& Model->IsProgrammer)
|
||||
if ((Model->IsBitFlipChecked) && Model->IsProgrammer)
|
||||
{
|
||||
TraceLogger::GetInstance().LogBitFlipUsed();
|
||||
|
||||
auto flipButton = static_cast<FlipButtons^>(sender);
|
||||
auto flipButton = static_cast<FlipButtons ^>(sender);
|
||||
Model->ButtonPressed->Execute(flipButton->ButtonId);
|
||||
}
|
||||
}
|
||||
@@ -181,17 +181,15 @@ void CalculatorProgrammerBitFlipPanel::UpdateCheckedStates()
|
||||
assert(!m_updatingCheckedStates);
|
||||
assert(m_flipButtons.size() == s_numBits);
|
||||
|
||||
if (Model == nullptr) { return; }
|
||||
if (Model == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static const wchar_t ch0 = LocalizationSettings::GetInstance().GetDigitSymbolFromEnUsDigit(L'0');
|
||||
|
||||
// Filter any unwanted characters from the displayed string.
|
||||
static constexpr array<wchar_t, 4> unwantedChars = {
|
||||
L' ',
|
||||
Utils::LRE,
|
||||
Utils::PDF,
|
||||
Utils::LRO
|
||||
};
|
||||
static constexpr array<wchar_t, 4> unwantedChars = { L' ', Utils::LRE, Utils::PDF, Utils::LRO };
|
||||
|
||||
wstringstream stream;
|
||||
wstring displayValue = Model->BinaryDisplayValue->Data();
|
||||
|
@@ -17,36 +17,33 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerBitFlipPanel sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerBitFlipPanel sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerBitFlipPanel();
|
||||
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel^ Model
|
||||
{
|
||||
CalculatorApp::ViewModel::StandardCalculatorViewModel^ get();
|
||||
}
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel
|
||||
^ Model { CalculatorApp::ViewModel::StandardCalculatorViewModel ^ get(); }
|
||||
|
||||
private:
|
||||
void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
private : void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnUnloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void SubscribePropertyChanged();
|
||||
void UnsubscribePropertyChanged();
|
||||
void OnPropertyChanged(Platform::Object^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void OnPropertyChanged(Platform::Object ^ sender, Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
|
||||
void AssignFlipButtons();
|
||||
|
||||
void SetVisibilityBinding(_In_ Windows::UI::Xaml::FrameworkElement^ element, _In_ Platform::String^ path, _In_ Windows::UI::Xaml::Data::IValueConverter^ converter);
|
||||
void OnBitToggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void SetVisibilityBinding(_In_ Windows::UI::Xaml::FrameworkElement ^ element, _In_ Platform::String ^ path,
|
||||
_In_ Windows::UI::Xaml::Data::IValueConverter ^ converter);
|
||||
void OnBitToggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void UpdateCheckedStates();
|
||||
|
||||
private:
|
||||
Windows::Foundation::EventRegistrationToken m_propertyChangedToken;
|
||||
|
||||
static const unsigned int s_numBits = 64;
|
||||
std::array<CalculatorApp::Controls::FlipButtons^, s_numBits> m_flipButtons;
|
||||
std::array<CalculatorApp::Controls::FlipButtons ^, s_numBits> m_flipButtons;
|
||||
bool m_updatingCheckedStates;
|
||||
};
|
||||
}
|
||||
|
@@ -20,21 +20,20 @@ using namespace Windows::UI::Xaml::Navigation;
|
||||
using namespace Windows::UI::ViewManagement;
|
||||
using namespace Windows::UI::Core;
|
||||
|
||||
CalculatorProgrammerDisplayPanel::CalculatorProgrammerDisplayPanel() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorProgrammerDisplayPanel::CalculatorProgrammerDisplayPanel() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerDisplayPanel::ShowBitFlip(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerDisplayPanel::ShowBitFlip(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogBitFlipPaneClicked();
|
||||
}
|
||||
|
||||
void CalculatorProgrammerDisplayPanel::OnBitLengthButtonPressed(Object^ parameter)
|
||||
void CalculatorProgrammerDisplayPanel::OnBitLengthButtonPressed(Object ^ parameter)
|
||||
{
|
||||
TraceLogger::GetInstance().LogBitLengthButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
String^ buttonId = parameter->ToString();
|
||||
String ^ buttonId = parameter->ToString();
|
||||
|
||||
QwordButton->Visibility = ::Visibility::Collapsed;
|
||||
DwordButton->Visibility = ::Visibility::Collapsed;
|
||||
@@ -90,7 +89,7 @@ void CalculatorProgrammerDisplayPanel::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
@@ -8,8 +8,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerDisplayPanel sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerDisplayPanel sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerDisplayPanel();
|
||||
@@ -23,14 +22,15 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
|
||||
private:
|
||||
void ShowBitFlip(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnBitLengthButtonPressed(Platform::Object^ parameter);
|
||||
void ShowBitFlip(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnBitLengthButtonPressed(Platform::Object ^ parameter);
|
||||
|
||||
bool m_isErrorVisualState;
|
||||
};
|
||||
|
@@ -36,7 +36,7 @@ CalculatorProgrammerOperators::CalculatorProgrammerOperators()
|
||||
CopyMenuItem->Text = AppResourceProvider::GetInstance().GetResourceString(L"copyMenuItem");
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -45,7 +45,7 @@ void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object^ sender, _In_ R
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -54,7 +54,7 @@ void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object^ sender, _In_ R
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -63,7 +63,7 @@ void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object^ sender, _In_ R
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::BinButtonChecked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::BinButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogRadixButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
if (Model)
|
||||
@@ -101,9 +101,9 @@ void CalculatorProgrammerOperators::SetRadixButton(RADIX_TYPE radixType)
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerOperators::OnCopyMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerOperators::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto source = safe_cast<RadixButton^>(ProgrammerOperatorsContextMenu->Target);
|
||||
auto source = safe_cast<RadixButton ^>(ProgrammerOperatorsContextMenu->Target);
|
||||
|
||||
CopyPasteManager::CopyToClipboard(source->GetRawDisplayValue());
|
||||
}
|
||||
|
@@ -9,8 +9,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerOperators();
|
||||
@@ -23,16 +22,15 @@ namespace CalculatorApp
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(CalculatorProgrammerOperators);
|
||||
|
||||
DEPENDENCY_PROPERTY(_In_ Windows::UI::Xaml::Style^, SymbolButtonStyle);
|
||||
DEPENDENCY_PROPERTY(_In_ Windows::UI::Xaml::Style ^, SymbolButtonStyle);
|
||||
|
||||
internal:
|
||||
void SetRadixButton(RADIX_TYPE radixType);
|
||||
internal : void SetRadixButton(RADIX_TYPE radixType);
|
||||
|
||||
private:
|
||||
void DecButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void HexButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void BinButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OctButtonChecked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void DecButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void HexButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void BinButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OctButtonChecked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -23,8 +23,7 @@ using namespace Windows::UI::Xaml::Data;
|
||||
using namespace CalculatorApp::Common;
|
||||
using namespace Windows::UI::Xaml::Media;
|
||||
|
||||
CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -32,19 +31,20 @@ CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators() :
|
||||
SetVisibilityBinding(ProgRadixOps, L"IsBinaryBitFlippingEnabled", booleanToVisibilityNegationConverter);
|
||||
}
|
||||
|
||||
void CalculatorProgrammerRadixOperators::OnLoaded(Object^, RoutedEventArgs^)
|
||||
void CalculatorProgrammerRadixOperators::OnLoaded(Object ^, RoutedEventArgs ^)
|
||||
{
|
||||
m_progModeRadixChangeToken = Model->ProgModeRadixChange += ref new ProgModeRadixChangeHandler(this, &CalculatorProgrammerRadixOperators::ProgModeRadixChange);
|
||||
m_progModeRadixChangeToken = Model->ProgModeRadixChange +=
|
||||
ref new ProgModeRadixChangeHandler(this, &CalculatorProgrammerRadixOperators::ProgModeRadixChange);
|
||||
}
|
||||
void CalculatorProgrammerRadixOperators::OnUnloaded(Object^, RoutedEventArgs^)
|
||||
void CalculatorProgrammerRadixOperators::OnUnloaded(Object ^, RoutedEventArgs ^)
|
||||
{
|
||||
Model->ProgModeRadixChange -= m_progModeRadixChangeToken;
|
||||
}
|
||||
|
||||
void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
bool isShiftChecked = static_cast<ToggleButton^>(sender)->IsChecked->Value;
|
||||
auto scvm = safe_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
bool isShiftChecked = static_cast<ToggleButton ^>(sender)->IsChecked->Value;
|
||||
auto scvm = safe_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
scvm->IsShiftProgrammerChecked = isShiftChecked;
|
||||
|
||||
if (RolButton == nullptr)
|
||||
@@ -69,9 +69,9 @@ void CalculatorProgrammerRadixOperators::Shift_Clicked(Platform::Object^ sender,
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorProgrammerRadixOperators::SetVisibilityBinding(FrameworkElement^ element, String^ path, IValueConverter^ converter)
|
||||
void CalculatorProgrammerRadixOperators::SetVisibilityBinding(FrameworkElement ^ element, String ^ path, IValueConverter ^ converter)
|
||||
{
|
||||
Binding^ commandBinding = ref new Binding();
|
||||
Binding ^ commandBinding = ref new Binding();
|
||||
commandBinding->Path = ref new PropertyPath(path);
|
||||
commandBinding->Converter = converter;
|
||||
element->SetBinding(VisibilityProperty, commandBinding);
|
||||
@@ -92,18 +92,18 @@ void CalculatorProgrammerRadixOperators::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
NumberPad->IsErrorVisualState = m_isErrorVisualState;
|
||||
}
|
||||
}
|
||||
|
||||
String^ CalculatorProgrammerRadixOperators::ParenthesisCountToString(unsigned int count) {
|
||||
String ^ CalculatorProgrammerRadixOperators::ParenthesisCountToString(unsigned int count)
|
||||
{
|
||||
return (count == 0) ? ref new String() : ref new String(to_wstring(count).data());
|
||||
}
|
||||
|
||||
|
||||
void CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators::OpenParenthesisButton_GotFocus(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorProgrammerRadixOperators::CalculatorProgrammerRadixOperators::OpenParenthesisButton_GotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->SetOpenParenthesisCountNarratorAnnouncement();
|
||||
}
|
||||
|
@@ -9,8 +9,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorProgrammerRadixOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorProgrammerRadixOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorProgrammerRadixOperators();
|
||||
@@ -22,23 +21,24 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
Platform::String^ ParenthesisCountToString(unsigned int count);
|
||||
Platform::String ^ ParenthesisCountToString(unsigned int count);
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(CalculatorProgrammerRadixOperators);
|
||||
|
||||
private:
|
||||
void Shift_Clicked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void SetVisibilityBinding(Windows::UI::Xaml::FrameworkElement^ element, Platform::String^ path, Windows::UI::Xaml::Data::IValueConverter^ converter);
|
||||
void OnLoaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnUnloaded(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void Shift_Clicked(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void SetVisibilityBinding(Windows::UI::Xaml::FrameworkElement ^ element, Platform::String ^ path, Windows::UI::Xaml::Data::IValueConverter ^ converter);
|
||||
void OnLoaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnUnloaded(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void ProgModeRadixChange();
|
||||
|
||||
bool m_isErrorVisualState;
|
||||
Windows::Foundation::EventRegistrationToken m_progModeRadixChangeToken;
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -29,27 +29,26 @@ using namespace Windows::UI::Core;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
CalculatorScientificAngleButtons::CalculatorScientificAngleButtons() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorScientificAngleButtons::CalculatorScientificAngleButtons() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void CalculatorScientificAngleButtons::HypButton_Toggled(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void CalculatorScientificAngleButtons::HypButton_Toggled(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
TraceLogger::GetInstance().LogHypButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}
|
||||
|
||||
void CalculatorScientificAngleButtons::FToEButton_Toggled(_In_ Object^ sender,_In_ RoutedEventArgs^ e)
|
||||
void CalculatorScientificAngleButtons::FToEButton_Toggled(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto viewModel = safe_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
auto viewModel = safe_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
viewModel->FtoEButtonToggled();
|
||||
}
|
||||
|
||||
void CalculatorApp::CalculatorScientificAngleButtons::OnAngleButtonPressed(_In_ Object^ commandParameter)
|
||||
void CalculatorApp::CalculatorScientificAngleButtons::OnAngleButtonPressed(_In_ Object ^ commandParameter)
|
||||
{
|
||||
TraceLogger::GetInstance().LogAngleButtonUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
String^ buttonId = static_cast<String^>(commandParameter);
|
||||
String ^ buttonId = static_cast<String ^>(commandParameter);
|
||||
|
||||
DegreeButton->Visibility = ::Visibility::Collapsed;
|
||||
RadianButton->Visibility = ::Visibility::Collapsed;
|
||||
@@ -85,7 +84,7 @@ void CalculatorScientificAngleButtons::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorScientificAngleButtons sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorScientificAngleButtons sealed
|
||||
{
|
||||
public:
|
||||
CalculatorScientificAngleButtons();
|
||||
@@ -27,16 +26,17 @@ namespace CalculatorApp
|
||||
|
||||
COMMAND_FOR_METHOD(ButtonPressed, CalculatorScientificAngleButtons::OnAngleButtonPressed)
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
|
||||
private:
|
||||
void OnAngleButtonPressed(_In_ Platform::Object^ commandParameter);
|
||||
void FToEButton_Toggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void HypButton_Toggled(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnAngleButtonPressed(_In_ Platform::Object ^ commandParameter);
|
||||
void FToEButton_Toggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void HypButton_Toggled(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
bool m_isErrorVisualState;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@@ -39,14 +39,14 @@ CalculatorScientificOperators::CalculatorScientificOperators()
|
||||
Common::KeyboardShortcutManager::ShiftButtonChecked(false);
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::ShortLayout_Completed(_In_ Platform::Object^ /*sender*/, _In_ Platform::Object^ /*e*/)
|
||||
void CalculatorScientificOperators::ShortLayout_Completed(_In_ Platform::Object ^ /*sender*/, _In_ Platform::Object ^ /*e*/)
|
||||
{
|
||||
IsWideLayout = false;
|
||||
SetOperatorRowVisibility();
|
||||
Common::KeyboardShortcutManager::ShiftButtonChecked(Model->IsShiftChecked);
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::WideLayout_Completed(_In_ Platform::Object^ /*sender*/, _In_ Platform::Object^ /*e*/)
|
||||
void CalculatorScientificOperators::WideLayout_Completed(_In_ Platform::Object ^ /*sender*/, _In_ Platform::Object ^ /*e*/)
|
||||
{
|
||||
IsWideLayout = true;
|
||||
SetOperatorRowVisibility();
|
||||
@@ -55,12 +55,12 @@ void CalculatorScientificOperators::WideLayout_Completed(_In_ Platform::Object^
|
||||
|
||||
void CalculatorScientificOperators::OnIsErrorVisualStatePropertyChanged(bool /*oldValue*/, bool newValue)
|
||||
{
|
||||
String^ newState = newValue ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = newValue ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
NumberPad->IsErrorVisualState = newValue;
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Xaml::RoutedEventArgs^ /*e*/)
|
||||
void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object ^ /*sender*/, _In_ Windows::UI::Xaml::RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
bool isChecked = ShiftButton->IsChecked->Value;
|
||||
Model->IsShiftChecked = isChecked;
|
||||
@@ -68,7 +68,8 @@ void CalculatorScientificOperators::shiftButton_Check(_In_ Platform::Object^ /*s
|
||||
SetOperatorRowVisibility();
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::shiftButton_IsEnabledChanged(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ /*e*/)
|
||||
void CalculatorScientificOperators::shiftButton_IsEnabledChanged(_In_ Platform::Object ^ /*sender*/,
|
||||
_In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ /*e*/)
|
||||
{
|
||||
SetOperatorRowVisibility();
|
||||
Common::KeyboardShortcutManager::ShiftButtonChecked(ShiftButton->IsEnabled && ShiftButton->IsChecked->Value);
|
||||
@@ -99,11 +100,12 @@ void CalculatorScientificOperators::SetOperatorRowVisibility()
|
||||
InvRow2->Visibility = invRowVis;
|
||||
}
|
||||
|
||||
void CalculatorScientificOperators::OpenParenthesisButton_GotFocus(Object^ sender, RoutedEventArgs^ e)
|
||||
void CalculatorScientificOperators::OpenParenthesisButton_GotFocus(Object ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->SetOpenParenthesisCountNarratorAnnouncement();
|
||||
}
|
||||
|
||||
String^ CalculatorScientificOperators::ParenthesisCountToString(unsigned int count) {
|
||||
String ^ CalculatorScientificOperators::ParenthesisCountToString(unsigned int count)
|
||||
{
|
||||
return (count == 0) ? ref new String() : ref new String(to_wstring(count).data());
|
||||
}
|
||||
|
@@ -16,8 +16,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorScientificOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorScientificOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorScientificOperators();
|
||||
@@ -32,15 +31,19 @@ namespace CalculatorApp
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT_AND_CALLBACK(bool, IsErrorVisualState, false);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(bool, IsWideLayout, false);
|
||||
|
||||
bool IsShiftEnabled(bool isWideLayout, bool isErrorState) { return !(isWideLayout || isErrorState); }
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
Platform::String^ ParenthesisCountToString(unsigned int count);
|
||||
bool IsShiftEnabled(bool isWideLayout, bool isErrorState)
|
||||
{
|
||||
return !(isWideLayout || isErrorState);
|
||||
}
|
||||
void OpenParenthesisButton_GotFocus(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
Platform::String ^ ParenthesisCountToString(unsigned int count);
|
||||
|
||||
private:
|
||||
void ShortLayout_Completed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void WideLayout_Completed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void ShortLayout_Completed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void WideLayout_Completed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnIsErrorVisualStatePropertyChanged(bool oldValue, bool newValue);
|
||||
void shiftButton_Check(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void shiftButton_IsEnabledChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ e);
|
||||
void shiftButton_Check(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void shiftButton_IsEnabledChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ e);
|
||||
void SetOperatorRowVisibility();
|
||||
};
|
||||
}
|
||||
|
@@ -24,13 +24,13 @@ using namespace Windows::UI::Xaml::Navigation;
|
||||
|
||||
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
|
||||
|
||||
CalculatorStandardOperators::CalculatorStandardOperators() :
|
||||
m_isErrorVisualState(false)
|
||||
CalculatorStandardOperators::CalculatorStandardOperators() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
bool CalculatorStandardOperators::IsErrorVisualState::get() {
|
||||
bool CalculatorStandardOperators::IsErrorVisualState::get()
|
||||
{
|
||||
return m_isErrorVisualState;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ void CalculatorStandardOperators::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
NumberPad->IsErrorVisualState = m_isErrorVisualState;
|
||||
}
|
||||
|
@@ -13,8 +13,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class CalculatorStandardOperators sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class CalculatorStandardOperators sealed
|
||||
{
|
||||
public:
|
||||
CalculatorStandardOperators();
|
||||
|
@@ -51,7 +51,7 @@ DateCalculator::DateCalculator()
|
||||
// Setting the FirstDayofWeek
|
||||
DateDiff_FromDate->FirstDayOfWeek = localizationSettings.GetFirstDayOfWeek();
|
||||
DateDiff_ToDate->FirstDayOfWeek = localizationSettings.GetFirstDayOfWeek();
|
||||
|
||||
|
||||
// Setting the Language explicitly is not required,
|
||||
// this is a workaround for the bug in the control due to which
|
||||
// the displayed date is incorrect for non Gregorian Calendar Systems
|
||||
@@ -79,10 +79,9 @@ DateCalculator::DateCalculator()
|
||||
DateDiff_ToDate->MaxDate = maxYear;
|
||||
|
||||
// Set the PlaceHolderText for CalendarDatePicker
|
||||
DateTimeFormatter^ dateTimeFormatter = LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(
|
||||
L"day month year",
|
||||
localizationSettings.GetCalendarIdentifier(),
|
||||
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used
|
||||
DateTimeFormatter ^ dateTimeFormatter =
|
||||
LocalizationService::GetRegionalSettingsAwareDateTimeFormatter(L"day month year", localizationSettings.GetCalendarIdentifier(),
|
||||
ClockIdentifiers::TwentyFourHour); // Clock Identifier is not used
|
||||
|
||||
DateDiff_FromDate->DateFormat = L"day month year";
|
||||
DateDiff_ToDate->DateFormat = L"day month year";
|
||||
@@ -93,14 +92,15 @@ DateCalculator::DateCalculator()
|
||||
DateDiff_ToDate->PlaceholderText = placeholderText;
|
||||
|
||||
CopyMenuItem->Text = AppResourceProvider::GetInstance().GetResourceString(L"copyMenuItem");
|
||||
m_dateCalcOptionChangedEventToken = DateCalculationOption->SelectionChanged += ref new SelectionChangedEventHandler(this, &DateCalculator::DateCalcOption_Changed);
|
||||
m_dateCalcOptionChangedEventToken = DateCalculationOption->SelectionChanged +=
|
||||
ref new SelectionChangedEventHandler(this, &DateCalculator::DateCalcOption_Changed);
|
||||
}
|
||||
|
||||
void DateCalculator::FromDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_ CalendarDatePickerDateChangedEventArgs^ e)
|
||||
void DateCalculator::FromDate_DateChanged(_In_ CalendarDatePicker ^ sender, _In_ CalendarDatePickerDateChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->NewDate != nullptr)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
dateCalcViewModel->FromDate = e->NewDate->Value;
|
||||
TraceLogger::GetInstance().LogDateDifferenceModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}
|
||||
@@ -110,11 +110,11 @@ void DateCalculator::FromDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_
|
||||
}
|
||||
}
|
||||
|
||||
void DateCalculator::ToDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_ CalendarDatePickerDateChangedEventArgs^ e)
|
||||
void DateCalculator::ToDate_DateChanged(_In_ CalendarDatePicker ^ sender, _In_ CalendarDatePickerDateChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->NewDate != nullptr)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
dateCalcViewModel->ToDate = e->NewDate->Value;
|
||||
TraceLogger::GetInstance().LogDateDifferenceModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
|
||||
}
|
||||
@@ -124,13 +124,14 @@ void DateCalculator::ToDate_DateChanged(_In_ CalendarDatePicker^ sender, _In_ Ca
|
||||
}
|
||||
}
|
||||
|
||||
void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker^ sender, _In_ CalendarDatePickerDateChangedEventArgs^ e)
|
||||
void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker ^ sender, _In_ CalendarDatePickerDateChangedEventArgs ^ e)
|
||||
{
|
||||
if (e->NewDate != nullptr)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
dateCalcViewModel->StartDate = e->NewDate->Value;
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), dateCalcViewModel->IsAddMode);
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()),
|
||||
dateCalcViewModel->IsAddMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -138,15 +139,16 @@ void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker^ sender, _I
|
||||
}
|
||||
}
|
||||
|
||||
void CalculatorApp::DateCalculator::OffsetValue_Changed(_In_ Platform::Object^ sender, _In_ SelectionChangedEventArgs^ e)
|
||||
void CalculatorApp::DateCalculator::OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ SelectionChangedEventArgs ^ e)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()), dateCalcViewModel->IsAddMode);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
TraceLogger::GetInstance().LogDateAddSubtractModeUsed(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()),
|
||||
dateCalcViewModel->IsAddMode);
|
||||
}
|
||||
|
||||
void DateCalculator::OnCopyMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void DateCalculator::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto calcResult = safe_cast<TextBlock^>(ResultsContextMenu->Target);
|
||||
auto calcResult = safe_cast<TextBlock ^>(ResultsContextMenu->Target);
|
||||
|
||||
CopyPasteManager::CopyToClipboard(calcResult->Text);
|
||||
}
|
||||
@@ -178,13 +180,13 @@ void DateCalculator::SetDefaultFocus()
|
||||
DateCalculationOption->Focus(::FocusState::Programmatic);
|
||||
}
|
||||
|
||||
void DateCalculator::DateCalcOption_Changed(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e)
|
||||
void DateCalculator::DateCalcOption_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e)
|
||||
{
|
||||
FindName("AddSubtractDateGrid");
|
||||
DateCalculationOption->SelectionChanged -= m_dateCalcOptionChangedEventToken;
|
||||
}
|
||||
|
||||
void CalculatorApp::DateCalculator::AddSubtractDateGrid_Loaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void CalculatorApp::DateCalculator::AddSubtractDateGrid_Loaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
const auto& localizationSettings = LocalizationSettings::GetInstance();
|
||||
|
||||
@@ -198,7 +200,7 @@ void CalculatorApp::DateCalculator::AddSubtractDateGrid_Loaded(_In_ Platform::Ob
|
||||
AddSubtract_FromDate->DateFormat = L"day month year";
|
||||
}
|
||||
|
||||
void DateCalculator::ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ calendarDatePicker, Windows::Foundation::DateTime dateTime)
|
||||
void DateCalculator::ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ calendarDatePicker, Windows::Foundation::DateTime dateTime)
|
||||
{
|
||||
// Reselect the unselected Date
|
||||
calendarDatePicker->Date = ref new Box<DateTime>(dateTime);
|
||||
@@ -207,25 +209,25 @@ void DateCalculator::ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::Cale
|
||||
calendarDatePicker->IsCalendarOpen = false;
|
||||
}
|
||||
|
||||
void DateCalculator::OffsetDropDownClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
void DateCalculator::OffsetDropDownClosed(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
RaiseLiveRegionChangedAutomationEvent(/* DateDiff mode */ false);
|
||||
}
|
||||
|
||||
void DateCalculator::CalendarFlyoutClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
void DateCalculator::CalendarFlyoutClosed(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel^>(this->DataContext);
|
||||
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
|
||||
RaiseLiveRegionChangedAutomationEvent(dateCalcViewModel->IsDateDiffMode);
|
||||
}
|
||||
|
||||
void DateCalculator::RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode)
|
||||
{
|
||||
TextBlock^ resultTextBlock = (isDateDiffMode ? DateDiffAllUnitsResultLabel : DateResultLabel);
|
||||
String^ automationName = AutomationProperties::GetName(resultTextBlock);
|
||||
TextBlock ^ resultTextBlock = (isDateDiffMode ? DateDiffAllUnitsResultLabel : DateResultLabel);
|
||||
String ^ automationName = AutomationProperties::GetName(resultTextBlock);
|
||||
TextBlockAutomationPeer::FromElement(resultTextBlock)->RaiseAutomationEvent(AutomationEvents::LiveRegionChanged);
|
||||
}
|
||||
|
||||
void DateCalculator::AddSubtractOption_Checked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void DateCalculator::AddSubtractOption_Checked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
RaiseLiveRegionChangedAutomationEvent(/* DateDiff mode */ false);
|
||||
}
|
||||
|
@@ -21,8 +21,7 @@ const int c_minYear = 1601;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class DateCalculator sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class DateCalculator sealed
|
||||
{
|
||||
public:
|
||||
DateCalculator();
|
||||
@@ -30,18 +29,21 @@ namespace CalculatorApp
|
||||
void SetDefaultFocus();
|
||||
|
||||
private:
|
||||
void FromDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs^ e);
|
||||
void ToDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs^ e);
|
||||
void AddSubtract_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ sender, _In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs^ e);
|
||||
void OffsetValue_Changed(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void DateCalcOption_Changed(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
|
||||
void AddSubtractDateGrid_Loaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void AddSubtractOption_Checked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker^ calendarDatePicker, Windows::Foundation::DateTime dateTime);
|
||||
void OffsetDropDownClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void CalendarFlyoutClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void FromDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
|
||||
void ToDate_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
|
||||
void AddSubtract_DateChanged(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ sender,
|
||||
_In_ Windows::UI::Xaml::Controls::CalendarDatePickerDateChangedEventArgs ^ e);
|
||||
void OffsetValue_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void DateCalcOption_Changed(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::SelectionChangedEventArgs ^ e);
|
||||
void AddSubtractDateGrid_Loaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void AddSubtractOption_Checked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void ReselectCalendarDate(_In_ Windows::UI::Xaml::Controls::CalendarDatePicker ^ calendarDatePicker, Windows::Foundation::DateTime dateTime);
|
||||
void OffsetDropDownClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void CalendarFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void RaiseLiveRegionChangedAutomationEvent(_In_ bool isDateDiffMode);
|
||||
|
||||
Windows::Foundation::EventRegistrationToken m_dateCalcOptionChangedEventToken;
|
||||
|
@@ -40,10 +40,10 @@ HistoryList::HistoryList()
|
||||
HistoryEmpty->FlowDirection = LocalizationService::GetInstance()->GetFlowDirection();
|
||||
}
|
||||
|
||||
void HistoryList::ListView_ItemClick(_In_ Object^ sender, _In_ ItemClickEventArgs^ e)
|
||||
void HistoryList::ListView_ItemClick(_In_ Object ^ sender, _In_ ItemClickEventArgs ^ e)
|
||||
{
|
||||
HistoryViewModel^ historyVM = static_cast<HistoryViewModel^>(this->DataContext);
|
||||
HistoryItemViewModel^ clickedItem = safe_cast<HistoryItemViewModel^>(e->ClickedItem);
|
||||
HistoryViewModel ^ historyVM = static_cast<HistoryViewModel ^>(this->DataContext);
|
||||
HistoryItemViewModel ^ clickedItem = safe_cast<HistoryItemViewModel ^>(e->ClickedItem);
|
||||
|
||||
// When the user clears the history list in the overlay view and presses enter, the clickedItem is nullptr
|
||||
if (clickedItem != nullptr)
|
||||
@@ -52,16 +52,16 @@ void HistoryList::ListView_ItemClick(_In_ Object^ sender, _In_ ItemClickEventArg
|
||||
}
|
||||
}
|
||||
|
||||
void HistoryList::OnDeleteMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void HistoryList::OnDeleteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto clickedItem = safe_cast<HistoryItemViewModel^>(safe_cast<FrameworkElement^>(sender)->DataContext);
|
||||
auto clickedItem = safe_cast<HistoryItemViewModel ^>(safe_cast<FrameworkElement ^>(sender)->DataContext);
|
||||
|
||||
Model->DeleteItem(clickedItem);
|
||||
}
|
||||
|
||||
void HistoryList::OnDeleteSwipeInvoked(_In_ MUXC::SwipeItem^ sender, _In_ MUXC::SwipeItemInvokedEventArgs^ e)
|
||||
void HistoryList::OnDeleteSwipeInvoked(_In_ MUXC::SwipeItem ^ sender, _In_ MUXC::SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
auto swipedItem = safe_cast<HistoryItemViewModel^>(e->SwipeControl->DataContext);
|
||||
auto swipedItem = safe_cast<HistoryItemViewModel ^>(e->SwipeControl->DataContext);
|
||||
|
||||
Model->DeleteItem(swipedItem);
|
||||
}
|
||||
|
@@ -15,8 +15,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class HistoryList sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class HistoryList sealed
|
||||
{
|
||||
public:
|
||||
HistoryList();
|
||||
@@ -34,8 +33,8 @@ namespace CalculatorApp
|
||||
private:
|
||||
Windows::Foundation::Rect m_visibleBounds;
|
||||
Windows::Foundation::Rect m_coreBounds;
|
||||
void ListView_ItemClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs^ e);
|
||||
void OnDeleteMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnDeleteSwipeInvoked(_In_ Microsoft::UI::Xaml::Controls::SwipeItem^ sender, _In_ Microsoft::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
void ListView_ItemClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
|
||||
void OnDeleteMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnDeleteSwipeInvoked(_In_ Microsoft::UI::Xaml::Controls::SwipeItem ^ sender, _In_ Microsoft::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -63,8 +63,7 @@ namespace CalculatorApp::VisualStates
|
||||
}
|
||||
}
|
||||
|
||||
MainPage::MainPage() :
|
||||
m_model(ref new ApplicationViewModel())
|
||||
MainPage::MainPage() : m_model(ref new ApplicationViewModel())
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -83,7 +82,7 @@ MainPage::MainPage() :
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
void MainPage::OnNavigatedTo(NavigationEventArgs ^ e)
|
||||
{
|
||||
if (m_model->CalculatorViewModel)
|
||||
{
|
||||
@@ -93,7 +92,7 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
ViewMode initialMode = ViewMode::Standard;
|
||||
if (e->Parameter != nullptr)
|
||||
{
|
||||
String^ stringParameter = dynamic_cast<String^>(e->Parameter);
|
||||
String ^ stringParameter = dynamic_cast<String ^>(e->Parameter);
|
||||
if (stringParameter != nullptr)
|
||||
{
|
||||
initialMode = (ViewMode)stoi(stringParameter->Data());
|
||||
@@ -101,7 +100,7 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationDataContainer^ localSettings = ApplicationData::Current->LocalSettings;
|
||||
ApplicationDataContainer ^ localSettings = ApplicationData::Current->LocalSettings;
|
||||
if (localSettings->Values->HasKey(ApplicationViewModel::ModePropertyName))
|
||||
{
|
||||
initialMode = NavCategory::Deserialize(localSettings->Values->Lookup(ApplicationViewModel::ModePropertyName));
|
||||
@@ -111,15 +110,15 @@ void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
|
||||
m_model->Initialize(initialMode);
|
||||
}
|
||||
|
||||
void MainPage::WindowSizeChanged(_In_ Platform::Object^ /*sender*/, _In_ Windows::UI::Core::WindowSizeChangedEventArgs^ e)
|
||||
void MainPage::WindowSizeChanged(_In_ Platform::Object ^ /*sender*/, _In_ Windows::UI::Core::WindowSizeChangedEventArgs ^ e)
|
||||
{
|
||||
// We don't use layout aware page's view states, we have our own
|
||||
UpdateViewState();
|
||||
}
|
||||
|
||||
void MainPage::OnAppPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e)
|
||||
void MainPage::OnAppPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
String^ propertyName = e->PropertyName;
|
||||
String ^ propertyName = e->PropertyName;
|
||||
if (propertyName == ApplicationViewModel::ModePropertyName)
|
||||
{
|
||||
ViewMode newValue = m_model->Mode;
|
||||
@@ -233,7 +232,7 @@ void MainPage::UpdatePanelViewState()
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnPageLoaded(_In_ Object^, _In_ RoutedEventArgs^ args)
|
||||
void MainPage::OnPageLoaded(_In_ Object ^, _In_ RoutedEventArgs ^ args)
|
||||
{
|
||||
if (!m_converter && !m_calculator && !m_dateCalculator)
|
||||
{
|
||||
@@ -249,15 +248,15 @@ void MainPage::OnPageLoaded(_In_ Object^, _In_ RoutedEventArgs^ args)
|
||||
SetDefaultFocus();
|
||||
|
||||
// Delay load things later when we get a chance.
|
||||
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([]()
|
||||
{
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
TraceLogger::GetInstance().LogAppLaunchComplete();
|
||||
AppLifecycleLogger::GetInstance().LaunchUIResponsive();
|
||||
AppLifecycleLogger::GetInstance().LaunchVisibleComplete();
|
||||
}
|
||||
}));
|
||||
this->Dispatcher->RunAsync(
|
||||
CoreDispatcherPriority::Normal, ref new DispatchedHandler([]() {
|
||||
if (TraceLogger::GetInstance().UpdateWindowIdLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
|
||||
{
|
||||
TraceLogger::GetInstance().LogAppLaunchComplete();
|
||||
AppLifecycleLogger::GetInstance().LaunchUIResponsive();
|
||||
AppLifecycleLogger::GetInstance().LaunchVisibleComplete();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void MainPage::SetDefaultFocus()
|
||||
@@ -284,13 +283,13 @@ void MainPage::EnsureCalculator()
|
||||
m_calculator = ref new Calculator();
|
||||
m_calculator->Name = L"Calculator";
|
||||
m_calculator->DataContext = m_model->CalculatorViewModel;
|
||||
Binding^ isStandardBinding = ref new Binding();
|
||||
Binding ^ isStandardBinding = ref new Binding();
|
||||
isStandardBinding->Path = ref new PropertyPath(L"IsStandard");
|
||||
m_calculator->SetBinding(m_calculator->IsStandardProperty, isStandardBinding);
|
||||
Binding^ isScientificBinding = ref new Binding();
|
||||
Binding ^ isScientificBinding = ref new Binding();
|
||||
isScientificBinding->Path = ref new PropertyPath(L"IsScientific");
|
||||
m_calculator->SetBinding(m_calculator->IsScientificProperty, isScientificBinding);
|
||||
Binding^ isProgramerBinding = ref new Binding();
|
||||
Binding ^ isProgramerBinding = ref new Binding();
|
||||
isProgramerBinding->Path = ref new PropertyPath(L"IsProgrammer");
|
||||
m_calculator->SetBinding(m_calculator->IsProgrammerProperty, isProgramerBinding);
|
||||
m_calculator->Style = CalculatorBaseStyle;
|
||||
@@ -307,7 +306,6 @@ void MainPage::EnsureCalculator()
|
||||
{
|
||||
m_dateCalculator->CloseCalendarFlyout();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MainPage::EnsureDateCalculator()
|
||||
@@ -342,11 +340,11 @@ void MainPage::EnsureConverter()
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnNavLoaded(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MainPage::OnNavLoaded(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
if (NavView->SelectedItem == nullptr)
|
||||
{
|
||||
auto menuItems = static_cast<IObservableVector<Object^>^>(NavView->MenuItemsSource);
|
||||
auto menuItems = static_cast<IObservableVector<Object ^> ^>(NavView->MenuItemsSource);
|
||||
auto itemCount = static_cast<int>(menuItems->Size);
|
||||
auto flatIndex = NavCategory::GetFlatIndex(Model->Mode);
|
||||
|
||||
@@ -365,7 +363,7 @@ void MainPage::OnNavLoaded(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
NavView->SetValue(Common::KeyboardShortcutManager::VirtualKeyControlChordProperty, Common::MyVirtualKey::E);
|
||||
}
|
||||
|
||||
void MainPage::OnNavPaneOpening(_In_ MUXC::NavigationView^ sender, _In_ Object^ args)
|
||||
void MainPage::OnNavPaneOpening(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
if (!NavFooter)
|
||||
{
|
||||
@@ -373,24 +371,24 @@ void MainPage::OnNavPaneOpening(_In_ MUXC::NavigationView^ sender, _In_ Object^
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::OnNavPaneOpened(_In_ MUXC::NavigationView^ sender, _In_ Object^ args)
|
||||
void MainPage::OnNavPaneOpened(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
KeyboardShortcutManager::HonorShortcuts(false);
|
||||
TraceLogger::GetInstance().LogNavBarOpened();
|
||||
}
|
||||
|
||||
void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView^ sender, _In_ Object^ args)
|
||||
void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)
|
||||
{
|
||||
KeyboardShortcutManager::HonorShortcuts(true);
|
||||
this->SetDefaultFocus();
|
||||
}
|
||||
|
||||
void MainPage::OnAboutButtonClick(Object^ sender, ItemClickEventArgs^ e)
|
||||
void MainPage::OnAboutButtonClick(Object ^ sender, ItemClickEventArgs ^ e)
|
||||
{
|
||||
ShowAboutPage();
|
||||
}
|
||||
|
||||
void MainPage::OnAboutFlyoutOpened(_In_ Object^ sender, _In_ Object^ e)
|
||||
void MainPage::OnAboutFlyoutOpened(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
// Keep Ignoring Escape till the About page flyout is opened
|
||||
KeyboardShortcutManager::IgnoreEscape(false);
|
||||
@@ -398,7 +396,7 @@ void MainPage::OnAboutFlyoutOpened(_In_ Object^ sender, _In_ Object^ e)
|
||||
KeyboardShortcutManager::UpdateDropDownState(this->AboutPageFlyout);
|
||||
}
|
||||
|
||||
void MainPage::OnAboutFlyoutClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
void MainPage::OnAboutFlyoutClosed(_In_ Object ^ sender, _In_ Object ^ e)
|
||||
{
|
||||
// Start Honoring Escape once the About page flyout is closed
|
||||
KeyboardShortcutManager::HonorEscape();
|
||||
@@ -406,19 +404,19 @@ void MainPage::OnAboutFlyoutClosed(_In_ Object^ sender, _In_ Object^ e)
|
||||
KeyboardShortcutManager::UpdateDropDownState(nullptr);
|
||||
}
|
||||
|
||||
void MainPage::OnNavSelectionChanged(_In_ Object^ sender, _In_ MUXC::NavigationViewSelectionChangedEventArgs^ e)
|
||||
void MainPage::OnNavSelectionChanged(_In_ Object ^ sender, _In_ MUXC::NavigationViewSelectionChangedEventArgs ^ e)
|
||||
{
|
||||
auto item = dynamic_cast<MUXC::NavigationViewItem^>(e->SelectedItemContainer);
|
||||
auto item = dynamic_cast<MUXC::NavigationViewItem ^>(e->SelectedItemContainer);
|
||||
if (item != nullptr)
|
||||
{
|
||||
auto selectedItem = static_cast<NavCategory^>(item->DataContext);
|
||||
auto selectedItem = static_cast<NavCategory ^>(item->DataContext);
|
||||
Model->Mode = selectedItem->Mode;
|
||||
}
|
||||
}
|
||||
|
||||
IObservableVector<Object^>^ MainPage::CreateUIElementsForCategories(_In_ IObservableVector<NavCategoryGroup^>^ categories)
|
||||
IObservableVector<Object ^> ^ MainPage::CreateUIElementsForCategories(_In_ IObservableVector<NavCategoryGroup ^> ^ categories)
|
||||
{
|
||||
auto menuCategories = ref new Vector<Object^>();
|
||||
auto menuCategories = ref new Vector<Object ^>();
|
||||
|
||||
for (auto group : categories)
|
||||
{
|
||||
@@ -433,7 +431,7 @@ IObservableVector<Object^>^ MainPage::CreateUIElementsForCategories(_In_ IObserv
|
||||
return menuCategories;
|
||||
}
|
||||
|
||||
MUXC::NavigationViewItemHeader^ MainPage::CreateNavViewHeaderFromGroup(NavCategoryGroup^ group)
|
||||
MUXC::NavigationViewItemHeader ^ MainPage::CreateNavViewHeaderFromGroup(NavCategoryGroup ^ group)
|
||||
{
|
||||
auto header = ref new MUXC::NavigationViewItemHeader();
|
||||
header->DataContext = group;
|
||||
@@ -445,19 +443,19 @@ MUXC::NavigationViewItemHeader^ MainPage::CreateNavViewHeaderFromGroup(NavCatego
|
||||
return header;
|
||||
}
|
||||
|
||||
MUXC::NavigationViewItem^ MainPage::CreateNavViewItemFromCategory(NavCategory^ category)
|
||||
MUXC::NavigationViewItem ^ MainPage::CreateNavViewItemFromCategory(NavCategory ^ category)
|
||||
{
|
||||
auto item = ref new MUXC::NavigationViewItem();
|
||||
item->DataContext = category;
|
||||
|
||||
auto icon = ref new FontIcon();
|
||||
icon->FontFamily = static_cast<Windows::UI::Xaml::Media::FontFamily^>(App::Current->Resources->Lookup(L"CalculatorFontFamily"));
|
||||
icon->FontFamily = static_cast<Windows::UI::Xaml::Media::FontFamily ^>(App::Current->Resources->Lookup(L"CalculatorFontFamily"));
|
||||
icon->Glyph = category->Glyph;
|
||||
item->Icon = icon;
|
||||
|
||||
item->Content = category->Name;
|
||||
item->AccessKey = category->AccessKey;
|
||||
item->Style = static_cast<Windows::UI::Xaml::Style^>(Resources->Lookup(L"NavViewItemStyle"));
|
||||
item->Style = static_cast<Windows::UI::Xaml::Style ^>(Resources->Lookup(L"NavViewItemStyle"));
|
||||
|
||||
AutomationProperties::SetName(item, category->AutomationName);
|
||||
AutomationProperties::SetAutomationId(item, category->AutomationId);
|
||||
@@ -491,7 +489,7 @@ void MainPage::SetHeaderAutomationName()
|
||||
ViewMode mode = m_model->Mode;
|
||||
auto resProvider = AppResourceProvider::GetInstance();
|
||||
|
||||
String^ name;
|
||||
String ^ name;
|
||||
if (NavCategory::IsDateCalculatorViewMode(mode))
|
||||
{
|
||||
name = resProvider.GetResourceString(L"HeaderAutomationName_Date");
|
||||
@@ -520,12 +518,12 @@ void MainPage::SetHeaderAutomationName()
|
||||
|
||||
void MainPage::AnnounceCategoryName()
|
||||
{
|
||||
String^ categoryName = AutomationProperties::GetName(Header);
|
||||
NarratorAnnouncement^ announcement = CalculatorAnnouncement::GetCategoryNameChangedAnnouncement(categoryName);
|
||||
String ^ categoryName = AutomationProperties::GetName(Header);
|
||||
NarratorAnnouncement ^ announcement = CalculatorAnnouncement::GetCategoryNameChangedAnnouncement(categoryName);
|
||||
NarratorNotifier->Announce(announcement);
|
||||
}
|
||||
|
||||
void MainPage::OnNavItemInvoked(MUXC::NavigationView^ /*sender*/, _In_ MUXC::NavigationViewItemInvokedEventArgs^ e)
|
||||
void MainPage::OnNavItemInvoked(MUXC::NavigationView ^ /*sender*/, _In_ MUXC::NavigationViewItemInvokedEventArgs ^ e)
|
||||
{
|
||||
NavView->IsPaneOpen = false;
|
||||
}
|
||||
|
@@ -19,50 +19,51 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// A basic page that provides characteristics common to most applications.
|
||||
/// </summary>
|
||||
public ref class MainPage sealed
|
||||
public
|
||||
ref class MainPage sealed
|
||||
{
|
||||
public:
|
||||
MainPage();
|
||||
property CalculatorApp::ViewModel::ApplicationViewModel^ Model
|
||||
{
|
||||
CalculatorApp::ViewModel::ApplicationViewModel^ get(){
|
||||
return m_model;
|
||||
}
|
||||
}
|
||||
property CalculatorApp::ViewModel::ApplicationViewModel
|
||||
^ Model { CalculatorApp::ViewModel::ApplicationViewModel ^ get() { return m_model; } }
|
||||
|
||||
void UnregisterEventHandlers();
|
||||
void
|
||||
UnregisterEventHandlers();
|
||||
|
||||
void SetDefaultFocus();
|
||||
void SetHeaderAutomationName();
|
||||
|
||||
Windows::Foundation::Collections::IObservableVector<Platform::Object^>^ CreateUIElementsForCategories(_In_ Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup^>^ categories);
|
||||
Windows::Foundation::Collections::IObservableVector<
|
||||
Platform::Object
|
||||
^> ^ CreateUIElementsForCategories(_In_ Windows::Foundation::Collections::IObservableVector<CalculatorApp::Common::NavCategoryGroup ^> ^ categories);
|
||||
|
||||
protected:
|
||||
void OnNavigatedTo(_In_ Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
|
||||
void OnNavigatedTo(_In_ Windows::UI::Xaml::Navigation::NavigationEventArgs ^ e) override;
|
||||
|
||||
private:
|
||||
void WindowSizeChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Core::WindowSizeChangedEventArgs^ e);
|
||||
void OnAppPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void WindowSizeChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Core::WindowSizeChangedEventArgs ^ e);
|
||||
void OnAppPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
|
||||
void OnNavLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnNavPaneOpening(_In_ Microsoft::UI::Xaml::Controls::NavigationView^ sender, _In_ Platform::Object^ args);
|
||||
void OnNavPaneOpened(_In_ Microsoft::UI::Xaml::Controls::NavigationView^ sender, _In_ Platform::Object^ args);
|
||||
void OnNavPaneClosed(_In_ Microsoft::UI::Xaml::Controls::NavigationView^ sender, _In_ Platform::Object^ args);
|
||||
void OnNavSelectionChanged(_In_ Platform::Object^ sender, _In_ Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs^ e);
|
||||
void OnNavItemInvoked(Microsoft::UI::Xaml::Controls::NavigationView^ /*sender*/, _In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs^ e);
|
||||
void OnNavLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnNavPaneOpening(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnNavPaneOpened(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnNavPaneClosed(_In_ Microsoft::UI::Xaml::Controls::NavigationView ^ sender, _In_ Platform::Object ^ args);
|
||||
void OnNavSelectionChanged(_In_ Platform::Object ^ sender, _In_ Microsoft::UI::Xaml::Controls::NavigationViewSelectionChangedEventArgs ^ e);
|
||||
void OnNavItemInvoked(Microsoft::UI::Xaml::Controls::NavigationView ^ /*sender*/,
|
||||
_In_ Microsoft::UI::Xaml::Controls::NavigationViewItemInvokedEventArgs ^ e);
|
||||
|
||||
void OnAboutButtonClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs^ e);
|
||||
void OnAboutFlyoutOpened(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnAboutFlyoutClosed(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnAboutButtonClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
|
||||
void OnAboutFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnAboutFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItemHeader ^ CreateNavViewHeaderFromGroup(CalculatorApp::Common::NavCategoryGroup ^ group);
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItem ^ CreateNavViewItemFromCategory(CalculatorApp::Common::NavCategory ^ category);
|
||||
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItemHeader^ CreateNavViewHeaderFromGroup(CalculatorApp::Common::NavCategoryGroup^ group);
|
||||
Microsoft::UI::Xaml::Controls::NavigationViewItem^ CreateNavViewItemFromCategory(CalculatorApp::Common::NavCategory^ category);
|
||||
|
||||
void ShowHideControls(CalculatorApp::Common::ViewMode mode);
|
||||
void UpdateViewState();
|
||||
void UpdatePanelViewState();
|
||||
|
||||
void OnPageLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnPageLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void EnsureCalculator();
|
||||
void EnsureConverter();
|
||||
@@ -71,10 +72,10 @@ namespace CalculatorApp
|
||||
|
||||
void AnnounceCategoryName();
|
||||
|
||||
CalculatorApp::Calculator^ m_calculator;
|
||||
CalculatorApp::UnitConverter^ m_converter;
|
||||
CalculatorApp::DateCalculator^ m_dateCalculator;
|
||||
CalculatorApp::Calculator ^ m_calculator;
|
||||
CalculatorApp::UnitConverter ^ m_converter;
|
||||
CalculatorApp::DateCalculator ^ m_dateCalculator;
|
||||
Windows::Foundation::EventRegistrationToken m_windowSizeEventToken;
|
||||
CalculatorApp::ViewModel::ApplicationViewModel^ m_model;
|
||||
CalculatorApp::ViewModel::ApplicationViewModel ^ m_model;
|
||||
};
|
||||
}
|
||||
|
@@ -35,18 +35,17 @@ using namespace Windows::UI::ViewManagement;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(Memory, RowHeight);
|
||||
|
||||
Memory::Memory() :
|
||||
m_isErrorVisualState(false)
|
||||
Memory::Memory() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
m_memoryItemFlyout = safe_cast<MenuFlyout^>(Resources->Lookup("MemoryContextMenu"));
|
||||
m_memoryItemFlyout = safe_cast<MenuFlyout ^>(Resources->Lookup("MemoryContextMenu"));
|
||||
|
||||
MemoryPaneEmpty->FlowDirection = LocalizationService::GetInstance()->GetFlowDirection();
|
||||
}
|
||||
|
||||
void Memory::MemoryListItemClick(_In_ Object^ sender, _In_ ItemClickEventArgs^ e)
|
||||
void Memory::MemoryListItemClick(_In_ Object ^ sender, _In_ ItemClickEventArgs ^ e)
|
||||
{
|
||||
MemoryItemViewModel^ memorySlot = safe_cast<MemoryItemViewModel^>(e->ClickedItem);
|
||||
MemoryItemViewModel ^ memorySlot = safe_cast<MemoryItemViewModel ^>(e->ClickedItem);
|
||||
|
||||
// In case the memory list is clicked and enter is pressed,
|
||||
// On Item clicked event gets fired and e->ClickedItem is Null.
|
||||
@@ -56,20 +55,20 @@ void Memory::MemoryListItemClick(_In_ Object^ sender, _In_ ItemClickEventArgs^ e
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e)
|
||||
void Memory::OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e)
|
||||
{
|
||||
// Walk up the tree to find the ListViewItem.
|
||||
// There may not be one if the click wasn't on an item.
|
||||
auto requestedElement = safe_cast<FrameworkElement^>(e->OriginalSource);
|
||||
while ((requestedElement != sender) && !dynamic_cast<ListViewItem^>(requestedElement))
|
||||
auto requestedElement = safe_cast<FrameworkElement ^>(e->OriginalSource);
|
||||
while ((requestedElement != sender) && !dynamic_cast<ListViewItem ^>(requestedElement))
|
||||
{
|
||||
requestedElement = safe_cast<FrameworkElement^>(VisualTreeHelper::GetParent(requestedElement));
|
||||
requestedElement = safe_cast<FrameworkElement ^>(VisualTreeHelper::GetParent(requestedElement));
|
||||
}
|
||||
|
||||
if (requestedElement != sender)
|
||||
{
|
||||
// The context menu request was for a ListViewItem.
|
||||
auto memorySlot = safe_cast<MemoryItemViewModel^>(MemoryListView->ItemFromContainer(requestedElement));
|
||||
auto memorySlot = safe_cast<MemoryItemViewModel ^>(MemoryListView->ItemFromContainer(requestedElement));
|
||||
Point point;
|
||||
if (e->TryGetPosition(requestedElement, &point))
|
||||
{
|
||||
@@ -85,22 +84,22 @@ void Memory::OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::U
|
||||
}
|
||||
}
|
||||
|
||||
void Memory::OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
|
||||
void Memory::OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
m_memoryItemFlyout->Hide();
|
||||
}
|
||||
|
||||
void Memory::OnClearMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void Memory::OnClearMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
GetMemoryItemForCurrentFlyout()->Clear();
|
||||
}
|
||||
|
||||
void Memory::OnMemoryAddMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void Memory::OnMemoryAddMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
GetMemoryItemForCurrentFlyout()->MemoryAdd();
|
||||
}
|
||||
|
||||
void Memory::OnMemorySubtractMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void Memory::OnMemorySubtractMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
GetMemoryItemForCurrentFlyout()->MemorySubtract();
|
||||
}
|
||||
@@ -115,14 +114,14 @@ void Memory::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
||||
MemoryItemViewModel^ Memory::GetMemoryItemForCurrentFlyout()
|
||||
MemoryItemViewModel ^ Memory::GetMemoryItemForCurrentFlyout()
|
||||
{
|
||||
auto listViewItem = m_memoryItemFlyout->Target;
|
||||
|
||||
return safe_cast<MemoryItemViewModel^>(MemoryListView->ItemFromContainer(listViewItem));
|
||||
return safe_cast<MemoryItemViewModel ^>(MemoryListView->ItemFromContainer(listViewItem));
|
||||
}
|
||||
|
@@ -15,8 +15,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class Memory sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class Memory sealed
|
||||
{
|
||||
public:
|
||||
Memory();
|
||||
@@ -30,25 +29,25 @@ namespace CalculatorApp
|
||||
DEPENDENCY_PROPERTY_OWNER(Memory);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::GridLength, RowHeight);
|
||||
|
||||
property bool IsErrorVisualState {
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
bool get();
|
||||
void set(bool value);
|
||||
}
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::Controls::MenuFlyout^ m_memoryItemFlyout;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout ^ m_memoryItemFlyout;
|
||||
Windows::Foundation::Rect m_visibleBounds;
|
||||
Windows::Foundation::Rect m_coreBounds;
|
||||
bool m_isErrorVisualState;
|
||||
|
||||
void MemoryListItemClick(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnClearMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemoryAddMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemorySubtractMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
|
||||
CalculatorApp::ViewModel::MemoryItemViewModel^ GetMemoryItemForCurrentFlyout();
|
||||
void MemoryListItemClick(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Controls::ItemClickEventArgs ^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnClearMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemoryAddMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemorySubtractMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
CalculatorApp::ViewModel::MemoryItemViewModel ^ GetMemoryItemForCurrentFlyout();
|
||||
};
|
||||
}
|
||||
|
@@ -31,51 +31,51 @@ MemoryListItem::MemoryListItem()
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
|
||||
void MemoryListItem::OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
Control::OnPointerEntered(e);
|
||||
|
||||
// Only show hover buttons when the user is using mouse or pen.
|
||||
if (e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse || e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Pen)
|
||||
if (e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Mouse
|
||||
|| e->Pointer->PointerDeviceType == Windows::Devices::Input::PointerDeviceType::Pen)
|
||||
{
|
||||
VisualStateManager::GoToState(this, "MemoryButtonsVisible", true);
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryListItem::OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e)
|
||||
void MemoryListItem::OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e)
|
||||
{
|
||||
Control::OnPointerExited(e);
|
||||
|
||||
VisualStateManager::GoToState(this, "MemoryButtonsHidden", true);
|
||||
}
|
||||
|
||||
void MemoryListItem::OnClearButtonClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MemoryListItem::OnClearButtonClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->Clear();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemoryAddButtonClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MemoryListItem::OnMemoryAddButtonClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->MemoryAdd();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemorySubtractButtonClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void MemoryListItem::OnMemorySubtractButtonClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->MemorySubtract();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnClearSwipeInvoked(_In_ SwipeItem^ sender, SwipeItemInvokedEventArgs^ e)
|
||||
void MemoryListItem::OnClearSwipeInvoked(_In_ SwipeItem ^ sender, SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
Model->Clear();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemoryAddSwipeInvoked(_In_ SwipeItem^ sender, SwipeItemInvokedEventArgs^ e)
|
||||
void MemoryListItem::OnMemoryAddSwipeInvoked(_In_ SwipeItem ^ sender, SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
Model->MemoryAdd();
|
||||
}
|
||||
|
||||
void MemoryListItem::OnMemorySubtractSwipeInvoked(_In_ SwipeItem^ sender, SwipeItemInvokedEventArgs^ e)
|
||||
void MemoryListItem::OnMemorySubtractSwipeInvoked(_In_ SwipeItem ^ sender, SwipeItemInvokedEventArgs ^ e)
|
||||
{
|
||||
Model->MemorySubtract();
|
||||
}
|
||||
|
||||
|
@@ -11,26 +11,24 @@ namespace CalculatorApp
|
||||
/// <summary>
|
||||
/// Represents a single item in the Memory list.
|
||||
/// </summary>
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class MemoryListItem sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class MemoryListItem sealed
|
||||
{
|
||||
public:
|
||||
MemoryListItem();
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(MemoryListItem);
|
||||
DEPENDENCY_PROPERTY(CalculatorApp::ViewModel::MemoryItemViewModel^, Model);
|
||||
DEPENDENCY_PROPERTY(CalculatorApp::ViewModel::MemoryItemViewModel ^, Model);
|
||||
|
||||
protected:
|
||||
void OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
||||
void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e) override;
|
||||
void OnPointerEntered(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||
void OnPointerExited(Windows::UI::Xaml::Input::PointerRoutedEventArgs ^ e) override;
|
||||
|
||||
private:
|
||||
void OnClearButtonClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemoryAddButtonClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnMemorySubtractButtonClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnClearSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
void OnMemoryAddSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
void OnMemorySubtractSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs^ e);
|
||||
|
||||
void OnClearButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemoryAddButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnMemorySubtractButtonClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnClearSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem ^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
void OnMemoryAddSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem ^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
void OnMemorySubtractSwipeInvoked(_In_ Windows::UI::Xaml::Controls::SwipeItem ^ sender, Windows::UI::Xaml::Controls::SwipeItemInvokedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -31,13 +31,12 @@ using namespace CalculatorApp::Common;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(NumberPad, ButtonStyle);
|
||||
|
||||
NumberPad::NumberPad() :
|
||||
m_isErrorVisualState(false)
|
||||
NumberPad::NumberPad() : m_isErrorVisualState(false)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
const auto& localizationSettings = LocalizationSettings::GetInstance();
|
||||
|
||||
|
||||
this->DecimalSeparatorButton->Content = localizationSettings.GetDecimalSeparator();
|
||||
this->Num0Button->Content = localizationSettings.GetDigitSymbolFromEnUsDigit('0');
|
||||
this->Num1Button->Content = localizationSettings.GetDigitSymbolFromEnUsDigit('1');
|
||||
@@ -64,7 +63,7 @@ void NumberPad::ProgModeRadixChange()
|
||||
Num8Button->IsEnabled = true;
|
||||
Num9Button->IsEnabled = true;
|
||||
|
||||
auto vm = safe_cast<StandardCalculatorViewModel^>(this->DataContext);
|
||||
auto vm = safe_cast<StandardCalculatorViewModel ^>(this->DataContext);
|
||||
RADIX_TYPE radixType = vm->GetCurrentRadixType();
|
||||
|
||||
if (radixType == RADIX_TYPE::BIN_RADIX)
|
||||
@@ -95,7 +94,7 @@ void NumberPad::IsErrorVisualState::set(bool value)
|
||||
if (m_isErrorVisualState != value)
|
||||
{
|
||||
m_isErrorVisualState = value;
|
||||
String^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
String ^ newState = m_isErrorVisualState ? L"ErrorLayout" : L"NoErrorLayout";
|
||||
VisualStateManager::GoToState(this, newState, false);
|
||||
}
|
||||
}
|
||||
|
@@ -13,14 +13,13 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class NumberPad sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class NumberPad sealed
|
||||
{
|
||||
public:
|
||||
NumberPad();
|
||||
DEPENDENCY_PROPERTY_OWNER(NumberPad);
|
||||
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style^, ButtonStyle);
|
||||
DEPENDENCY_PROPERTY(Windows::UI::Xaml::Style ^, ButtonStyle);
|
||||
|
||||
property bool IsErrorVisualState
|
||||
{
|
||||
|
@@ -28,8 +28,9 @@ OperatorsPanel::OperatorsPanel()
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
StandardCalculatorViewModel^ OperatorsPanel::Model::get() {
|
||||
return static_cast<CalculatorApp::ViewModel::StandardCalculatorViewModel^>(this->DataContext);
|
||||
StandardCalculatorViewModel ^ OperatorsPanel::Model::get()
|
||||
{
|
||||
return static_cast<CalculatorApp::ViewModel::StandardCalculatorViewModel ^>(this->DataContext);
|
||||
}
|
||||
|
||||
void OperatorsPanel::OnIsBitFlipCheckedPropertyChanged(bool /*oldValue*/, bool newValue)
|
||||
|
@@ -11,17 +11,14 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class OperatorsPanel sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class OperatorsPanel sealed
|
||||
{
|
||||
public:
|
||||
OperatorsPanel();
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel^ Model
|
||||
{
|
||||
CalculatorApp::ViewModel::StandardCalculatorViewModel^ get();
|
||||
}
|
||||
property CalculatorApp::ViewModel::StandardCalculatorViewModel
|
||||
^ Model { CalculatorApp::ViewModel::StandardCalculatorViewModel ^ get(); }
|
||||
|
||||
DEPENDENCY_PROPERTY_OWNER(OperatorsPanel);
|
||||
DEPENDENCY_PROPERTY_OWNER(OperatorsPanel);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsBitFlipChecked);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(bool, IsErrorVisualState);
|
||||
|
||||
|
@@ -24,26 +24,28 @@ AspectRatioTrigger::~AspectRatioTrigger()
|
||||
UnregisterSizeChanged(Source);
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::OnSourcePropertyChanged(FrameworkElement^ oldValue, FrameworkElement^ newValue)
|
||||
void AspectRatioTrigger::OnSourcePropertyChanged(FrameworkElement ^ oldValue, FrameworkElement ^ newValue)
|
||||
{
|
||||
UnregisterSizeChanged(oldValue);
|
||||
RegisterSizeChanged(newValue);
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::RegisterSizeChanged(FrameworkElement^ element)
|
||||
void AspectRatioTrigger::RegisterSizeChanged(FrameworkElement ^ element)
|
||||
{
|
||||
if (element == nullptr) { return; }
|
||||
if (element == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (element != Source)
|
||||
{
|
||||
UnregisterSizeChanged(Source);
|
||||
}
|
||||
|
||||
m_sizeChangedToken =
|
||||
element->SizeChanged += ref new SizeChangedEventHandler(this, &AspectRatioTrigger::OnSizeChanged);
|
||||
m_sizeChangedToken = element->SizeChanged += ref new SizeChangedEventHandler(this, &AspectRatioTrigger::OnSizeChanged);
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::UnregisterSizeChanged(FrameworkElement^ element)
|
||||
void AspectRatioTrigger::UnregisterSizeChanged(FrameworkElement ^ element)
|
||||
{
|
||||
if ((element != nullptr) && (m_sizeChangedToken.Value != 0))
|
||||
{
|
||||
@@ -52,7 +54,7 @@ void AspectRatioTrigger::UnregisterSizeChanged(FrameworkElement^ element)
|
||||
}
|
||||
}
|
||||
|
||||
void AspectRatioTrigger::OnSizeChanged(Object^ sender, SizeChangedEventArgs^ e)
|
||||
void AspectRatioTrigger::OnSizeChanged(Object ^ sender, SizeChangedEventArgs ^ e)
|
||||
{
|
||||
UpdateIsActive(e->NewSize);
|
||||
}
|
||||
|
@@ -13,13 +13,15 @@
|
||||
|
||||
namespace CalculatorApp::Views::StateTriggers
|
||||
{
|
||||
public enum class Aspect
|
||||
public
|
||||
enum class Aspect
|
||||
{
|
||||
Height,
|
||||
Width
|
||||
};
|
||||
|
||||
public ref class AspectRatioTrigger sealed : public Windows::UI::Xaml::StateTriggerBase
|
||||
public
|
||||
ref class AspectRatioTrigger sealed : public Windows::UI::Xaml::StateTriggerBase
|
||||
{
|
||||
public:
|
||||
AspectRatioTrigger();
|
||||
@@ -27,7 +29,7 @@ namespace CalculatorApp::Views::StateTriggers
|
||||
DEPENDENCY_PROPERTY_OWNER(AspectRatioTrigger);
|
||||
|
||||
/* The source for which this class will respond to size changed events. */
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::FrameworkElement^, Source);
|
||||
DEPENDENCY_PROPERTY_WITH_CALLBACK(Windows::UI::Xaml::FrameworkElement ^, Source);
|
||||
|
||||
/* Either Height or Width. The property will determine which aspect is used as the numerator when calculating
|
||||
the aspect ratio. */
|
||||
@@ -42,11 +44,11 @@ namespace CalculatorApp::Views::StateTriggers
|
||||
private:
|
||||
~AspectRatioTrigger();
|
||||
|
||||
void OnSourcePropertyChanged(Windows::UI::Xaml::FrameworkElement^ oldValue, Windows::UI::Xaml::FrameworkElement^ newValue);
|
||||
void OnSourcePropertyChanged(Windows::UI::Xaml::FrameworkElement ^ oldValue, Windows::UI::Xaml::FrameworkElement ^ newValue);
|
||||
|
||||
void RegisterSizeChanged(Windows::UI::Xaml::FrameworkElement^ element);
|
||||
void UnregisterSizeChanged(Windows::UI::Xaml::FrameworkElement^ element);
|
||||
void OnSizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
|
||||
void RegisterSizeChanged(Windows::UI::Xaml::FrameworkElement ^ element);
|
||||
void UnregisterSizeChanged(Windows::UI::Xaml::FrameworkElement ^ element);
|
||||
void OnSizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||
|
||||
void UpdateIsActive(Windows::Foundation::Size sourceSize);
|
||||
|
||||
|
@@ -29,9 +29,9 @@ using namespace Windows::UI::Xaml::Navigation;
|
||||
|
||||
DEPENDENCY_PROPERTY_INITIALIZATION(SupplementaryResults, Results);
|
||||
|
||||
Object^ DelighterUnitToStyleConverter::Convert(Object^ value, TypeName /*targetType*/, Object^ /*parameter*/, String^ /*language*/)
|
||||
Object ^ DelighterUnitToStyleConverter::Convert(Object ^ value, TypeName /*targetType*/, Object ^ /*parameter*/, String ^ /*language*/)
|
||||
{
|
||||
Unit^ unit = safe_cast<Unit^>(value);
|
||||
Unit ^ unit = safe_cast<Unit ^>(value);
|
||||
|
||||
assert(unit->GetModelUnit().isWhimsical);
|
||||
if (!unit->GetModelUnit().isWhimsical)
|
||||
@@ -41,19 +41,19 @@ Object^ DelighterUnitToStyleConverter::Convert(Object^ value, TypeName /*targetT
|
||||
|
||||
std::wstring key = L"Unit_";
|
||||
key.append(std::to_wstring(unit->GetModelUnit().id));
|
||||
return safe_cast<IStyle^>(m_delighters->Lookup(ref new String(key.c_str())));
|
||||
return safe_cast<IStyle ^>(m_delighters->Lookup(ref new String(key.c_str())));
|
||||
}
|
||||
|
||||
Object^ DelighterUnitToStyleConverter::ConvertBack(Object^ /*value*/, TypeName /*targetType*/, Object^ /*parameter*/, String^ /*language*/)
|
||||
Object ^ DelighterUnitToStyleConverter::ConvertBack(Object ^ /*value*/, TypeName /*targetType*/, Object ^ /*parameter*/, String ^ /*language*/)
|
||||
{
|
||||
// We never use convert back, only one way binding supported
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Windows::UI::Xaml::DataTemplate^ SupplementaryResultDataTemplateSelector::SelectTemplateCore(Object^ item, DependencyObject^ /*container*/)
|
||||
Windows::UI::Xaml::DataTemplate ^ SupplementaryResultDataTemplateSelector::SelectTemplateCore(Object ^ item, DependencyObject ^ /*container*/)
|
||||
{
|
||||
SupplementaryResult^ result = safe_cast<SupplementaryResult^>(item);
|
||||
SupplementaryResult ^ result = safe_cast<SupplementaryResult ^>(item);
|
||||
if (result->IsWhimsical())
|
||||
{
|
||||
return DelighterTemplate;
|
||||
@@ -75,11 +75,11 @@ bool SupplementaryResultNoOverflowStackPanel::ShouldPrioritizeLastItem()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto lastChild = dynamic_cast<FrameworkElement^>(Children->GetAt(Children->Size - 1));
|
||||
auto lastChild = dynamic_cast<FrameworkElement ^>(Children->GetAt(Children->Size - 1));
|
||||
if (lastChild == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
auto suppResult = dynamic_cast<SupplementaryResult^>(lastChild->DataContext);
|
||||
return suppResult == nullptr? false: suppResult->IsWhimsical();
|
||||
auto suppResult = dynamic_cast<SupplementaryResult ^>(lastChild->DataContext);
|
||||
return suppResult == nullptr ? false : suppResult->IsWhimsical();
|
||||
}
|
||||
|
@@ -15,7 +15,8 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
public ref class DelighterUnitToStyleConverter sealed : public Windows::UI::Xaml::Data::IValueConverter
|
||||
public
|
||||
ref class DelighterUnitToStyleConverter sealed : public Windows::UI::Xaml::Data::IValueConverter
|
||||
{
|
||||
public:
|
||||
DelighterUnitToStyleConverter()
|
||||
@@ -24,18 +25,24 @@ namespace CalculatorApp
|
||||
m_delighters->Source = ref new Windows::Foundation::Uri(L"ms-appx:///Views/DelighterUnitStyles.xaml");
|
||||
}
|
||||
|
||||
internal:
|
||||
virtual Platform::Object^ Convert(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language) = Windows::UI::Xaml::Data::IValueConverter::Convert;
|
||||
virtual Platform::Object^ ConvertBack(Platform::Object^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object^ parameter, Platform::String^ language) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack;
|
||||
internal : virtual Platform::Object
|
||||
^ Convert(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::Convert;
|
||||
virtual Platform::Object
|
||||
^ ConvertBack(Platform::Object ^ value, Windows::UI::Xaml::Interop::TypeName targetType, Platform::Object ^ parameter,
|
||||
Platform::String ^ language) = Windows::UI::Xaml::Data::IValueConverter::ConvertBack;
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::ResourceDictionary^ m_delighters;
|
||||
Windows::UI::Xaml::ResourceDictionary ^ m_delighters;
|
||||
};
|
||||
|
||||
public ref class SupplementaryResultDataTemplateSelector sealed : public Windows::UI::Xaml::Controls::DataTemplateSelector
|
||||
public
|
||||
ref class SupplementaryResultDataTemplateSelector sealed : public Windows::UI::Xaml::Controls::DataTemplateSelector
|
||||
{
|
||||
public:
|
||||
SupplementaryResultDataTemplateSelector() {}
|
||||
SupplementaryResultDataTemplateSelector()
|
||||
{
|
||||
}
|
||||
|
||||
property Windows::UI::Xaml::DataTemplate^ RegularTemplate
|
||||
{
|
||||
@@ -53,22 +60,22 @@ namespace CalculatorApp
|
||||
virtual Windows::UI::Xaml::DataTemplate^ SelectTemplateCore(Platform::Object^ item, Windows::UI::Xaml::DependencyObject^ container) override;
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::DataTemplate^ m_regularTemplate;
|
||||
Windows::UI::Xaml::DataTemplate^ m_delighterTemplate;
|
||||
Windows::UI::Xaml::DataTemplate ^ m_regularTemplate;
|
||||
Windows::UI::Xaml::DataTemplate ^ m_delighterTemplate;
|
||||
};
|
||||
|
||||
public ref class SupplementaryResultNoOverflowStackPanel sealed: public CalculatorApp::Controls::HorizontalNoOverflowStackPanel
|
||||
public
|
||||
ref class SupplementaryResultNoOverflowStackPanel sealed : public CalculatorApp::Controls::HorizontalNoOverflowStackPanel
|
||||
{
|
||||
protected:
|
||||
virtual bool ShouldPrioritizeLastItem() override;
|
||||
};
|
||||
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class SupplementaryResults sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class SupplementaryResults sealed
|
||||
{
|
||||
public:
|
||||
SupplementaryResults();
|
||||
DEPENDENCY_PROPERTY_OWNER(SupplementaryResults);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(Windows::Foundation::Collections::IIterable<ViewModel::SupplementaryResult^>^, Results, nullptr);
|
||||
DEPENDENCY_PROPERTY_WITH_DEFAULT(Windows::Foundation::Collections::IIterable<ViewModel::SupplementaryResult ^> ^, Results, nullptr);
|
||||
};
|
||||
}
|
||||
|
@@ -20,8 +20,7 @@ using namespace Windows::Foundation::Collections;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
TitleBar::TitleBar() :
|
||||
m_coreTitleBar(CoreApplication::GetCurrentView()->TitleBar)
|
||||
TitleBar::TitleBar() : m_coreTitleBar(CoreApplication::GetCurrentView()->TitleBar)
|
||||
{
|
||||
m_uiSettings = ref new UISettings();
|
||||
m_accessibilitySettings = ref new AccessibilitySettings();
|
||||
@@ -33,24 +32,23 @@ namespace CalculatorApp
|
||||
AppName->Text = AppResourceProvider::GetInstance().GetResourceString(L"AppName");
|
||||
}
|
||||
|
||||
void TitleBar::OnLoaded(_In_ Object^ /*sender*/, _In_ RoutedEventArgs^ /*e*/)
|
||||
void TitleBar::OnLoaded(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
//Register events
|
||||
m_visibilityChangedToken = m_coreTitleBar->IsVisibleChanged += ref new TypedEventHandler<CoreApplicationViewTitleBar^, Object^>([this](CoreApplicationViewTitleBar^ cTitleBar, Object^)
|
||||
{
|
||||
this->SetTitleBarVisibility();
|
||||
});
|
||||
m_layoutChangedToken = m_coreTitleBar->LayoutMetricsChanged += ref new TypedEventHandler<CoreApplicationViewTitleBar^, Object^>(
|
||||
[this](CoreApplicationViewTitleBar^ cTitleBar, Object^)
|
||||
{
|
||||
this->LayoutRoot->Height = cTitleBar->Height;
|
||||
this->SetTitleBarPadding();
|
||||
});
|
||||
// Register events
|
||||
m_visibilityChangedToken = m_coreTitleBar->IsVisibleChanged += ref new TypedEventHandler<CoreApplicationViewTitleBar ^, Object ^>(
|
||||
[this](CoreApplicationViewTitleBar ^ cTitleBar, Object ^) { this->SetTitleBarVisibility(); });
|
||||
m_layoutChangedToken = m_coreTitleBar->LayoutMetricsChanged +=
|
||||
ref new TypedEventHandler<CoreApplicationViewTitleBar ^, Object ^>([this](CoreApplicationViewTitleBar ^ cTitleBar, Object ^) {
|
||||
this->LayoutRoot->Height = cTitleBar->Height;
|
||||
this->SetTitleBarPadding();
|
||||
});
|
||||
|
||||
m_colorValuesChangedToken = m_uiSettings->ColorValuesChanged += ref new TypedEventHandler<UISettings^, Object^>(this, &TitleBar::ColorValuesChanged);
|
||||
m_accessibilitySettingsToken = m_accessibilitySettings->HighContrastChanged += ref new Windows::Foundation::TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &CalculatorApp::TitleBar::OnHighContrastChanged);
|
||||
m_windowActivatedToken = Window::Current->Activated += ref new Windows::UI::Xaml::WindowActivatedEventHandler(this, &CalculatorApp::TitleBar::OnWindowActivated);
|
||||
//Set properties
|
||||
m_colorValuesChangedToken = m_uiSettings->ColorValuesChanged += ref new TypedEventHandler<UISettings ^, Object ^>(this, &TitleBar::ColorValuesChanged);
|
||||
m_accessibilitySettingsToken = m_accessibilitySettings->HighContrastChanged +=
|
||||
ref new Windows::Foundation::TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &CalculatorApp::TitleBar::OnHighContrastChanged);
|
||||
m_windowActivatedToken = Window::Current->Activated +=
|
||||
ref new Windows::UI::Xaml::WindowActivatedEventHandler(this, &CalculatorApp::TitleBar::OnWindowActivated);
|
||||
// Set properties
|
||||
LayoutRoot->Height = m_coreTitleBar->Height;
|
||||
SetTitleBarControlColors();
|
||||
SetTitleBarExtendView();
|
||||
@@ -58,9 +56,9 @@ namespace CalculatorApp
|
||||
SetTitleBarPadding();
|
||||
}
|
||||
|
||||
void TitleBar::OnUnloaded(_In_ Object^ /*sender*/, _In_ RoutedEventArgs^ /*e*/)
|
||||
void TitleBar::OnUnloaded(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
//Unregister events
|
||||
// Unregister events
|
||||
m_coreTitleBar->LayoutMetricsChanged -= m_layoutChangedToken;
|
||||
m_layoutChangedToken.Value = 0;
|
||||
m_coreTitleBar->IsVisibleChanged -= m_visibilityChangedToken;
|
||||
@@ -102,24 +100,28 @@ namespace CalculatorApp
|
||||
this->LayoutRoot->Padding = Thickness(leftAddition, 0, rightAddition, 0);
|
||||
}
|
||||
|
||||
void TitleBar::ColorValuesChanged(_In_ UISettings^ /*sender*/, _In_ Object^ /*e*/)
|
||||
void TitleBar::ColorValuesChanged(_In_ UISettings ^ /*sender*/, _In_ Object ^ /*e*/)
|
||||
{
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() {
|
||||
SetTitleBarControlColors();
|
||||
}));
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() { SetTitleBarControlColors(); }));
|
||||
}
|
||||
|
||||
void TitleBar::SetTitleBarControlColors()
|
||||
{
|
||||
auto applicationView = ApplicationView::GetForCurrentView();
|
||||
if (applicationView == nullptr) { return; }
|
||||
if (applicationView == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto applicationTitleBar = applicationView->TitleBar;
|
||||
if (applicationTitleBar == nullptr) { return; }
|
||||
if (applicationTitleBar == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_accessibilitySettings->HighContrast)
|
||||
{
|
||||
//Reset to use default colors.
|
||||
// Reset to use default colors.
|
||||
applicationTitleBar->ButtonBackgroundColor = nullptr;
|
||||
applicationTitleBar->ButtonForegroundColor = nullptr;
|
||||
applicationTitleBar->ButtonInactiveBackgroundColor = nullptr;
|
||||
@@ -132,12 +134,13 @@ namespace CalculatorApp
|
||||
else
|
||||
{
|
||||
Color bgColor = Colors::Transparent;
|
||||
Color fgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlPageTextBaseHighBrush"))->Color;
|
||||
Color inactivefgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlForegroundChromeDisabledLowBrush"))->Color;
|
||||
Color hoverbgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlBackgroundListLowBrush"))->Color;
|
||||
Color hoverfgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
Color pressedbgColor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlBackgroundListMediumBrush"))->Color;
|
||||
Color pressedfgCoolor = safe_cast<SolidColorBrush^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
Color fgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlPageTextBaseHighBrush"))->Color;
|
||||
Color inactivefgColor =
|
||||
safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlForegroundChromeDisabledLowBrush"))->Color;
|
||||
Color hoverbgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlBackgroundListLowBrush"))->Color;
|
||||
Color hoverfgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
Color pressedbgColor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlBackgroundListMediumBrush"))->Color;
|
||||
Color pressedfgCoolor = safe_cast<SolidColorBrush ^>(Application::Current->Resources->Lookup("SystemControlForegroundBaseHighBrush"))->Color;
|
||||
applicationTitleBar->ButtonBackgroundColor = bgColor;
|
||||
applicationTitleBar->ButtonForegroundColor = fgColor;
|
||||
applicationTitleBar->ButtonInactiveBackgroundColor = bgColor;
|
||||
@@ -152,14 +155,15 @@ namespace CalculatorApp
|
||||
void TitleBar::OnHighContrastChanged(_In_ AccessibilitySettings ^ /*sender*/, _In_ Object ^ /*args*/)
|
||||
{
|
||||
Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([this]() {
|
||||
SetTitleBarControlColors();
|
||||
SetTitleBarExtendView();
|
||||
SetTitleBarVisibility();
|
||||
}));
|
||||
SetTitleBarControlColors();
|
||||
SetTitleBarExtendView();
|
||||
SetTitleBarVisibility();
|
||||
}));
|
||||
}
|
||||
|
||||
void TitleBar::OnWindowActivated(_In_ Object ^ /*sender*/, _In_ WindowActivatedEventArgs ^e)
|
||||
void TitleBar::OnWindowActivated(_In_ Object ^ /*sender*/, _In_ WindowActivatedEventArgs ^ e)
|
||||
{
|
||||
VisualStateManager::GoToState(this, e->WindowActivationState == CoreWindowActivationState::Deactivated ? WindowNotFocused->Name : WindowFocused->Name, false);
|
||||
VisualStateManager::GoToState(this, e->WindowActivationState == CoreWindowActivationState::Deactivated ? WindowNotFocused->Name : WindowFocused->Name,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
@@ -7,36 +7,37 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Standalone control managing the title bar of the application.
|
||||
/// Display a transparent custom title bar when high-contrast is off and the native title bar when on.
|
||||
/// Automatically react to color changes, tablet mode, etc...
|
||||
/// </summary>
|
||||
public ref class TitleBar sealed
|
||||
public
|
||||
ref class TitleBar sealed
|
||||
{
|
||||
public:
|
||||
TitleBar();
|
||||
private:
|
||||
void OnLoaded(_In_ Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnUnloaded(_In_ Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
|
||||
void SetTitleBarText(Platform::String^ text);
|
||||
private:
|
||||
void OnLoaded(_In_ Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnUnloaded(_In_ Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void SetTitleBarText(Platform::String ^ text);
|
||||
void SetTitleBarVisibility();
|
||||
void SetTitleBarPadding();
|
||||
void SetTitleBarControlColors();
|
||||
void SetTitleBarExtendView();
|
||||
void ColorValuesChanged(_In_ Windows::UI::ViewManagement::UISettings^ sender, _In_ Platform::Object^ e);
|
||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^sender, Platform::Object ^args);
|
||||
void OnWindowActivated(Platform::Object ^sender, Windows::UI::Core::WindowActivatedEventArgs ^e);
|
||||
void ColorValuesChanged(_In_ Windows::UI::ViewManagement::UISettings ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnHighContrastChanged(Windows::UI::ViewManagement::AccessibilitySettings ^ sender, Platform::Object ^ args);
|
||||
void OnWindowActivated(Platform::Object ^ sender, Windows::UI::Core::WindowActivatedEventArgs ^ e);
|
||||
|
||||
Platform::Agile<Windows::ApplicationModel::Core::CoreApplicationViewTitleBar^> m_coreTitleBar;
|
||||
Platform::Agile<Windows::ApplicationModel::Core::CoreApplicationViewTitleBar ^> m_coreTitleBar;
|
||||
Windows::Foundation::EventRegistrationToken m_layoutChangedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_visibilityChangedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_colorValuesChangedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_windowActivatedToken;
|
||||
Windows::Foundation::EventRegistrationToken m_accessibilitySettingsToken;
|
||||
Windows::UI::ViewManagement::UISettings^ m_uiSettings;
|
||||
Windows::UI::ViewManagement::AccessibilitySettings^ m_accessibilitySettings;
|
||||
Windows::UI::ViewManagement::UISettings ^ m_uiSettings;
|
||||
Windows::UI::ViewManagement::AccessibilitySettings ^ m_accessibilitySettings;
|
||||
};
|
||||
}
|
||||
|
@@ -45,9 +45,7 @@ using namespace Windows::UI::ViewManagement;
|
||||
// There are 10,000 intervals in 1 ms.
|
||||
static const long long DURATION_500_MS = 10000 * 500;
|
||||
|
||||
UnitConverter::UnitConverter() :
|
||||
m_meteredConnectionOverride(false),
|
||||
m_isAnimationEnabled(false)
|
||||
UnitConverter::UnitConverter() : m_meteredConnectionOverride(false), m_isAnimationEnabled(false)
|
||||
{
|
||||
m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection();
|
||||
m_FlowDirectionHorizontalAlignment = m_layoutDirection == ::FlowDirection::RightToLeft ? ::HorizontalAlignment::Right : ::HorizontalAlignment::Left;
|
||||
@@ -70,16 +68,15 @@ UnitConverter::UnitConverter() :
|
||||
|
||||
InitializeOfflineStatusTextBlock();
|
||||
|
||||
m_resultsFlyout = static_cast<MenuFlyout^>(Resources->Lookup(L"CalculationResultContextMenu"));
|
||||
m_resultsFlyout = static_cast<MenuFlyout ^>(Resources->Lookup(L"CalculationResultContextMenu"));
|
||||
CopyMenuItem->Text = resLoader.GetResourceString(L"copyMenuItem");
|
||||
PasteMenuItem->Text = resLoader.GetResourceString(L"pasteMenuItem");
|
||||
}
|
||||
|
||||
void UnitConverter::OnPropertyChanged(_In_ Object^ sender, _In_ PropertyChangedEventArgs^ e)
|
||||
void UnitConverter::OnPropertyChanged(_In_ Object ^ sender, _In_ PropertyChangedEventArgs ^ e)
|
||||
{
|
||||
String^ propertyName = e->PropertyName;
|
||||
if (propertyName == UnitConverterViewModel::NetworkBehaviorPropertyName ||
|
||||
propertyName == UnitConverterViewModel::CurrencyDataLoadFailedPropertyName)
|
||||
String ^ propertyName = e->PropertyName;
|
||||
if (propertyName == UnitConverterViewModel::NetworkBehaviorPropertyName || propertyName == UnitConverterViewModel::CurrencyDataLoadFailedPropertyName)
|
||||
{
|
||||
OnNetworkBehaviorChanged();
|
||||
}
|
||||
@@ -165,7 +162,7 @@ void UnitConverter::SetFailedToRefreshStatus()
|
||||
void UnitConverter::InitializeOfflineStatusTextBlock()
|
||||
{
|
||||
auto resProvider = AppResourceProvider::GetInstance();
|
||||
std::wstring offlineStatusHyperlinkText = static_cast<String^>(resProvider.GetResourceString(L"OfflineStatusHyperlinkText"))->Data();
|
||||
std::wstring offlineStatusHyperlinkText = static_cast<String ^>(resProvider.GetResourceString(L"OfflineStatusHyperlinkText"))->Data();
|
||||
|
||||
// The resource string has the 'NetworkSettings' hyperlink wrapped with '%HL%'.
|
||||
// Break the string and assign pieces appropriately.
|
||||
@@ -188,10 +185,7 @@ void UnitConverter::InitializeOfflineStatusTextBlock()
|
||||
OfflineRunLink->Text = offlineStatusTextLink;
|
||||
OfflineRunAfterLink->Text = offlineStatusTextAfterHyperlink;
|
||||
|
||||
AutomationProperties::SetName(OfflineBlock,
|
||||
offlineStatusTextBeforeHyperlink + L" " +
|
||||
offlineStatusTextLink + L" " +
|
||||
offlineStatusTextAfterHyperlink);
|
||||
AutomationProperties::SetName(OfflineBlock, offlineStatusTextBeforeHyperlink + L" " + offlineStatusTextLink + L" " + offlineStatusTextAfterHyperlink);
|
||||
}
|
||||
|
||||
void UnitConverter::SetCurrencyTimestampFontWeight()
|
||||
@@ -206,7 +200,7 @@ void UnitConverter::SetCurrencyTimestampFontWeight()
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::OnValueKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
|
||||
void UnitConverter::OnValueKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e)
|
||||
{
|
||||
if (e->Key == VirtualKey::Space)
|
||||
{
|
||||
@@ -214,10 +208,10 @@ void UnitConverter::OnValueKeyDown(Platform::Object^ sender, Windows::UI::Xaml::
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::OnContextRequested(UIElement^ sender, ContextRequestedEventArgs^ e)
|
||||
void UnitConverter::OnContextRequested(UIElement ^ sender, ContextRequestedEventArgs ^ e)
|
||||
{
|
||||
OnValueSelected(sender);
|
||||
auto requestedElement = safe_cast<FrameworkElement^>(sender);
|
||||
auto requestedElement = safe_cast<FrameworkElement ^>(sender);
|
||||
|
||||
PasteMenuItem->IsEnabled = CopyPasteManager::HasStringToPaste();
|
||||
|
||||
@@ -235,21 +229,20 @@ void UnitConverter::OnContextRequested(UIElement^ sender, ContextRequestedEventA
|
||||
e->Handled = true;
|
||||
}
|
||||
|
||||
void UnitConverter::OnContextCanceled(UIElement^ sender, RoutedEventArgs^ e)
|
||||
void UnitConverter::OnContextCanceled(UIElement ^ sender, RoutedEventArgs ^ e)
|
||||
{
|
||||
m_resultsFlyout->Hide();
|
||||
}
|
||||
|
||||
void UnitConverter::OnCopyMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void UnitConverter::OnCopyMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
auto calcResult = safe_cast<CalculationResult^>(m_resultsFlyout->Target);
|
||||
auto calcResult = safe_cast<CalculationResult ^>(m_resultsFlyout->Target);
|
||||
CopyPasteManager::CopyToClipboard(calcResult->GetRawDisplayValue());
|
||||
}
|
||||
|
||||
void UnitConverter::OnPasteMenuItemClicked(_In_ Object^ sender, _In_ RoutedEventArgs^ e)
|
||||
void UnitConverter::OnPasteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
|
||||
{
|
||||
CopyPasteManager::GetStringToPaste(Model->Mode, CategoryGroupType::Converter).then([this](String^ pastedString)
|
||||
{
|
||||
CopyPasteManager::GetStringToPaste(Model->Mode, CategoryGroupType::Converter).then([this](String ^ pastedString) {
|
||||
Model->OnPaste(pastedString, Model->Mode);
|
||||
});
|
||||
}
|
||||
@@ -262,34 +255,29 @@ void UnitConverter::AnimateConverter()
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::OnValueSelected(_In_ Platform::Object^ sender)
|
||||
void UnitConverter::OnValueSelected(_In_ Platform::Object ^ sender)
|
||||
{
|
||||
auto value = safe_cast<CalculationResult^>(sender);
|
||||
auto value = safe_cast<CalculationResult ^>(sender);
|
||||
// update the font size since the font is changed to bold
|
||||
value->UpdateTextState();
|
||||
safe_cast<UnitConverterViewModel^>(this->DataContext)->OnValueActivated(AsActivatable(value));
|
||||
safe_cast<UnitConverterViewModel ^>(this->DataContext)->OnValueActivated(AsActivatable(value));
|
||||
}
|
||||
|
||||
void UnitConverter::UpdateDropDownState(_In_ Platform::Object^ sender, _In_ Platform::Object^ e)
|
||||
void UnitConverter::UpdateDropDownState(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e)
|
||||
{
|
||||
safe_cast<UnitConverterViewModel^>(this->DataContext)->IsDropDownOpen = (Units1->IsDropDownOpen) || (Units2->IsDropDownOpen);
|
||||
safe_cast<UnitConverterViewModel ^>(this->DataContext)->IsDropDownOpen = (Units1->IsDropDownOpen) || (Units2->IsDropDownOpen);
|
||||
KeyboardShortcutManager::UpdateDropDownState((Units1->IsDropDownOpen) || (Units2->IsDropDownOpen));
|
||||
}
|
||||
|
||||
void UnitConverter::OnLoaded(_In_ Object^, _In_ RoutedEventArgs^)
|
||||
void UnitConverter::OnLoaded(_In_ Object ^, _In_ RoutedEventArgs ^)
|
||||
{
|
||||
}
|
||||
|
||||
void UnitConverter::SetDefaultFocus()
|
||||
{
|
||||
const std::vector<Control^> focusPrecedence = {
|
||||
Value1,
|
||||
CurrencyRefreshBlockControl,
|
||||
OfflineBlock,
|
||||
ClearEntryButtonPos0
|
||||
};
|
||||
const std::vector<Control ^> focusPrecedence = { Value1, CurrencyRefreshBlockControl, OfflineBlock, ClearEntryButtonPos0 };
|
||||
|
||||
for (Control^ control : focusPrecedence)
|
||||
for (Control ^ control : focusPrecedence)
|
||||
{
|
||||
if (control->Focus(::FocusState::Programmatic))
|
||||
{
|
||||
@@ -298,7 +286,7 @@ void UnitConverter::SetDefaultFocus()
|
||||
}
|
||||
}
|
||||
|
||||
void UnitConverter::CurrencyRefreshButton_Click(_In_ Object^ /*sender*/, _In_ RoutedEventArgs^ /*e*/)
|
||||
void UnitConverter::CurrencyRefreshButton_Click(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/)
|
||||
{
|
||||
if (Model->NetworkBehavior == NetworkAccessBehavior::OptIn)
|
||||
{
|
||||
@@ -308,17 +296,16 @@ void UnitConverter::CurrencyRefreshButton_Click(_In_ Object^ /*sender*/, _In_ Ro
|
||||
Model->RefreshCurrencyRatios();
|
||||
}
|
||||
|
||||
void UnitConverter::OnDataContextChanged(_In_ FrameworkElement^ sender, _In_ DataContextChangedEventArgs^ args)
|
||||
void UnitConverter::OnDataContextChanged(_In_ FrameworkElement ^ sender, _In_ DataContextChangedEventArgs ^ args)
|
||||
{
|
||||
Model->PropertyChanged -= m_propertyChangedToken;
|
||||
|
||||
m_propertyChangedToken =
|
||||
Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &UnitConverter::OnPropertyChanged);
|
||||
m_propertyChangedToken = Model->PropertyChanged += ref new PropertyChangedEventHandler(this, &UnitConverter::OnPropertyChanged);
|
||||
|
||||
OnNetworkBehaviorChanged();
|
||||
}
|
||||
|
||||
void UnitConverter::Units1_IsEnabledChanged(Object^ sender, DependencyPropertyChangedEventArgs^ e)
|
||||
void UnitConverter::Units1_IsEnabledChanged(Object ^ sender, DependencyPropertyChangedEventArgs ^ e)
|
||||
{
|
||||
if ((Units1->Visibility == ::Visibility::Visible) && Units1->IsEnabled)
|
||||
{
|
||||
@@ -352,12 +339,12 @@ void UnitConverter::StartProgressRingWithDelay()
|
||||
|
||||
m_delayTimer = ref new DispatcherTimer();
|
||||
m_delayTimer->Interval = delay;
|
||||
m_delayTimer->Tick += ref new EventHandler<Object^>(this, &UnitConverter::OnDelayTimerTick);
|
||||
m_delayTimer->Tick += ref new EventHandler<Object ^>(this, &UnitConverter::OnDelayTimerTick);
|
||||
|
||||
m_delayTimer->Start();
|
||||
}
|
||||
|
||||
void UnitConverter::OnDelayTimerTick(Object^ /*sender*/, Object^ /*e*/)
|
||||
void UnitConverter::OnDelayTimerTick(Object ^ /*sender*/, Object ^ /*e*/)
|
||||
{
|
||||
CurrencyLoadingProgressRing->IsActive = true;
|
||||
m_delayTimer->Stop();
|
||||
@@ -374,8 +361,8 @@ void UnitConverter::HideProgressRing()
|
||||
}
|
||||
|
||||
// The function will make sure the UI will have enough space to display supplementary results and currency information
|
||||
void CalculatorApp::UnitConverter::SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e)
|
||||
void CalculatorApp::UnitConverter::SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e)
|
||||
{
|
||||
//We add 0.01 to be sure to not create an infinite loop with SizeChanged events cascading due to float approximation
|
||||
// We add 0.01 to be sure to not create an infinite loop with SizeChanged events cascading due to float approximation
|
||||
RowDltrUnits->MinHeight = max(48.0, e->NewSize.Height + 0.01);
|
||||
}
|
||||
|
@@ -16,8 +16,7 @@
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
[Windows::Foundation::Metadata::WebHostHidden]
|
||||
public ref class UnitConverter sealed
|
||||
[Windows::Foundation::Metadata::WebHostHidden] public ref class UnitConverter sealed
|
||||
{
|
||||
public:
|
||||
UnitConverter();
|
||||
@@ -44,20 +43,20 @@ namespace CalculatorApp
|
||||
void SetDefaultFocus();
|
||||
|
||||
private:
|
||||
void OnValueKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnPasteMenuItemClicked(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnValueSelected(_In_ Platform::Object^ sender);
|
||||
void UpdateDropDownState(_In_ Platform::Object^ sender, _In_ Platform::Object^ e);
|
||||
void OnLoaded(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void CurrencyRefreshButton_Click(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs^ e);
|
||||
void OnValueKeyDown(Platform::Object ^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs ^ e);
|
||||
void OnContextRequested(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::Input::ContextRequestedEventArgs ^ e);
|
||||
void OnContextCanceled(Windows::UI::Xaml::UIElement ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnCopyMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnPasteMenuItemClicked(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void OnValueSelected(_In_ Platform::Object ^ sender);
|
||||
void UpdateDropDownState(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e);
|
||||
void OnLoaded(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
void CurrencyRefreshButton_Click(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::RoutedEventArgs ^ e);
|
||||
|
||||
void OnPropertyChanged(_In_ Platform::Object^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs^ e);
|
||||
void OnDataContextChanged(_In_ Windows::UI::Xaml::FrameworkElement^ sender, _In_ Windows::UI::Xaml::DataContextChangedEventArgs^ args);
|
||||
void OnPropertyChanged(_In_ Platform::Object ^ sender, _In_ Windows::UI::Xaml::Data::PropertyChangedEventArgs ^ e);
|
||||
void OnDataContextChanged(_In_ Windows::UI::Xaml::FrameworkElement ^ sender, _In_ Windows::UI::Xaml::DataContextChangedEventArgs ^ args);
|
||||
void OnIsDisplayVisibleChanged();
|
||||
void Units1_IsEnabledChanged(Platform::Object^ sender, Windows::UI::Xaml::DependencyPropertyChangedEventArgs^ e);
|
||||
void Units1_IsEnabledChanged(Platform::Object ^ sender, Windows::UI::Xaml::DependencyPropertyChangedEventArgs ^ e);
|
||||
|
||||
void OnNetworkBehaviorChanged();
|
||||
void OnNormalNetworkAccess();
|
||||
@@ -73,22 +72,22 @@ namespace CalculatorApp
|
||||
void SetCurrencyTimestampFontWeight();
|
||||
|
||||
void StartProgressRingWithDelay();
|
||||
void OnDelayTimerTick(Platform::Object^ sender, Platform::Object^ e);
|
||||
void OnDelayTimerTick(Platform::Object ^ sender, Platform::Object ^ e);
|
||||
void HideProgressRing();
|
||||
|
||||
private:
|
||||
Windows::UI::Xaml::FlowDirection m_layoutDirection;
|
||||
Windows::Foundation::EventRegistrationToken m_propertyChangedToken;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout^ m_resultsFlyout;
|
||||
|
||||
Platform::String^ m_chargesMayApplyText;
|
||||
Platform::String^ m_failedToRefreshText;
|
||||
Windows::UI::Xaml::Controls::MenuFlyout ^ m_resultsFlyout;
|
||||
|
||||
Platform::String ^ m_chargesMayApplyText;
|
||||
Platform::String ^ m_failedToRefreshText;
|
||||
|
||||
bool m_meteredConnectionOverride;
|
||||
|
||||
Windows::UI::Xaml::DispatcherTimer^ m_delayTimer;
|
||||
Windows::UI::Xaml::DispatcherTimer ^ m_delayTimer;
|
||||
|
||||
bool m_isAnimationEnabled;
|
||||
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object^ sender, Windows::UI::Xaml::SizeChangedEventArgs^ e);
|
||||
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
|
||||
};
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ using namespace Windows::UI::Xaml::Navigation;
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
WindowFrameService^ WindowFrameService::CreateNewWindowFrameService(_In_ Frame^ viewFrame, bool createdByUs, Platform::WeakReference parent)
|
||||
WindowFrameService ^ WindowFrameService::CreateNewWindowFrameService(_In_ Frame ^ viewFrame, bool createdByUs, Platform::WeakReference parent)
|
||||
{
|
||||
assert(CoreWindow::GetForCurrentThread() != nullptr);
|
||||
auto frameService = ref new WindowFrameService(viewFrame, parent);
|
||||
@@ -34,7 +34,7 @@ namespace CalculatorApp
|
||||
return frameService;
|
||||
}
|
||||
|
||||
WindowFrameService::WindowFrameService(_In_ Frame^ frame, WeakReference parent)
|
||||
WindowFrameService::WindowFrameService(_In_ Frame ^ frame, WeakReference parent)
|
||||
: m_currentWindow(CoreWindow::GetForCurrentThread())
|
||||
, m_coreDispatcher(m_currentWindow->Dispatcher)
|
||||
, m_frame(frame)
|
||||
@@ -57,7 +57,7 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
CoreDispatcher^ WindowFrameService::GetCoreDispatcher()
|
||||
CoreDispatcher ^ WindowFrameService::GetCoreDispatcher()
|
||||
{
|
||||
return m_coreDispatcher.Get();
|
||||
}
|
||||
@@ -67,17 +67,17 @@ namespace CalculatorApp
|
||||
return m_viewId;
|
||||
}
|
||||
|
||||
Frame^ WindowFrameService::GetFrame()
|
||||
Frame ^ WindowFrameService::GetFrame()
|
||||
{
|
||||
return m_frame;
|
||||
}
|
||||
|
||||
Page^ WindowFrameService::GetCurrentPage()
|
||||
Page ^ WindowFrameService::GetCurrentPage()
|
||||
{
|
||||
return dynamic_cast<Page^>(m_frame->Content);
|
||||
return dynamic_cast<Page ^>(m_frame->Content);
|
||||
}
|
||||
|
||||
void WindowFrameService::SetNewFrame(_In_ Windows::UI::Xaml::Controls::Frame^ frame)
|
||||
void WindowFrameService::SetNewFrame(_In_ Windows::UI::Xaml::Controls::Frame ^ frame)
|
||||
{
|
||||
assert(frame->BackStackDepth == 0);
|
||||
m_frame = frame;
|
||||
@@ -102,22 +102,21 @@ namespace CalculatorApp
|
||||
{
|
||||
auto that(this);
|
||||
task_completion_event<void> closingHandlersCompletedEvent;
|
||||
m_coreDispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler([that, closingHandlersCompletedEvent]()
|
||||
{
|
||||
KeyboardShortcutManager::OnWindowClosed(that->m_viewId);
|
||||
Window::Current->Content = nullptr;
|
||||
that->InvokeWindowClosingHandlers();
|
||||
// This is to ensure InvokeWindowClosingHandlers is be done before RemoveWindowFromMap
|
||||
// If InvokeWindowClosingHandlers throws any exception we want it to crash the application
|
||||
// so we are OK not setting closingHandlersCompletedEvent in that case
|
||||
closingHandlersCompletedEvent.set();
|
||||
that->m_coreDispatcher->StopProcessEvents();
|
||||
Window::Current->Close();
|
||||
}));
|
||||
m_coreDispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler([that, closingHandlersCompletedEvent]() {
|
||||
KeyboardShortcutManager::OnWindowClosed(that->m_viewId);
|
||||
Window::Current->Content = nullptr;
|
||||
that->InvokeWindowClosingHandlers();
|
||||
// This is to ensure InvokeWindowClosingHandlers is be done before RemoveWindowFromMap
|
||||
// If InvokeWindowClosingHandlers throws any exception we want it to crash the application
|
||||
// so we are OK not setting closingHandlersCompletedEvent in that case
|
||||
closingHandlersCompletedEvent.set();
|
||||
that->m_coreDispatcher->StopProcessEvents();
|
||||
Window::Current->Close();
|
||||
}));
|
||||
return create_task(closingHandlersCompletedEvent);
|
||||
}
|
||||
|
||||
void WindowFrameService::OnConsolidated(_In_ ApplicationView^ sender, _In_ ApplicationViewConsolidatedEventArgs^ e)
|
||||
void WindowFrameService::OnConsolidated(_In_ ApplicationView ^ sender, _In_ ApplicationViewConsolidatedEventArgs ^ e)
|
||||
{
|
||||
LogOnViewClosed(CoreWindow::GetForCurrentThread());
|
||||
auto parent = m_parent.Resolve<App>();
|
||||
@@ -127,7 +126,7 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
void WindowFrameService::OnClosed(_In_ CoreWindow^ sender, _In_ CoreWindowEventArgs^ args)
|
||||
void WindowFrameService::OnClosed(_In_ CoreWindow ^ sender, _In_ CoreWindowEventArgs ^ args)
|
||||
{
|
||||
LogOnViewClosed(sender);
|
||||
auto parent = m_parent.Resolve<App>();
|
||||
@@ -137,7 +136,7 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
void WindowFrameService::LogOnViewClosed(_In_ CoreWindow^ coreWindow)
|
||||
void WindowFrameService::LogOnViewClosed(_In_ CoreWindow ^ coreWindow)
|
||||
{
|
||||
if (coreWindow)
|
||||
{
|
||||
@@ -149,7 +148,7 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
void WindowFrameService::RegisterRuntimeWindowService(TypeName serviceId, _In_opt_ Object^ service)
|
||||
void WindowFrameService::RegisterRuntimeWindowService(TypeName serviceId, _In_opt_ Object ^ service)
|
||||
{
|
||||
if (TryResolveRuntimeWindowService(serviceId))
|
||||
{
|
||||
@@ -164,7 +163,7 @@ namespace CalculatorApp
|
||||
return m_runtimeServicesMap.erase(serviceId.Name) > 0;
|
||||
}
|
||||
|
||||
Object^ WindowFrameService::ResolveRuntimeWindowService(TypeName serviceId)
|
||||
Object ^ WindowFrameService::ResolveRuntimeWindowService(TypeName serviceId)
|
||||
{
|
||||
auto service = TryResolveRuntimeWindowService(serviceId);
|
||||
|
||||
@@ -178,7 +177,7 @@ namespace CalculatorApp
|
||||
}
|
||||
}
|
||||
|
||||
_Ret_maybenull_ Object^ WindowFrameService::TryResolveRuntimeWindowService(TypeName serviceId)
|
||||
_Ret_maybenull_ Object ^ WindowFrameService::TryResolveRuntimeWindowService(TypeName serviceId)
|
||||
{
|
||||
auto entry = m_runtimeServicesMap.find(serviceId.Name);
|
||||
|
||||
|
@@ -3,60 +3,60 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace CalculatorApp
|
||||
{
|
||||
|
||||
public ref class WindowFrameService sealed
|
||||
public
|
||||
ref class WindowFrameService sealed
|
||||
{
|
||||
public:
|
||||
Windows::UI::Xaml::Controls::Page^ GetCurrentPage();
|
||||
void SetNewFrame(_In_ Windows::UI::Xaml::Controls::Frame^ frame);
|
||||
Windows::UI::Xaml::Controls::Page ^ GetCurrentPage();
|
||||
void SetNewFrame(_In_ Windows::UI::Xaml::Controls::Frame ^ frame);
|
||||
|
||||
internal:
|
||||
// createdByUs means any window that we create.
|
||||
// !createdByUs means the main window
|
||||
static WindowFrameService^ CreateNewWindowFrameService(_In_ Windows::UI::Xaml::Controls::Frame^ viewFrame,
|
||||
bool createdByUs,
|
||||
Platform::WeakReference parent);
|
||||
internal :
|
||||
// createdByUs means any window that we create.
|
||||
// !createdByUs means the main window
|
||||
static WindowFrameService
|
||||
^ CreateNewWindowFrameService(_In_ Windows::UI::Xaml::Controls::Frame ^ viewFrame, bool createdByUs, Platform::WeakReference parent);
|
||||
|
||||
Windows::UI::Core::CoreDispatcher^ GetCoreDispatcher();
|
||||
Windows::UI::Core::CoreDispatcher ^ GetCoreDispatcher();
|
||||
int GetViewId();
|
||||
|
||||
void RegisterOnWindowClosingHandler(std::function<void()> onWindowClosingHandler);
|
||||
concurrency::task<void> HandleViewRelease();
|
||||
|
||||
// Throws InvalidArgumentException if a service is already registered with the specified id
|
||||
void RegisterRuntimeWindowService(Windows::UI::Xaml::Interop::TypeName serviceId, _In_opt_ Platform::Object^ service);
|
||||
void RegisterRuntimeWindowService(Windows::UI::Xaml::Interop::TypeName serviceId, _In_opt_ Platform::Object ^ service);
|
||||
|
||||
// Returns false if no service was registered with the specified id
|
||||
bool RemoveRuntimeWindowService(Windows::UI::Xaml::Interop::TypeName serviceId);
|
||||
|
||||
// Throws InvalidArgumentException if no service is registered with the specified id
|
||||
Platform::Object^ ResolveRuntimeWindowService(Windows::UI::Xaml::Interop::TypeName serviceId);
|
||||
Platform::Object ^ ResolveRuntimeWindowService(Windows::UI::Xaml::Interop::TypeName serviceId);
|
||||
|
||||
// Returns nullptr if no service is registered with the specified id
|
||||
_Ret_maybenull_ Platform::Object^ TryResolveRuntimeWindowService(Windows::UI::Xaml::Interop::TypeName serviceId);
|
||||
_Ret_maybenull_ Platform::Object ^ TryResolveRuntimeWindowService(Windows::UI::Xaml::Interop::TypeName serviceId);
|
||||
|
||||
Windows::UI::Xaml::Controls::Frame^ GetFrame();
|
||||
Windows::UI::Xaml::Controls::Frame ^ GetFrame();
|
||||
void InvokeWindowClosingHandlers();
|
||||
|
||||
private:
|
||||
WindowFrameService(_In_ Windows::UI::Xaml::Controls::Frame^ viewFrame, Platform::WeakReference parent);
|
||||
WindowFrameService(_In_ Windows::UI::Xaml::Controls::Frame ^ viewFrame, Platform::WeakReference parent);
|
||||
void InitializeFrameService(bool createdByUs);
|
||||
|
||||
void OnConsolidated(_In_ Windows::UI::ViewManagement::ApplicationView^ sender, _In_ Windows::UI::ViewManagement::ApplicationViewConsolidatedEventArgs^ e);
|
||||
void OnClosed(_In_ Windows::UI::Core::CoreWindow^ sender, _In_ Windows::UI::Core::CoreWindowEventArgs^ args);
|
||||
void OnConsolidated(_In_ Windows::UI::ViewManagement::ApplicationView ^ sender,
|
||||
_In_ Windows::UI::ViewManagement::ApplicationViewConsolidatedEventArgs ^ e);
|
||||
void OnClosed(_In_ Windows::UI::Core::CoreWindow ^ sender, _In_ Windows::UI::Core::CoreWindowEventArgs ^ args);
|
||||
|
||||
void LogOnViewClosed(_In_ Windows::UI::Core::CoreWindow^ coreWindow);
|
||||
void LogOnViewClosed(_In_ Windows::UI::Core::CoreWindow ^ coreWindow);
|
||||
|
||||
private:
|
||||
Platform::Agile<Windows::UI::Core::CoreWindow^> m_currentWindow;
|
||||
Platform::Agile<Windows::UI::Core::CoreDispatcher^> m_coreDispatcher;
|
||||
Windows::UI::Xaml::Controls::Frame^ m_frame;
|
||||
Platform::Agile<Windows::UI::Core::CoreWindow ^> m_currentWindow;
|
||||
Platform::Agile<Windows::UI::Core::CoreDispatcher ^> m_coreDispatcher;
|
||||
Windows::UI::Xaml::Controls::Frame ^ m_frame;
|
||||
int m_viewId;
|
||||
Platform::WeakReference m_parent;
|
||||
|
||||
std::unordered_map<Platform::String^, Platform::Object^> m_runtimeServicesMap;
|
||||
std::unordered_map<Platform::String ^, Platform::Object ^> m_runtimeServicesMap;
|
||||
std::vector<std::function<void()>> m_onWindowClosingHandlers;
|
||||
};
|
||||
}
|
||||
|
@@ -45,7 +45,9 @@
|
||||
// Once the app switches to min version RS3, the namespaces can be removed.
|
||||
// TODO - MSFT 12735088
|
||||
namespace StandardPeers = Windows::UI::Xaml::Automation::Peers;
|
||||
namespace CalculatorApp::Common::Automation {}
|
||||
namespace CalculatorApp::Common::Automation
|
||||
{
|
||||
}
|
||||
namespace CustomPeers = CalculatorApp::Common::Automation;
|
||||
|
||||
// Project Headers
|
||||
|
Reference in New Issue
Block a user