Path: blob/master/samples/winrt/ImageManipulations/common/LayoutAwarePage.h
16339 views
//*********************************************************1//2// Copyright (c) Microsoft. All rights reserved.3// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF4// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY5// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR6// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.7//8//*********************************************************910#pragma once1112#include <collection.h>1314namespace SDKSample15{16namespace Common17{18/// <summary>19/// Typical implementation of Page that provides several important conveniences:20/// <list type="bullet">21/// <item>22/// <description>Application view state to visual state mapping</description>23/// </item>24/// <item>25/// <description>GoBack, GoForward, and GoHome event handlers</description>26/// </item>27/// <item>28/// <description>Mouse and keyboard shortcuts for navigation</description>29/// </item>30/// <item>31/// <description>State management for navigation and process lifetime management</description>32/// </item>33/// <item>34/// <description>A default view model</description>35/// </item>36/// </list>37/// </summary>38[Windows::Foundation::Metadata::WebHostHidden]39public ref class LayoutAwarePage : Windows::UI::Xaml::Controls::Page40{41internal:42LayoutAwarePage();4344public:45void StartLayoutUpdates(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);46void StopLayoutUpdates(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);47void InvalidateVisualState();48static property Windows::UI::Xaml::DependencyProperty^ DefaultViewModelProperty49{50Windows::UI::Xaml::DependencyProperty^ get();51};52property Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ DefaultViewModel53{54Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ get();55void set(Windows::Foundation::Collections::IObservableMap<Platform::String^, Platform::Object^>^ value);56}5758protected:59virtual void GoHome(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);60virtual void GoBack(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);61virtual void GoForward(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);62virtual Platform::String^ DetermineVisualState(Windows::UI::ViewManagement::ApplicationViewState viewState);63virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;64virtual void OnNavigatedFrom(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;65virtual void LoadState(Platform::Object^ navigationParameter,66Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState);67virtual void SaveState(Windows::Foundation::Collections::IMap<Platform::String^, Platform::Object^>^ pageState);6869private:70Platform::String^ _pageKey;71bool _navigationShortcutsRegistered;72Platform::Collections::Map<Platform::String^, Platform::Object^>^ _defaultViewModel;73Windows::Foundation::EventRegistrationToken _windowSizeEventToken,74_acceleratorKeyEventToken, _pointerPressedEventToken;75Platform::Collections::Vector<Windows::UI::Xaml::Controls::Control^>^ _layoutAwareControls;76void WindowSizeChanged(Platform::Object^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e);77void OnLoaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);78void OnUnloaded(Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);7980void CoreDispatcher_AcceleratorKeyActivated(Windows::UI::Core::CoreDispatcher^ sender,81Windows::UI::Core::AcceleratorKeyEventArgs^ args);82void CoreWindow_PointerPressed(Windows::UI::Core::CoreWindow^ sender,83Windows::UI::Core::PointerEventArgs^ args);84LayoutAwarePage^ _this; // Strong reference to self, cleaned up in OnUnload85};86}87}888990