Browse Source

Add SelectImageCard Control

pull/165/head
Ionite 1 year ago
parent
commit
c20e062a1c
No known key found for this signature in database
  1. 1
      StabilityMatrix.Avalonia/App.axaml
  2. 3
      StabilityMatrix.Avalonia/App.axaml.cs
  3. 105
      StabilityMatrix.Avalonia/Controls/SelectImageCard.axaml
  4. 7
      StabilityMatrix.Avalonia/Controls/SelectImageCard.axaml.cs
  5. 365
      StabilityMatrix.Avalonia/DesignData/DesignData.cs
  6. 20
      StabilityMatrix.Avalonia/ViewModels/Inference/SelectImageCardViewModel.cs

1
StabilityMatrix.Avalonia/App.axaml

@ -45,5 +45,6 @@
<StyleInclude Source="Controls/AdvancedImageBox.axaml"/>
<StyleInclude Source="Controls/FrameCarousel.axaml"/>
<StyleInclude Source="Controls/CodeCompletion/CompletionWindow.axaml"/>
<StyleInclude Source="Controls/SelectImageCard.axaml"/>
</Application.Styles>
</Application>

3
StabilityMatrix.Avalonia/App.axaml.cs

@ -307,6 +307,7 @@ public sealed class App : Application
services.AddTransient<StackExpanderViewModel>();
services.AddTransient<ModelCardViewModel>();
services.AddTransient<BatchSizeCardViewModel>();
services.AddTransient<SelectImageCardViewModel>();
// Dialog factory
services.AddSingleton<ServiceManager<ViewModelBase>>(
@ -339,6 +340,7 @@ public sealed class App : Application
.Register(provider.GetRequiredService<ImageViewerViewModel>)
.Register(provider.GetRequiredService<FirstLaunchSetupViewModel>)
.Register(provider.GetRequiredService<PackageImportViewModel>)
.Register(provider.GetRequiredService<SelectImageCardViewModel>)
);
}
@ -367,6 +369,7 @@ public sealed class App : Application
services.AddTransient<UpscalerCard>();
services.AddTransient<ModelCard>();
services.AddTransient<BatchSizeCard>();
services.AddTransient<SelectImageCard>();
services.AddSingleton<NewCheckpointsPage>();
// Dialogs

105
StabilityMatrix.Avalonia/Controls/SelectImageCard.axaml

@ -0,0 +1,105 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ui="using:FluentAvalonia.UI.Controls"
xmlns:controls="using:StabilityMatrix.Avalonia.Controls"
xmlns:mocks="using:StabilityMatrix.Avalonia.DesignData"
xmlns:vmInference="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Inference"
x:DataType="vmInference:SelectImageCardViewModel">
<Design.PreviewWith>
<Panel Width="600" Height="500">
<Grid ColumnDefinitions="*,*" MaxHeight="400">
<controls:SelectImageCard
Margin="4"
DataContext="{x:Static mocks:DesignData.SelectImageCardViewModel}" />
<controls:SelectImageCard
Grid.Column="1"
Margin="4"
DataContext="{x:Static mocks:DesignData.SelectImageCardViewModel_WithImage}" />
</Grid>
</Panel>
</Design.PreviewWith>
<Styles.Resources>
<ExperimentalAcrylicMaterial
x:Key="AcrylicMaterial"
FallbackColor="{DynamicResource ThemeBackgroundColor}"
TintColor="Black"
TintOpacity="0.78"
MaterialOpacity="0.9"
BackgroundSource="Digger" />
</Styles.Resources>
<Style Selector="controls|SelectImageCard">
<!-- Set Defaults -->
<Setter Property="Template">
<ControlTemplate>
<controls:Card
Padding="12"
VerticalContentAlignment="{TemplateBinding VerticalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}">
<!-- Background frame -->
<ExperimentalAcrylicBorder
VerticalAlignment="Stretch"
Material="{StaticResource AcrylicMaterial}"
CornerRadius="4">
<Panel>
<!-- Image -->
<controls:BetterAdvancedImage
CornerRadius="4"
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
IsVisible="{Binding !IsSelectionAvailable}"
Source="{Binding ImageSource.RemoteUrl}"/>
<!-- Selection Prompt -->
<controls:LineDashFrame
IsVisible="{Binding IsSelectionAvailable}"
Stroke="DimGray"
StrokeThickness="3"
StrokeDashLine="6"
StrokeDashSpace="6">
<Grid
Cursor="Hand"
RowDefinitions="*,Auto,Auto"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<ui:SymbolIcon
FontSize="28"
Symbol="ImageCopyFilled"/>
<TextBlock
Grid.Row="1"
Text="Drag an image here"
Foreground="DarkGray">
</TextBlock>
<StackPanel
Grid.Row="2"
Margin="0,4,0,0"
HorizontalAlignment="Center"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Foreground="DarkGray"
Text="or"/>
<Button
Content="Browse"
Margin="4,0"
Padding="4"/>
</StackPanel>
</Grid>
</controls:LineDashFrame>
</Panel>
</ExperimentalAcrylicBorder>
</controls:Card>
</ControlTemplate>
</Setter>
</Style>
</Styles>

7
StabilityMatrix.Avalonia/Controls/SelectImageCard.axaml.cs

@ -0,0 +1,7 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
namespace StabilityMatrix.Avalonia.Controls;
public class SelectImageCard : TemplatedControl { }

365
StabilityMatrix.Avalonia/DesignData/DesignData.cs

@ -36,7 +36,8 @@ namespace StabilityMatrix.Avalonia.DesignData;
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
public static class DesignData
{
[NotNull] public static IServiceProvider? Services { get; set; }
[NotNull]
public static IServiceProvider? Services { get; set; }
private static bool isInitialized;
@ -50,38 +51,42 @@ public static class DesignData
var services = new ServiceCollection();
var activePackageId = Guid.NewGuid();
services.AddSingleton<ISettingsManager, MockSettingsManager>(_ => new MockSettingsManager
{
Settings =
{
InstalledPackages = new List<InstalledPackage>
services.AddSingleton<ISettingsManager, MockSettingsManager>(
_ =>
new MockSettingsManager
{
new()
{
Id = activePackageId,
DisplayName = "My Installed Package",
DisplayVersion = "v1.0.0",
PackageName = "stable-diffusion-webui",
PackageVersion = "v1.0.0",
LibraryPath = $"Packages{Path.DirectorySeparatorChar}example-webui",
LastUpdateCheck = DateTimeOffset.Now
},
new()
Settings =
{
Id = Guid.NewGuid(),
DisplayName = "Comfy Diffusion WebUI Dev Branch Long Name",
PackageName = "ComfyUI",
DisplayVersion = "main@ab73d4a",
LibraryPath = $"Packages{Path.DirectorySeparatorChar}example-webui",
LastUpdateCheck = DateTimeOffset.Now
InstalledPackages = new List<InstalledPackage>
{
new()
{
Id = activePackageId,
DisplayName = "My Installed Package",
DisplayVersion = "v1.0.0",
PackageName = "stable-diffusion-webui",
PackageVersion = "v1.0.0",
LibraryPath = $"Packages{Path.DirectorySeparatorChar}example-webui",
LastUpdateCheck = DateTimeOffset.Now
},
new()
{
Id = Guid.NewGuid(),
DisplayName = "Comfy Diffusion WebUI Dev Branch Long Name",
PackageName = "ComfyUI",
DisplayVersion = "main@ab73d4a",
LibraryPath = $"Packages{Path.DirectorySeparatorChar}example-webui",
LastUpdateCheck = DateTimeOffset.Now
}
},
ActiveInstalledPackageId = activePackageId
}
},
ActiveInstalledPackageId = activePackageId
}
});
}
);
// General services
services.AddLogging()
services
.AddLogging()
.AddSingleton<INavigationService, NavigationService>()
.AddSingleton<IPackageFactory, PackageFactory>()
.AddSingleton<IUpdateHelper, UpdateHelper>()
@ -132,26 +137,31 @@ public static class DesignData
LaunchOptionsViewModel = Services.GetRequiredService<LaunchOptionsViewModel>();
LaunchOptionsViewModel.Cards = new[]
{
LaunchOptionCard.FromDefinition(new LaunchOptionDefinition
{
Name = "Host",
Type = LaunchOptionType.String,
Description = "The host name for the Web UI",
DefaultValue = "localhost",
Options = {"--host"}
}),
LaunchOptionCard.FromDefinition(new LaunchOptionDefinition
{
Name = "API",
Type = LaunchOptionType.Bool,
Options = {"--api"}
})
LaunchOptionCard.FromDefinition(
new LaunchOptionDefinition
{
Name = "Host",
Type = LaunchOptionType.String,
Description = "The host name for the Web UI",
DefaultValue = "localhost",
Options = { "--host" }
}
),
LaunchOptionCard.FromDefinition(
new LaunchOptionDefinition
{
Name = "API",
Type = LaunchOptionType.Bool,
Options = { "--api" }
}
)
};
LaunchOptionsViewModel.UpdateFilterCards();
InstallerViewModel = Services.GetRequiredService<InstallerViewModel>();
InstallerViewModel.AvailablePackages =
packageFactory.GetAllAvailablePackages().ToImmutableArray();
InstallerViewModel.AvailablePackages = packageFactory
.GetAllAvailablePackages()
.ToImmutableArray();
InstallerViewModel.SelectedPackage = InstallerViewModel.AvailablePackages[0];
InstallerViewModel.ReleaseNotes = "## Release Notes\nThis is a test release note.";
@ -168,8 +178,9 @@ public static class DesignData
{
FilePath = "~/Models/StableDiffusion/electricity-light.safetensors",
Title = "Auroral Background",
PreviewImagePath = "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/" +
"78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
PreviewImagePath =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/"
+ "78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
ConnectedModel = new ConnectedModelInfo
{
VersionName = "Lightning Auroral",
@ -184,11 +195,7 @@ public static class DesignData
}
}
},
new()
{
FilePath = "~/Models/Lora/model.safetensors",
Title = "Some model"
},
new() { FilePath = "~/Models/Lora/model.safetensors", Title = "Some model" },
},
},
new(settingsManager, downloadService, modelFinder)
@ -210,11 +217,7 @@ public static class DesignData
},
CheckpointFiles = new AdvancedObservableList<CheckpointFile>
{
new()
{
FilePath = "~/Models/Lora/lora_v2.pt",
Title = "Best Lora v2",
}
new() { FilePath = "~/Models/Lora/lora_v2.pt", Title = "Best Lora v2", }
}
}
};
@ -224,8 +227,8 @@ public static class DesignData
folder.DisplayedCheckpointFiles = folder.CheckpointFiles;
}
CheckpointBrowserViewModel.ModelCards = new
ObservableCollection<CheckpointBrowserCardViewModel>
CheckpointBrowserViewModel.ModelCards =
new ObservableCollection<CheckpointBrowserCardViewModel>
{
dialogFactory.Get<CheckpointBrowserCardViewModel>(vm =>
{
@ -243,8 +246,9 @@ public static class DesignData
{
FilePath = "~/Models/StableDiffusion/electricity-light.safetensors",
Title = "Auroral Background",
PreviewImagePath = "https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/" +
"78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
PreviewImagePath =
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/"
+ "78fd2a0a-42b6-42b0-9815-81cb11bb3d05/00009-2423234823.jpeg",
ConnectedModel = new ConnectedModelInfo
{
VersionName = "Lightning Auroral",
@ -259,19 +263,22 @@ public static class DesignData
}
}
},
new()
{
FilePath = "~/Models/Lora/model.safetensors",
Title = "Some model"
}
new() { FilePath = "~/Models/Lora/model.safetensors", Title = "Some model" }
};
ProgressManagerViewModel.ProgressItems.AddRange(new ProgressItemViewModelBase[]
{
new ProgressItemViewModel(new ProgressItem(Guid.NewGuid(), "Test File.exe",
new ProgressReport(0.5f, "Downloading..."))),
new MockDownloadProgressItemViewModel("Test File 2.exe"),
});
ProgressManagerViewModel.ProgressItems.AddRange(
new ProgressItemViewModelBase[]
{
new ProgressItemViewModel(
new ProgressItem(
Guid.NewGuid(),
"Test File.exe",
new ProgressReport(0.5f, "Downloading...")
)
),
new MockDownloadProgressItemViewModel("Test File 2.exe"),
}
);
UpdateViewModel = Services.GetRequiredService<UpdateViewModel>();
UpdateViewModel.UpdateText =
@ -282,9 +289,14 @@ public static class DesignData
isInitialized = true;
}
[NotNull] public static InstallerViewModel? InstallerViewModel { get; private set; }
[NotNull] public static LaunchOptionsViewModel? LaunchOptionsViewModel { get; private set; }
[NotNull] public static UpdateViewModel? UpdateViewModel { get; private set; }
[NotNull]
public static InstallerViewModel? InstallerViewModel { get; private set; }
[NotNull]
public static LaunchOptionsViewModel? LaunchOptionsViewModel { get; private set; }
[NotNull]
public static UpdateViewModel? UpdateViewModel { get; private set; }
public static ServiceManager<ViewModelBase> DialogFactory =>
Services.GetRequiredService<ServiceManager<ViewModelBase>>();
@ -306,13 +318,15 @@ public static class DesignData
var vm = Services.GetRequiredService<PackageManagerViewModel>();
vm.SetPackages(settings.Settings.InstalledPackages);
vm.SetUnknownPackages(new InstalledPackage[]
{
UnknownInstalledPackage.FromDirectoryName("sd-unknown-with-long-name"),
});
vm.SetUnknownPackages(
new InstalledPackage[]
{
UnknownInstalledPackage.FromDirectoryName("sd-unknown-with-long-name"),
}
);
vm.PackageCards[0].IsUpdateAvailable = true;
return vm;
}
}
@ -325,10 +339,10 @@ public static class DesignData
public static SettingsViewModel SettingsViewModel =>
Services.GetRequiredService<SettingsViewModel>();
public static InferenceSettingsViewModel InferenceSettingsViewModel =>
Services.GetRequiredService<InferenceSettingsViewModel>();
public static CheckpointBrowserViewModel CheckpointBrowserViewModel =>
Services.GetRequiredService<CheckpointBrowserViewModel>();
@ -341,7 +355,8 @@ public static class DesignData
new()
{
Name = "BB95 Furry Mix",
Description = @"Introducing SnoutMix
Description =
@"Introducing SnoutMix
A Mix of non-Furry and Furry models such as Furtastic and BB95Furry to create a great variety of anthro AI generation options, but bringing out more detail, still giving a lot of freedom to customise the human aspects, and having great backgrounds, with a focus on something more realistic. Works well with realistic character loras.
The gallery images are often inpainted, but you will get something very similar if copying their data directly. They are inpainted using the same model, therefore all results are possible without anything custom/hidden-away. Controlnet Tiled is applied to enhance them further afterwards. Gallery images were made with same model but before it was renamed",
BaseModel = "SD 1.5",
@ -368,19 +383,18 @@ The gallery images are often inpainted, but you will get something very similar
Fp = CivitModelFpType.fp32,
Size = CivitModelSize.full
},
Hashes = new CivitFileHashes
{
BLAKE3 = "ABCD"
}
Hashes = new CivitFileHashes { BLAKE3 = "ABCD" }
}
}
}
};
var sampleViewModel =
new ModelVersionViewModel(new HashSet<string> {"ABCD"}, sampleCivitVersions[0]);
var sampleViewModel = new ModelVersionViewModel(
new HashSet<string> { "ABCD" },
sampleCivitVersions[0]
);
// Sample data for dialogs
vm.Versions = new List<ModelVersionViewModel> {sampleViewModel};
vm.Versions = new List<ModelVersionViewModel> { sampleViewModel };
vm.Title = sampleCivitVersions[0].Name;
vm.Description = sampleCivitVersions[0].Description;
vm.SelectedVersionViewModel = sampleViewModel;
@ -388,7 +402,7 @@ The gallery images are often inpainted, but you will get something very similar
public static OneClickInstallViewModel OneClickInstallViewModel =>
Services.GetRequiredService<OneClickInstallViewModel>();
public static InferenceViewModel InferenceViewModel =>
Services.GetRequiredService<InferenceViewModel>();
@ -419,113 +433,115 @@ The gallery images are often inpainted, but you will get something very similar
}
});
public static EnvVarsViewModel EnvVarsViewModel => DialogFactory.Get<EnvVarsViewModel>(
viewModel =>
public static EnvVarsViewModel EnvVarsViewModel =>
DialogFactory.Get<EnvVarsViewModel>(viewModel =>
{
viewModel.EnvVars = new ObservableCollection<EnvVarKeyPair>
{
new("UWU", "TRUE"),
};
viewModel.EnvVars = new ObservableCollection<EnvVarKeyPair> { new("UWU", "TRUE"), };
});
public static InferenceTextToImageViewModel InferenceTextToImageViewModel =>
DialogFactory.Get<InferenceTextToImageViewModel>();
public static PackageImportViewModel PackageImportViewModel =>
DialogFactory.Get<PackageImportViewModel>();
public static RefreshBadgeViewModel RefreshBadgeViewModel => new()
{
State = ProgressState.Success
};
public static RefreshBadgeViewModel RefreshBadgeViewModel =>
new() { State = ProgressState.Success };
public static SeedCardViewModel SeedCardViewModel => new();
public static SamplerCardViewModel SamplerCardViewModel => DialogFactory.Get<SamplerCardViewModel>(vm =>
{
vm.Steps = 20;
vm.CfgScale = 7;
vm.IsDenoiseStrengthEnabled = false;
vm.IsDimensionsEnabled = true;
vm.SelectedSampler = new ComfySampler("euler");
});
public static SamplerCardViewModel SamplerCardViewModelScaleMode => DialogFactory.Get<SamplerCardViewModel>(vm =>
{
vm.Steps = 20;
vm.CfgScale = 7;
vm.SelectedSampler = new ComfySampler("euler");
vm.IsDimensionsEnabled = false;
vm.IsCfgScaleEnabled = false;
vm.IsSamplerSelectionEnabled = false;
vm.IsDenoiseStrengthEnabled = true;
});
public static SamplerCardViewModel SamplerCardViewModel =>
DialogFactory.Get<SamplerCardViewModel>(vm =>
{
vm.Steps = 20;
vm.CfgScale = 7;
vm.IsDenoiseStrengthEnabled = false;
vm.IsDimensionsEnabled = true;
vm.SelectedSampler = new ComfySampler("euler");
});
public static SamplerCardViewModel SamplerCardViewModelScaleMode =>
DialogFactory.Get<SamplerCardViewModel>(vm =>
{
vm.Steps = 20;
vm.CfgScale = 7;
vm.SelectedSampler = new ComfySampler("euler");
vm.IsDimensionsEnabled = false;
vm.IsCfgScaleEnabled = false;
vm.IsSamplerSelectionEnabled = false;
vm.IsDenoiseStrengthEnabled = true;
});
public static ModelCardViewModel ModelCardViewModel => DialogFactory.Get<ModelCardViewModel>();
public static ImageGalleryCardViewModel ImageGalleryCardViewModel =>
DialogFactory.Get<ImageGalleryCardViewModel>(vm =>
{
vm.ImageSources.AddRange(new ImageSource[]
{
new(new Uri("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4a7e00a7-6f18-42d4-87c0-10e792df2640/width=1152")),
new(new Uri("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a318ac1f-3ad0-48ac-98cc-79126febcc17/width=1024")),
new(new Uri("https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/16588c94-6595-4be9-8806-d7e6e22d198c/width=1152")),
});
vm.ImageSources.AddRange(
new ImageSource[]
{
new(
new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/4a7e00a7-6f18-42d4-87c0-10e792df2640/width=1152"
)
),
new(
new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a318ac1f-3ad0-48ac-98cc-79126febcc17/width=1024"
)
),
new(
new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/16588c94-6595-4be9-8806-d7e6e22d198c/width=1152"
)
),
}
);
});
public static PromptCardViewModel PromptCardViewModel =>
DialogFactory.Get<PromptCardViewModel>(vm =>
{
vm.PromptDocument.Text = "house, (high quality), [example], BREAK\n\n<lora:details:0.8>";
vm.PromptDocument.Text =
"house, (high quality), [example], BREAK\n\n<lora:details:0.8>";
vm.NegativePromptDocument.Text = "blurry, jpeg artifacts";
});
public static StackCardViewModel StackCardViewModel =>
DialogFactory.Get<StackCardViewModel>(vm =>
{
vm.AddCards(new LoadableViewModelBase[]
{
SamplerCardViewModel,
SeedCardViewModel,
});
vm.AddCards(new LoadableViewModelBase[] { SamplerCardViewModel, SeedCardViewModel, });
});
public static StackExpanderViewModel StackExpanderViewModel =>
DialogFactory.Get<StackExpanderViewModel>(vm =>
{
vm.Title = "Hires Fix";
vm.AddCards(new LoadableViewModelBase[]
{
SamplerCardViewModel,
SeedCardViewModel,
});
vm.AddCards(new LoadableViewModelBase[] { SamplerCardViewModel, SeedCardViewModel, });
});
public static UpscalerCardViewModel UpscalerCardViewModel =>
DialogFactory.Get<UpscalerCardViewModel>();
public static BatchSizeCardViewModel BatchSizeCardViewModel =>
DialogFactory.Get<BatchSizeCardViewModel>();
public static IList<ICompletionData> SampleCompletionData => new List<ICompletionData>
{
new TagCompletionData("test1", TagType.General),
new TagCompletionData("test2", TagType.Artist),
new TagCompletionData("test3", TagType.Character),
new TagCompletionData("test4", TagType.Copyright),
new TagCompletionData("test5", TagType.Species),
new TagCompletionData("test_unknown", TagType.Invalid),
};
public static IList<ICompletionData> SampleCompletionData =>
new List<ICompletionData>
{
new TagCompletionData("test1", TagType.General),
new TagCompletionData("test2", TagType.Artist),
new TagCompletionData("test3", TagType.Character),
new TagCompletionData("test4", TagType.Copyright),
new TagCompletionData("test5", TagType.Species),
new TagCompletionData("test_unknown", TagType.Invalid),
};
public static CompletionList SampleCompletionList
{
get
{
var list = new CompletionList
{
IsFiltering = true
};
var list = new CompletionList { IsFiltering = true };
list.CompletionData.AddRange(SampleCompletionData);
list.FilteredCompletionData.AddRange(list.CompletionData);
list.SelectItem("te", true);
@ -533,16 +549,36 @@ The gallery images are often inpainted, but you will get something very similar
}
}
public static ImageViewerViewModel ImageViewerViewModel
=> DialogFactory.Get<ImageViewerViewModel>(vm =>
public static ImageViewerViewModel ImageViewerViewModel =>
DialogFactory.Get<ImageViewerViewModel>(vm =>
{
vm.ImageSource = new ImageSource(new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a318ac1f-3ad0-48ac-98cc-79126febcc17/width=1500"));
vm.ImageSource = new ImageSource(
new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a318ac1f-3ad0-48ac-98cc-79126febcc17/width=1500"
)
);
});
public static ImageSource SampleImageSource => new(new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a318ac1f-3ad0-48ac-98cc-79126febcc17/width=1500"));
public static SelectImageCardViewModel SelectImageCardViewModel =>
DialogFactory.Get<SelectImageCardViewModel>();
public static SelectImageCardViewModel SelectImageCardViewModel_WithImage =>
DialogFactory.Get<SelectImageCardViewModel>(vm =>
{
vm.ImageSource = new ImageSource(
new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a318ac1f-3ad0-48ac-98cc-79126febcc17/width=1500"
)
);
});
public static ImageSource SampleImageSource =>
new(
new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/a318ac1f-3ad0-48ac-98cc-79126febcc17/width=1500"
)
);
public static Indexer Types => new();
public class Indexer
@ -551,8 +587,9 @@ The gallery images are often inpainted, but you will get something very similar
{
get
{
var type = Type.GetType(typeName) ??
throw new ArgumentException($"Type {typeName} not found");
var type =
Type.GetType(typeName)
?? throw new ArgumentException($"Type {typeName} not found");
try
{
return Services.GetService(type);

20
StabilityMatrix.Avalonia/ViewModels/Inference/SelectImageCardViewModel.cs

@ -0,0 +1,20 @@
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Avalonia.Controls;
using StabilityMatrix.Avalonia.Models;
using StabilityMatrix.Avalonia.ViewModels.Base;
using StabilityMatrix.Core.Attributes;
namespace StabilityMatrix.Avalonia.ViewModels.Inference;
[View(typeof(SelectImageCard))]
public partial class SelectImageCardViewModel : ViewModelBase
{
[ObservableProperty]
private ImageSource? imageSource;
[ObservableProperty]
[NotifyPropertyChangedFor(nameof(IsSelectionAvailable))]
private bool isSelectionEnabled = true;
public bool IsSelectionAvailable => IsSelectionEnabled && ImageSource == null;
}
Loading…
Cancel
Save