示例#1
0
        private void ActivateScreen(ScreenEventArgs args)
        {
            // There is no such registered screen type. Possibly throw an exception here.
            if (!this.ScreenFactoryRegistry.HasFactory(args.ScreenKey))
            {
                return;
            }

            // Check if an active screen exists.
            if (this.ScreenCollection.ContainsKey(this.activeScreenKey))
            {
                // Get the currently active screen
                IScreen activeScreen = this.ScreenCollection[this.activeScreenKey];
                // Check if we can leave
                if (activeScreen.CanLeave())
                {
                    IScreen screen = this.ScreenCollection[this.activeScreenKey];
                    this.VisibilityService.LeaveViewAnimation(screen.View, () =>
                    {
                        mainRegion.Deactivate(screen.View);
                        mainRegion.Remove(screen.View);
                        IScreen newScreen = EnsureScreenExists(args.ScreenKey, args.ScreenSubject, args.RegionName);
                        ShowScreen(args.ScreenKey, args.RegionName);
                    });
                }
                else
                {
                    activeScreen.CleanUp(); //TODO: implement CleanUp
                }
            }
            else
            {
                // no active screen exists
                IScreen newScreen = EnsureScreenExists(args.ScreenKey, args.ScreenSubject, args.RegionName);
                ShowScreen(args.ScreenKey, args.RegionName);
            }
        }