Multi-Platform Package Manager for Stable Diffusion
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Avalonia.Controls;
|
|
|
|
using Avalonia.Controls.Primitives;
|
|
|
|
using Avalonia.Media.Imaging;
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
using FluentAvalonia.UI.Controls;
|
|
|
|
using StabilityMatrix.Avalonia.Helpers;
|
|
|
|
using StabilityMatrix.Core.Helper;
|
|
|
|
|
|
|
|
namespace StabilityMatrix.Avalonia.Controls;
|
|
|
|
|
|
|
|
public partial class AdvancedImageBoxView : UserControl
|
|
|
|
{
|
|
|
|
public AdvancedImageBoxView()
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
|
|
|
{
|
|
|
|
base.OnApplyTemplate(e);
|
|
|
|
|
|
|
|
if (this.FindControl<MenuFlyoutItem>("CopyMenuItem") is { } copyMenuItem)
|
|
|
|
{
|
|
|
|
copyMenuItem.Command = new AsyncRelayCommand<Bitmap?>(FlyoutCopy);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static async Task FlyoutCopy(Bitmap? image)
|
|
|
|
{
|
|
|
|
if (image is null || !Compat.IsWindows)
|
|
|
|
return;
|
|
|
|
|
|
|
|
await Task.Run(() =>
|
|
|
|
{
|
|
|
|
if (Compat.IsWindows)
|
|
|
|
{
|
|
|
|
WindowsClipboard.SetBitmap(image);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|