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.
40 lines
1.1 KiB
40 lines
1.1 KiB
12 months ago
|
using System;
|
||
|
using System.Drawing;
|
||
|
using Avalonia.Controls;
|
||
|
using Avalonia.Controls.Primitives;
|
||
|
using DynamicData.Binding;
|
||
|
using StabilityMatrix.Avalonia.ViewModels.Inference;
|
||
|
using StabilityMatrix.Core.Attributes;
|
||
1 year ago
|
|
||
1 year ago
|
namespace StabilityMatrix.Avalonia.Controls;
|
||
|
|
||
|
[Transient]
|
||
12 months ago
|
public class SelectImageCard : DropTargetTemplatedControlBase
|
||
|
{
|
||
|
/// <inheritdoc />
|
||
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||
|
{
|
||
|
base.OnApplyTemplate(e);
|
||
|
|
||
|
if (DataContext is not SelectImageCardViewModel vm)
|
||
|
return;
|
||
|
|
||
|
if (e.NameScope.Find<BetterAdvancedImage>("PART_BetterAdvancedImage") is not { } image)
|
||
|
return;
|
||
|
|
||
|
image
|
||
|
.WhenPropertyChanged(x => x.CurrentImage)
|
||
|
.Subscribe(propertyValue =>
|
||
|
{
|
||
|
if (propertyValue.Value?.Size is { } size)
|
||
|
{
|
||
|
vm.CurrentBitmapSize = new Size(Convert.ToInt32(size.Width), Convert.ToInt32(size.Height));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
vm.CurrentBitmapSize = Size.Empty;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|