예제 #1
0
        public void When_Relative_Path_With_Leading_Slash_From_Root()
        {
            var withSlash    = XamlFilePathHelper.ResolveAbsoluteSource("App.xaml", "/App/Xaml/Test_Dictionary.xaml");
            var withoutSlash = XamlFilePathHelper.ResolveAbsoluteSource("App.xaml", "App/Xaml/Test_Dictionary.xaml");

            Assert.AreEqual(withoutSlash, withSlash);
        }
예제 #2
0
        public static ResourceDictionary RetrieveDictionaryForSource(string source, string currentAbsolutePath)
        {
            if (source == null)
            {
                // Null is unusual but valid in this context
                return(new ResourceDictionary());
            }

            if (!XamlFilePathHelper.IsAbsolutePath(source))
            {
                // If we don't have an absolute path it must be a local resource reference
                source = XamlFilePathHelper.LocalResourcePrefix + XamlFilePathHelper.ResolveAbsoluteSource(currentAbsolutePath, source);
            }
            if (_registeredDictionariesByUri.TryGetValue(source, out var factory))
            {
                return(factory());
            }

            throw new InvalidOperationException($"Cannot locate resource from '{source}'");
        }
예제 #3
0
        private void UpdateSource()
        {
            var requestedVersion = ControlsResourcesVersion;

            if (ControlsResourcesVersion > MaxSupportedResourcesVersion)
            {
                if (this.Log().IsEnabled(LogLevel.Warning))
                {
                    this.Log().LogWarning($"" +
                                          $"WinUI resources version {ControlsResourcesVersion} is not supported " +
                                          $"in Uno Platform yet. Falling back to {MaxSupportedResourcesVersion} styles.");
                }
                requestedVersion = MaxSupportedResourcesVersion;
            }

            switch (requestedVersion)
            {
            case ControlsResourcesVersion.Version1:
#if !__NETSTD_REFERENCE__
                Uno.UI.FluentTheme.v1.GlobalStaticResources.Initialize();
                Uno.UI.FluentTheme.v1.GlobalStaticResources.RegisterDefaultStyles();
                Uno.UI.FluentTheme.v1.GlobalStaticResources.RegisterResourceDictionariesBySource();
#endif
                break;

            case ControlsResourcesVersion.Version2:
#if !__NETSTD_REFERENCE__
                Uno.UI.FluentTheme.v2.GlobalStaticResources.Initialize();
                Uno.UI.FluentTheme.v2.GlobalStaticResources.RegisterDefaultStyles();
                Uno.UI.FluentTheme.v2.GlobalStaticResources.RegisterResourceDictionariesBySource();
#endif
                break;
            }


            Source = new Uri(XamlFilePathHelper.AppXIdentifier + XamlFilePathHelper.GetWinUIThemeResourceUrl((int)requestedVersion));

            _isUsingResourcesVersion2 = requestedVersion == ControlsResourcesVersion.Version2;
        }
예제 #4
0
 private void UpdateSource()
 {
     Source = new Uri(XamlFilePathHelper.AppXIdentifier + XamlFilePathHelper.GetWinUIThemeResourceUrl(1));
 }