Codemaid
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using Avalonia.Controls.Primitives;
|
||||
using FluentAvalonia.UI.Media.Animation;
|
||||
using FluentAvalonia.UI.Navigation;
|
||||
using System.Reflection;
|
||||
using Toolkit.Foundation;
|
||||
using Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Toolkit.Avalonia;
|
||||
public class NavigationRegion(INavigationRegionCollection collection) :
|
||||
INavigationRegion
|
||||
{
|
||||
public void Register(string name,
|
||||
public void Register(string name,
|
||||
object target)
|
||||
{
|
||||
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>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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;
|
||||
|
||||
public bool TryDecrypt(byte[] cipher,
|
||||
byte[] key,
|
||||
byte[] key,
|
||||
out byte[]? decryptedData)
|
||||
{
|
||||
decryptedData = null;
|
||||
@@ -47,4 +47,4 @@ public class AesDecryptor :
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,12 @@
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public class AesEncryptor :
|
||||
public class AesEncryptor :
|
||||
IEncryptor
|
||||
{
|
||||
private const int IvSize = 16;
|
||||
|
||||
public bool TryEncrypt(byte[] data,
|
||||
public bool TryEncrypt(byte[] data,
|
||||
byte[] key,
|
||||
out byte[]? encryptedData)
|
||||
{
|
||||
@@ -46,4 +46,4 @@ public class AesEncryptor :
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,4 @@ public enum AggerateMode
|
||||
{
|
||||
Append,
|
||||
Reset
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,7 @@ public class Cache<TKey, TValue>(IComparer<TKey> comparer) :
|
||||
notnull
|
||||
{
|
||||
private readonly List<KeyValuePair<TKey, TValue?>> items = [];
|
||||
|
||||
public TValue? this[TKey key]
|
||||
{
|
||||
get
|
||||
@@ -108,6 +109,7 @@ public class Cache<TKey, TValue>(IComparer<TKey> comparer) :
|
||||
|
||||
items.Insert(index, new KeyValuePair<TKey, TValue?>(key, value));
|
||||
}
|
||||
|
||||
public void Clear() => items.Clear();
|
||||
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() =>
|
||||
|
||||
@@ -7,4 +7,4 @@ public record Cancel
|
||||
|
||||
public static CancelEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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,
|
||||
Action<IComponentBuilder> builderDelegate)
|
||||
Action<IComponentBuilder> builderDelegate)
|
||||
where TComponent : class, IComponent
|
||||
{
|
||||
if (provider.GetRequiredService<IServiceFactory>() is IServiceFactory factory)
|
||||
@@ -23,7 +23,7 @@ public class Component :
|
||||
|
||||
return factory.Create<TComponent>(builder);
|
||||
}
|
||||
return default ;
|
||||
return default;
|
||||
}
|
||||
|
||||
public virtual IComponentBuilder Create() => builder;
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace Toolkit.Foundation;
|
||||
|
||||
public class ComponentFactory(IServiceProvider provider,
|
||||
IProxyServiceCollection<IComponentBuilder> proxy,
|
||||
IComponentScopeCollection scopes) :
|
||||
IComponentScopeCollection scopes) :
|
||||
IComponentFactory
|
||||
{
|
||||
public IComponentHost? Create<TComponent, TConfiguration>(string name,
|
||||
TConfiguration configuration,
|
||||
TConfiguration configuration,
|
||||
Action<IServiceCollection>? servicesDelegate = null)
|
||||
where TComponent : IComponent
|
||||
where TConfiguration : ComponentConfiguration, new()
|
||||
@@ -56,4 +56,4 @@ public class ComponentFactory(IServiceProvider provider,
|
||||
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,14 +10,13 @@ public class ComponentHost(IServiceProvider services,
|
||||
{
|
||||
public IServiceProvider Services => services;
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
public TConfiguration? GetConfiguration<TConfiguration>() where TConfiguration : ComponentConfiguration
|
||||
{
|
||||
return Services.GetService<TConfiguration>();
|
||||
return Services.GetService<TConfiguration>();
|
||||
}
|
||||
|
||||
public async Task StartAsync(CancellationToken cancellationToken = default)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ConfirmEventArgs<TValue>(TValue Value);
|
||||
public record ConfirmEventArgs<TValue>(TValue Value);
|
||||
@@ -1,3 +1,3 @@
|
||||
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() =>
|
||||
new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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>() where TValue : new() => new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record DeactivatedEventArgs<TValue>(TValue? Value = default);
|
||||
public record DeactivatedEventArgs<TValue>(TValue? Value = default);
|
||||
@@ -1,3 +1,3 @@
|
||||
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() =>
|
||||
new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public class HandlerProvider(SubscriptionCollection subscriptions) :
|
||||
public class HandlerProvider(SubscriptionCollection subscriptions) :
|
||||
IHandlerProvider
|
||||
{
|
||||
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>
|
||||
{
|
||||
Task Activated(TResult result);
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface IAggerate
|
||||
{
|
||||
object? Key { get; init; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface IDecryptor
|
||||
{
|
||||
bool TryDecrypt(byte[] cipher,
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface IDisposerRequired
|
||||
{
|
||||
IDisposer Disposer { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface IHandlerProvider
|
||||
{
|
||||
IEnumerable<object?> Get(Type type,
|
||||
IEnumerable<object?> Get(Type type,
|
||||
object? key = null);
|
||||
}
|
||||
@@ -153,4 +153,4 @@ public static class IHostBuilderExtension
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface IKeyDeriver
|
||||
{
|
||||
byte[] DeriveKey(byte[] phrased,
|
||||
byte[] salt,
|
||||
int keySize = 32,
|
||||
byte[] salt,
|
||||
int keySize = 32,
|
||||
int iterations = 10000);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface IKeyGenerator
|
||||
{
|
||||
byte[] Generate(int size);
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
|
||||
namespace Toolkit.Foundation
|
||||
namespace Toolkit.Foundation
|
||||
{
|
||||
public interface IMediator
|
||||
{
|
||||
Task<object?> Handle(object message,
|
||||
Task<object?> Handle(object message,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<TResponse?> Handle<TMessage, TResponse>(TMessage message,
|
||||
CancellationToken cancellationToken = default)
|
||||
Task<TResponse?> Handle<TMessage, TResponse>(TMessage message,
|
||||
CancellationToken cancellationToken = default)
|
||||
where TMessage : notnull;
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface IMediatorRequired
|
||||
{
|
||||
IMediator Mediator { get; }
|
||||
}
|
||||
}
|
||||
@@ -4,4 +4,4 @@ public interface INavigationRegion
|
||||
{
|
||||
void Register(string name,
|
||||
object target);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
public interface INavigationScope
|
||||
{
|
||||
void Navigate(string route,
|
||||
void Navigate(string route,
|
||||
object? sender = null,
|
||||
object? region = null,
|
||||
EventHandler? navigated = null,
|
||||
EventHandler? navigated = null,
|
||||
object[]? parameters = null);
|
||||
|
||||
void Back(object? region);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface IPasswordHasher
|
||||
{
|
||||
string HashPassword(string password, int iterations = 10000);
|
||||
|
||||
@@ -11,7 +11,7 @@ public interface IPublisher
|
||||
void Publish<TMessage>(TMessage message,
|
||||
object key)
|
||||
where TMessage : notnull;
|
||||
|
||||
|
||||
void Publish(object message,
|
||||
Func<Func<Task>, Task> marshal,
|
||||
object? key = null);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface IPublisherRequired
|
||||
{
|
||||
IPublisher Publisher { get; }
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface IServiceFactoryRequired
|
||||
{
|
||||
IServiceFactory Factory { get; }
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface IServiceProviderRequired
|
||||
{
|
||||
IServiceProvider Provider { get; }
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface ISubscriptionRequired
|
||||
{
|
||||
ISubscription Subscription { get; }
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@
|
||||
public interface IValueInvoker<TValue>
|
||||
{
|
||||
public void Invoke(TValue args);
|
||||
}
|
||||
}
|
||||
@@ -5,4 +5,4 @@ public interface IValueStore<T>
|
||||
T? Value { get; }
|
||||
|
||||
void Set(T value);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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;
|
||||
|
||||
public class KeyDeriver :
|
||||
public class KeyDeriver :
|
||||
IKeyDeriver
|
||||
{
|
||||
public byte[] DeriveKey(byte[] phrase,
|
||||
byte[] salt,
|
||||
int keySize = 32,
|
||||
public byte[] DeriveKey(byte[] phrase,
|
||||
byte[] salt,
|
||||
int keySize = 32,
|
||||
int iterations = 100000)
|
||||
{
|
||||
using Rfc2898DeriveBytes pbkdf2 = new(phrase, salt, iterations, HashAlgorithmName.SHA256);
|
||||
return pbkdf2.GetBytes(keySize);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public class KeyGenerator :
|
||||
public class KeyGenerator :
|
||||
IKeyGenerator
|
||||
{
|
||||
public byte[] Generate(int size)
|
||||
@@ -12,4 +12,4 @@ public class KeyGenerator :
|
||||
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class Mediator(IHandlerProvider handlerProvider,
|
||||
{
|
||||
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 })!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@ public record Modified
|
||||
{
|
||||
public static ModifiedEventArgs<TValue> As<TValue>(TValue oldValue, TValue newValue) =>
|
||||
new(oldValue, newValue);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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;
|
||||
|
||||
public record MoveEventArgs<TValue>(int Index, TValue Value);
|
||||
public record MoveEventArgs<TValue>(int Index, TValue Value);
|
||||
@@ -1,3 +1,3 @@
|
||||
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);
|
||||
navigationScope = descriptor?.Services?.GetRequiredService<INavigationScope>();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.Data.SqlTypes;
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
@@ -11,8 +10,8 @@ public class NavigationScope(IPublisher publisher,
|
||||
IContentTemplateDescriptorProvider contentTemplateDescriptorProvider) :
|
||||
INavigationScope
|
||||
{
|
||||
public void Navigate(string route,
|
||||
object? sender = null,
|
||||
public void Navigate(string route,
|
||||
object? sender = null,
|
||||
object? region = null,
|
||||
EventHandler? navigated = null,
|
||||
object[]? parameters = null)
|
||||
@@ -57,6 +56,7 @@ public class NavigationScope(IPublisher publisher,
|
||||
case "self":
|
||||
region = view;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (navigationRegionProvider.TryGet(region, out object? value))
|
||||
{
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
public class NotificationAttribute(object key) : Attribute
|
||||
{
|
||||
public object Key => key;
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,4 @@ public class Notify
|
||||
|
||||
public static NotifyEventArgs<TValue> As<TValue>() where TValue : new() =>
|
||||
new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
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];
|
||||
|
||||
bool selected = false;
|
||||
if (item is ISelectable selectable)
|
||||
{
|
||||
selected = selectable.Selected;
|
||||
|
||||
SelectedItem = default;
|
||||
SelectedIndex = -1;
|
||||
}
|
||||
|
||||
RemoveItem(oldIndex);
|
||||
Insert(newIndex, item);
|
||||
|
||||
if (selected)
|
||||
{
|
||||
SelectedIndex = newIndex;
|
||||
SelectedItem = item;
|
||||
|
||||
if (item is ISelectable selectable2)
|
||||
{
|
||||
selectable2.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -493,14 +513,6 @@ public partial class ObservableCollection<TItem> :
|
||||
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,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public class PasswordHasher :
|
||||
public class PasswordHasher :
|
||||
IPasswordHasher
|
||||
{
|
||||
private const int SaltSize = 16;
|
||||
@@ -16,4 +16,4 @@ public class PasswordHasher :
|
||||
|
||||
return $"{Convert.ToBase64String(salt)}:{Convert.ToBase64String(hash)}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class Publisher(IHandlerProvider handlerProvider,
|
||||
Publish(message, async args => await args(), null);
|
||||
|
||||
public void Publish<TMessage>(TMessage message, object key)
|
||||
where TMessage : notnull =>
|
||||
where TMessage : notnull =>
|
||||
Publish(message, async args => await args(), key);
|
||||
|
||||
public void Publish(object message,
|
||||
@@ -59,7 +59,7 @@ public class Publisher(IHandlerProvider handlerProvider,
|
||||
Publish(new TMessage(), async args => await args(), null);
|
||||
|
||||
public void PublishUI<TMessage>(object key)
|
||||
where TMessage : new() =>
|
||||
where TMessage : new() =>
|
||||
Publish(new TMessage(), args => dispatcher.Invoke(async () => await args()), key);
|
||||
|
||||
public void PublishUI<TMessage>(TMessage message)
|
||||
|
||||
@@ -4,4 +4,4 @@ public record RemoveAt
|
||||
{
|
||||
public static RemoveAtEventArgs<TValue> As<TValue>(int index) =>
|
||||
new(index);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record RemoveAtEventArgs<TValue>(int Index);
|
||||
public record RemoveAtEventArgs<TValue>(int Index);
|
||||
@@ -1,3 +1,3 @@
|
||||
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() =>
|
||||
new(new TValue());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record RequestEventArgs<TValue>(TValue Value);
|
||||
public record RequestEventArgs<TValue>(TValue Value);
|
||||
@@ -1,3 +1,3 @@
|
||||
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,
|
||||
string key)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.3.24172.9" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.1-preview.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.4.24266.19" />
|
||||
<PackageReference Include="System.Reactive" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
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 void Set(T value) => Value = value;
|
||||
}
|
||||
}
|
||||
@@ -9,4 +9,4 @@ public class AttachedBehaviour : Trigger
|
||||
Interaction.ExecuteActions(AssociatedObject, Actions, null);
|
||||
base.OnAttachedToVisualTree();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,14 +21,13 @@ public class AttachedEventTriggerBehaviour : Trigger
|
||||
{
|
||||
if (AssociatedObject is Interactive interactive)
|
||||
{
|
||||
interactive.AddHandler(RoutedEvent, (object sender, RoutedEventArgs args) => {
|
||||
|
||||
interactive.AddHandler(RoutedEvent, (object sender, RoutedEventArgs args) =>
|
||||
{
|
||||
Interaction.ExecuteActions(AssociatedObject, Actions, null);
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
base.OnAttached();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,4 +43,4 @@ public class InvokeNavigationViewItemAction :
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
namespace Toolkit.UI.Avalonia;
|
||||
|
||||
public class ItemInvokedEventArgs :
|
||||
public class ItemInvokedEventArgs :
|
||||
RoutedEventArgs
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,19 +21,20 @@ public class NavigateRegionAction :
|
||||
|
||||
[Content]
|
||||
public ActionCollection Actions => actions ??= [];
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => GetValue(NameProperty);
|
||||
set => SetValue(NameProperty, value);
|
||||
}
|
||||
|
||||
public object? Execute(object? sender,
|
||||
public object? Execute(object? sender,
|
||||
object? parameter)
|
||||
{
|
||||
if (sender is Control control)
|
||||
{
|
||||
if (control.DataContext is IObservableViewModel observableViewModel)
|
||||
{
|
||||
{
|
||||
if (observableViewModel.Provider.GetRequiredService<INavigationRegion>() is INavigationRegion navigationRegion)
|
||||
{
|
||||
navigationRegion.Register(Name, sender);
|
||||
@@ -44,4 +45,4 @@ public class NavigateRegionAction :
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ public class NavigationViewItemExtension
|
||||
AvaloniaProperty.RegisterAttached<NavigationViewItem, bool>("IsItemClickEnabled",
|
||||
typeof(NavigationViewItemExtension), false);
|
||||
|
||||
public static readonly RoutedEvent<ItemInvokedEventArgs> ItemClickEvent =
|
||||
RoutedEvent.Register<ItemInvokedEventArgs>("ItemClick",
|
||||
public static readonly RoutedEvent<ItemInvokedEventArgs> ItemClickEvent =
|
||||
RoutedEvent.Register<ItemInvokedEventArgs>("ItemClick",
|
||||
RoutingStrategies.Bubble, typeof(NavigationViewItemExtension));
|
||||
|
||||
static NavigationViewItemExtension()
|
||||
@@ -20,7 +20,7 @@ public class NavigationViewItemExtension
|
||||
IsItemClickEnabledProperty.Changed.AddClassHandler<NavigationViewItem>(OnIsItemClickEnabledPropertyChanged);
|
||||
}
|
||||
|
||||
private static void OnIsItemClickEnabledPropertyChanged(NavigationViewItem sender,
|
||||
private static void OnIsItemClickEnabledPropertyChanged(NavigationViewItem sender,
|
||||
AvaloniaPropertyChangedEventArgs args)
|
||||
{
|
||||
bool TrySetupNavigationView()
|
||||
@@ -43,7 +43,7 @@ public class NavigationViewItemExtension
|
||||
}
|
||||
|
||||
if (!TrySetupNavigationView())
|
||||
{
|
||||
{
|
||||
void OnAttachedToVisualTree(object? _, VisualTreeAttachmentEventArgs __)
|
||||
{
|
||||
sender.AttachedToVisualTree -= OnAttachedToVisualTree;
|
||||
@@ -57,12 +57,12 @@ public class NavigationViewItemExtension
|
||||
public static bool GetIsItemClickEnabled(NavigationViewItem element) =>
|
||||
element.GetValue(IsItemClickEnabledProperty);
|
||||
|
||||
public static void SetIsItemClickEnabled(NavigationViewItem element, bool value) =>
|
||||
public static void SetIsItemClickEnabled(NavigationViewItem element, bool 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);
|
||||
|
||||
public static void RemoveItemClickHandler(NavigationViewItem element, EventHandler<ItemInvokedEventArgs> 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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class BitmapIconSource : FluentAvalonia.UI.Controls.BitmapIconSource
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
||||
get => GetValue(ContentProperty);
|
||||
set => SetValue(ContentProperty, value);
|
||||
}
|
||||
|
||||
public IDataTemplate? IconTemplate
|
||||
{
|
||||
get => GetValue(ContentTemplateProperty);
|
||||
@@ -36,7 +37,6 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
||||
}
|
||||
|
||||
return base.MeasureOverride(availableSize);
|
||||
|
||||
}
|
||||
|
||||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs args)
|
||||
@@ -58,6 +58,7 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
||||
|
||||
base.OnDetachedFromLogicalTree(args);
|
||||
}
|
||||
|
||||
private void CreateContent()
|
||||
{
|
||||
content = new ContentControl();
|
||||
@@ -68,4 +69,4 @@ public class ContentIcon : FluentAvalonia.UI.Controls.FAIconElement
|
||||
LogicalChildren.Add(content);
|
||||
VisualChildren.Add(content);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,10 @@ public class ContentIconSource : FluentAvalonia.UI.Controls.IconSource
|
||||
get => GetValue(ContentProperty);
|
||||
set => SetValue(ContentProperty, value);
|
||||
}
|
||||
|
||||
public IDataTemplate? IconTemplate
|
||||
{
|
||||
get => GetValue(ContentTemplateProperty);
|
||||
set => SetValue(ContentTemplateProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class FAIconElement : FluentAvalonia.UI.Controls.FAIconElement
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class FAPathIcon : FluentAvalonia.UI.Controls.FAPathIcon
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class FontIcon : FluentAvalonia.UI.Controls.FontIcon
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
namespace Kromek.UI.Avalonia.Controls
|
||||
{
|
||||
|
||||
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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class ImageIcon : FluentAvalonia.UI.Controls.ImageIcon
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class ImageIconSource : FluentAvalonia.UI.Controls.ImageIconSource
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,5 @@
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.LogicalTree;
|
||||
using Avalonia.Metadata;
|
||||
using Avalonia;
|
||||
|
||||
namespace Toolkit.UI.Controls.Avalonia;
|
||||
namespace Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
public class PathIconSource : FluentAvalonia.UI.Controls.PathIconSource
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class SymbolIcon : FluentAvalonia.UI.Controls.SymbolIcon
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
public class SymbolIconSource : FluentAvalonia.UI.Controls.SymbolIconSource
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Kromek.UI.Avalonia.Controls;
|
||||
using System;
|
||||
|
||||
namespace Toolkit.UI.Controls.Avalonia;
|
||||
|
||||
@@ -157,7 +155,6 @@ public class PersonPicture : TemplatedControl
|
||||
|
||||
if (change.Property == ProfilePictureProperty)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,6 +294,7 @@ public class PersonPicture : TemplatedControl
|
||||
PseudoClasses.Set(":NoBadge", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateBadgeNumber()
|
||||
{
|
||||
if (badgingEllipse == null || badgeNumberTextBlock == null)
|
||||
@@ -322,6 +320,7 @@ public class PersonPicture : TemplatedControl
|
||||
badgeNumberTextBlock.Text = "99+";
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDisplayName()
|
||||
{
|
||||
displayNameInitials = PersonPictureInitialsGenerator.InitialsFromDisplayName(DisplayName);
|
||||
@@ -376,4 +375,4 @@ public class PersonPicture : TemplatedControl
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,4 @@ internal enum PersonPictureCharacterType
|
||||
Standard = 1,
|
||||
Symbolic = 2,
|
||||
Glyph = 3
|
||||
}
|
||||
}
|
||||
@@ -22,18 +22,21 @@ internal class PersonPictureInitialsGenerator
|
||||
case PersonPictureCharacterType.Glyph:
|
||||
result = PersonPictureCharacterType.Glyph;
|
||||
break;
|
||||
|
||||
case PersonPictureCharacterType.Symbolic:
|
||||
if (result != PersonPictureCharacterType.Glyph)
|
||||
{
|
||||
result = PersonPictureCharacterType.Symbolic;
|
||||
}
|
||||
break;
|
||||
|
||||
case PersonPictureCharacterType.Standard:
|
||||
if ((result != PersonPictureCharacterType.Glyph) && (result != PersonPictureCharacterType.Symbolic))
|
||||
{
|
||||
result = PersonPictureCharacterType.Standard;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -44,7 +47,6 @@ internal class PersonPictureInitialsGenerator
|
||||
|
||||
public static PersonPictureCharacterType GetCharacterType(char character)
|
||||
{
|
||||
|
||||
// IPA Extensions
|
||||
if ((character >= 0x0250) && (character <= 0x02AF))
|
||||
{
|
||||
@@ -147,7 +149,7 @@ internal class PersonPictureInitialsGenerator
|
||||
{
|
||||
return PersonPictureCharacterType.Symbolic;
|
||||
}
|
||||
// CJK Unified Ideographs Extension
|
||||
// CJK Unified Ideographs Extension
|
||||
if ((character >= 0x3400) && (character <= 0x4DBF))
|
||||
{
|
||||
return PersonPictureCharacterType.Symbolic;
|
||||
@@ -317,6 +319,7 @@ internal class PersonPictureInitialsGenerator
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetFirstFullCharacter(string str)
|
||||
{
|
||||
int start = 0;
|
||||
@@ -385,6 +388,7 @@ internal class PersonPictureInitialsGenerator
|
||||
|
||||
return value.Substring(startIndex, length);
|
||||
}
|
||||
|
||||
private static string[] Split(string source, char delim, int maxIterations = 25)
|
||||
{
|
||||
return source.Split(new[] { delim }, maxIterations);
|
||||
@@ -412,4 +416,4 @@ internal class PersonPictureInitialsGenerator
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,6 @@ public class PersonPictureTemplateSettings : AvaloniaObject
|
||||
private static readonly StyledProperty<ImageBrush?> ActualImageBrushProperty =
|
||||
AvaloniaProperty.Register<PersonPictureTemplateSettings, ImageBrush?>(nameof(ActualImageBrush));
|
||||
|
||||
|
||||
private static readonly StyledProperty<string> ActualInitialsProperty =
|
||||
AvaloniaProperty.Register<PersonPictureTemplateSettings, string>(nameof(ActualInitials));
|
||||
|
||||
@@ -23,4 +22,4 @@ public class PersonPictureTemplateSettings : AvaloniaObject
|
||||
get => GetValue(ActualInitialsProperty);
|
||||
set => SetValue(ActualInitialsProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,4 +333,4 @@ namespace Toolkit.UI.Controls.Avalonia
|
||||
return totalSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,4 +33,4 @@ namespace Toolkit.UI.Controls.Avalonia
|
||||
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