Exemplo n.º 1
0
        /// <summary>Adds a back key handler for a given page. </summary>
        /// <param name="page">The page. </param>
        /// <param name="handler">The handler. </param>
        public void Add(MtPage page, Func<object, bool> handler)
        {
            if (!_isEventRegistered)
            {
#if WINDOWS_UAP
                if (page.Frame.AutomaticBackButtonHandling)
                {
                    SystemNavigationManager.GetForCurrentView().BackRequested += OnBackKeyPressed;
                }
#else
                if (_hardwareButtonsType == null)
                {
                    _hardwareButtonsType = Type.GetType(
                        "Windows.Phone.UI.Input.HardwareButtons, " +
                        "Windows, Version=255.255.255.255, Culture=neutral, " +
                        "PublicKeyToken=null, ContentType=WindowsRuntime");
                }

                _registrationToken = EventUtilities.RegisterStaticEvent(_hardwareButtonsType, "BackPressed", OnBackKeyPressed);
#endif
                _isEventRegistered = true;
            }

            _handlers.Insert(0, new Tuple<MtPage, Func<object, bool>>(page, handler));
        }
Exemplo n.º 2
0
        public NavigationKeyHandler(MtPage page)
        {
            _page = page;
            _goBackActions = new List<Func<CancelEventArgs, Task>>();

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
                return;

            page.Loaded += OnPageLoaded;
            page.Unloaded += OnPageUnloaded;
        }
Exemplo n.º 3
0
        public NavigationKeyHandler(MtPage page)
        {
            _page          = page;
            _goBackActions = new List <Func <CancelEventArgs, Task> >();

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                return;
            }

            page.Loaded   += OnPageLoaded;
            page.Unloaded += OnPageUnloaded;
        }
Exemplo n.º 4
0
        /// <summary>Removes a back key pressed handler for a given page. </summary>
        /// <param name="page">The page. </param>
        public void Remove(MtPage page)
        {
            _handlers.Remove(_handlers.Single(h => h.Item1 == page));

            if (_handlers.Count == 0)
            {
#if WINDOWS_UAP_UNUSED
                HardwareButtons.BackPressed -= OnBackKeyPressed;
#else
                EventUtilities.DeregisterStaticEvent(_hardwareButtonsType, "BackPressed", _registrationToken);
#endif
                _isEventRegistered = false; 
            }
        }
Exemplo n.º 5
0
        /// <summary>Removes a back key pressed handler for a given page. </summary>
        /// <param name="page">The page. </param>
        public void Remove(MtPage page)
        {
            _handlers.Remove(_handlers.Single(h => h.Item1 == page));

            if (_handlers.Count == 0)
            {
#if WINDOWS_UAP
                SystemNavigationManager.GetForCurrentView().BackRequested -= OnBackKeyPressed;
#else
                EventUtilities.DeregisterStaticEvent(_hardwareButtonsType, "BackPressed", _registrationToken);
#endif
                _isEventRegistered = false; 
            }
        }
Exemplo n.º 6
0
        /// <summary>Removes a back key pressed handler for a given page. </summary>
        /// <param name="page">The page. </param>
        public void Remove(MtPage page)
        {
            _handlers.Remove(_handlers.Single(h => h.Item1 == page));

            if (_handlers.Count == 0)
            {
#if WINDOWS_UAP
                SystemNavigationManager.GetForCurrentView().BackRequested -= OnBackKeyPressed;
#else
                EventUtilities.DeregisterStaticEvent(_hardwareButtonsType, "BackPressed", _registrationToken);
#endif
                _isEventRegistered = false;
            }
        }
Exemplo n.º 7
0
        /// <summary>Removes a back key pressed handler for a given page. </summary>
        /// <param name="page">The page. </param>
        public void Remove(MtPage page)
        {
            _handlers.Remove(_handlers.Single(h => h.Item1 == page));

            if (_handlers.Count == 0)
            {
#if WINDOWS_UAP_UNUSED
                HardwareButtons.BackPressed -= OnBackKeyPressed;
#else
                EventUtilities.DeregisterStaticEvent(_hardwareButtonsType, "BackPressed", _registrationToken);
#endif
                _isEventRegistered = false;
            }
        }
Exemplo n.º 8
0
        /// <summary>Adds a back key handler for a given page. </summary>
        /// <param name="page">The page. </param>
        /// <param name="handler">The handler. </param>
        public void Add(MtPage page, Func<object, bool> handler)
        {
            if (!_isEventRegistered)
            {
#if WINDOWS_UAP_UNUSED
                HardwareButtons.BackPressed += OnBackKeyPressed;
#else
                if (_hardwareButtonsType == null)
                {
                    _hardwareButtonsType = Type.GetType(
                        "Windows.Phone.UI.Input.HardwareButtons, " +
                        "Windows, Version=255.255.255.255, Culture=neutral, " +
                        "PublicKeyToken=null, ContentType=WindowsRuntime");
                }

                _registrationToken = EventUtilities.RegisterStaticEvent(_hardwareButtonsType, "BackPressed", OnBackKeyPressed);
#endif
                _isEventRegistered = true;
            }

            _handlers.Insert(0, new Tuple<MtPage, Func<object, bool>>(page, handler));
        }
Exemplo n.º 9
0
        /// <summary>Adds a back key handler for a given page. </summary>
        /// <param name="page">The page. </param>
        /// <param name="handler">The handler. </param>
        public void Add(MtPage page, Func <object, bool> handler)
        {
            if (!_isEventRegistered)
            {
#if WINDOWS_UAP
                SystemNavigationManager.GetForCurrentView().BackRequested += OnBackKeyPressed;
#else
                if (_hardwareButtonsType == null)
                {
                    _hardwareButtonsType = Type.GetType(
                        "Windows.Phone.UI.Input.HardwareButtons, " +
                        "Windows, Version=255.255.255.255, Culture=neutral, " +
                        "PublicKeyToken=null, ContentType=WindowsRuntime");
                }

                _registrationToken = EventUtilities.RegisterStaticEvent(_hardwareButtonsType, "BackPressed", OnBackKeyPressed);
#endif
                _isEventRegistered = true;
            }

            _handlers.Insert(0, new Tuple <MtPage, Func <object, bool> >(page, handler));
        }
Exemplo n.º 10
0
 public PageStateHandler(MtPage page)
 {
     _page = page; 
 }
Exemplo n.º 11
0
 /// <summary>Registers the view model for state handling. </summary>
 /// <param name="viewModel">The view model. </param>
 /// <param name="page">The page. </param>
 public static void RegisterViewModelForStateHandling(IStateHandlingViewModel viewModel, MtPage page)
 {
     page.PageStateHandler.SaveState += (sender, args) => viewModel.OnSaveState(args);
     page.PageStateHandler.LoadState += (sender, args) => viewModel.OnLoadState(args);
 }
Exemplo n.º 12
0
 public PageStateHandler(MtPage page, string pageKey)
 {
     _page = page;
     PageKey = pageKey;
 }
Exemplo n.º 13
0
 public PageStateHandler(MtPage page, string pageKey)
 {
     _page   = page;
     PageKey = pageKey;
 }
Exemplo n.º 14
0
 public PageStateHandler(MtPage page)
 {
     _page = page;
 }