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