Codemaid
This commit is contained in:
@@ -4,7 +4,7 @@ using Toolkit.UI.Controls.Avalonia;
|
|||||||
|
|
||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
|
|
||||||
public class ContentDialogHandler(IDispatcher dispatcher) :
|
public class ContentDialogHandler :
|
||||||
INotificationHandler<NavigateEventArgs<ContentDialog>>
|
INotificationHandler<NavigateEventArgs<ContentDialog>>
|
||||||
{
|
{
|
||||||
public async Task Handle(NavigateEventArgs<ContentDialog> args)
|
public async Task Handle(NavigateEventArgs<ContentDialog> args)
|
||||||
@@ -83,7 +83,7 @@ public class ContentDialogHandler(IDispatcher dispatcher) :
|
|||||||
{
|
{
|
||||||
await deactivating.OnDeactivating();
|
await deactivating.OnDeactivating();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ public class FileProvider(ITopLevelProvider topLevelProvider) :
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return storageFiles.Select(file => file.Path.LocalPath).ToList();
|
return storageFiles.Select(file => file.Path.LocalPath).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Array.Empty<string>();
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ public class FrameHandler :
|
|||||||
|
|
||||||
if (args.Parameters is not null)
|
if (args.Parameters is not null)
|
||||||
{
|
{
|
||||||
if (args.Parameters.TryGetValue("Transition",
|
if (args.Parameters.TryGetValue("Transition",
|
||||||
out object? transition))
|
out object? transition))
|
||||||
{
|
{
|
||||||
switch ($"{transition}")
|
switch ($"{transition}")
|
||||||
@@ -142,6 +142,7 @@ public class FrameHandler :
|
|||||||
navigationOptions.TransitionInfoOverride =
|
navigationOptions.TransitionInfoOverride =
|
||||||
new SuppressNavigationTransitionInfo();
|
new SuppressNavigationTransitionInfo();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "FromLeft":
|
case "FromLeft":
|
||||||
case "FromRight":
|
case "FromRight":
|
||||||
case "FromTop":
|
case "FromTop":
|
||||||
@@ -155,7 +156,7 @@ public class FrameHandler :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Parameters.TryGetValue("IsBackStackEnabled",
|
if (args.Parameters.TryGetValue("IsBackStackEnabled",
|
||||||
out object? isBackStackEnabled))
|
out object? isBackStackEnabled))
|
||||||
{
|
{
|
||||||
if (isBackStackEnabled is bool value)
|
if (isBackStackEnabled is bool value)
|
||||||
@@ -164,7 +165,7 @@ public class FrameHandler :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.Parameters.TryGetValue("ClearBackStack",
|
if (args.Parameters.TryGetValue("ClearBackStack",
|
||||||
out object? clearBackStack))
|
out object? clearBackStack))
|
||||||
{
|
{
|
||||||
if (clearBackStack is bool clearBool)
|
if (clearBackStack is bool clearBool)
|
||||||
@@ -177,7 +178,7 @@ public class FrameHandler :
|
|||||||
|
|
||||||
if (clearBackStack is string clearString)
|
if (clearBackStack is string clearString)
|
||||||
{
|
{
|
||||||
if (clearString.StartsWith('[') && clearString.EndsWith(']') &&
|
if (clearString.StartsWith('[') && clearString.EndsWith(']') &&
|
||||||
clearString.Contains('-'))
|
clearString.Contains('-'))
|
||||||
{
|
{
|
||||||
string range = clearString.Trim('[', ']');
|
string range = clearString.Trim('[', ']');
|
||||||
@@ -197,7 +198,7 @@ public class FrameHandler :
|
|||||||
{
|
{
|
||||||
postNavigateActions.Add(() => CleanUp(1, frame.BackStack.Count));
|
postNavigateActions.Add(() => CleanUp(1, frame.BackStack.Count));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ public interface IImageResizer
|
|||||||
int targetWidth,
|
int targetWidth,
|
||||||
int targetHeight,
|
int targetHeight,
|
||||||
bool maintainAspectRatio);
|
bool maintainAspectRatio);
|
||||||
}
|
}
|
||||||
@@ -129,7 +129,7 @@ public static class IServiceCollectionExtensions
|
|||||||
|
|
||||||
services.AddTransient<IClipboardWriter, ClipboardWriter>();
|
services.AddTransient<IClipboardWriter, ClipboardWriter>();
|
||||||
|
|
||||||
services.AddTransient<IImageReader, ImageReader>();
|
services.AddTransient<IImageReader, ImageReader>();
|
||||||
services.AddTransient<IImageWriter, ImageWriter>();
|
services.AddTransient<IImageWriter, ImageWriter>();
|
||||||
services.AddTransient<IImageResizer, ImageResizer>();
|
services.AddTransient<IImageResizer, ImageResizer>();
|
||||||
|
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ namespace Toolkit.Avalonia;
|
|||||||
public interface ITopLevelProvider
|
public interface ITopLevelProvider
|
||||||
{
|
{
|
||||||
TopLevel? Get();
|
TopLevel? Get();
|
||||||
}
|
}
|
||||||
@@ -3,15 +3,15 @@ using Toolkit.Foundation;
|
|||||||
|
|
||||||
namespace Toolkit.Avalonia;
|
namespace Toolkit.Avalonia;
|
||||||
|
|
||||||
public class ImageReader(IImageResizer imageResizer) :
|
public class ImageReader(IImageResizer imageResizer) :
|
||||||
IImageReader
|
IImageReader
|
||||||
{
|
{
|
||||||
public IImageDescriptor Get(Stream stream,
|
public IImageDescriptor Get(Stream stream,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
bool maintainAspectRatio)
|
bool maintainAspectRatio)
|
||||||
{
|
{
|
||||||
Bitmap resizedImage = imageResizer.Resize(stream, width, height, maintainAspectRatio);
|
Bitmap resizedImage = imageResizer.Resize(stream, width, height, maintainAspectRatio);
|
||||||
return new ImageDescriptor(resizedImage, width, height);
|
return new ImageDescriptor(resizedImage, width, height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,4 +14,4 @@ public class ImageWriter :
|
|||||||
bitmap.Save(stream);
|
bitmap.Save(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,4 +27,4 @@ public class TopLevelProvider :
|
|||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,4 +6,4 @@ public record Activation
|
|||||||
|
|
||||||
public static ActivationEventArgs<TSender> As<TSender>() =>
|
public static ActivationEventArgs<TSender> As<TSender>() =>
|
||||||
new();
|
new();
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ActivationBuilder(IActivation Value, object? Key = null);
|
public record ActivationBuilder(IActivation Value, object? Key = null);
|
||||||
@@ -193,6 +193,7 @@ public class Cache<TKey, TValue>(IComparer<TKey> comparer) :
|
|||||||
value = default;
|
value = default;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class KeyValuePairComparer<TK, TV>(IComparer<TK> comparer) :
|
private class KeyValuePairComparer<TK, TV>(IComparer<TK> comparer) :
|
||||||
IComparer<KeyValuePair<TK, TV>>
|
IComparer<KeyValuePair<TK, TV>>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ChangedEventArgs<TSender>(TSender? Sender = default);
|
public record ChangedEventArgs<TSender>(TSender? Sender = default);
|
||||||
@@ -5,4 +5,4 @@ public record Close
|
|||||||
public static CloseEventArgs<TSender> As<TSender>(TSender sender) => new(sender);
|
public static CloseEventArgs<TSender> As<TSender>(TSender sender) => new(sender);
|
||||||
|
|
||||||
public static CloseEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender());
|
public static CloseEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender());
|
||||||
}
|
}
|
||||||
@@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
|
|
||||||
public class Component :
|
public class Component :
|
||||||
IComponent
|
IComponent
|
||||||
{
|
{
|
||||||
private readonly IComponentBuilder builder;
|
private readonly IComponentBuilder builder;
|
||||||
|
|
||||||
protected Component(IComponentBuilder builder) =>
|
protected Component(IComponentBuilder builder) =>
|
||||||
this.builder = builder;
|
this.builder = builder;
|
||||||
|
|
||||||
public static TComponent? Create<TComponent>(IServiceProvider provider,
|
public static TComponent? Create<TComponent>(IServiceProvider provider,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
public class ContentFactory(IServiceProvider provider,
|
public class ContentFactory(IServiceProvider provider,
|
||||||
IServiceFactory factory) : IContentFactory
|
IServiceFactory factory) : IContentFactory
|
||||||
{
|
{
|
||||||
public Task<object?> CreateAsync(IContentTemplateDescriptor descriptor,
|
public Task<object?> CreateAsync(IContentTemplateDescriptor descriptor,
|
||||||
object[] parameters)
|
object[] parameters)
|
||||||
{
|
{
|
||||||
object? content = parameters is { Length: > 0 }
|
object? content = parameters is { Length: > 0 }
|
||||||
@@ -24,4 +24,4 @@ public class ContentFactory(IServiceProvider provider,
|
|||||||
|
|
||||||
return Task.FromResult<object?>(content);
|
return Task.FromResult<object?>(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record CreateEventArgs<TSender>(TSender? Sender = default,
|
public record CreateEventArgs<TSender>(TSender? Sender = default,
|
||||||
params object[] Parameters);
|
params object[] Parameters);
|
||||||
@@ -7,4 +7,4 @@ public record Delete
|
|||||||
|
|
||||||
public static DeleteEventArgs<TSender> As<TSender>() where TSender : new() =>
|
public static DeleteEventArgs<TSender> As<TSender>() where TSender : new() =>
|
||||||
new(new TSender());
|
new(new TSender());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record FileFilter(string Name, List<string> Extensions, bool AllowMultiple = false);
|
public record FileFilter(string Name, List<string> Extensions, bool AllowMultiple = false);
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IClipboardWriter
|
public interface IClipboardWriter
|
||||||
{
|
{
|
||||||
Task Write<TContent>(TContent content);
|
Task Write<TContent>(TContent content);
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,4 @@ public static class ICollectionSynchronizationExtensions
|
|||||||
{
|
{
|
||||||
public static int IndexOf<TItem>(this ICollectionSynchronization<TItem> synchronization,
|
public static int IndexOf<TItem>(this ICollectionSynchronization<TItem> synchronization,
|
||||||
TItem item) => synchronization is IList<TItem> collection ? collection.IndexOf(item) : -1;
|
TItem item) => synchronization is IList<TItem> collection ? collection.IndexOf(item) : -1;
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ namespace Toolkit.Foundation;
|
|||||||
public interface IComponentFactory
|
public interface IComponentFactory
|
||||||
{
|
{
|
||||||
IComponentHost? Create<TComponent, TConfiguration>(string name,
|
IComponentHost? Create<TComponent, TConfiguration>(string name,
|
||||||
TConfiguration? configuration = null,
|
TConfiguration? configuration = null,
|
||||||
Action<IServiceCollection>? servicesDelegate = null)
|
Action<IServiceCollection>? servicesDelegate = null)
|
||||||
where TComponent : IComponent
|
where TComponent : IComponent
|
||||||
where TConfiguration : ComponentConfiguration, new();
|
where TConfiguration : ComponentConfiguration, new();
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
|
namespace Toolkit.Foundation
|
||||||
namespace Toolkit.Foundation
|
|
||||||
{
|
{
|
||||||
public interface IContentFactory
|
public interface IContentFactory
|
||||||
{
|
{
|
||||||
Task<object?> CreateAsync(IContentTemplateDescriptor descriptor,
|
Task<object?> CreateAsync(IContentTemplateDescriptor descriptor,
|
||||||
object[] resolvedArguments);
|
object[] resolvedArguments);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public static class IHostBuilderExtension
|
|||||||
sections.Add(section);
|
sections.Add(section);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string section in sections)
|
foreach (string section in sections)
|
||||||
{
|
{
|
||||||
if (context.Properties.TryGetValue(section, out object? value))
|
if (context.Properties.TryGetValue(section, out object? value))
|
||||||
@@ -112,7 +112,7 @@ public static class IHostBuilderExtension
|
|||||||
configurations.Add(typeof(TConfiguration));
|
configurations.Add(typeof(TConfiguration));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
context.Properties.Add(section, new List<Type> { typeof(TConfiguration) });
|
context.Properties.Add(section, new List<Type> { typeof(TConfiguration) });
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ public interface IImageDescriptor
|
|||||||
public int Width { get; }
|
public int Width { get; }
|
||||||
|
|
||||||
public int Height { get; }
|
public int Height { get; }
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
public interface IImageReader
|
public interface IImageReader
|
||||||
{
|
{
|
||||||
IImageDescriptor Get(Stream stream,
|
IImageDescriptor Get(Stream stream,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
bool maintainAspectRatio = false);
|
bool maintainAspectRatio = false);
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IIndexed
|
public interface IIndexed
|
||||||
{
|
{
|
||||||
public int Index { get; }
|
public int Index { get; }
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IInitialization
|
public interface IInitialization
|
||||||
{
|
{
|
||||||
void Initialize();
|
void Initialize();
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IPrimaryConfirmation
|
public interface IPrimaryConfirmation
|
||||||
{
|
{
|
||||||
Task<bool> ConfirmPrimary();
|
Task<bool> ConfirmPrimary();
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public static class IServiceCollectionExtensions
|
public static class IServiceCollectionExtensions
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddCache<TKey, TValue>(this IServiceCollection services)
|
public static IServiceCollection AddCache<TKey, TValue>(this IServiceCollection services)
|
||||||
@@ -37,7 +38,7 @@ public static class IServiceCollectionExtensions
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddHandler<THandler>(this IServiceCollection services,
|
public static IServiceCollection AddHandler<THandler>(this IServiceCollection services,
|
||||||
ServiceLifetime lifetime = ServiceLifetime.Transient,
|
ServiceLifetime lifetime = ServiceLifetime.Transient,
|
||||||
string? key = null)
|
string? key = null)
|
||||||
where THandler : IHandler
|
where THandler : IHandler
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ namespace Toolkit.Foundation;
|
|||||||
|
|
||||||
public static class IServiceProviderExtensions
|
public static class IServiceProviderExtensions
|
||||||
{
|
{
|
||||||
public static object GetRequiredKeyedService(this IServiceProvider provider,
|
public static object GetRequiredKeyedService(this IServiceProvider provider,
|
||||||
Type serviceType,
|
Type serviceType,
|
||||||
Action<object> serviceDelegate,
|
Action<object> serviceDelegate,
|
||||||
object? serviceKey)
|
object? serviceKey)
|
||||||
{
|
{
|
||||||
object service = provider.GetRequiredKeyedService(serviceType, serviceKey);
|
object service = provider.GetRequiredKeyedService(serviceType, serviceKey);
|
||||||
@@ -14,4 +14,4 @@ public static class IServiceProviderExtensions
|
|||||||
|
|
||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ using System.Linq.Expressions;
|
|||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public interface IValidation :
|
public interface IValidation :
|
||||||
INotifyPropertyChanged
|
INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
IReadOnlyDictionary<string, string> Errors { get; }
|
IReadOnlyDictionary<string, string> Errors { get; }
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ public interface IValidatorCollection :
|
|||||||
void Add(string key, Validator binder);
|
void Add(string key, Validator binder);
|
||||||
|
|
||||||
bool TryGet(string key, [MaybeNull] out Validator? value);
|
bool TryGet(string key, [MaybeNull] out Validator? value);
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ public class Mediator(IHandlerProvider handlerProvider,
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<object?> Handle(Type responseType,
|
public async Task<object?> Handle(Type responseType,
|
||||||
object message,
|
object message,
|
||||||
object? key = null,
|
object? key = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
@@ -57,7 +57,7 @@ public class Mediator(IHandlerProvider handlerProvider,
|
|||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<object?>> HandleMany(Type responseType,
|
public async Task<List<object?>> HandleMany(Type responseType,
|
||||||
object message,
|
object message,
|
||||||
object? key = null,
|
object? key = null,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
@@ -97,7 +97,7 @@ public class Mediator(IHandlerProvider handlerProvider,
|
|||||||
List<object?> handlers = GetHandlers(message, handlerType, key);
|
List<object?> handlers = GetHandlers(message, handlerType, key);
|
||||||
foreach (object? handler in handlers)
|
foreach (object? handler in handlers)
|
||||||
{
|
{
|
||||||
MethodInfo? handleMethod = handler?.GetType().GetMethod("Handle",
|
MethodInfo? handleMethod = handler?.GetType().GetMethod("Handle",
|
||||||
[messageType, typeof(CancellationToken)]);
|
[messageType, typeof(CancellationToken)]);
|
||||||
|
|
||||||
if (handleMethod is not null)
|
if (handleMethod is not null)
|
||||||
@@ -127,7 +127,7 @@ public class Mediator(IHandlerProvider handlerProvider,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<object?> GetHandlers(object message,
|
private List<object?> GetHandlers(object message,
|
||||||
Type handlerWrapperType,
|
Type handlerWrapperType,
|
||||||
object? key)
|
object? key)
|
||||||
{
|
{
|
||||||
@@ -151,7 +151,7 @@ public class Mediator(IHandlerProvider handlerProvider,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<object?> keyedServices = key is not null ? provider.GetKeyedServices(handlerWrapperType, key) :
|
IEnumerable<object?> keyedServices = key is not null ? provider.GetKeyedServices(handlerWrapperType, key) :
|
||||||
provider.GetServices(handlerWrapperType);
|
provider.GetServices(handlerWrapperType);
|
||||||
AddHandlers(keyedServices);
|
AddHandlers(keyedServices);
|
||||||
|
|
||||||
@@ -160,5 +160,4 @@ public class Mediator(IHandlerProvider handlerProvider,
|
|||||||
|
|
||||||
return handlers.SelectMany(entry => entry.Value).ToList();
|
return handlers.SelectMany(entry => entry.Value).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public static class MediatorExtensions
|
public static class MediatorExtensions
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -10,7 +10,7 @@ public class NavigateBackHandler(IComponentScopeProvider provider) :
|
|||||||
if (provider.Get(args.Scope ?? "Root")
|
if (provider.Get(args.Scope ?? "Root")
|
||||||
is ComponentScopeDescriptor descriptor)
|
is ComponentScopeDescriptor descriptor)
|
||||||
{
|
{
|
||||||
if (descriptor?.Services?.GetService<INavigation>() is
|
if (descriptor?.Services?.GetService<INavigation>() is
|
||||||
INavigation navigationScope)
|
INavigation navigationScope)
|
||||||
{
|
{
|
||||||
navigationScope.Back(args.Context);
|
navigationScope.Back(args.Context);
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class Navigation(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
currentSegmentIndex++;
|
currentSegmentIndex++;
|
||||||
|
|
||||||
if (provider.GetKeyedService<IContentTemplateDescriptor>(segment)
|
if (provider.GetKeyedService<IContentTemplateDescriptor>(segment)
|
||||||
is IContentTemplateDescriptor descriptor)
|
is IContentTemplateDescriptor descriptor)
|
||||||
{
|
{
|
||||||
Dictionary<string, object>? arguments = parameters?.ToDictionary(x => x.Key, x => x.Value, StringComparer.InvariantCultureIgnoreCase) ?? [];
|
Dictionary<string, object>? arguments = parameters?.ToDictionary(x => x.Key, x => x.Value, StringComparer.InvariantCultureIgnoreCase) ?? [];
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
|
|
||||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||||
public class NotificationAttribute(Type type,
|
public class NotificationAttribute(Type type,
|
||||||
object key) : Attribute
|
object key) : Attribute
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public static class ObjectExtensions
|
|||||||
{
|
{
|
||||||
Type type = obj.GetType();
|
Type type = obj.GetType();
|
||||||
|
|
||||||
object? key = selector();
|
object? key = selector();
|
||||||
if (type.GetProperty($"{key}") is PropertyInfo property && property.GetValue(obj) is { } value)
|
if (type.GetProperty($"{key}") is PropertyInfo property && property.GetValue(obj) is { } value)
|
||||||
{
|
{
|
||||||
return value;
|
return value;
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ public partial class Observable(IServiceProvider provider,
|
|||||||
|
|
||||||
public virtual void OnInitialize()
|
public virtual void OnInitialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
@@ -129,10 +128,9 @@ public partial class Observable<TValue> :
|
|||||||
|
|
||||||
protected virtual void OnValueChanged()
|
protected virtual void OnValueChanged()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnValueChanged(TValue? value) => OnValueChanged();
|
private partial void OnValueChanged(TValue? value) => OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class Observable<TKey, TValue> :
|
public partial class Observable<TKey, TValue> :
|
||||||
@@ -148,8 +146,8 @@ public partial class Observable<TKey, TValue> :
|
|||||||
public Observable(IServiceProvider provider,
|
public Observable(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
TKey key,
|
TKey key,
|
||||||
TValue? value = default) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
TValue? value = default) : base(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
@@ -160,8 +158,7 @@ public partial class Observable<TKey, TValue> :
|
|||||||
|
|
||||||
protected virtual void OnValueChanged()
|
protected virtual void OnValueChanged()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnValueChanged(TValue? value) => OnValueChanged();
|
private partial void OnValueChanged(TValue? value) => OnValueChanged();
|
||||||
}
|
}
|
||||||
@@ -146,7 +146,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
|
|
||||||
private Func<TItem>? defaultSelectionFactory;
|
private Func<TItem>? defaultSelectionFactory;
|
||||||
|
|
||||||
public void SetSource(IList<TItem> source,
|
public void SetSource(IList<TItem> source,
|
||||||
Func<TItem>? defaultSelectionFactory)
|
Func<TItem>? defaultSelectionFactory)
|
||||||
{
|
{
|
||||||
foreach (TItem item in source)
|
foreach (TItem item in source)
|
||||||
@@ -167,7 +167,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SourceCollectionChanged(object? sender,
|
private void SourceCollectionChanged(object? sender,
|
||||||
NotifyCollectionChangedEventArgs args)
|
NotifyCollectionChangedEventArgs args)
|
||||||
{
|
{
|
||||||
switch (args.Action)
|
switch (args.Action)
|
||||||
@@ -181,6 +181,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Remove:
|
case NotifyCollectionChangedAction.Remove:
|
||||||
if (args.OldItems is not null)
|
if (args.OldItems is not null)
|
||||||
{
|
{
|
||||||
@@ -193,6 +194,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyCollectionChangedAction.Reset:
|
case NotifyCollectionChangedAction.Reset:
|
||||||
|
|
||||||
Clear();
|
Clear();
|
||||||
@@ -263,7 +265,6 @@ public partial class ObservableCollection<TItem> :
|
|||||||
}
|
}
|
||||||
catch (InvalidCastException)
|
catch (InvalidCastException)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Add(item!);
|
Add(item!);
|
||||||
@@ -296,7 +297,6 @@ public partial class ObservableCollection<TItem> :
|
|||||||
Disposer.Dispose(item);
|
Disposer.Dispose(item);
|
||||||
Disposer.Remove(this, item);
|
Disposer.Remove(this, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearItems();
|
ClearItems();
|
||||||
@@ -351,7 +351,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
Disposer.Dispose(this);
|
Disposer.Dispose(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate(Func<ActivationBuilder> aggregateDelegate,
|
public void Activate(Func<ActivationBuilder> aggregateDelegate,
|
||||||
bool reset = false)
|
bool reset = false)
|
||||||
{
|
{
|
||||||
if (reset)
|
if (reset)
|
||||||
@@ -501,7 +501,6 @@ public partial class ObservableCollection<TItem> :
|
|||||||
|
|
||||||
public virtual void OnInitialize()
|
public virtual void OnInitialize()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Initialize()
|
public virtual void Initialize()
|
||||||
@@ -722,7 +721,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
CollectionChanged?.Invoke(this, args);
|
CollectionChanged?.Invoke(this, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnIsActivatedChanged(bool value)
|
private partial void OnIsActivatedChanged(bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
@@ -734,7 +733,7 @@ public partial class ObservableCollection<TItem> :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnSelectedItemChanged(TItem? oldValue, TItem? newValue)
|
private partial void OnSelectedItemChanged(TItem? oldValue, TItem? newValue)
|
||||||
{
|
{
|
||||||
if (oldValue is ISelectable oldSelection)
|
if (oldValue is ISelectable oldSelection)
|
||||||
{
|
{
|
||||||
@@ -749,10 +748,9 @@ public partial class ObservableCollection<TItem> :
|
|||||||
Publisher.Publish(Selection.As(SelectedItem));
|
Publisher.Publish(Selection.As(SelectedItem));
|
||||||
OnSelectedItemChanged();
|
OnSelectedItemChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnSelectedItemChanged()
|
protected virtual void OnSelectedItemChanged()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSelection(TItem item)
|
private void UpdateSelection(TItem item)
|
||||||
@@ -776,7 +774,7 @@ public partial class ObservableCollection<TValue, TViewModel>(IServiceProvider p
|
|||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
TValue value) : ObservableCollection<TViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
TValue value) : ObservableCollection<TViewModel>(provider, factory, mediator, publisher, subscriber, disposer)
|
||||||
where TViewModel : notnull, IDisposable
|
where TViewModel : notnull, IDisposable
|
||||||
@@ -786,25 +784,24 @@ public partial class ObservableCollection<TValue, TViewModel>(IServiceProvider p
|
|||||||
|
|
||||||
protected virtual void OnValueChanged()
|
protected virtual void OnValueChanged()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnValueChanged(TValue value) => OnValueChanged();
|
private partial void OnValueChanged(TValue value) => OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class ObservableCollection<TViewModel, TKey, TValue> :
|
public partial class ObservableCollection<TViewModel, TKey, TValue> :
|
||||||
ObservableCollection<TViewModel>
|
ObservableCollection<TViewModel>
|
||||||
where TViewModel : notnull, IDisposable
|
where TViewModel : notnull, IDisposable
|
||||||
where TKey : notnull
|
where TKey : notnull
|
||||||
{
|
{
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private TKey key;
|
private TKey key;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private TValue value;
|
private TValue value;
|
||||||
|
|
||||||
public ObservableCollection(IServiceProvider provider,
|
public ObservableCollection(IServiceProvider provider,
|
||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
@@ -820,8 +817,8 @@ public partial class ObservableCollection<TViewModel, TKey, TValue> :
|
|||||||
IServiceFactory factory,
|
IServiceFactory factory,
|
||||||
IMediator mediator,
|
IMediator mediator,
|
||||||
IPublisher publisher,
|
IPublisher publisher,
|
||||||
ISubscriber subscriber,
|
ISubscriber subscriber,
|
||||||
IDisposer disposer,
|
IDisposer disposer,
|
||||||
IEnumerable<TViewModel> items,
|
IEnumerable<TViewModel> items,
|
||||||
TKey key,
|
TKey key,
|
||||||
TValue value) : base(provider, factory, mediator, publisher, subscriber, disposer, items)
|
TValue value) : base(provider, factory, mediator, publisher, subscriber, disposer, items)
|
||||||
@@ -832,13 +829,12 @@ public partial class ObservableCollection<TViewModel, TKey, TValue> :
|
|||||||
|
|
||||||
protected virtual void OnValueChanged()
|
protected virtual void OnValueChanged()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnValueChanged(TValue value) => OnValueChanged();
|
private partial void OnValueChanged(TValue value) => OnValueChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ObservableCollection :
|
public class ObservableCollection :
|
||||||
ObservableCollection<IDisposable>
|
ObservableCollection<IDisposable>
|
||||||
{
|
{
|
||||||
public ObservableCollection(IServiceProvider provider,
|
public ObservableCollection(IServiceProvider provider,
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ public record Open
|
|||||||
public static OpenEventArgs<TSender> As<TSender>(TSender sender) => new(sender);
|
public static OpenEventArgs<TSender> As<TSender>(TSender sender) => new(sender);
|
||||||
|
|
||||||
public static OpenEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender());
|
public static OpenEventArgs<TSender> As<TSender>() where TSender : new() => new(new TSender());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record OpenEventArgs<TSender>(TSender? Sender = default);
|
public record OpenEventArgs<TSender>(TSender? Sender = default);
|
||||||
@@ -7,4 +7,4 @@ public class Read
|
|||||||
|
|
||||||
public static ReadEventArgs<TSender> As<TSender>() where TSender : new() =>
|
public static ReadEventArgs<TSender> As<TSender>() where TSender : new() =>
|
||||||
new(new TSender());
|
new(new TSender());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ReadEventArgs<TSender>(TSender? Sender = default);
|
public record ReadEventArgs<TSender>(TSender? Sender = default);
|
||||||
@@ -19,6 +19,7 @@ public static class TupleExtensions
|
|||||||
(T3)Convert.ChangeType(parameters[2], typeof(T3)),
|
(T3)Convert.ChangeType(parameters[2], typeof(T3)),
|
||||||
(T4)Convert.ChangeType(parameters[3], typeof(T4))
|
(T4)Convert.ChangeType(parameters[3], typeof(T4))
|
||||||
);
|
);
|
||||||
|
|
||||||
public static (T1, T2, T3, T4, T5) CreateValueTuple<T1, T2, T3, T4, T5>(this object[] parameters) => (
|
public static (T1, T2, T3, T4, T5) CreateValueTuple<T1, T2, T3, T4, T5>(this object[] parameters) => (
|
||||||
(T1)Convert.ChangeType(parameters[0], typeof(T1)),
|
(T1)Convert.ChangeType(parameters[0], typeof(T1)),
|
||||||
(T2)Convert.ChangeType(parameters[1], typeof(T2)),
|
(T2)Convert.ChangeType(parameters[1], typeof(T2)),
|
||||||
@@ -56,4 +57,4 @@ public static class TupleExtensions
|
|||||||
(T7)Convert.ChangeType(parameters[6], typeof(T7)),
|
(T7)Convert.ChangeType(parameters[6], typeof(T7)),
|
||||||
(T8)Convert.ChangeType(parameters[7], typeof(T8))
|
(T8)Convert.ChangeType(parameters[7], typeof(T8))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -9,15 +9,16 @@ public class Validation(IValidatorCollection validators) :
|
|||||||
private readonly ValidationErrorCollection errors = [];
|
private readonly ValidationErrorCollection errors = [];
|
||||||
|
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
public IReadOnlyDictionary<string, string> Errors =>
|
|
||||||
|
public IReadOnlyDictionary<string, string> Errors =>
|
||||||
errors.AsReadOnly();
|
errors.AsReadOnly();
|
||||||
|
|
||||||
public bool HasErrors =>
|
public bool HasErrors =>
|
||||||
Errors.Count > 0;
|
Errors.Count > 0;
|
||||||
|
|
||||||
internal IValidatorCollection Validators { get; } = validators;
|
internal IValidatorCollection Validators { get; } = validators;
|
||||||
|
|
||||||
public void Add<TProperty>(Expression<Func<TProperty>> property,
|
public void Add<TProperty>(Expression<Func<TProperty>> property,
|
||||||
ValidationRule[] rules,
|
ValidationRule[] rules,
|
||||||
ValidationTrigger trigger = ValidationTrigger.Deferred)
|
ValidationTrigger trigger = ValidationTrigger.Deferred)
|
||||||
{
|
{
|
||||||
@@ -36,8 +37,7 @@ public class Validation(IValidatorCollection validators) :
|
|||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> Validate<TProperty>(Expression<Func<TProperty>> property,
|
||||||
public async Task<bool> Validate<TProperty>(Expression<Func<TProperty>> property,
|
|
||||||
ValidationRule[] rules)
|
ValidationRule[] rules)
|
||||||
{
|
{
|
||||||
string? name = GetPropertyName(property);
|
string? name = GetPropertyName(property);
|
||||||
@@ -109,11 +109,13 @@ public class Validation(IValidatorCollection validators) :
|
|||||||
OnPropertyChanged(nameof(Errors), null, null);
|
OnPropertyChanged(nameof(Errors), null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Clear()
|
private void Clear()
|
||||||
{
|
{
|
||||||
errors.Clear();
|
errors.Clear();
|
||||||
OnPropertyChanged(nameof(Errors), null, null);
|
OnPropertyChanged(nameof(Errors), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetPropertyName<T>(Expression<Func<T>> expression)
|
private string GetPropertyName<T>(Expression<Func<T>> expression)
|
||||||
{
|
{
|
||||||
return expression.Body switch
|
return expression.Body switch
|
||||||
@@ -123,4 +125,4 @@ public class Validation(IValidatorCollection validators) :
|
|||||||
_ => string.Empty
|
_ => string.Empty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using System.Collections.Specialized;
|
using System.Collections;
|
||||||
using System.Collections;
|
using System.Collections.Specialized;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
@@ -61,10 +61,10 @@ public class ValidationErrorCollection :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object? IDictionary.this[object key]
|
object? IDictionary.this[object key]
|
||||||
{
|
{
|
||||||
get => ((IDictionary)items)[key];
|
get => ((IDictionary)items)[key];
|
||||||
set => ((IDictionary)items)[key] = value;
|
set => ((IDictionary)items)[key] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(string key, string value)
|
public void Add(string key, string value)
|
||||||
@@ -73,7 +73,7 @@ public class ValidationErrorCollection :
|
|||||||
NotifyAdd(key, value);
|
NotifyAdd(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICollection<KeyValuePair<string, string>>.Add(KeyValuePair<string, string> item) =>
|
void ICollection<KeyValuePair<string, string>>.Add(KeyValuePair<string, string> item) =>
|
||||||
Add(item.Key, item.Value);
|
Add(item.Key, item.Value);
|
||||||
|
|
||||||
void IDictionary.Add(object key, object? value) =>
|
void IDictionary.Add(object key, object? value) =>
|
||||||
@@ -93,24 +93,24 @@ public class ValidationErrorCollection :
|
|||||||
bool ICollection<KeyValuePair<string, string>>.Contains(KeyValuePair<string, string> item) =>
|
bool ICollection<KeyValuePair<string, string>>.Contains(KeyValuePair<string, string> item) =>
|
||||||
items.Contains(item);
|
items.Contains(item);
|
||||||
|
|
||||||
bool IDictionary.Contains(object key) =>
|
bool IDictionary.Contains(object key) =>
|
||||||
((IDictionary)items).Contains(key);
|
((IDictionary)items).Contains(key);
|
||||||
|
|
||||||
public bool ContainsKey(string key) => items.ContainsKey(key);
|
public bool ContainsKey(string key) => items.ContainsKey(key);
|
||||||
|
|
||||||
public void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex) =>
|
public void CopyTo(KeyValuePair<string, string>[] array, int arrayIndex) =>
|
||||||
((IDictionary<string, string>)items).CopyTo(array, arrayIndex);
|
((IDictionary<string, string>)items).CopyTo(array, arrayIndex);
|
||||||
|
|
||||||
void ICollection.CopyTo(Array array, int index) =>
|
void ICollection.CopyTo(Array array, int index) =>
|
||||||
((ICollection)items).CopyTo(array, index);
|
((ICollection)items).CopyTo(array, index);
|
||||||
|
|
||||||
public IEnumerator<KeyValuePair<string, string>> GetEnumerator() =>
|
public IEnumerator<KeyValuePair<string, string>> GetEnumerator() =>
|
||||||
items.GetEnumerator();
|
items.GetEnumerator();
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() =>
|
IEnumerator IEnumerable.GetEnumerator() =>
|
||||||
items.GetEnumerator();
|
items.GetEnumerator();
|
||||||
|
|
||||||
IDictionaryEnumerator IDictionary.GetEnumerator() =>
|
IDictionaryEnumerator IDictionary.GetEnumerator() =>
|
||||||
((IDictionary)items).GetEnumerator();
|
((IDictionary)items).GetEnumerator();
|
||||||
|
|
||||||
public bool Remove(string key)
|
public bool Remove(string key)
|
||||||
@@ -131,10 +131,10 @@ public class ValidationErrorCollection :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(string key) =>
|
public bool Contains(string key) =>
|
||||||
items.ContainsKey(key);
|
items.ContainsKey(key);
|
||||||
|
|
||||||
bool ICollection<KeyValuePair<string, string>>.Remove(KeyValuePair<string, string> item) =>
|
bool ICollection<KeyValuePair<string, string>>.Remove(KeyValuePair<string, string> item) =>
|
||||||
Remove(item.Key);
|
Remove(item.Key);
|
||||||
|
|
||||||
void IDictionary.Remove(object key) => Remove((string)key);
|
void IDictionary.Remove(object key) => Remove((string)key);
|
||||||
@@ -146,7 +146,7 @@ public class ValidationErrorCollection :
|
|||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count)));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count)));
|
||||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]"));
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs($"Item[{key}]"));
|
||||||
|
|
||||||
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
|
CollectionChanged?.Invoke(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add,
|
||||||
new[] { new KeyValuePair<string, string>(key, value) }, -1));
|
new[] { new KeyValuePair<string, string>(key, value) }, -1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ public class ValidationRule
|
|||||||
private readonly Func<bool>? syncValidation;
|
private readonly Func<bool>? syncValidation;
|
||||||
private readonly Func<Task<bool>>? asyncValidation;
|
private readonly Func<Task<bool>>? asyncValidation;
|
||||||
|
|
||||||
public ValidationRule(Func<bool> validation,
|
public ValidationRule(Func<bool> validation,
|
||||||
string message)
|
string message)
|
||||||
{
|
{
|
||||||
syncValidation = validation;
|
syncValidation = validation;
|
||||||
@@ -47,4 +47,4 @@ public class ValidationRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Message { get; }
|
public string Message { get; }
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,4 @@ public enum ValidationTrigger
|
|||||||
{
|
{
|
||||||
Deferred,
|
Deferred,
|
||||||
Immediate
|
Immediate
|
||||||
}
|
}
|
||||||
@@ -19,4 +19,4 @@ public class Validator(string propertyName,
|
|||||||
|
|
||||||
return (true, null);
|
return (true, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Collections;
|
||||||
using System.Collections;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
@@ -10,15 +10,15 @@ public class ValidatorCollection :
|
|||||||
|
|
||||||
public int Count => binders.Count;
|
public int Count => binders.Count;
|
||||||
|
|
||||||
public void Add(string key, Validator binder) =>
|
public void Add(string key, Validator binder) =>
|
||||||
binders.Add(key, binder);
|
binders.Add(key, binder);
|
||||||
|
|
||||||
public IEnumerator<Validator> GetEnumerator() =>
|
public IEnumerator<Validator> GetEnumerator() =>
|
||||||
binders.Select(x => x.Value).GetEnumerator();
|
binders.Select(x => x.Value).GetEnumerator();
|
||||||
|
|
||||||
public bool TryGet(string key, [MaybeNull] out Validator? value) =>
|
public bool TryGet(string key, [MaybeNull] out Validator? value) =>
|
||||||
binders.TryGetValue(key, out value);
|
binders.TryGetValue(key, out value);
|
||||||
|
|
||||||
IEnumerator IEnumerable.GetEnumerator() =>
|
IEnumerator IEnumerable.GetEnumerator() =>
|
||||||
binders.Select(x => x.Value).GetEnumerator();
|
binders.Select(x => x.Value).GetEnumerator();
|
||||||
}
|
}
|
||||||
@@ -17,5 +17,5 @@ public partial class ValueViewModel<TValue>(IServiceProvider provider,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnValueChanged(TValue? value) => OnChanged(value);
|
private partial void OnValueChanged(TValue? value) => OnChanged(value);
|
||||||
}
|
}
|
||||||
@@ -10,4 +10,4 @@ public class WriteClipboardHandler(IClipboardWriter clipboardWriter) :
|
|||||||
await clipboardWriter.Write(clipboard.Value);
|
await clipboardWriter.Write(clipboard.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Toolkit.UI.Avalonia;
|
namespace Toolkit.UI.Avalonia;
|
||||||
|
|
||||||
public class AttachedBehaviour :
|
public class AttachedBehaviour :
|
||||||
Trigger
|
Trigger
|
||||||
{
|
{
|
||||||
protected override void OnAttachedToVisualTree()
|
protected override void OnAttachedToVisualTree()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class BooleanToPasswordCharConverter :
|
|||||||
MarkupExtension,
|
MarkupExtension,
|
||||||
IValueConverter
|
IValueConverter
|
||||||
{
|
{
|
||||||
public override object ProvideValue(IServiceProvider serviceProvider) =>
|
public override object ProvideValue(IServiceProvider serviceProvider) =>
|
||||||
this;
|
this;
|
||||||
|
|
||||||
public char PasswordChar { get; set; }
|
public char PasswordChar { get; set; }
|
||||||
@@ -16,6 +16,6 @@ public class BooleanToPasswordCharConverter :
|
|||||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||||
value is bool boolValue ? boolValue ? '\0' : PasswordChar : (object)PasswordChar;
|
value is bool boolValue ? boolValue ? '\0' : PasswordChar : (object)PasswordChar;
|
||||||
|
|
||||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ namespace Toolkit.UI.Avalonia;
|
|||||||
public class ConditionCollection :
|
public class ConditionCollection :
|
||||||
ObservableCollection<ComparisonCondition>
|
ObservableCollection<ComparisonCondition>
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using Avalonia.Metadata;
|
using Avalonia.Metadata;
|
||||||
|
|
||||||
namespace Toolkit.UI.Avalonia;
|
namespace Toolkit.UI.Avalonia;
|
||||||
|
|
||||||
public class ConditionalExpression :
|
public class ConditionalExpression :
|
||||||
AvaloniaObject,
|
AvaloniaObject,
|
||||||
ICondition
|
ICondition
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public class InvokeNavigationViewItemAction :
|
|||||||
AvaloniaObject,
|
AvaloniaObject,
|
||||||
IAction
|
IAction
|
||||||
{
|
{
|
||||||
|
private int currentIndex;
|
||||||
|
|
||||||
public static readonly StyledProperty<int> SelectedIndexProperty =
|
public static readonly StyledProperty<int> SelectedIndexProperty =
|
||||||
AvaloniaProperty.Register<InvokeNavigationViewItemAction, int>(nameof(SelectedIndex), 0);
|
AvaloniaProperty.Register<InvokeNavigationViewItemAction, int>(nameof(SelectedIndex), 0);
|
||||||
|
|
||||||
@@ -30,6 +32,11 @@ public class InvokeNavigationViewItemAction :
|
|||||||
|
|
||||||
public object? Execute(object? sender, object? parameter)
|
public object? Execute(object? sender, object? parameter)
|
||||||
{
|
{
|
||||||
|
//if (SelectedIndex == currentIndex)
|
||||||
|
//{
|
||||||
|
// return false;
|
||||||
|
//}
|
||||||
|
|
||||||
if ((Target ?? sender) is NavigationViewItem navigationViewItem)
|
if ((Target ?? sender) is NavigationViewItem navigationViewItem)
|
||||||
{
|
{
|
||||||
Dispatcher.UIThread.Post(() =>
|
Dispatcher.UIThread.Post(() =>
|
||||||
@@ -53,6 +60,7 @@ public class InvokeNavigationViewItemAction :
|
|||||||
if (collection is { Count: > 0 })
|
if (collection is { Count: > 0 })
|
||||||
{
|
{
|
||||||
navigationView.SetValue(NavigationView.SelectedItemProperty, collection[SelectedIndex]);
|
navigationView.SetValue(NavigationView.SelectedItemProperty, collection[SelectedIndex]);
|
||||||
|
currentIndex = SelectedIndex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -64,5 +72,4 @@ public class InvokeNavigationViewItemAction :
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,8 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Toolkit.UI.Avalonia;
|
namespace Toolkit.UI.Avalonia;
|
||||||
|
|
||||||
public class NamedTypeConverter :
|
public class NamedTypeConverter :
|
||||||
MarkupExtension,
|
MarkupExtension,
|
||||||
IValueConverter
|
IValueConverter
|
||||||
{
|
{
|
||||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||||
@@ -20,4 +20,4 @@ public class NamedTypeConverter :
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override object ProvideValue(IServiceProvider serviceProvider) => this;
|
public override object ProvideValue(IServiceProvider serviceProvider) => this;
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,6 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Xaml.Interactivity;
|
using Avalonia.Xaml.Interactivity;
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
using Toolkit.UI.Controls.Avalonia;
|
|
||||||
|
|
||||||
namespace Toolkit.UI.Avalonia;
|
namespace Toolkit.UI.Avalonia;
|
||||||
|
|
||||||
|
|||||||
@@ -65,4 +65,4 @@ public class NavigationViewExtension
|
|||||||
|
|
||||||
public static void RemoveItemInvokedHandler(NavigationViewItem element, EventHandler<ItemInvokedEventArgs> handler) =>
|
public static void RemoveItemInvokedHandler(NavigationViewItem element, EventHandler<ItemInvokedEventArgs> handler) =>
|
||||||
element.RemoveHandler(ItemInvokedEvent, handler);
|
element.RemoveHandler(ItemInvokedEvent, handler);
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,8 @@ using Avalonia.Media;
|
|||||||
using Path = Avalonia.Controls.Shapes.Path;
|
using Path = Avalonia.Controls.Shapes.Path;
|
||||||
|
|
||||||
namespace Toolkit.UI.Controls.Avalonia;
|
namespace Toolkit.UI.Controls.Avalonia;
|
||||||
public class ContentBadge :
|
|
||||||
|
public class ContentBadge :
|
||||||
ContentControl
|
ContentControl
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<string> BadgePathProperty =
|
public static readonly StyledProperty<string> BadgePathProperty =
|
||||||
@@ -95,14 +96,17 @@ public class ContentBadge :
|
|||||||
offsetX = 0;
|
offsetX = 0;
|
||||||
offsetY = 0;
|
offsetY = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentBadgePlacement.TopRight:
|
case ContentBadgePlacement.TopRight:
|
||||||
offsetX = backgroundWidth - scaledWidth;
|
offsetX = backgroundWidth - scaledWidth;
|
||||||
offsetY = 0;
|
offsetY = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentBadgePlacement.BottomLeft:
|
case ContentBadgePlacement.BottomLeft:
|
||||||
offsetX = 0;
|
offsetX = 0;
|
||||||
offsetY = backgroundHeight - scaledHeight;
|
offsetY = backgroundHeight - scaledHeight;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ContentBadgePlacement.BottomRight:
|
case ContentBadgePlacement.BottomRight:
|
||||||
offsetX = backgroundWidth - scaledWidth;
|
offsetX = backgroundWidth - scaledWidth;
|
||||||
offsetY = backgroundHeight - scaledHeight;
|
offsetY = backgroundHeight - scaledHeight;
|
||||||
@@ -154,5 +158,4 @@ public class ContentBadge :
|
|||||||
base.OnSizeChanged(args);
|
base.OnSizeChanged(args);
|
||||||
UpdateBadge();
|
UpdateBadge();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,5 +6,4 @@ public enum ContentBadgePlacement
|
|||||||
TopRight,
|
TopRight,
|
||||||
BottomLeft,
|
BottomLeft,
|
||||||
BottomRight
|
BottomRight
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5,4 +5,4 @@ public class NavigationViewItem :
|
|||||||
{
|
{
|
||||||
protected override Type StyleKeyOverride =>
|
protected override Type StyleKeyOverride =>
|
||||||
typeof(FluentAvalonia.UI.Controls.NavigationViewItem);
|
typeof(FluentAvalonia.UI.Controls.NavigationViewItem);
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ public class NavigationViewItemSeparator :
|
|||||||
{
|
{
|
||||||
protected override Type StyleKeyOverride =>
|
protected override Type StyleKeyOverride =>
|
||||||
typeof(FluentAvalonia.UI.Controls.NavigationViewItemSeparator);
|
typeof(FluentAvalonia.UI.Controls.NavigationViewItemSeparator);
|
||||||
}
|
}
|
||||||
@@ -75,15 +75,14 @@
|
|||||||
BadgePath="{TemplateBinding BadgePath}"
|
BadgePath="{TemplateBinding BadgePath}"
|
||||||
BadgePlacement="{TemplateBinding BadgePlacement}"
|
BadgePlacement="{TemplateBinding BadgePlacement}"
|
||||||
BadgeSize="{TemplateBinding BadgeSize}"
|
BadgeSize="{TemplateBinding BadgeSize}"
|
||||||
Foreground="Red"
|
Foreground="{TemplateBinding BadgeBrush}"
|
||||||
IsBadgeVisible="{TemplateBinding IsBadgeVisible}">
|
IsBadgeVisible="{TemplateBinding IsBadgeVisible}">
|
||||||
<Grid>
|
<Grid>
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Name="PART_ContentPresenter"
|
Name="PART_ContentPresenter"
|
||||||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
Content="{TemplateBinding Content}"
|
Content="{TemplateBinding Content}" />
|
||||||
/>
|
|
||||||
<Border
|
<Border
|
||||||
Name="SelectionIndicator"
|
Name="SelectionIndicator"
|
||||||
BorderBrush="{DynamicResource AccentFillColorDefaultBrush}"
|
BorderBrush="{DynamicResource AccentFillColorDefaultBrush}"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using System.Collections.Specialized;
|
|||||||
|
|
||||||
namespace Toolkit.UI.Controls.Avalonia;
|
namespace Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
public class Overflow :
|
public class Overflow :
|
||||||
TemplatedControl
|
TemplatedControl
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<ITemplate<Panel?>> ItemsPanelProperty =
|
public static readonly StyledProperty<ITemplate<Panel?>> ItemsPanelProperty =
|
||||||
@@ -29,7 +29,6 @@ public class Overflow :
|
|||||||
private static readonly StyledProperty<OverflowTemplateSettings> TemplateSettingsProperty =
|
private static readonly StyledProperty<OverflowTemplateSettings> TemplateSettingsProperty =
|
||||||
AvaloniaProperty.Register<Overflow, OverflowTemplateSettings>(nameof(TemplateSettings));
|
AvaloniaProperty.Register<Overflow, OverflowTemplateSettings>(nameof(TemplateSettings));
|
||||||
|
|
||||||
|
|
||||||
private readonly ObservableCollection<object> primaryCollection = [];
|
private readonly ObservableCollection<object> primaryCollection = [];
|
||||||
|
|
||||||
private readonly ObservableCollection<object> secondaryCollection = [];
|
private readonly ObservableCollection<object> secondaryCollection = [];
|
||||||
@@ -60,6 +59,7 @@ public class Overflow :
|
|||||||
get => GetValue(ItemsSourceProperty);
|
get => GetValue(ItemsSourceProperty);
|
||||||
set => SetValue(ItemsSourceProperty, value);
|
set => SetValue(ItemsSourceProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[InheritDataTypeFromItems(nameof(ItemsSource))]
|
[InheritDataTypeFromItems(nameof(ItemsSource))]
|
||||||
public IDataTemplate? ItemTemplate
|
public IDataTemplate? ItemTemplate
|
||||||
{
|
{
|
||||||
@@ -146,6 +146,7 @@ public class Overflow :
|
|||||||
object? selection = args.GetNewValue<object>();
|
object? selection = args.GetNewValue<object>();
|
||||||
SetValue(SelectedItemProperty, selection);
|
SetValue(SelectedItemProperty, selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSourceCollectionChanged(object? sender,
|
private void OnSourceCollectionChanged(object? sender,
|
||||||
NotifyCollectionChangedEventArgs args)
|
NotifyCollectionChangedEventArgs args)
|
||||||
{
|
{
|
||||||
@@ -306,5 +307,4 @@ public class Overflow :
|
|||||||
TemplateSettings.SetValue(OverflowTemplateSettings.SecondarySelectionProperty, null);
|
TemplateSettings.SetValue(OverflowTemplateSettings.SecondarySelectionProperty, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media;
|
||||||
|
|
||||||
namespace Toolkit.UI.Controls.Avalonia;
|
namespace Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
public class OverflowItem :
|
public class OverflowItem :
|
||||||
ListBoxItem
|
ListBoxItem
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<double> BadgeSizeProperty =
|
public static readonly StyledProperty<IBrush> BadgeBrushProperty =
|
||||||
AvaloniaProperty.Register<OverflowItem, double>(nameof(BadgeSize), 14);
|
AvaloniaProperty.Register<OverflowItem, IBrush>(nameof(BadgeBrush));
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> IsBadgeVisibleProperty =
|
|
||||||
AvaloniaProperty.Register<OverflowItem, bool>(nameof(IsBadgeVisible), true);
|
|
||||||
|
|
||||||
public static readonly StyledProperty<string> BadgePathProperty =
|
public static readonly StyledProperty<string> BadgePathProperty =
|
||||||
AvaloniaProperty.Register<OverflowItem, string>(nameof(BadgePath));
|
AvaloniaProperty.Register<OverflowItem, string>(nameof(BadgePath));
|
||||||
@@ -18,6 +16,18 @@ public class OverflowItem :
|
|||||||
public static readonly StyledProperty<ContentBadgePlacement> BadgePlacementProperty =
|
public static readonly StyledProperty<ContentBadgePlacement> BadgePlacementProperty =
|
||||||
AvaloniaProperty.Register<OverflowItem, ContentBadgePlacement>(nameof(BadgePlacement), ContentBadgePlacement.BottomRight);
|
AvaloniaProperty.Register<OverflowItem, ContentBadgePlacement>(nameof(BadgePlacement), ContentBadgePlacement.BottomRight);
|
||||||
|
|
||||||
|
public static readonly StyledProperty<double> BadgeSizeProperty =
|
||||||
|
AvaloniaProperty.Register<OverflowItem, double>(nameof(BadgeSize), 14);
|
||||||
|
|
||||||
|
public static readonly StyledProperty<bool> IsBadgeVisibleProperty =
|
||||||
|
AvaloniaProperty.Register<OverflowItem, bool>(nameof(IsBadgeVisible), true);
|
||||||
|
|
||||||
|
public IBrush BadgeBrush
|
||||||
|
{
|
||||||
|
get => GetValue(BadgeBrushProperty);
|
||||||
|
set => SetValue(BadgeBrushProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
public string BadgePath
|
public string BadgePath
|
||||||
{
|
{
|
||||||
get => GetValue(BadgePathProperty);
|
get => GetValue(BadgePathProperty);
|
||||||
@@ -41,5 +51,4 @@ public class OverflowItem :
|
|||||||
get => GetValue(IsBadgeVisibleProperty);
|
get => GetValue(IsBadgeVisibleProperty);
|
||||||
set => SetValue(IsBadgeVisibleProperty, value);
|
set => SetValue(IsBadgeVisibleProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,5 +45,4 @@ public class OverflowTemplateSettings :
|
|||||||
get => GetValue(SecondarySelectionProperty);
|
get => GetValue(SecondarySelectionProperty);
|
||||||
set => SetValue(SecondarySelectionProperty, value);
|
set => SetValue(SecondarySelectionProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,5 +39,4 @@ public class TemplateListBox :
|
|||||||
recycleKey = DefaultRecycleKey;
|
recycleKey = DefaultRecycleKey;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7,7 +7,6 @@ using Avalonia.Media.Imaging;
|
|||||||
|
|
||||||
namespace Toolkit.UI.Controls.Avalonia;
|
namespace Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
|
|
||||||
public class PersonPicture : TemplatedControl
|
public class PersonPicture : TemplatedControl
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<string> BadgeGlyphProperty =
|
public static readonly StyledProperty<string> BadgeGlyphProperty =
|
||||||
|
|||||||
@@ -8,15 +8,56 @@ public class PersonPictureColourGenerator
|
|||||||
{
|
{
|
||||||
private readonly string[] colours =
|
private readonly string[] colours =
|
||||||
[
|
[
|
||||||
"#FFB900", "#FF8C00", "#F7630C", "#CA5010", "#DA3B01", "#EF6950", "#D13438", "#FF4343",
|
"#FFB900",
|
||||||
"#E74856", "#E81123", "#EA005E", "#C30052", "#E3008C", "#BF0077", "#C239B3", "#9A0089",
|
"#FF8C00",
|
||||||
"#0078D7", "#0063B1", "#8E8CD8", "#6B69D6", "#8764B8", "#744DA9", "#B146C2", "#881798",
|
"#F7630C",
|
||||||
"#0099BC", "#2D7D9A", "#00B7C3", "#038387", "#00B294", "#018574", "#00CC6A", "#10893E",
|
"#CA5010",
|
||||||
"#7A7574", "#5D5A58", "#68768A", "#515C6B", "#567C73", "#486860", "#498205", "#107C10",
|
"#DA3B01",
|
||||||
"#767676", "#4C4A48", "#69797E", "#4A5459", "#647C64", "#525E54", "#847545", "#7E735F"
|
"#EF6950",
|
||||||
|
"#D13438",
|
||||||
|
"#FF4343",
|
||||||
|
"#E74856",
|
||||||
|
"#E81123",
|
||||||
|
"#EA005E",
|
||||||
|
"#C30052",
|
||||||
|
"#E3008C",
|
||||||
|
"#BF0077",
|
||||||
|
"#C239B3",
|
||||||
|
"#9A0089",
|
||||||
|
"#0078D7",
|
||||||
|
"#0063B1",
|
||||||
|
"#8E8CD8",
|
||||||
|
"#6B69D6",
|
||||||
|
"#8764B8",
|
||||||
|
"#744DA9",
|
||||||
|
"#B146C2",
|
||||||
|
"#881798",
|
||||||
|
"#0099BC",
|
||||||
|
"#2D7D9A",
|
||||||
|
"#00B7C3",
|
||||||
|
"#038387",
|
||||||
|
"#00B294",
|
||||||
|
"#018574",
|
||||||
|
"#00CC6A",
|
||||||
|
"#10893E",
|
||||||
|
"#7A7574",
|
||||||
|
"#5D5A58",
|
||||||
|
"#68768A",
|
||||||
|
"#515C6B",
|
||||||
|
"#567C73",
|
||||||
|
"#486860",
|
||||||
|
"#498205",
|
||||||
|
"#107C10",
|
||||||
|
"#767676",
|
||||||
|
"#4C4A48",
|
||||||
|
"#69797E",
|
||||||
|
"#4A5459",
|
||||||
|
"#647C64",
|
||||||
|
"#525E54",
|
||||||
|
"#847545",
|
||||||
|
"#7E735F"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public Color GenerateColour(string input)
|
public Color GenerateColour(string input)
|
||||||
{
|
{
|
||||||
byte[] hashBytes = GetHash(input);
|
byte[] hashBytes = GetHash(input);
|
||||||
@@ -42,4 +83,4 @@ public class PersonPictureColourGenerator
|
|||||||
|
|
||||||
return Color.FromArgb(a, r, g, b);
|
return Color.FromArgb(a, r, g, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,7 +33,6 @@ public class SettingsExpander :
|
|||||||
set => SetValue(IsToggleableProperty, value);
|
set => SetValue(IsToggleableProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected override Type StyleKeyOverride =>
|
protected override Type StyleKeyOverride =>
|
||||||
typeof(SettingsExpander);
|
typeof(SettingsExpander);
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@ using Avalonia.Input;
|
|||||||
|
|
||||||
namespace Toolkit.UI.Controls.Avalonia;
|
namespace Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
public class SettingsExpanderToggleButton :
|
public class SettingsExpanderToggleButton :
|
||||||
ToggleButton
|
ToggleButton
|
||||||
{
|
{
|
||||||
public static readonly StyledProperty<bool> IsToggleableProperty =
|
public static readonly StyledProperty<bool> IsToggleableProperty =
|
||||||
|
|||||||
Reference in New Issue
Block a user