Exemplo n.º 1
0
        void UpdateLineElementBrushes()
        {
            var props = editorFormatMap.GetProperties(isActive ? ThemeClassificationTypeNameKeys.CurrentLine : ThemeClassificationTypeNameKeys.CurrentLineNoFocus);

            currentLineHighlighterElement.ForegroundBrush = ResourceDictionaryUtilities.GetForegroundBrush(props);
            currentLineHighlighterElement.BackgroundBrush = ResourceDictionaryUtilities.GetBackgroundBrush(props);
        }
Exemplo n.º 2
0
        public CurrentThemeResourceDictionary()
        {
            var themesManager = DiContainer.SP?.GetRequiredService <IThemesManager>() !;
            var currentTheme  = themesManager.GetResolvedCurrent();

            Source = ResourceDictionaryUtilities.GetSourceUri(currentTheme.ResourceDictionaryLocation);
        }
Exemplo n.º 3
0
 public Theme(string name, string resourceDictionaryLocation, string?source = null, string?assemblyName = null)
 {
     Name = name;
     assemblyName ??= Assembly.GetCallingAssembly().GetName().Name ?? throw new ArgumentException($"{nameof(assemblyName)} is not set and cannot retrieve the {nameof(AssemblyName.Name)} of {nameof(Assembly.GetCallingAssembly)}");
     ResourceDictionaryLocation = ResourceDictionaryUtilities.CheckLocation(resourceDictionaryLocation, assemblyName);
     Source = source ?? assemblyName[(assemblyName.LastIndexOf('.') + 1)..];
 }
        public static void AddTypeDateTemplate <ForType>(this IServiceProvider serviceProvider, string resourceDictionaryLocation)
        {
            var rd = ResourceDictionaryUtilities.Get(resourceDictionaryLocation, typeof(ForType).Assembly);

            foreach (var possibleKey in GetPossibleKeys <ForType>())
            {
                if (rd.Contains(possibleKey))
                {
                    serviceProvider.GetRequiredService <ITypeDataTemplateManager>().Add(typeof(ForType), (DataTemplate)rd[possibleKey]);
                    return;
                }
            }
            foreach (var item in rd.Values.OfType <DataTemplate>())
            {
                if (item.DataType is Type dt && dt == typeof(ForType))
                {
                    serviceProvider.GetRequiredService <ITypeDataTemplateManager>().Add(typeof(ForType), item);
                    return;
                }
            }
            throw new KeyNotFoundException($"Cannot find a {nameof(DataTemplate)} for {typeof(ForType).Name} inside {resourceDictionaryLocation}");
        }
Exemplo n.º 5
0
        void UpdateLineSeparatorBrush()
        {
            if (editorFormatMap is null)
            {
                return;
            }
            var props = editorFormatMap.GetProperties(ThemeClassificationTypeNameKeys.LineSeparator);
            var brush = ResourceDictionaryUtilities.GetForegroundBrush(props);

            if (brush is null)
            {
                brush = new SolidColorBrush(Color.FromRgb(0xA5, 0xA5, 0xA5));
            }
            if (brush.CanFreeze)
            {
                brush.Freeze();
            }
            if (!BrushComparer.Equals(lineSeparatorBrush, brush))
            {
                lineSeparatorBrush = brush;
                UpdateLineSeparatorElementsForeground();
            }
        }
 public static void AddTypeDateTemplate <ForType>(this IServiceProvider serviceProvider, string resourceDictionaryLocation, object templateKey)
 {
     serviceProvider.GetRequiredService <ITypeDataTemplateManager>().Add(typeof(ForType), (DataTemplate)
                                                                         ResourceDictionaryUtilities.Get(resourceDictionaryLocation, typeof(ForType).Assembly)
                                                                         [templateKey]);
 }