public void Register(ScreenKeyType screenType, Type registeredScreenFactoryType)
 {
     if (!HasFactory(screenType))
     {
         this.ScreenFactoryCollection.Add(screenType, registeredScreenFactoryType);
     }
 }
        public IScreenFactory Get(ScreenKeyType screenType)
        {
            IScreenFactory screenFactory = null;

            if (this.HasFactory(screenType))
            {
                Type registeredScreenFactory = ScreenFactoryCollection[screenType];
                screenFactory = (IScreenFactory)Container.Resolve(registeredScreenFactory);
            }
            return(screenFactory);
        }
Ejemplo n.º 3
0
        public ScreenConductor(IUnityContainer container,
                               IScreenFactoryRegistry screenFactoryRegistry,
                               IEventAggregator eventAggregator,
                               IRegionManager regionManager,
                               IVisibilityService visibilityService)
        {
            this.activeScreenKey = ScreenKeyType.None;

            this.Container             = container;
            this.ScreenFactoryRegistry = screenFactoryRegistry;
            this.EventAggregator       = eventAggregator;
            this.RegionManager         = regionManager;
            this.VisibilityService     = visibilityService;

            this.ScreenCollection = new Dictionary <ScreenKeyType, IScreen>();
            mainRegion            = this.RegionManager.Regions[RegionConstants.REGION_MAIN_AREA];
            SubscribeToEvents();
        }
Ejemplo n.º 4
0
        private void ShowScreen(ScreenKeyType screenKey, string regionName)
        {
            if (!this.ScreenCollection.ContainsKey(screenKey))
            {
                return;
            }

            IScreen screen = this.ScreenCollection[screenKey];

            if (regionName != null && regionName != RegionConstants.REGION_MAIN_AREA)
            {
                targetRegion = this.RegionManager.Regions[regionName];
                targetRegion.Add(screen.View);
                targetRegion.Activate(screen.View);
            }
            else
            {
                this.activeScreenKey = screenKey;
                mainRegion.Add(screen.View);
                mainRegion.Activate(screen.View);
            }
            this.VisibilityService.EnterViewAnimation(screen.View);
        }
Ejemplo n.º 5
0
        private IScreen EnsureScreenExists(ScreenKeyType screenKey, object screenSubject, string regionName)
        {
            IScreen screen = null;

            // use the screen type to see if the screen exists in the collection
            if (ScreenCollection.ContainsKey(screenKey))
            {
                screen = ScreenCollection[screenKey];
            }
            else // if it does not, then use the screen type to get the factory that is made for creating that type of screen and make it, add to collection
            {
                if (this.ScreenFactoryRegistry.HasFactory(screenKey))
                {
                    screen = this.ScreenFactoryRegistry.Get(screenKey).CreateScreen(screenSubject);
                    ScreenCollection.Add(screenKey, screen);
                }
                else
                {
                    throw new ArgumentOutOfRangeException("Screen Key not found");
                }
            }
            return(screen);
        }
 public bool HasFactory(ScreenKeyType screenType)
 {
     return(this.ScreenFactoryCollection.ContainsKey(screenType));
 }