Codemaid
This commit is contained in:
@@ -2,7 +2,6 @@
|
|||||||
using Avalonia.Controls.Primitives;
|
using Avalonia.Controls.Primitives;
|
||||||
using FluentAvalonia.UI.Media.Animation;
|
using FluentAvalonia.UI.Media.Animation;
|
||||||
using FluentAvalonia.UI.Navigation;
|
using FluentAvalonia.UI.Navigation;
|
||||||
using System.Reflection;
|
|
||||||
using Toolkit.Foundation;
|
using Toolkit.Foundation;
|
||||||
using Toolkit.UI.Controls.Avalonia;
|
using Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Toolkit.Avalonia;
|
|||||||
public class NavigationRegion(INavigationRegionCollection collection) :
|
public class NavigationRegion(INavigationRegionCollection collection) :
|
||||||
INavigationRegion
|
INavigationRegion
|
||||||
{
|
{
|
||||||
public void Register(string name,
|
public void Register(string name,
|
||||||
object target)
|
object target)
|
||||||
{
|
{
|
||||||
if (target is Control control)
|
if (target is Control control)
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ public record Activate
|
|||||||
public static ActivateEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
public static ActivateEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||||
|
|
||||||
public static ActivateEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
public static ActivateEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ActivateEventArgs<TValue>(TValue? Value = default);
|
public record ActivateEventArgs<TValue>(TValue? Value = default);
|
||||||
@@ -5,4 +5,4 @@ public record Activated
|
|||||||
public static ActivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
public static ActivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||||
|
|
||||||
public static ActivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
public static ActivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ActivatedEventArgs<TValue>(TValue? Value = default);
|
public record ActivatedEventArgs<TValue>(TValue? Value = default);
|
||||||
@@ -8,7 +8,7 @@ public class AesDecryptor :
|
|||||||
private const int IvSize = 16;
|
private const int IvSize = 16;
|
||||||
|
|
||||||
public bool TryDecrypt(byte[] cipher,
|
public bool TryDecrypt(byte[] cipher,
|
||||||
byte[] key,
|
byte[] key,
|
||||||
out byte[]? decryptedData)
|
out byte[]? decryptedData)
|
||||||
{
|
{
|
||||||
decryptedData = null;
|
decryptedData = null;
|
||||||
@@ -47,4 +47,4 @@ public class AesDecryptor :
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public class AesEncryptor :
|
public class AesEncryptor :
|
||||||
IEncryptor
|
IEncryptor
|
||||||
{
|
{
|
||||||
private const int IvSize = 16;
|
private const int IvSize = 16;
|
||||||
|
|
||||||
public bool TryEncrypt(byte[] data,
|
public bool TryEncrypt(byte[] data,
|
||||||
byte[] key,
|
byte[] key,
|
||||||
out byte[]? encryptedData)
|
out byte[]? encryptedData)
|
||||||
{
|
{
|
||||||
@@ -46,4 +46,4 @@ public class AesEncryptor :
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,4 @@ public enum AggerateMode
|
|||||||
{
|
{
|
||||||
Append,
|
Append,
|
||||||
Reset
|
Reset
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,7 @@ public class Cache<TKey, TValue>(IComparer<TKey> comparer) :
|
|||||||
notnull
|
notnull
|
||||||
{
|
{
|
||||||
private readonly List<KeyValuePair<TKey, TValue?>> items = [];
|
private readonly List<KeyValuePair<TKey, TValue?>> items = [];
|
||||||
|
|
||||||
public TValue? this[TKey key]
|
public TValue? this[TKey key]
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -108,6 +109,7 @@ public class Cache<TKey, TValue>(IComparer<TKey> comparer) :
|
|||||||
|
|
||||||
items.Insert(index, new KeyValuePair<TKey, TValue?>(key, value));
|
items.Insert(index, new KeyValuePair<TKey, TValue?>(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear() => items.Clear();
|
public void Clear() => items.Clear();
|
||||||
|
|
||||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() =>
|
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() =>
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ public record Cancel
|
|||||||
|
|
||||||
public static CancelEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static CancelEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record CancelEventArgs<TValue>(TValue Value);
|
public record CancelEventArgs<TValue>(TValue Value);
|
||||||
@@ -5,4 +5,4 @@ public record Changed
|
|||||||
public static ChangedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
public static ChangedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||||
|
|
||||||
public static ChangedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
public static ChangedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ChangedEventArgs<TValue>(TValue? Value = default);
|
public record ChangedEventArgs<TValue>(TValue? Value = default);
|
||||||
@@ -13,7 +13,7 @@ public class Component :
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static TComponent? Create<TComponent>(IServiceProvider provider,
|
public static TComponent? Create<TComponent>(IServiceProvider provider,
|
||||||
Action<IComponentBuilder> builderDelegate)
|
Action<IComponentBuilder> builderDelegate)
|
||||||
where TComponent : class, IComponent
|
where TComponent : class, IComponent
|
||||||
{
|
{
|
||||||
if (provider.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
if (provider.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||||
@@ -23,7 +23,7 @@ public class Component :
|
|||||||
|
|
||||||
return factory.Create<TComponent>(builder);
|
return factory.Create<TComponent>(builder);
|
||||||
}
|
}
|
||||||
return default ;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IComponentBuilder Create() => builder;
|
public virtual IComponentBuilder Create() => builder;
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ namespace Toolkit.Foundation;
|
|||||||
|
|
||||||
public class ComponentFactory(IServiceProvider provider,
|
public class ComponentFactory(IServiceProvider provider,
|
||||||
IProxyServiceCollection<IComponentBuilder> proxy,
|
IProxyServiceCollection<IComponentBuilder> proxy,
|
||||||
IComponentScopeCollection scopes) :
|
IComponentScopeCollection scopes) :
|
||||||
IComponentFactory
|
IComponentFactory
|
||||||
{
|
{
|
||||||
public IComponentHost? Create<TComponent, TConfiguration>(string name,
|
public IComponentHost? Create<TComponent, TConfiguration>(string name,
|
||||||
TConfiguration configuration,
|
TConfiguration configuration,
|
||||||
Action<IServiceCollection>? servicesDelegate = null)
|
Action<IServiceCollection>? servicesDelegate = null)
|
||||||
where TComponent : IComponent
|
where TComponent : IComponent
|
||||||
where TConfiguration : ComponentConfiguration, new()
|
where TConfiguration : ComponentConfiguration, new()
|
||||||
@@ -56,4 +56,4 @@ public class ComponentFactory(IServiceProvider provider,
|
|||||||
|
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,14 +10,13 @@ public class ComponentHost(IServiceProvider services,
|
|||||||
{
|
{
|
||||||
public IServiceProvider Services => services;
|
public IServiceProvider Services => services;
|
||||||
|
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public TConfiguration? GetConfiguration<TConfiguration>() where TConfiguration : ComponentConfiguration
|
public TConfiguration? GetConfiguration<TConfiguration>() where TConfiguration : ComponentConfiguration
|
||||||
{
|
{
|
||||||
return Services.GetService<TConfiguration>();
|
return Services.GetService<TConfiguration>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartAsync(CancellationToken cancellationToken = default)
|
public async Task StartAsync(CancellationToken cancellationToken = default)
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ConfirmEventArgs<TValue>(TValue Value);
|
public record ConfirmEventArgs<TValue>(TValue Value);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record CreateEventArgs<TValue>(TValue Value);
|
public record CreateEventArgs<TValue>(TValue Value);
|
||||||
@@ -7,4 +7,4 @@ public record Created
|
|||||||
|
|
||||||
public static CreatedEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static CreatedEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record CreatedEventArgs<TValue>(TValue Value);
|
public record CreatedEventArgs<TValue>(TValue Value);
|
||||||
@@ -5,4 +5,4 @@ public record Deactivated
|
|||||||
public static DeactivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
public static DeactivatedEventArgs<TValue> As<TValue>(TValue value) => new(value);
|
||||||
|
|
||||||
public static DeactivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
public static DeactivatedEventArgs<TValue> As<TValue>() where TValue : new() => new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record DeactivatedEventArgs<TValue>(TValue? Value = default);
|
public record DeactivatedEventArgs<TValue>(TValue? Value = default);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record DeleteEventArgs<TValue>(TValue Value);
|
public record DeleteEventArgs<TValue>(TValue Value);
|
||||||
@@ -7,4 +7,4 @@ public record Edit
|
|||||||
|
|
||||||
public static EditEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static EditEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public class HandlerProvider(SubscriptionCollection subscriptions) :
|
public class HandlerProvider(SubscriptionCollection subscriptions) :
|
||||||
IHandlerProvider
|
IHandlerProvider
|
||||||
{
|
{
|
||||||
public IEnumerable<object?> Get(Type type,
|
public IEnumerable<object?> Get(Type type,
|
||||||
@@ -24,4 +24,4 @@ public class HandlerProvider(SubscriptionCollection subscriptions) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,4 +8,4 @@ public interface IActivated
|
|||||||
public interface IActivated<TResult>
|
public interface IActivated<TResult>
|
||||||
{
|
{
|
||||||
Task Activated(TResult result);
|
Task Activated(TResult result);
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IAggerate
|
public interface IAggerate
|
||||||
{
|
{
|
||||||
object? Key { get; init; }
|
object? Key { get; init; }
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public interface IDecryptor
|
public interface IDecryptor
|
||||||
{
|
{
|
||||||
bool TryDecrypt(byte[] cipher,
|
bool TryDecrypt(byte[] cipher,
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IDisposerRequired
|
public interface IDisposerRequired
|
||||||
{
|
{
|
||||||
IDisposer Disposer { get; }
|
IDisposer Disposer { get; }
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
|
namespace Toolkit.Foundation;
|
||||||
namespace Toolkit.Foundation;
|
|
||||||
|
|
||||||
public interface IHandlerProvider
|
public interface IHandlerProvider
|
||||||
{
|
{
|
||||||
IEnumerable<object?> Get(Type type,
|
IEnumerable<object?> Get(Type type,
|
||||||
object? key = null);
|
object? key = null);
|
||||||
}
|
}
|
||||||
@@ -153,4 +153,4 @@ public static class IHostBuilderExtension
|
|||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public interface IKeyDeriver
|
public interface IKeyDeriver
|
||||||
{
|
{
|
||||||
byte[] DeriveKey(byte[] phrased,
|
byte[] DeriveKey(byte[] phrased,
|
||||||
byte[] salt,
|
byte[] salt,
|
||||||
int keySize = 32,
|
int keySize = 32,
|
||||||
int iterations = 10000);
|
int iterations = 10000);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public interface IKeyGenerator
|
public interface IKeyGenerator
|
||||||
{
|
{
|
||||||
byte[] Generate(int size);
|
byte[] Generate(int size);
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
|
namespace Toolkit.Foundation
|
||||||
namespace Toolkit.Foundation
|
|
||||||
{
|
{
|
||||||
public interface IMediator
|
public interface IMediator
|
||||||
{
|
{
|
||||||
Task<object?> Handle(object message,
|
Task<object?> Handle(object message,
|
||||||
CancellationToken cancellationToken = default);
|
CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
Task<TResponse?> Handle<TMessage, TResponse>(TMessage message,
|
Task<TResponse?> Handle<TMessage, TResponse>(TMessage message,
|
||||||
CancellationToken cancellationToken = default)
|
CancellationToken cancellationToken = default)
|
||||||
where TMessage : notnull;
|
where TMessage : notnull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IMediatorRequired
|
public interface IMediatorRequired
|
||||||
{
|
{
|
||||||
IMediator Mediator { get; }
|
IMediator Mediator { get; }
|
||||||
}
|
}
|
||||||
@@ -4,4 +4,4 @@ public interface INavigationRegion
|
|||||||
{
|
{
|
||||||
void Register(string name,
|
void Register(string name,
|
||||||
object target);
|
object target);
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
public interface INavigationScope
|
public interface INavigationScope
|
||||||
{
|
{
|
||||||
void Navigate(string route,
|
void Navigate(string route,
|
||||||
object? sender = null,
|
object? sender = null,
|
||||||
object? region = null,
|
object? region = null,
|
||||||
EventHandler? navigated = null,
|
EventHandler? navigated = null,
|
||||||
object[]? parameters = null);
|
object[]? parameters = null);
|
||||||
|
|
||||||
void Back(object? region);
|
void Back(object? region);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public interface IPasswordHasher
|
public interface IPasswordHasher
|
||||||
{
|
{
|
||||||
string HashPassword(string password, int iterations = 10000);
|
string HashPassword(string password, int iterations = 10000);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public interface IPublisher
|
|||||||
void Publish<TMessage>(TMessage message,
|
void Publish<TMessage>(TMessage message,
|
||||||
object key)
|
object key)
|
||||||
where TMessage : notnull;
|
where TMessage : notnull;
|
||||||
|
|
||||||
void Publish(object message,
|
void Publish(object message,
|
||||||
Func<Func<Task>, Task> marshal,
|
Func<Func<Task>, Task> marshal,
|
||||||
object? key = null);
|
object? key = null);
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IPublisherRequired
|
public interface IPublisherRequired
|
||||||
{
|
{
|
||||||
IPublisher Publisher { get; }
|
IPublisher Publisher { get; }
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IServiceFactoryRequired
|
public interface IServiceFactoryRequired
|
||||||
{
|
{
|
||||||
IServiceFactory Factory { get; }
|
IServiceFactory Factory { get; }
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IServiceProviderRequired
|
public interface IServiceProviderRequired
|
||||||
{
|
{
|
||||||
IServiceProvider Provider { get; }
|
IServiceProvider Provider { get; }
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface ISubscriptionRequired
|
public interface ISubscriptionRequired
|
||||||
{
|
{
|
||||||
ISubscription Subscription { get; }
|
ISubscription Subscription { get; }
|
||||||
}
|
}
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
public interface IValueInvoker<TValue>
|
public interface IValueInvoker<TValue>
|
||||||
{
|
{
|
||||||
public void Invoke(TValue args);
|
public void Invoke(TValue args);
|
||||||
}
|
}
|
||||||
@@ -5,4 +5,4 @@ public interface IValueStore<T>
|
|||||||
T? Value { get; }
|
T? Value { get; }
|
||||||
|
|
||||||
void Set(T value);
|
void Set(T value);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record InsertEventArgs<TValue>(int Index, TValue Value);
|
public record InsertEventArgs<TValue>(int Index, TValue Value);
|
||||||
@@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public class KeyDeriver :
|
public class KeyDeriver :
|
||||||
IKeyDeriver
|
IKeyDeriver
|
||||||
{
|
{
|
||||||
public byte[] DeriveKey(byte[] phrase,
|
public byte[] DeriveKey(byte[] phrase,
|
||||||
byte[] salt,
|
byte[] salt,
|
||||||
int keySize = 32,
|
int keySize = 32,
|
||||||
int iterations = 100000)
|
int iterations = 100000)
|
||||||
{
|
{
|
||||||
using Rfc2898DeriveBytes pbkdf2 = new(phrase, salt, iterations, HashAlgorithmName.SHA256);
|
using Rfc2898DeriveBytes pbkdf2 = new(phrase, salt, iterations, HashAlgorithmName.SHA256);
|
||||||
return pbkdf2.GetBytes(keySize);
|
return pbkdf2.GetBytes(keySize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public class KeyGenerator :
|
public class KeyGenerator :
|
||||||
IKeyGenerator
|
IKeyGenerator
|
||||||
{
|
{
|
||||||
public byte[] Generate(int size)
|
public byte[] Generate(int size)
|
||||||
@@ -12,4 +12,4 @@ public class KeyGenerator :
|
|||||||
|
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,7 +51,7 @@ public class Mediator(IHandlerProvider handlerProvider,
|
|||||||
{
|
{
|
||||||
if (handler?.GetType().GetMethod("Handle", [messageType, typeof(CancellationToken)]) is MethodInfo handleMethod)
|
if (handler?.GetType().GetMethod("Handle", [messageType, typeof(CancellationToken)]) is MethodInfo handleMethod)
|
||||||
{
|
{
|
||||||
return await (Task<TResponse?>)handleMethod.Invoke(handler,
|
return await (Task<TResponse?>)handleMethod.Invoke(handler,
|
||||||
new object[] { message, cancellationToken })!;
|
new object[] { message, cancellationToken })!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ public record Modified
|
|||||||
{
|
{
|
||||||
public static ModifiedEventArgs<TValue> As<TValue>(TValue oldValue, TValue newValue) =>
|
public static ModifiedEventArgs<TValue> As<TValue>(TValue oldValue, TValue newValue) =>
|
||||||
new(oldValue, newValue);
|
new(oldValue, newValue);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ModifiedEventArgs<TValue>(TValue OldView, TValue NewValue);
|
public record ModifiedEventArgs<TValue>(TValue OldView, TValue NewValue);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record MoveEventArgs<TValue>(int Index, TValue Value);
|
public record MoveEventArgs<TValue>(int Index, TValue Value);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record MoveToEventArgs<TValue>(int OldIndex, int NewIndex);
|
public record MoveToEventArgs<TValue>(int OldIndex, int NewIndex);
|
||||||
@@ -25,8 +25,8 @@ public class NavigateHandler(NamedComponent scope,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (navigationScope is null)
|
if (navigationScope is null)
|
||||||
{
|
{
|
||||||
ComponentScopeDescriptor? descriptor = componentScopeProvider.Get(args.Scope ?? scope.Name);
|
ComponentScopeDescriptor? descriptor = componentScopeProvider.Get(args.Scope ?? scope.Name);
|
||||||
navigationScope = descriptor?.Services?.GetRequiredService<INavigationScope>();
|
navigationScope = descriptor?.Services?.GetRequiredService<INavigationScope>();
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System.Data.SqlTypes;
|
|
||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
@@ -11,8 +10,8 @@ public class NavigationScope(IPublisher publisher,
|
|||||||
IContentTemplateDescriptorProvider contentTemplateDescriptorProvider) :
|
IContentTemplateDescriptorProvider contentTemplateDescriptorProvider) :
|
||||||
INavigationScope
|
INavigationScope
|
||||||
{
|
{
|
||||||
public void Navigate(string route,
|
public void Navigate(string route,
|
||||||
object? sender = null,
|
object? sender = null,
|
||||||
object? region = null,
|
object? region = null,
|
||||||
EventHandler? navigated = null,
|
EventHandler? navigated = null,
|
||||||
object[]? parameters = null)
|
object[]? parameters = null)
|
||||||
@@ -57,6 +56,7 @@ public class NavigationScope(IPublisher publisher,
|
|||||||
case "self":
|
case "self":
|
||||||
region = view;
|
region = view;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (navigationRegionProvider.TryGet(region, out object? value))
|
if (navigationRegionProvider.TryGet(region, out object? value))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,4 +4,4 @@
|
|||||||
public class NotificationAttribute(object key) : Attribute
|
public class NotificationAttribute(object key) : Attribute
|
||||||
{
|
{
|
||||||
public object Key => key;
|
public object Key => key;
|
||||||
}
|
}
|
||||||
@@ -7,4 +7,4 @@ public class Notify
|
|||||||
|
|
||||||
public static NotifyEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static NotifyEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record NotifyEventArgs<TValue>(TValue Value);
|
public record NotifyEventArgs<TValue>(TValue Value);
|
||||||
@@ -365,9 +365,29 @@ public partial class ObservableCollection<TItem> :
|
|||||||
|
|
||||||
TItem item = this[oldIndex];
|
TItem item = this[oldIndex];
|
||||||
|
|
||||||
|
bool selected = false;
|
||||||
|
if (item is ISelectable selectable)
|
||||||
|
{
|
||||||
|
selected = selectable.Selected;
|
||||||
|
|
||||||
|
SelectedItem = default;
|
||||||
|
SelectedIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
RemoveItem(oldIndex);
|
RemoveItem(oldIndex);
|
||||||
Insert(newIndex, item);
|
Insert(newIndex, item);
|
||||||
|
|
||||||
|
if (selected)
|
||||||
|
{
|
||||||
|
SelectedIndex = newIndex;
|
||||||
|
SelectedItem = item;
|
||||||
|
|
||||||
|
if (item is ISelectable selectable2)
|
||||||
|
{
|
||||||
|
selectable2.Selected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,14 +513,6 @@ public partial class ObservableCollection<TItem> :
|
|||||||
added.Selected = true;
|
added.Selected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
partial void OnSelectedItemChanged(TItem? oldValue, TItem? newValue)
|
|
||||||
{
|
|
||||||
if (oldValue is ISelectable selectable)
|
|
||||||
{
|
|
||||||
selectable.Selected = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class ObservableCollection<TValue, TViewModel>(IServiceProvider provider,
|
public partial class ObservableCollection<TValue, TViewModel>(IServiceProvider provider,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public class PasswordHasher :
|
public class PasswordHasher :
|
||||||
IPasswordHasher
|
IPasswordHasher
|
||||||
{
|
{
|
||||||
private const int SaltSize = 16;
|
private const int SaltSize = 16;
|
||||||
@@ -16,4 +16,4 @@ public class PasswordHasher :
|
|||||||
|
|
||||||
return $"{Convert.ToBase64String(salt)}:{Convert.ToBase64String(hash)}";
|
return $"{Convert.ToBase64String(salt)}:{Convert.ToBase64String(hash)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ public class Publisher(IHandlerProvider handlerProvider,
|
|||||||
Publish(message, async args => await args(), null);
|
Publish(message, async args => await args(), null);
|
||||||
|
|
||||||
public void Publish<TMessage>(TMessage message, object key)
|
public void Publish<TMessage>(TMessage message, object key)
|
||||||
where TMessage : notnull =>
|
where TMessage : notnull =>
|
||||||
Publish(message, async args => await args(), key);
|
Publish(message, async args => await args(), key);
|
||||||
|
|
||||||
public void Publish(object message,
|
public void Publish(object message,
|
||||||
@@ -59,7 +59,7 @@ public class Publisher(IHandlerProvider handlerProvider,
|
|||||||
Publish(new TMessage(), async args => await args(), null);
|
Publish(new TMessage(), async args => await args(), null);
|
||||||
|
|
||||||
public void PublishUI<TMessage>(object key)
|
public void PublishUI<TMessage>(object key)
|
||||||
where TMessage : new() =>
|
where TMessage : new() =>
|
||||||
Publish(new TMessage(), args => dispatcher.Invoke(async () => await args()), key);
|
Publish(new TMessage(), args => dispatcher.Invoke(async () => await args()), key);
|
||||||
|
|
||||||
public void PublishUI<TMessage>(TMessage message)
|
public void PublishUI<TMessage>(TMessage message)
|
||||||
|
|||||||
@@ -4,4 +4,4 @@ public record RemoveAt
|
|||||||
{
|
{
|
||||||
public static RemoveAtEventArgs<TValue> As<TValue>(int index) =>
|
public static RemoveAtEventArgs<TValue> As<TValue>(int index) =>
|
||||||
new(index);
|
new(index);
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record RemoveAtEventArgs<TValue>(int Index);
|
public record RemoveAtEventArgs<TValue>(int Index);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ReplaceEventArgs<TValue>(int Index, TValue Value);
|
public record ReplaceEventArgs<TValue>(int Index, TValue Value);
|
||||||
@@ -7,4 +7,4 @@ public class Request
|
|||||||
|
|
||||||
public static RequestEventArgs<TValue> As<TValue>() where TValue : new() =>
|
public static RequestEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||||
new(new TValue());
|
new(new TValue());
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record RequestEventArgs<TValue>(TValue Value);
|
public record RequestEventArgs<TValue>(TValue Value);
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record SelectionEventArgs<TValue>(TValue? Value);
|
public record SelectionEventArgs<TValue>(TValue? Value);
|
||||||
@@ -49,7 +49,6 @@ public class Subscription(SubscriptionCollection subscriptions,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void RemoveSubscriber(object subscriber,
|
private void RemoveSubscriber(object subscriber,
|
||||||
string key)
|
string key)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.3.24172.9" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.4.24266.19" />
|
||||||
<PackageReference Include="System.Reactive" Version="6.0.1-preview.1" />
|
<PackageReference Include="System.Reactive" Version="6.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
namespace Toolkit.Foundation;
|
namespace Toolkit.Foundation;
|
||||||
|
|
||||||
public record ValidationEventArgs<TValue>(TValue Value);
|
public record ValidationEventArgs<TValue>(TValue Value);
|
||||||
@@ -6,4 +6,4 @@ public class ValueStore<T> :
|
|||||||
public T? Value { get; private set; }
|
public T? Value { get; private set; }
|
||||||
|
|
||||||
public void Set(T value) => Value = value;
|
public void Set(T value) => Value = value;
|
||||||
}
|
}
|
||||||
@@ -9,4 +9,4 @@ public class AttachedBehaviour : Trigger
|
|||||||
Interaction.ExecuteActions(AssociatedObject, Actions, null);
|
Interaction.ExecuteActions(AssociatedObject, Actions, null);
|
||||||
base.OnAttachedToVisualTree();
|
base.OnAttachedToVisualTree();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -21,14 +21,13 @@ public class AttachedEventTriggerBehaviour : Trigger
|
|||||||
{
|
{
|
||||||
if (AssociatedObject is Interactive interactive)
|
if (AssociatedObject is Interactive interactive)
|
||||||
{
|
{
|
||||||
interactive.AddHandler(RoutedEvent, (object sender, RoutedEventArgs args) => {
|
interactive.AddHandler(RoutedEvent, (object sender, RoutedEventArgs args) =>
|
||||||
|
{
|
||||||
Interaction.ExecuteActions(AssociatedObject, Actions, null);
|
Interaction.ExecuteActions(AssociatedObject, Actions, null);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnAttached();
|
base.OnAttached();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,4 +43,4 @@ public class InvokeNavigationViewItemAction :
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
namespace Toolkit.UI.Avalonia;
|
namespace Toolkit.UI.Avalonia;
|
||||||
|
|
||||||
public class ItemInvokedEventArgs :
|
public class ItemInvokedEventArgs :
|
||||||
RoutedEventArgs
|
RoutedEventArgs
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -21,19 +21,20 @@ public class NavigateRegionAction :
|
|||||||
|
|
||||||
[Content]
|
[Content]
|
||||||
public ActionCollection Actions => actions ??= [];
|
public ActionCollection Actions => actions ??= [];
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get => GetValue(NameProperty);
|
get => GetValue(NameProperty);
|
||||||
set => SetValue(NameProperty, value);
|
set => SetValue(NameProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object? Execute(object? sender,
|
public object? Execute(object? sender,
|
||||||
object? parameter)
|
object? parameter)
|
||||||
{
|
{
|
||||||
if (sender is Control control)
|
if (sender is Control control)
|
||||||
{
|
{
|
||||||
if (control.DataContext is IObservableViewModel observableViewModel)
|
if (control.DataContext is IObservableViewModel observableViewModel)
|
||||||
{
|
{
|
||||||
if (observableViewModel.Provider.GetRequiredService<INavigationRegion>() is INavigationRegion navigationRegion)
|
if (observableViewModel.Provider.GetRequiredService<INavigationRegion>() is INavigationRegion navigationRegion)
|
||||||
{
|
{
|
||||||
navigationRegion.Register(Name, sender);
|
navigationRegion.Register(Name, sender);
|
||||||
@@ -44,4 +45,4 @@ public class NavigateRegionAction :
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,8 @@ public class NavigationViewItemExtension
|
|||||||
AvaloniaProperty.RegisterAttached<NavigationViewItem, bool>("IsItemClickEnabled",
|
AvaloniaProperty.RegisterAttached<NavigationViewItem, bool>("IsItemClickEnabled",
|
||||||
typeof(NavigationViewItemExtension), false);
|
typeof(NavigationViewItemExtension), false);
|
||||||
|
|
||||||
public static readonly RoutedEvent<ItemInvokedEventArgs> ItemClickEvent =
|
public static readonly RoutedEvent<ItemInvokedEventArgs> ItemClickEvent =
|
||||||
RoutedEvent.Register<ItemInvokedEventArgs>("ItemClick",
|
RoutedEvent.Register<ItemInvokedEventArgs>("ItemClick",
|
||||||
RoutingStrategies.Bubble, typeof(NavigationViewItemExtension));
|
RoutingStrategies.Bubble, typeof(NavigationViewItemExtension));
|
||||||
|
|
||||||
static NavigationViewItemExtension()
|
static NavigationViewItemExtension()
|
||||||
@@ -20,7 +20,7 @@ public class NavigationViewItemExtension
|
|||||||
IsItemClickEnabledProperty.Changed.AddClassHandler<NavigationViewItem>(OnIsItemClickEnabledPropertyChanged);
|
IsItemClickEnabledProperty.Changed.AddClassHandler<NavigationViewItem>(OnIsItemClickEnabledPropertyChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnIsItemClickEnabledPropertyChanged(NavigationViewItem sender,
|
private static void OnIsItemClickEnabledPropertyChanged(NavigationViewItem sender,
|
||||||
AvaloniaPropertyChangedEventArgs args)
|
AvaloniaPropertyChangedEventArgs args)
|
||||||
{
|
{
|
||||||
bool TrySetupNavigationView()
|
bool TrySetupNavigationView()
|
||||||
@@ -43,7 +43,7 @@ public class NavigationViewItemExtension
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!TrySetupNavigationView())
|
if (!TrySetupNavigationView())
|
||||||
{
|
{
|
||||||
void OnAttachedToVisualTree(object? _, VisualTreeAttachmentEventArgs __)
|
void OnAttachedToVisualTree(object? _, VisualTreeAttachmentEventArgs __)
|
||||||
{
|
{
|
||||||
sender.AttachedToVisualTree -= OnAttachedToVisualTree;
|
sender.AttachedToVisualTree -= OnAttachedToVisualTree;
|
||||||
@@ -57,12 +57,12 @@ public class NavigationViewItemExtension
|
|||||||
public static bool GetIsItemClickEnabled(NavigationViewItem element) =>
|
public static bool GetIsItemClickEnabled(NavigationViewItem element) =>
|
||||||
element.GetValue(IsItemClickEnabledProperty);
|
element.GetValue(IsItemClickEnabledProperty);
|
||||||
|
|
||||||
public static void SetIsItemClickEnabled(NavigationViewItem element, bool value) =>
|
public static void SetIsItemClickEnabled(NavigationViewItem element, bool value) =>
|
||||||
element.SetValue(IsItemClickEnabledProperty, value);
|
element.SetValue(IsItemClickEnabledProperty, value);
|
||||||
|
|
||||||
public static void AddItemClickHandler(NavigationViewItem element, EventHandler<ItemInvokedEventArgs> handler) =>
|
public static void AddItemClickHandler(NavigationViewItem element, EventHandler<ItemInvokedEventArgs> handler) =>
|
||||||
element.AddHandler(ItemClickEvent, handler);
|
element.AddHandler(ItemClickEvent, handler);
|
||||||
|
|
||||||
public static void RemoveItemClickHandler(NavigationViewItem element, EventHandler<ItemInvokedEventArgs> handler) =>
|
public static void RemoveItemClickHandler(NavigationViewItem element, EventHandler<ItemInvokedEventArgs> handler) =>
|
||||||
element.RemoveHandler(ItemClickEvent, handler);
|
element.RemoveHandler(ItemClickEvent, handler);
|
||||||
}
|
}
|
||||||
@@ -1,357 +0,0 @@
|
|||||||
<ResourceDictionary
|
|
||||||
xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:controls="using:Toolkit.UI.Controls.Avalonia"
|
|
||||||
xmlns:ui="using:FluentAvalonia.UI.Controls">
|
|
||||||
<Design.PreviewWith>
|
|
||||||
<Border Padding="20" />
|
|
||||||
</Design.PreviewWith>
|
|
||||||
<ControlTheme x:Key="{x:Type ui:ContentDialog}" TargetType="ui:ContentDialog">
|
|
||||||
<Setter Property="Foreground" Value="{DynamicResource ContentDialogForeground}" />
|
|
||||||
<Setter Property="Background" Value="{DynamicResource ContentDialogBackground}" />
|
|
||||||
<Setter Property="BorderBrush" Value="{DynamicResource ContentDialogBorderBrush}" />
|
|
||||||
<Setter Property="BorderThickness" Value="{DynamicResource ContentDialogBorderWidth}" />
|
|
||||||
<Setter Property="CornerRadius" Value="{DynamicResource OverlayCornerRadius}" />
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate>
|
|
||||||
<Border Name="Container">
|
|
||||||
<Panel Name="LayoutRoot" Background="{DynamicResource ContentDialogSmokeFill}">
|
|
||||||
<controls:BlurBehind />
|
|
||||||
<ui:FABorder
|
|
||||||
Name="BackgroundElement"
|
|
||||||
MinWidth="{DynamicResource ContentDialogMinWidth}"
|
|
||||||
MinHeight="{DynamicResource ContentDialogMinHeight}"
|
|
||||||
MaxWidth="{DynamicResource ContentDialogMaxWidth}"
|
|
||||||
MaxHeight="{DynamicResource ContentDialogMaxHeight}"
|
|
||||||
HorizontalAlignment="Center"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Background="{TemplateBinding Background}"
|
|
||||||
BorderBrush="{TemplateBinding BorderBrush}"
|
|
||||||
BorderThickness="{StaticResource ContentDialogBorderWidth}"
|
|
||||||
BoxShadow="0 8 32 0 #66000000"
|
|
||||||
CornerRadius="{TemplateBinding CornerRadius}">
|
|
||||||
<!-- Even in WinUI, shadow is always black regardless of light/dark mode -->
|
|
||||||
|
|
||||||
<!--
|
|
||||||
if this border isn't here, dialog space displays outside of corner radius at top
|
|
||||||
if we put ClipToBounds=True on BackgroundElement above, it clips the shadow
|
|
||||||
-->
|
|
||||||
<Border ClipToBounds="True" CornerRadius="{TemplateBinding CornerRadius}">
|
|
||||||
<Grid
|
|
||||||
Name="DialogSpace"
|
|
||||||
ClipToBounds="True"
|
|
||||||
RowDefinitions="*,Auto">
|
|
||||||
<ScrollViewer
|
|
||||||
Name="ContentScrollViewer"
|
|
||||||
HorizontalScrollBarVisibility="Disabled"
|
|
||||||
VerticalScrollBarVisibility="Auto">
|
|
||||||
<Border
|
|
||||||
Padding="{DynamicResource ContentDialogPadding}"
|
|
||||||
Background="{DynamicResource ContentDialogTopOverlay}"
|
|
||||||
BorderBrush="{DynamicResource ContentDialogSeparatorBorderBrush}"
|
|
||||||
BorderThickness="{StaticResource ContentDialogSeparatorThickness}">
|
|
||||||
<Grid RowDefinitions="Auto,*">
|
|
||||||
<Grid.Styles>
|
|
||||||
<!-- Make sure text wrapping is on -->
|
|
||||||
<Style Selector="TextBlock">
|
|
||||||
<Setter Property="TextWrapping" Value="Wrap" />
|
|
||||||
</Style>
|
|
||||||
</Grid.Styles>
|
|
||||||
<ContentControl
|
|
||||||
Name="Title"
|
|
||||||
Margin="{StaticResource ContentDialogTitleMargin}"
|
|
||||||
HorizontalAlignment="Left"
|
|
||||||
VerticalAlignment="Top"
|
|
||||||
Content="{TemplateBinding Title}"
|
|
||||||
ContentTemplate="{TemplateBinding TitleTemplate}"
|
|
||||||
FontFamily="Default"
|
|
||||||
FontSize="20"
|
|
||||||
FontWeight="SemiBold"
|
|
||||||
Foreground="{TemplateBinding Foreground}">
|
|
||||||
<ContentControl.Template>
|
|
||||||
<ControlTemplate>
|
|
||||||
<ContentPresenter
|
|
||||||
Margin="{TemplateBinding Padding}"
|
|
||||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
|
||||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
||||||
Content="{TemplateBinding Content}"
|
|
||||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
|
||||||
</ControlTemplate>
|
|
||||||
</ContentControl.Template>
|
|
||||||
</ContentControl>
|
|
||||||
|
|
||||||
<ContentPresenter
|
|
||||||
Name="Content"
|
|
||||||
Grid.Row="1"
|
|
||||||
Content="{TemplateBinding Content}"
|
|
||||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
|
||||||
FontFamily="{StaticResource ContentControlThemeFontFamily}"
|
|
||||||
FontSize="{StaticResource ControlContentThemeFontSize}"
|
|
||||||
Foreground="{TemplateBinding Foreground}" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</ScrollViewer>
|
|
||||||
|
|
||||||
<Border
|
|
||||||
Grid.Row="1"
|
|
||||||
Padding="{StaticResource ContentDialogPadding}"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Bottom"
|
|
||||||
Background="{TemplateBinding Background}">
|
|
||||||
<Grid Name="CommandSpace">
|
|
||||||
<!--
|
|
||||||
B/C we can't target Row/Column defs in Styles like WinUI
|
|
||||||
this still uses the old Col defs, but it works the same
|
|
||||||
way in the end...
|
|
||||||
-->
|
|
||||||
<Grid.ColumnDefinitions>
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
<ColumnDefinition Width="0.5*" />
|
|
||||||
<ColumnDefinition Width="0.5*" />
|
|
||||||
<ColumnDefinition Width="*" />
|
|
||||||
</Grid.ColumnDefinitions>
|
|
||||||
<Button
|
|
||||||
Name="PrimaryButton"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Center"
|
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
Content="{TemplateBinding PrimaryButtonText}"
|
|
||||||
IsEnabled="{TemplateBinding IsPrimaryButtonEnabled}"
|
|
||||||
IsVisible="False" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Name="SecondaryButton"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Center"
|
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
Content="{TemplateBinding SecondaryButtonText}"
|
|
||||||
IsEnabled="{TemplateBinding IsSecondaryButtonEnabled}"
|
|
||||||
IsVisible="False" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
Name="CloseButton"
|
|
||||||
HorizontalAlignment="Stretch"
|
|
||||||
VerticalAlignment="Stretch"
|
|
||||||
HorizontalContentAlignment="Center"
|
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
Content="{TemplateBinding CloseButtonText}"
|
|
||||||
IsVisible="False" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</ui:FABorder>
|
|
||||||
</Panel>
|
|
||||||
</Border>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
|
|
||||||
<!-- Handle hidden dialog -->
|
|
||||||
<Style Selector="^:hidden /template/ Panel#LayoutRoot">
|
|
||||||
<Style.Animations>
|
|
||||||
<Animation FillMode="Forward" Duration="00:00:00.167">
|
|
||||||
<KeyFrame Cue="0%">
|
|
||||||
<Setter Property="Opacity" Value="1.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="100%">
|
|
||||||
<Setter Property="Opacity" Value="0.0" />
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</KeyFrame>
|
|
||||||
</Animation>
|
|
||||||
</Style.Animations>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:hidden /template/ Border#Container">
|
|
||||||
<Style.Animations>
|
|
||||||
<Animation FillMode="Forward" Duration="00:00:00.167">
|
|
||||||
<KeyFrame Cue="0%">
|
|
||||||
<Setter Property="ScaleTransform.ScaleX" Value="1.0" />
|
|
||||||
<Setter Property="ScaleTransform.ScaleY" Value="1.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="100%" KeySpline="0,0 0,1">
|
|
||||||
<Setter Property="ScaleTransform.ScaleX" Value="1.05" />
|
|
||||||
<Setter Property="ScaleTransform.ScaleY" Value="1.05" />
|
|
||||||
</KeyFrame>
|
|
||||||
</Animation>
|
|
||||||
</Style.Animations>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Handle open dialog -->
|
|
||||||
<Style Selector="^:open /template/ Panel#LayoutRoot">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Style.Animations>
|
|
||||||
<!--
|
|
||||||
Animation applies with priority of LocalValue
|
|
||||||
To overrule the IsVisible=False in :hidden, set
|
|
||||||
IsVisible=True in BOTH KeyFrames here
|
|
||||||
-->
|
|
||||||
<Animation FillMode="Forward" Duration="00:00:00.250">
|
|
||||||
<KeyFrame Cue="0%">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Opacity" Value="0.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="100%">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Opacity" Value="1.0" />
|
|
||||||
</KeyFrame>
|
|
||||||
</Animation>
|
|
||||||
</Style.Animations>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:open /template/ Border#Container">
|
|
||||||
<Style.Animations>
|
|
||||||
<Animation FillMode="Forward" Duration="00:00:00.250">
|
|
||||||
<KeyFrame Cue="0%">
|
|
||||||
<Setter Property="ScaleTransform.ScaleX" Value="1.05" />
|
|
||||||
<Setter Property="ScaleTransform.ScaleY" Value="1.05" />
|
|
||||||
</KeyFrame>
|
|
||||||
<KeyFrame Cue="100%" KeySpline="0,0 0,1">
|
|
||||||
<Setter Property="ScaleTransform.ScaleX" Value="1.00" />
|
|
||||||
<Setter Property="ScaleTransform.ScaleY" Value="1.00" />
|
|
||||||
</KeyFrame>
|
|
||||||
</Animation>
|
|
||||||
</Style.Animations>
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Handle showing smoke layer -->
|
|
||||||
<Style Selector="^:nosmokelayer /template/ Panel#LayoutRoot">
|
|
||||||
<Setter Property="Background" Value="{x:Null}" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Handle FullDialogSizing -->
|
|
||||||
<Style Selector="^:fullsize /template/ ui|FABorder#BackgroundElement">
|
|
||||||
<Setter Property="VerticalAlignment" Value="Stretch" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Primary Button Only -->
|
|
||||||
<Style Selector="^:primary /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary /template/ Button#SecondaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Secondary Button Only -->
|
|
||||||
<Style Selector="^:secondary /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:secondary /template/ Button#SecondaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:secondary /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Close Button Only -->
|
|
||||||
<Style Selector="^:close /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:close /template/ Button#SecondaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:close /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Margins are defined by ContentDialogButtonSpacing (8) -->
|
|
||||||
|
|
||||||
<!-- Primary and Secondary -->
|
|
||||||
<Style Selector="^:primary:secondary /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="0" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="0 0 4 0" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:secondary /template/ Button#SecondaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="4 0 0 0" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:secondary /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Primary and Close Buttons -->
|
|
||||||
<Style Selector="^:primary:close /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="0" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="0 0 4 0" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:close /template/ Button#SecondaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:close /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="4 0 0 0" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Primary and Secondary Buttons -->
|
|
||||||
<Style Selector="^:primary:secondary /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="0" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="0 0 4 0" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:secondary /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:secondary /template/ Button#SecondaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="4 0 0 0" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
<!-- Secondary and Close Buttons -->
|
|
||||||
<Style Selector="^:secondary:close /template/ Button#Secondary">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="0" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="0 0 4 0" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:secondary:close /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="False" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:secondary:close /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="2" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="4 0 0 0" />
|
|
||||||
</Style>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- All Buttons -->
|
|
||||||
<Style Selector="^:primary:secondary:close /template/ Button#PrimaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="0" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
|
||||||
<Setter Property="Margin" Value="0 0 4 0" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:secondary:close /template/ Button#SecondaryButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="1" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="2" />
|
|
||||||
<Setter Property="Margin" Value="4 0 4 0" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:primary:secondary:close /template/ Button#CloseButton">
|
|
||||||
<Setter Property="IsVisible" Value="True" />
|
|
||||||
<Setter Property="Grid.Column" Value="3" />
|
|
||||||
<Setter Property="Grid.ColumnSpan" Value="1" />
|
|
||||||
<Setter Property="Margin" Value="4 0 0 0" />
|
|
||||||
</Style>
|
|
||||||
</ControlTheme>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class BitmapIcon : FluentAvalonia.UI.Controls.BitmapIcon
|
public class BitmapIcon : FluentAvalonia.UI.Controls.BitmapIcon
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class BitmapIconSource : FluentAvalonia.UI.Controls.BitmapIconSource
|
public class BitmapIconSource : FluentAvalonia.UI.Controls.BitmapIconSource
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -22,6 +22,7 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
|||||||
get => GetValue(ContentProperty);
|
get => GetValue(ContentProperty);
|
||||||
set => SetValue(ContentProperty, value);
|
set => SetValue(ContentProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDataTemplate? IconTemplate
|
public IDataTemplate? IconTemplate
|
||||||
{
|
{
|
||||||
get => GetValue(ContentTemplateProperty);
|
get => GetValue(ContentTemplateProperty);
|
||||||
@@ -36,7 +37,6 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
|||||||
}
|
}
|
||||||
|
|
||||||
return base.MeasureOverride(availableSize);
|
return base.MeasureOverride(availableSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs args)
|
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs args)
|
||||||
@@ -58,6 +58,7 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
|||||||
|
|
||||||
base.OnDetachedFromLogicalTree(args);
|
base.OnDetachedFromLogicalTree(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateContent()
|
private void CreateContent()
|
||||||
{
|
{
|
||||||
content = new ContentControl();
|
content = new ContentControl();
|
||||||
@@ -68,4 +69,4 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
|||||||
LogicalChildren.Add(content);
|
LogicalChildren.Add(content);
|
||||||
VisualChildren.Add(content);
|
VisualChildren.Add(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,9 +18,10 @@ public class ContentIconSource : FluentAvalonia.UI.Controls.IconSource
|
|||||||
get => GetValue(ContentProperty);
|
get => GetValue(ContentProperty);
|
||||||
set => SetValue(ContentProperty, value);
|
set => SetValue(ContentProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDataTemplate? IconTemplate
|
public IDataTemplate? IconTemplate
|
||||||
{
|
{
|
||||||
get => GetValue(ContentTemplateProperty);
|
get => GetValue(ContentTemplateProperty);
|
||||||
set => SetValue(ContentTemplateProperty, value);
|
set => SetValue(ContentTemplateProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class FAIconElement : FluentAvalonia.UI.Controls.FAIconElement
|
public class FAIconElement : FluentAvalonia.UI.Controls.FAIconElement
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class FAPathIcon : FluentAvalonia.UI.Controls.FAPathIcon
|
public class FAPathIcon : FluentAvalonia.UI.Controls.FAPathIcon
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class FontIcon : FluentAvalonia.UI.Controls.FontIcon
|
public class FontIcon : FluentAvalonia.UI.Controls.FontIcon
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
namespace Kromek.UI.Avalonia.Controls
|
namespace Kromek.UI.Avalonia.Controls
|
||||||
{
|
{
|
||||||
|
|
||||||
public class FontIconSource : FluentAvalonia.UI.Controls.FontIconSource
|
public class FontIconSource : FluentAvalonia.UI.Controls.FontIconSource
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -32,4 +32,4 @@ public class IconHelper
|
|||||||
return (FluentAvalonia.UI.Controls.FAIconElement?)invoker?.Invoke(null, new object[] { source });
|
return (FluentAvalonia.UI.Controls.FAIconElement?)invoker?.Invoke(null, new object[] { source });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class ImageIcon : FluentAvalonia.UI.Controls.ImageIcon
|
public class ImageIcon : FluentAvalonia.UI.Controls.ImageIcon
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class ImageIconSource : FluentAvalonia.UI.Controls.ImageIconSource
|
public class ImageIconSource : FluentAvalonia.UI.Controls.ImageIconSource
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
using Avalonia.Controls.Templates;
|
namespace Toolkit.UI.Controls.Avalonia;
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.LogicalTree;
|
|
||||||
using Avalonia.Metadata;
|
|
||||||
using Avalonia;
|
|
||||||
|
|
||||||
namespace Toolkit.UI.Controls.Avalonia;
|
|
||||||
|
|
||||||
public class PathIconSource : FluentAvalonia.UI.Controls.PathIconSource
|
public class PathIconSource : FluentAvalonia.UI.Controls.PathIconSource
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class SymbolIcon : FluentAvalonia.UI.Controls.SymbolIcon
|
public class SymbolIcon : FluentAvalonia.UI.Controls.SymbolIcon
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -2,5 +2,4 @@
|
|||||||
|
|
||||||
public class SymbolIconSource : FluentAvalonia.UI.Controls.SymbolIconSource
|
public class SymbolIconSource : FluentAvalonia.UI.Controls.SymbolIconSource
|
||||||
{
|
{
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -4,8 +4,6 @@ using Avalonia.Controls.Primitives;
|
|||||||
using Avalonia.Controls.Shapes;
|
using Avalonia.Controls.Shapes;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Kromek.UI.Avalonia.Controls;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Toolkit.UI.Controls.Avalonia;
|
namespace Toolkit.UI.Controls.Avalonia;
|
||||||
|
|
||||||
@@ -157,7 +155,6 @@ public class PersonPicture : TemplatedControl
|
|||||||
|
|
||||||
if (change.Property == ProfilePictureProperty)
|
if (change.Property == ProfilePictureProperty)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,6 +294,7 @@ public class PersonPicture : TemplatedControl
|
|||||||
PseudoClasses.Set(":NoBadge", true);
|
PseudoClasses.Set(":NoBadge", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateBadgeNumber()
|
private void UpdateBadgeNumber()
|
||||||
{
|
{
|
||||||
if (badgingEllipse == null || badgeNumberTextBlock == null)
|
if (badgingEllipse == null || badgeNumberTextBlock == null)
|
||||||
@@ -322,6 +320,7 @@ public class PersonPicture : TemplatedControl
|
|||||||
badgeNumberTextBlock.Text = "99+";
|
badgeNumberTextBlock.Text = "99+";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateDisplayName()
|
private void UpdateDisplayName()
|
||||||
{
|
{
|
||||||
displayNameInitials = PersonPictureInitialsGenerator.InitialsFromDisplayName(DisplayName);
|
displayNameInitials = PersonPictureInitialsGenerator.InitialsFromDisplayName(DisplayName);
|
||||||
@@ -376,4 +375,4 @@ public class PersonPicture : TemplatedControl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,4 +6,4 @@ internal enum PersonPictureCharacterType
|
|||||||
Standard = 1,
|
Standard = 1,
|
||||||
Symbolic = 2,
|
Symbolic = 2,
|
||||||
Glyph = 3
|
Glyph = 3
|
||||||
}
|
}
|
||||||
@@ -22,18 +22,21 @@ internal class PersonPictureInitialsGenerator
|
|||||||
case PersonPictureCharacterType.Glyph:
|
case PersonPictureCharacterType.Glyph:
|
||||||
result = PersonPictureCharacterType.Glyph;
|
result = PersonPictureCharacterType.Glyph;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PersonPictureCharacterType.Symbolic:
|
case PersonPictureCharacterType.Symbolic:
|
||||||
if (result != PersonPictureCharacterType.Glyph)
|
if (result != PersonPictureCharacterType.Glyph)
|
||||||
{
|
{
|
||||||
result = PersonPictureCharacterType.Symbolic;
|
result = PersonPictureCharacterType.Symbolic;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PersonPictureCharacterType.Standard:
|
case PersonPictureCharacterType.Standard:
|
||||||
if ((result != PersonPictureCharacterType.Glyph) && (result != PersonPictureCharacterType.Symbolic))
|
if ((result != PersonPictureCharacterType.Glyph) && (result != PersonPictureCharacterType.Symbolic))
|
||||||
{
|
{
|
||||||
result = PersonPictureCharacterType.Standard;
|
result = PersonPictureCharacterType.Standard;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -44,7 +47,6 @@ internal class PersonPictureInitialsGenerator
|
|||||||
|
|
||||||
public static PersonPictureCharacterType GetCharacterType(char character)
|
public static PersonPictureCharacterType GetCharacterType(char character)
|
||||||
{
|
{
|
||||||
|
|
||||||
// IPA Extensions
|
// IPA Extensions
|
||||||
if ((character >= 0x0250) && (character <= 0x02AF))
|
if ((character >= 0x0250) && (character <= 0x02AF))
|
||||||
{
|
{
|
||||||
@@ -147,7 +149,7 @@ internal class PersonPictureInitialsGenerator
|
|||||||
{
|
{
|
||||||
return PersonPictureCharacterType.Symbolic;
|
return PersonPictureCharacterType.Symbolic;
|
||||||
}
|
}
|
||||||
// CJK Unified Ideographs Extension
|
// CJK Unified Ideographs Extension
|
||||||
if ((character >= 0x3400) && (character <= 0x4DBF))
|
if ((character >= 0x3400) && (character <= 0x4DBF))
|
||||||
{
|
{
|
||||||
return PersonPictureCharacterType.Symbolic;
|
return PersonPictureCharacterType.Symbolic;
|
||||||
@@ -317,6 +319,7 @@ internal class PersonPictureInitialsGenerator
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetFirstFullCharacter(string str)
|
private static string GetFirstFullCharacter(string str)
|
||||||
{
|
{
|
||||||
int start = 0;
|
int start = 0;
|
||||||
@@ -385,6 +388,7 @@ internal class PersonPictureInitialsGenerator
|
|||||||
|
|
||||||
return value.Substring(startIndex, length);
|
return value.Substring(startIndex, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string[] Split(string source, char delim, int maxIterations = 25)
|
private static string[] Split(string source, char delim, int maxIterations = 25)
|
||||||
{
|
{
|
||||||
return source.Split(new[] { delim }, maxIterations);
|
return source.Split(new[] { delim }, maxIterations);
|
||||||
@@ -412,4 +416,4 @@ internal class PersonPictureInitialsGenerator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ public class PersonPictureTemplateSettings : AvaloniaObject
|
|||||||
private static readonly StyledProperty<ImageBrush?> ActualImageBrushProperty =
|
private static readonly StyledProperty<ImageBrush?> ActualImageBrushProperty =
|
||||||
AvaloniaProperty.Register<PersonPictureTemplateSettings, ImageBrush?>(nameof(ActualImageBrush));
|
AvaloniaProperty.Register<PersonPictureTemplateSettings, ImageBrush?>(nameof(ActualImageBrush));
|
||||||
|
|
||||||
|
|
||||||
private static readonly StyledProperty<string> ActualInitialsProperty =
|
private static readonly StyledProperty<string> ActualInitialsProperty =
|
||||||
AvaloniaProperty.Register<PersonPictureTemplateSettings, string>(nameof(ActualInitials));
|
AvaloniaProperty.Register<PersonPictureTemplateSettings, string>(nameof(ActualInitials));
|
||||||
|
|
||||||
@@ -23,4 +22,4 @@ public class PersonPictureTemplateSettings : AvaloniaObject
|
|||||||
get => GetValue(ActualInitialsProperty);
|
get => GetValue(ActualInitialsProperty);
|
||||||
set => SetValue(ActualInitialsProperty, value);
|
set => SetValue(ActualInitialsProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,4 +333,4 @@ namespace Toolkit.UI.Controls.Avalonia
|
|||||||
return totalSize;
|
return totalSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -33,4 +33,4 @@ namespace Toolkit.UI.Controls.Avalonia
|
|||||||
set => SetValue(ExtraSmallToSmallProperty, value);
|
set => SetValue(ExtraSmallToSmallProperty, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,4 +41,4 @@ namespace Toolkit.UI.Controls.Avalonia
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user