Browse Source

Add ImageViewerDialog

pull/165/head
Ionite 1 year ago
parent
commit
942ee35fbb
No known key found for this signature in database
  1. 3
      StabilityMatrix.Avalonia/App.axaml.cs
  2. 4
      StabilityMatrix.Avalonia/DesignData/DesignData.cs
  3. 14
      StabilityMatrix.Avalonia/ViewModels/Dialogs/ImageViewerViewModel.cs
  4. 30
      StabilityMatrix.Avalonia/Views/Dialogs/ImageViewerDialog.axaml
  5. 18
      StabilityMatrix.Avalonia/Views/Dialogs/ImageViewerDialog.axaml.cs

3
StabilityMatrix.Avalonia/App.axaml.cs

@ -248,6 +248,7 @@ public sealed class App : Application
services.AddTransient<LaunchOptionsViewModel>(); services.AddTransient<LaunchOptionsViewModel>();
services.AddTransient<ExceptionViewModel>(); services.AddTransient<ExceptionViewModel>();
services.AddTransient<EnvVarsViewModel>(); services.AddTransient<EnvVarsViewModel>();
services.AddTransient<ImageViewerViewModel>();
services.AddSingleton<FirstLaunchSetupViewModel>(); services.AddSingleton<FirstLaunchSetupViewModel>();
services.AddSingleton<UpdateViewModel>(); services.AddSingleton<UpdateViewModel>();
@ -303,6 +304,7 @@ public sealed class App : Application
.Register(provider.GetRequiredService<UpscalerCardViewModel>) .Register(provider.GetRequiredService<UpscalerCardViewModel>)
.Register(provider.GetRequiredService<ModelCardViewModel>) .Register(provider.GetRequiredService<ModelCardViewModel>)
.Register(provider.GetRequiredService<BatchSizeCardViewModel>) .Register(provider.GetRequiredService<BatchSizeCardViewModel>)
.Register(provider.GetRequiredService<ImageViewerViewModel>)
.Register(provider.GetRequiredService<FirstLaunchSetupViewModel>)); .Register(provider.GetRequiredService<FirstLaunchSetupViewModel>));
} }
@ -338,6 +340,7 @@ public sealed class App : Application
services.AddTransient<UpdateDialog>(); services.AddTransient<UpdateDialog>();
services.AddTransient<ExceptionDialog>(); services.AddTransient<ExceptionDialog>();
services.AddTransient<EnvVarsDialog>(); services.AddTransient<EnvVarsDialog>();
services.AddTransient<ImageViewerDialog>();
// Controls // Controls
services.AddTransient<RefreshBadge>(); services.AddTransient<RefreshBadge>();

4
StabilityMatrix.Avalonia/DesignData/DesignData.cs

@ -480,11 +480,15 @@ public static class DesignData
IsFiltering = true IsFiltering = true
}; };
list.CompletionData.AddRange(SampleCompletionData); list.CompletionData.AddRange(SampleCompletionData);
list.FilteredCompletionData.AddRange(list.CompletionData);
list.SelectItem("te", true); list.SelectItem("te", true);
return list; return list;
} }
} }
public static ImageViewerViewModel ImageViewerViewModel
=> DialogFactory.Get<ImageViewerViewModel>();
public static Indexer Types => new(); public static Indexer Types => new();
public class Indexer public class Indexer

14
StabilityMatrix.Avalonia/ViewModels/Dialogs/ImageViewerViewModel.cs

@ -0,0 +1,14 @@
using Avalonia.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Avalonia.Views.Dialogs;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Dialogs;
[View(typeof(ImageViewerDialog))]
public partial class ImageViewerViewModel : ViewModelBase
{
[ObservableProperty]
private Bitmap? image;
}

30
StabilityMatrix.Avalonia/Views/Dialogs/ImageViewerDialog.axaml

@ -0,0 +1,30 @@
<controls:UserControlBase xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:StabilityMatrix.Avalonia.ViewModels"
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:mocks="clr-namespace:StabilityMatrix.Avalonia.DesignData"
xmlns:controls="clr-namespace:StabilityMatrix.Avalonia.Controls"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:vmDialogs="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Dialogs"
d:DataContext="{x:Static mocks:DesignData.ImageViewerViewModel}"
x:DataType="vmDialogs:ImageViewerViewModel"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="StabilityMatrix.Avalonia.Views.Dialogs.ImageViewerDialog">
<Grid>
<controls:AdvancedImageBox
Name="MainImageBox"
RenderOptions.BitmapInterpolationMode="None"
Image="{Binding Image}"/>
<!-- The preview tracker -->
<Image
MinHeight="100"
MinWidth="100"
RenderOptions.BitmapInterpolationMode="HighQuality"
Source="{Binding #MainImageBox.TrackerImage}"
HorizontalAlignment="Left"
VerticalAlignment="Bottom"/>
</Grid>
</controls:UserControlBase>

18
StabilityMatrix.Avalonia/Views/Dialogs/ImageViewerDialog.axaml.cs

@ -0,0 +1,18 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace StabilityMatrix.Avalonia.Views.Dialogs;
public partial class ImageViewerDialog : UserControl
{
public ImageViewerDialog()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
}
Loading…
Cancel
Save