Ejemplo n.º 1
0
        /// <summary>Called when a new instance of the application has been created. </summary>
        /// <param name="frame">The frame. </param>
        /// <param name="args">The launch arguments.</param>
        public override Task OnInitializedAsync(MtFrame frame, ApplicationExecutionState args)
        {
            frame.PageAnimation = new TurnstilePageAnimation();

            // TODO: Run when the app is started (not resumed)
            return null;
        }
        public MtNavigationService(MtFrame rootFrame)
        {
            this.RootFrame = rootFrame;

            this.RootFrame.Navigated += RootFrame_Navigated;

            this.RootFrame.Navigating += RootFrame_Navigating;
        }
Ejemplo n.º 3
0
 /// <summary>Deregisters a frame. </summary>
 /// <param name="frame">The frame. </param>
 public static void DeregisterFrame(MtFrame frame)
 {
     SessionState.Remove((String)frame.GetValue(FrameSessionStateKeyProperty));
     _registeredFrames.RemoveAll((weakFrameReference) =>
     {
         MtFrame testFrame;
         return(!weakFrameReference.TryGetTarget(out testFrame) || testFrame == frame);
     });
 }
Ejemplo n.º 4
0
        private static void RestoreFrameNavigationState(MtFrame frame)
        {
            var frameState = SessionStateForFrame(frame);

            if (frameState.ContainsKey("Navigation"))
            {
                frame.SetNavigationState((String)frameState["Navigation"]);
            }
        }
Ejemplo n.º 5
0
        public HamburgerFrame()
        {
            Frame = new MtFrame();
            Frame.PageAnimation = null; 
            Frame.Navigated += FrameOnNavigated;

            Hamburger = new Hamburger();
            Hamburger.Content = Frame; 
            Hamburger.ItemChanged += HamburgerOnItemChanged;
        }
Ejemplo n.º 6
0
        /// <summary>Called when a new instance of the application has been created. </summary>
        /// <param name="frame">The frame. </param><param name="args">The launch arguments.</param>
        public override Task OnInitializedAsync(MtFrame frame, ApplicationExecutionState args)
        {
            // TODO: Initialize application and register more message types if needed. 

            var mapper = RegexViewModelToViewMapper.CreateDefaultMapper(GetType().GetTypeInfo().Assembly);
            Messenger.Default.Register(DefaultActions.GetNavigateMessageAction(mapper, frame));
            Messenger.Default.Register(DefaultActions.GetGoBackMessageAction(frame));
            Messenger.Default.Register(DefaultActions.GetTextMessageAction());

            return base.OnInitializedAsync(frame, args);
        }
Ejemplo n.º 7
0
        public override Task OnInitializedAsync(MtFrame frame, ApplicationExecutionState args)
        {
            // TODO: Called when the app is started (not resumed)

            //frame.PageAnimation = new TurnstilePageAnimation { UseBitmapCacheMode = true };
            //frame.PageAnimation = new PushPageAnimation();

            var mapper = RegexViewModelToViewMapper.CreateDefaultMapper(typeof(App).GetTypeInfo().Assembly);
            Messenger.Default.Register(DefaultActions.GetNavigateMessageAction(mapper, frame));

            return null;
        }
Ejemplo n.º 8
0
        /// <summary>Initializes a new instance of the <see cref="HamburgerFrameBuilder"/> class.</summary>
        public HamburgerFrameBuilder()
        {
            DeselectWhenPageNotFound = true;

            Frame = new MtFrame();
            Frame.PageAnimation = null;
            Frame.Navigated    += FrameOnNavigated;

            Hamburger              = new Hamburger();
            Hamburger.Content      = Frame;
            Hamburger.ItemChanged += HamburgerOnItemChanged;
        }
Ejemplo n.º 9
0
        /// <summary>Initializes a new instance of the <see cref="HamburgerFrameBuilder"/> class.</summary>
        public HamburgerFrameBuilder()
        {
            DeselectWhenPageNotFound = true; 
                 
            Frame = new MtFrame();
            Frame.PageAnimation = null; 
            Frame.Navigated += FrameOnNavigated;

            Hamburger = new Hamburger();
            Hamburger.Content = Frame; 
            Hamburger.ItemChanged += HamburgerOnItemChanged;
        }
Ejemplo n.º 10
0
        public Shell(MtFrame rootFrame)
        {
            this.RootFrame = rootFrame;

            this.InitializeComponent();

            this.main_content.Content = this.RootFrame;

            this.Loaded += Shell_Loaded;

            this.HideToastTimer = new DispatcherTimer();
            this.HideToastTimer.Interval = TimeSpan.FromSeconds(3);
            this.HideToastTimer.Tick += HideToastTimer_Tick;
        }
Ejemplo n.º 11
0
        /// <exception cref="InvalidOperationException">The base type is not an MtPage. Change the base type from Page to MtPage. </exception>
        internal MtPage GetPage(MtFrame frame)
        {
            if (Page == null)
            {
                var page = Activator.CreateInstance(Type) as MtPage;
                if (page == null)
                    throw new InvalidOperationException("The base type is not an MtPage. Change the base type from Page to MtPage. ");

                Page = page;
                Page.Frame = frame;
            }

            return Page;
        }
Ejemplo n.º 12
0
        /// <summary>Initializes a new instance of the <see cref="HamburgerFrameBuilder"/> class.</summary>
        public HamburgerFrameBuilder()
        {
            DeselectWhenPageNotFound = true;

            Frame = new MtFrame();
            Frame.PageAnimation = null;
            Frame.Navigated    += OnFrameNavigated;

            Hamburger              = new Hamburger();
            Hamburger.Content      = Frame;
            Hamburger.ItemChanged += async(s, e) => await OnSelectedHamburgerItemChanged(s, e);

            Hamburger.PaneVisibilityChanged += HamburgerOnPaneVisibilityChanged;
        }
Ejemplo n.º 13
0
        /// <exception cref="InvalidOperationException">The base type is not an MtPage. Change the base type from Page to MtPage. </exception>
        internal MtPage GetPage(MtFrame frame)
        {
            if (Page == null)
            {
                var page = Activator.CreateInstance(Type) as MtPage;
                if (page == null)
                {
                    throw new InvalidOperationException("The base type is not an MtPage. Change the base type from Page to MtPage. ");
                }

                Page       = page;
                Page.Frame = frame;
            }

            return(Page);
        }
Ejemplo n.º 14
0
        /// <summary>Registers a frame so that its navigation state can be saved and restored. </summary>
        /// <param name="frame">The frame. </param>
        /// <param name="sessionStateKey">The session state key. </param>
        public static void RegisterFrame(MtFrame frame, String sessionStateKey)
        {
            if (frame.GetValue(FrameSessionStateKeyProperty) != null)
            {
                throw new InvalidOperationException("Frames can only be registered to one session state key");
            }

            if (frame.GetValue(FrameSessionStateProperty) != null)
            {
                throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all");
            }

            frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
            _registeredFrames.Add(new WeakReference <MtFrame>(frame));

            RestoreFrameNavigationState(frame);
        }
Ejemplo n.º 15
0
        /// <summary>Gets the session state for a given frame. </summary>
        /// <param name="frame">The frame. </param>
        /// <returns>The session state. </returns>
        public static Dictionary <String, Object> SessionStateForFrame(MtFrame frame)
        {
            var frameState = (Dictionary <String, Object>)frame.GetValue(FrameSessionStateProperty);

            if (frameState == null)
            {
                var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
                if (frameSessionKey != null)
                {
                    if (!_sessionState.ContainsKey(frameSessionKey))
                    {
                        _sessionState[frameSessionKey] = new Dictionary <String, Object>();
                    }
                    frameState = (Dictionary <String, Object>)_sessionState[frameSessionKey];
                }
                else
                {
                    frameState = new Dictionary <String, Object>();
                }
                frame.SetValue(FrameSessionStateProperty, frameState);
            }
            return(frameState);
        }
Ejemplo n.º 16
0
 /// <summary>Gets the default handling action of <see cref="NavigateMessage"/> objects. </summary>
 /// <param name="mapper">The mapper which maps view model types to view types. </param>
 /// <param name="frame">The frame. </param>
 /// <returns>The message action. </returns>
 public static Action<NavigateMessage> GetNavigateMessageAction(IViewModelToViewMapper mapper, MtFrame frame)
 {
     return async message => await frame.NavigateAsync(mapper.Map(message.ViewModelType), message.Parameter);
 }
Ejemplo n.º 17
0
 internal void SetFrame(MtFrame frame, string pageKey)
 {
     Frame = frame;
     PageStateHandler.PageKey = pageKey;
 }
Ejemplo n.º 18
0
        /// <summary>Registers a frame so that its navigation state can be saved and restored. </summary>
        /// <param name="frame">The frame. </param>
        /// <param name="sessionStateKey">The session state key. </param>
        public static void RegisterFrame(MtFrame frame, String sessionStateKey)
        {
            if (frame.GetValue(FrameSessionStateKeyProperty) != null)
                throw new InvalidOperationException("Frames can only be registered to one session state key");

            if (frame.GetValue(FrameSessionStateProperty) != null)
                throw new InvalidOperationException("Frames must be either be registered before accessing frame session state, or not registered at all");

            frame.SetValue(FrameSessionStateKeyProperty, sessionStateKey);
            _registeredFrames.Add(new WeakReference<MtFrame>(frame));

            RestoreFrameNavigationState(frame);
        }
Ejemplo n.º 19
0
 public override async Task OnInitializedAsync(MtFrame frame, ApplicationExecutionState args)
 {
     //await HideStatusBarAsync();
 }
Ejemplo n.º 20
0
 private static void RestoreFrameNavigationState(MtFrame frame)
 {
     var frameState = SessionStateForFrame(frame);
     if (frameState.ContainsKey("Navigation"))
         frame.SetNavigationState((String)frameState["Navigation"]);
 }
Ejemplo n.º 21
0
 private static void SaveFrameNavigationState(MtFrame frame)
 {
     var frameState = SessionStateForFrame(frame);
     frameState["Navigation"] = frame.GetNavigationState();
 }
Ejemplo n.º 22
0
 /// <summary>Gets the session state for a given frame. </summary>
 /// <param name="frame">The frame. </param>
 /// <returns>The session state. </returns>
 public static Dictionary<String, Object> SessionStateForFrame(MtFrame frame)
 {
     var frameState = (Dictionary<String, Object>)frame.GetValue(FrameSessionStateProperty);
     if (frameState == null)
     {
         var frameSessionKey = (String)frame.GetValue(FrameSessionStateKeyProperty);
         if (frameSessionKey != null)
         {
             if (!_sessionState.ContainsKey(frameSessionKey))
                 _sessionState[frameSessionKey] = new Dictionary<String, Object>();
             frameState = (Dictionary<String, Object>)_sessionState[frameSessionKey];
         }
         else
             frameState = new Dictionary<String, Object>();
         frame.SetValue(FrameSessionStateProperty, frameState);
     }
     return frameState;
 }
Ejemplo n.º 23
0
        public string GetNavigationState(MtFrame frame)
        {
            // remove pages which do not support tombstoning
            var pagesToSerialize = _pages;
            var currentIndexToSerialize = CurrentIndex;
            var firstPageToRemove = _pages.FirstOrDefault(p =>
            {
                var page = p.GetPage(frame);
                return !page.IsSuspendable;
            });

            if (firstPageToRemove != null)
            {
                var index = pagesToSerialize.IndexOf(firstPageToRemove);
                pagesToSerialize = _pages.Take(index).ToList();
                currentIndexToSerialize = index - 1;
            }

            var output = DataContractSerialization.Serialize(
                new MtFrameDescription
                {
                    CurrentPageIndex = currentIndexToSerialize,
                    PageStack = pagesToSerialize
                },
                true, MtSuspensionManager.KnownTypes.ToArray());

            return output;
        }
Ejemplo n.º 24
0
 /// <summary>Gets the default handling action of <see cref="GoBackMessage"/> objects. </summary>
 /// <param name="frame">The frame to call the navigation methods on. </param>
 /// <returns>The message action. </returns>
 public static Action<GoBackMessage> GetGoBackMessageAction(MtFrame frame)
 {
     return message => frame.GoBackAsync();
 }
Ejemplo n.º 25
0
 /// <summary>Called when a new instance of the application has been created. </summary>
 /// <param name="frame">The frame. </param>
 /// <param name="args">The launch arguments.</param>
 public virtual Task OnInitializedAsync(MtFrame frame, ApplicationExecutionState args)
 {
     return(null); // Must be empty
 }
Ejemplo n.º 26
0
 /// <summary>Called when a new instance of the application has been created. </summary>
 /// <param name="frame">The frame. </param>
 /// <param name="args">The launch arguments.</param>
 public virtual Task OnInitializedAsync(MtFrame frame, ApplicationExecutionState args)
 {
     return null; // Must be empty
 }
Ejemplo n.º 27
0
        private static void SaveFrameNavigationState(MtFrame frame)
        {
            var frameState = SessionStateForFrame(frame);

            frameState["Navigation"] = frame.GetNavigationState();
        }
Ejemplo n.º 28
0
 internal void SetFrame(MtFrame frame, string pageKey)
 {
     Frame = frame;
     PageStateHandler.PageKey = pageKey;
 }
Ejemplo n.º 29
0
 /// <summary>Deregisters a frame. </summary>
 /// <param name="frame">The frame. </param>
 public static void DeregisterFrame(MtFrame frame)
 {
     SessionState.Remove((String)frame.GetValue(FrameSessionStateKeyProperty));
     _registeredFrames.RemoveAll((weakFrameReference) =>
     {
         MtFrame testFrame;
         return !weakFrameReference.TryGetTarget(out testFrame) || testFrame == frame;
     });
 }
Ejemplo n.º 30
0
        private void InitializeFrame()
        {
            var frame = new MtFrame();
            frame.DisableForwardStack = false;
            frame.Navigated += Frame_Navigated;
            this.RootFrame = frame;
            this.NavigationService = new MtNavigationService(frame);

            this.ConfigureContainer();
            this.ConfigureViewModelLocator();
        }