Beispiel #1
0
        void IConfigChangeHandler.ConfigUpdated(ConfigSettings newSettings)
        {
            if (_currentSkin == null || _currentSkin.Name != newSettings.SkinName)
            {
                var newSkin = new Skin(newSettings.SkinName);

                _skinLoader.Load(newSkin);

                _currentSkin = newSkin;
            }
        }
Beispiel #2
0
        public void Load(Skin newSkin)
        {
            _view.Invoke(() =>
            {
                newSkin.Resource = _skinResourceLoader.LoadOrGet(newSkin);

                var appResources = Application.Current.Resources.MergedDictionaries;

                if (appResources.Contains(newSkin.Resource))
                    appResources.Remove(newSkin.Resource);

                appResources.Add(newSkin.Resource);
            });
        }
        public void CanGet_AlreadyLoaded_Resource()
        {
            var boot = new Bootstrapper(Create.Stub<IConfigSettings>(),
                                        Create.Stub<ICradiatorView>());
            boot.CreateKernel();

            var skin1 = new Skin("Stack"); // these tests are reliant on xaml file names in the main assembly (Skin folder)
            var skin2 = new Skin("Grid");
            var skin3 = new Skin("StackPhoto");

            Application.ResourceAssembly = Assembly.GetAssembly(typeof (Skin));

            var skinResourceLoader = new SkinResourceLoader();

            var resourceSkin1 = skinResourceLoader.LoadOrGet(skin1);
            var resourceSkin2 = skinResourceLoader.LoadOrGet(skin2);
            var resourceSkin3 = skinResourceLoader.LoadOrGet(skin3);

            Assert.That(skinResourceLoader.LoadOrGet(skin3), Is.SameAs(resourceSkin3));
            Assert.That(skinResourceLoader.LoadOrGet(skin2), Is.SameAs(resourceSkin2));
            Assert.That(skinResourceLoader.LoadOrGet(skin1), Is.SameAs(resourceSkin1));
        }