Egorozh.ColorPicker.Avalonia.Dialog by Egorozh.ColorPicker.Avalonia.Dialog

<PackageReference Include="Egorozh.ColorPicker.Avalonia.Dialog" Version="0.10.7" />

 FluentColorPickerTheme

using Avalonia.Controls; using Avalonia.Markup.Xaml; using Avalonia.Styling; using Avalonia.Themes.Fluent; using System; using System.Collections.Generic; using System.Runtime.CompilerServices; namespace Egorozh.ColorPicker.Dialog { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public class FluentColorPickerTheme { private readonly Uri _baseUri; [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] private IStyle[] _loaded; private bool _isLoading; public IReadOnlyList<IStyle> Children => _loaded ?? Array.Empty<IStyle>(); bool HasResources { get { object obj = (object)(Loaded as IResourceProvider); if (obj == null) return false; return obj.get_HasResources(); } } [System.Runtime.CompilerServices.Nullable(2)] public IResourceHost Owner { [System.Runtime.CompilerServices.NullableContext(2)] get { object obj = (object)(Loaded as IResourceProvider); if (obj == null) return null; return obj.get_Owner(); } } public FluentThemeMode Mode { get; set; } public IStyle Loaded { get { if (_loaded == null) { _isLoading = true; IStyle val = AvaloniaXamlLoader.Load(GetUri(), _baseUri); _loaded = (IStyle[])new IStyle[1] { val }; _isLoading = false; } IStyle[] loaded = _loaded; if (loaded == null) return null; return loaded[0]; } } public event EventHandler OwnerChanged { add { IResourceProvider val = Loaded as IResourceProvider; if (val != null) val.add_OwnerChanged(value); } remove { IResourceProvider val = Loaded as IResourceProvider; if (val != null) val.remove_OwnerChanged(value); } } public FluentColorPickerTheme(Uri baseUri) { _baseUri = baseUri; } public FluentColorPickerTheme(IServiceProvider serviceProvider) { _baseUri = serviceProvider.GetService(typeof(IUriContext)).get_BaseUri(); } public SelectorMatchResult TryAttach(IStyleable target, [System.Runtime.CompilerServices.Nullable(2)] IStyleHost host) { return Loaded.TryAttach(target, host); } public bool TryGetResource(object key, [System.Runtime.CompilerServices.Nullable(2)] out object value) { if (!_isLoading) { IResourceProvider val = Loaded as IResourceProvider; if (val != null) return val.TryGetResource(key, ref value); } value = null; return false; } public void AddOwner(IResourceHost owner) { object obj = (object)(Loaded as IResourceProvider); if (obj != null) obj.AddOwner(owner); } public void RemoveOwner(IResourceHost owner) { object obj = (object)(Loaded as IResourceProvider); if (obj != null) obj.RemoveOwner(owner); } protected virtual Uri GetUri() { if ((int)Mode != 1) return new Uri("avares://Egorozh.ColorPicker.Avalonia.Dialog/Themes/FluentLight.axaml", UriKind.Absolute); return new Uri("avares://Egorozh.ColorPicker.Avalonia.Dialog/Themes/FluentDark.axaml", UriKind.Absolute); } } }