示例#1
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            var customPresenter = new CustomViewPresenter(rootFrame);

            Mvx.RegisterSingleton <IMvxViewPresenter>(customPresenter);
            return(customPresenter);
        }
        /// <summary>
        /// Provides storage for session state associated with the specified <see cref="Frame"/>.
        /// Frames that have been previously registered with <see cref="RegisterFrame"/> have
        /// their session state saved and restored automatically as a part of the global
        /// <see cref="SessionState"/>.  Frames that are not registered have transient state
        /// that can still be useful when restoring pages that have been discarded from the
        /// navigation cache.
        /// </summary>
        /// <remarks>Apps may choose to rely on <see cref="LayoutAwarePage"/> to manage
        /// page-specific state instead of working with frame session state directly.</remarks>
        /// <param name="frame">The instance for which session state is desired.</param>
        /// <returns>A collection of state subject to the same serialization mechanism as
        /// <see cref="SessionState"/>.</returns>
        public Dictionary <String, Object> SessionStateForFrame(IMvxWindowsFrame frame)
        {
            var frameState = (Dictionary <String, Object>)frame.GetValue(this.MvxFrameSessionStateProperty);

            if (frameState == null)
            {
                var frameSessionKey = (String)frame.GetValue(this.MvxFrameSessionStateKeyProperty);
                if (frameSessionKey != null)
                {
                    // Registered frames reflect the corresponding session state
                    if (!this._sessionState.ContainsKey(frameSessionKey))
                    {
                        this._sessionState[frameSessionKey] = new Dictionary <String, Object>();
                    }
                    frameState = (Dictionary <String, Object>) this._sessionState[frameSessionKey];
                }
                else
                {
                    // Frames that aren't registered have transient state
                    frameState = new Dictionary <String, Object>();
                }
                frame.SetValue(this.MvxFrameSessionStateProperty, frameState);
            }
            return(frameState);
        }
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            //custom view presenter to gain better control over navigation
            var presenter = new CustomViewPresenter(rootFrame);

            return(presenter);
        }
示例#4
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            var presenter = new MvxFormsUwpViewPresenter(rootFrame, FormsApplication);

            Mvx.RegisterSingleton <IMvxFormsViewPresenter>(presenter);
            return(presenter);
        }
示例#5
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            var customPresenter = new SoundByteViewPresenter(rootFrame);

            Mvx.IoCProvider.RegisterSingleton <MvxWindowsViewPresenter>(customPresenter);
            return(customPresenter);
        }
        // Create View Presenter for UWP application:
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            //Create UWP View Presenter object:
            var mvxUwpPresenter = new MvxUwpAppPresenter(rootFrame);

            return(mvxUwpPresenter);
        }
示例#7
0
        public MvxWindowsViewPresenter(IMvxWindowsFrame rootFrame)
        {
            _rootFrame = rootFrame;
            _logger    = MvxLogHost.GetLog <MvxWindowsViewPresenter>();

            SystemNavigationManager.GetForCurrentView().BackRequested += BackButtonOnBackRequested;
        }
示例#8
0
        public static MvxWindowsSetupSingleton EnsureSingletonAvailable(IMvxWindowsFrame rootFrame)
        {
            var instance = EnsureSingletonAvailable <MvxWindowsSetupSingleton>();

            instance.PlatformSetup <MvxWindowsSetup>()?.PlatformInitialize(rootFrame);
            return(instance);
        }
示例#9
0
 protected virtual void RestoreFrameNavigationState(IMvxWindowsFrame frame)
 {
     var frameState = SessionStateForFrame(frame);
     if (frameState.ContainsKey("Navigation"))
     {
         frame.SetNavigationState((string)frameState["Navigation"]);
     }
 }
示例#10
0
        /// <summary>
        /// Adds our <see cref="BackStackHintHandler"/> to the <see cref="MvxWindowsViewPresenter"/>.
        /// </summary>
        /// <param name="rootFrame"></param>
        /// <returns></returns>
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            var viewPresenter    = base.CreateViewPresenter(rootFrame);
            var backStackHandler = new BackStackHintHandler(rootFrame);

            viewPresenter.AddPresentationHintHandler <ClearBackstackHint>(backStackHandler.HandleClearBackstackHint);
            viewPresenter.AddPresentationHintHandler <PopBackstackHint>(backStackHandler.HandlePopBackstackHint);
            return(viewPresenter);
        }
        private void RestoreFrameNavigationState(IMvxWindowsFrame frame)
        {
            var frameState = this.SessionStateForFrame(frame);

            if (frameState.ContainsKey("Navigation"))
            {
                frame.SetNavigationState((String)frameState["Navigation"]);
            }
        }
示例#12
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            var xamarinFormsApp = new MvxFormsApp();
            var presenter       = new MvxFormsWindowsUWPPagePresenter(rootFrame, xamarinFormsApp);

            Mvx.RegisterSingleton <IMvxViewPresenter>(presenter);

            return(presenter);
        }
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            Xamarin.Forms.Forms.Init(_launchActivatedEventArgs);

            var presenter = new MvxFormsUwpPagePresenter(rootFrame, FormsApplication);

            Mvx.RegisterSingleton <IMvxViewPresenter>(presenter);

            return(presenter);
        }
示例#14
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            Forms.Init(null);

            var xamarinFormsApp = new MvxFormsApp();
            var presenter = new MvxFormsWindowsStorePagePresenter(rootFrame, xamarinFormsApp);
            Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);

            return presenter;
        }
示例#15
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            Forms.Init(_launchActivatedEventArgs);

            var xamarinFormsApp = new MvxFormsApp();
            var presenter = new MvxFormsWindowsUWPPagePresenter(rootFrame, xamarinFormsApp);
            Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);

            return presenter;
        }
示例#16
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            Forms.Init(_launchActivatedEventArgs);

            var xamarinFormsApp = new MvxFormsApp();
            var presenter       = new MvxFormsWindows81PagePresenter(rootFrame, xamarinFormsApp);

            Mvx.RegisterSingleton <IMvxViewPresenter>(presenter);

            return(presenter);
        }
 /// <summary>
 /// Disassociates a <see cref="Frame"/> previously registered by <see cref="RegisterFrame"/>
 /// from <see cref="SessionState"/>.  Any navigation state previously captured will be
 /// removed.
 /// </summary>
 /// <param name="frame">An instance whose navigation history should no longer be
 /// managed.</param>
 public void UnregisterFrame(IMvxWindowsFrame frame)
 {
     // Remove session state and remove the frame from the list of frames whose navigation
     // state will be saved (along with any weak references that are no longer reachable)
     this.SessionState.Remove((String)frame.GetValue(this.MvxFrameSessionStateKeyProperty));
     this._registeredFrames.RemoveAll((weakFrameReference) =>
     {
         IMvxWindowsFrame testFrame;
         return(!weakFrameReference.TryGetTarget(out testFrame) || testFrame == frame);
     });
 }
示例#18
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            Forms.Init(_launchActivatedEventArgs);

            MvxFormsApp = new PageRendererExampleApp();

            var presenter = new MvxFormsWindowsUWPPagePresenter(rootFrame, MvxFormsApp);
            Mvx.RegisterSingleton<IMvxViewPresenter>(presenter);
            Mvx.LazyConstructAndRegisterSingleton<IImageHolder, ImageHolder>();

            return presenter;
        }
示例#19
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            Forms.Init(launchActivatedEventArgs);

            //var xamarinFormsApp = new App();

            var presenter = new MvxFormsUwpViewPresenter(rootFrame, new MvxFormsApplication());


            Mvx.RegisterSingleton <IMvxViewPresenter>(presenter);
            return(presenter);
        }
示例#20
0
        protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
        {
            Forms.Init(_launchActivatedEventArgs);

            MvxFormsApp = new PageRendererExampleApp();

            var presenter = new MvxFormsUwpPagePresenter(rootFrame, MvxFormsApp);

            Mvx.RegisterSingleton <IMvxViewPresenter>(presenter);
            Mvx.LazyConstructAndRegisterSingleton <IImageHolder, ImageHolder>();

            return(presenter);
        }
        /// <summary>
        /// Registers a <see cref="Frame"/> instance to allow its navigation history to be saved to
        /// and restored from <see cref="SessionState"/>.  Frames should be registered once
        /// immediately after creation if they will participate in session state management.  Upon
        /// registration if state has already been restored for the specified key
        /// the navigation history will immediately be restored.  Subsequent invocations of
        /// <see cref="RestoreAsync"/> will also restore navigation history.
        /// </summary>
        /// <param name="frame">An instance whose navigation history should be managed by
        /// <see cref="MvxSuspensionManager"/></param>
        /// <param name="sessionStateKey">A unique key into <see cref="SessionState"/> used to
        /// store navigation-related information.</param>
        public void RegisterFrame(IMvxWindowsFrame frame, String sessionStateKey)
        {
            if (frame.GetValue(this.MvxFrameSessionStateKeyProperty) != null)
            {
                throw new InvalidOperationException("Frames can only be registered to one session state key");
            }

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

            // Use a dependency property to associate the session key with a frame, and keep a list of frames whose
            // navigation state should be managed
            frame.SetValue(this.MvxFrameSessionStateKeyProperty, sessionStateKey);
            this._registeredFrames.Add(new WeakReference <IMvxWindowsFrame>(frame));

            // Check to see if navigation state can be restored
            this.RestoreFrameNavigationState(frame);
        }
示例#22
0
 protected MvxWindowsSetup(IMvxWindowsFrame rootFrame)
 {
     this._rootFrame = rootFrame;
 }
示例#23
0
 public Setup(IMvxWindowsFrame rootFrame) : base(rootFrame) {}
示例#24
0
 public MvxWindowsMultiRegionViewPresenter(IMvxWindowsFrame rootFrame)
     : base(rootFrame)
 {
     this._rootFrame = rootFrame;
 }
示例#25
0
 protected virtual IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
 {
     return new MvxWindowsViewPresenter(rootFrame);
 }
示例#26
0
        /// <summary>
        /// Registers a <see cref="Frame"/> instance to allow its navigation history to be saved to
        /// and restored from <see cref="SessionState"/>.  Frames should be registered once
        /// immediately after creation if they will participate in session state management.  Upon
        /// registration if state has already been restored for the specified key
        /// the navigation history will immediately be restored.  Subsequent invocations of
        /// <see cref="RestoreAsync"/> will also restore navigation history.
        /// </summary>
        /// <param name="frame">An instance whose navigation history should be managed by
        /// <see cref="MvxSuspensionManager"/></param>
        /// <param name="sessionStateKey">A unique key into <see cref="SessionState"/> used to
        /// store navigation-related information.</param>
        public void RegisterFrame(IMvxWindowsFrame frame, string sessionStateKey)
        {
            if (frame.GetValue(this.MvxFrameSessionStateKeyProperty) != null)
            {
                throw new InvalidOperationException("Frames can only be registered to one session state key");
            }

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

            // Use a dependency property to associate the session key with a frame, and keep a list of frames whose
            // navigation state should be managed
            frame.SetValue(this.MvxFrameSessionStateKeyProperty, sessionStateKey);
            this._registeredFrames.Add(new WeakReference<IMvxWindowsFrame>(frame));

            // Check to see if navigation state can be restored
            this.RestoreFrameNavigationState(frame);
        }
示例#27
0
 public CustomViewPresenter(IMvxWindowsFrame rootFrame)
     : base(rootFrame)
 {
     _rootFrame = rootFrame;
 }
 public MvxFormsWindows81PagePresenter(IMvxWindowsFrame rootFrame, Application mvxFormsApp)
     : base(mvxFormsApp)
 {
     _rootFrame = rootFrame;
 }
 public MvxWindowsViewPresenter(IMvxWindowsFrame rootFrame)
 {
     _rootFrame = rootFrame;
 }
示例#30
0
 private void SaveFrameNavigationState(IMvxWindowsFrame frame)
 {
     var frameState = this.SessionStateForFrame(frame);
     frameState["Navigation"] = frame.GetNavigationState();
 }
示例#31
0
 private void RestoreFrameNavigationState(IMvxWindowsFrame frame)
 {
     var frameState = this.SessionStateForFrame(frame);
     if (frameState.ContainsKey("Navigation"))
     {
         frame.SetNavigationState((string)frameState["Navigation"]);
     }
 }
示例#32
0
        /// <summary>
        /// Provides storage for session state associated with the specified <see cref="Frame"/>.
        /// Frames that have been previously registered with <see cref="RegisterFrame"/> have
        /// their session state saved and restored automatically as a part of the global
        /// <see cref="SessionState"/>.  Frames that are not registered have transient state
        /// that can still be useful when restoring pages that have been discarded from the
        /// navigation cache.
        /// </summary>
        /// <remarks>Apps may choose to rely on <see cref="LayoutAwarePage"/> to manage
        /// page-specific state instead of working with frame session state directly.</remarks>
        /// <param name="frame">The instance for which session state is desired.</param>
        /// <returns>A collection of state subject to the same serialization mechanism as
        /// <see cref="SessionState"/>.</returns>
        public Dictionary<string, object> SessionStateForFrame(IMvxWindowsFrame frame)
        {
            var frameState = (Dictionary<string, object>)frame.GetValue(this.MvxFrameSessionStateProperty);

            if (frameState == null)
            {
                var frameSessionKey = (string)frame.GetValue(this.MvxFrameSessionStateKeyProperty);
                if (frameSessionKey != null)
                {
                    // Registered frames reflect the corresponding session state
                    if (!this.SessionState.ContainsKey(frameSessionKey))
                    {
                        this.SessionState[frameSessionKey] = new Dictionary<string, object>();
                    }
                    frameState = (Dictionary<string, object>)this.SessionState[frameSessionKey];
                }
                else
                {
                    // Frames that aren't registered have transient state
                    frameState = new Dictionary<string, object>();
                }
                frame.SetValue(this.MvxFrameSessionStateProperty, frameState);
            }
            return frameState;
        }
示例#33
0
 /// <summary>
 /// Disassociates a <see cref="Frame"/> previously registered by <see cref="RegisterFrame"/>
 /// from <see cref="SessionState"/>.  Any navigation state previously captured will be
 /// removed.
 /// </summary>
 /// <param name="frame">An instance whose navigation history should no longer be
 /// managed.</param>
 public void UnregisterFrame(IMvxWindowsFrame frame)
 {
     // Remove session state and remove the frame from the list of frames whose navigation
     // state will be saved (along with any weak references that are no longer reachable)
     this.SessionState.Remove((string)frame.GetValue(this.MvxFrameSessionStateKeyProperty));
     this._registeredFrames.RemoveAll((weakFrameReference) =>
     {
         IMvxWindowsFrame testFrame;
         return !weakFrameReference.TryGetTarget(out testFrame) || testFrame == frame;
     });
 }
示例#34
0
 protected virtual IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
 {
     return(new MvxWindowsViewPresenter(rootFrame));
 }
示例#35
0
        protected virtual MvxWindowsViewDispatcher CreateViewDispatcher(IMvxWindowsFrame rootFrame)
        {
            var presenter = this.CreateViewPresenter(this._rootFrame);

            return(new MvxWindowsViewDispatcher(presenter, rootFrame));
        }
 public MvxWindowsViewDispatcher(IMvxWindowsViewPresenter presenter, IMvxWindowsFrame rootFrame)
     : base(rootFrame.UnderlyingControl.Dispatcher)
 {
     this._presenter = presenter;
 }
 public CurrentViewModelPresenter(IMvxWindowsFrame rootFrame) : base(rootFrame)
 {
 }
        private void SaveFrameNavigationState(IMvxWindowsFrame frame)
        {
            var frameState = this.SessionStateForFrame(frame);

            frameState["Navigation"] = frame.GetNavigationState();
        }
示例#39
0
 protected virtual MvxWindowsViewDispatcher CreateViewDispatcher(IMvxWindowsFrame rootFrame)
 {
     return(new MvxWindowsViewDispatcher(Presenter, rootFrame));
 }
示例#40
0
 protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
 {
     return new MvxWindowsMultiRegionViewPresenter(rootFrame);
 }
        public CustomViewPresenter(IMvxWindowsFrame rootFrame)
            : base(rootFrame)
        {
            _rootFrame = rootFrame;

        }
示例#42
0
 public virtual void PlatformInitialize(IMvxWindowsFrame rootFrame)
 {
     _rootFrame = rootFrame;
 }
示例#43
0
 protected MvxWindowsSetup(IMvxWindowsFrame rootFrame)
 {
     this._rootFrame = rootFrame;
 }
示例#44
0
 public MvxFormsUwpViewPresenter(IMvxWindowsFrame rootFrame) : base(rootFrame)
 {
 }
示例#45
0
 protected virtual MvxWindowsViewDispatcher CreateViewDispatcher(IMvxWindowsFrame rootFrame)
 {
     var presenter = this.CreateViewPresenter(this._rootFrame);
     return new MvxWindowsViewDispatcher(presenter, rootFrame);
 }
示例#46
0
 public MvxFormsUwpViewPresenter(IMvxWindowsFrame rootFrame, MvxFormsApplication formsApplication) : this(rootFrame)
 {
     FormsApplication = formsApplication ?? throw new ArgumentNullException(nameof(formsApplication), "MvxFormsApplication cannot be null");
 }
示例#47
0
 public MvxFormsWindowsUWPMasterDetailPagePresenter(IMvxWindowsFrame rootFrame, Application mvxFormsApp)
     : base(mvxFormsApp)
 {
     _rootFrame = rootFrame;
 }
示例#48
0
		protected override IMvxWindowsViewPresenter CreateViewPresenter(IMvxWindowsFrame rootFrame)
		{
			return new CustomViewPresenter(rootFrame);
		}