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.

226 lines
11 KiB

<UserControl 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:controls="clr-namespace:StabilityMatrix.Avalonia.Controls"
xmlns:dialogs="clr-namespace:StabilityMatrix.Avalonia.ViewModels.Dialogs"
xmlns:designData="clr-namespace:StabilityMatrix.Avalonia.DesignData"
mc:Ignorable="d" d:DesignWidth="700" d:DesignHeight="850"
x:DataType="dialogs:SelectModelVersionViewModel"
xmlns:fluentAvalonia="clr-namespace:FluentIcons.Avalonia.Fluent;assembly=FluentIcons.Avalonia.Fluent"
xmlns:models="clr-namespace:StabilityMatrix.Avalonia.Models"
xmlns:avalonia="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia"
xmlns:lang="clr-namespace:StabilityMatrix.Avalonia.Languages"
xmlns:markupExtensions="clr-namespace:StabilityMatrix.Avalonia.MarkupExtensions"
xmlns:controls1="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:input="clr-namespace:FluentAvalonia.UI.Input;assembly=FluentAvalonia"
d:DataContext="{x:Static designData:DesignData.SelectModelVersionViewModel}"
x:Class="StabilityMatrix.Avalonia.Views.Dialogs.SelectModelVersionDialog">
<Grid
Margin="8"
MinHeight="450"
MinWidth="700"
RowDefinitions="Auto, *, Auto"
ColumnDefinitions="*,Auto,*">
<Grid.Resources>
<input:StandardUICommand x:Key="ImportCommand"
Command="{Binding Import}"/>
</Grid.Resources>
<Grid Grid.Row="0" Grid.Column="0" RowDefinitions="Auto, Auto, Auto">
<Carousel Grid.Row="0"
ItemsSource="{Binding ImageUrls}"
SelectedIndex="{Binding SelectedImageIndex}">
<Carousel.PageTransition>
<CompositePageTransition>
<PageSlide Orientation="Horizontal" Duration="0.167">
<PageSlide.SlideInEasing>
<SineEaseIn />
</PageSlide.SlideInEasing>
<PageSlide.SlideOutEasing>
<SineEaseOut />
</PageSlide.SlideOutEasing>
</PageSlide>
<CrossFade Duration="0.167" />
</CompositePageTransition>
</Carousel.PageTransition>
<Carousel.ItemTemplate>
<DataTemplate DataType="{x:Type models:ImageSource}">
<controls:BetterImage Margin="8"
VerticalAlignment="Top"
HorizontalAlignment="Center"
Height="300"
Stretch="UniformToFill"
Source="{Binding BitmapAsync^}" />
</DataTemplate>
</Carousel.ItemTemplate>
</Carousel>
<StackPanel Grid.Row="1" Orientation="Horizontal"
Margin="0,0,0,8"
VerticalAlignment="Bottom"
HorizontalAlignment="Center">
<TextBlock Text="{Binding DisplayedPageNumber}"/>
<TextBlock Text="/"/>
<TextBlock Text="{Binding ImageUrls.Count}"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Bottom">
<Button Command="{Binding PreviousImage}"
Margin="0,0,8,0"
IsEnabled="{Binding CanGoToPreviousImage}"
ToolTip.Tip="{x:Static lang:Resources.Label_PreviousImage}"
ToolTip.Placement="Top">
<avalonia:Icon Value="fa-solid fa-caret-left"/>
</Button>
<Button Command="{Binding NextImage}"
IsEnabled="{Binding CanGoToNextImage}"
ToolTip.Tip="{x:Static lang:Resources.Label_NextImage}"
ToolTip.Placement="Top">
<avalonia:Icon Value="fa-solid fa-caret-right"/>
</Button>
</StackPanel>
</Grid>
<ListBox Grid.Row="0" Grid.Column="1"
Margin="8"
MaxHeight="360"
VerticalAlignment="Top"
ItemsSource="{Binding Versions}"
SelectedItem="{Binding SelectedVersionViewModel}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type dialogs:ModelVersionViewModel}">
<Grid ColumnDefinitions="Auto, Auto"
RowDefinitions="Auto, Auto"
MinWidth="128"
Margin="0,4,0,4">
<fluentAvalonia:SymbolIcon Grid.Row="0"
Grid.Column="0"
Grid.RowSpan="2"
Symbol="Checkmark"
Foreground="Lime"
IsVisible="{Binding IsInstalled}"
VerticalAlignment="Center" />
<TextBlock Grid.Row="0" Grid.Column="1"
Margin="4, 0"
Padding="4"
Text="{Binding ModelVersion.Name}" />
<TextBlock Grid.Row="1" Grid.Column="1"
Margin="6, 0, 0, 0"
FontSize="11"
Padding="4, 0, 4, 4"
Text="{Binding ModelVersion.BaseModel}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.Template>
<ControlTemplate>
<ScrollViewer>
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
</ListBox>
<ListBox Grid.Row="0" Grid.Column="2"
MaxHeight="360"
VerticalAlignment="Top"
ItemsSource="{Binding SelectedVersionViewModel.CivitFileViewModels}"
SelectedItem="{Binding SelectedFile}">
<ListBox.Template>
<ControlTemplate>
<ScrollViewer>
<ItemsPresenter Margin="8" />
</ScrollViewer>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type dialogs:CivitFileViewModel}">
<Grid RowDefinitions="Auto, Auto" ColumnDefinitions="Auto, *"
Margin="0,4,0,4">
<Grid.ContextFlyout>
<controls1:FAMenuFlyout>
<controls1:MenuFlyoutItem
IsVisible="{Binding IsInstalled}"
Command="{StaticResource ImportCommand}"
IconSource="Download"
Text="{x:Static lang:Resources.Action_Import}" />
</controls1:FAMenuFlyout>
</Grid.ContextFlyout>
<fluentAvalonia:SymbolIcon Grid.Row="0" Grid.RowSpan="2"
Grid.Column="0"
Margin="0, 0, 8, 0"
Symbol="Checkmark"
Foreground="Lime"
IsVisible="{Binding IsInstalled}"
VerticalAlignment="Center" />
<TextBlock Grid.Row="0" Grid.Column="1"
Text="{Binding CivitFile.DisplayName}"
Margin="0, 4, 0, 4"
TextWrapping="Wrap" />
<TextBlock Grid.Row="1" Grid.Column="1"
FontSize="11"
Margin="0, 4, 0, 4"
TextWrapping="Wrap">
<Run Text="{Binding CivitFile.Metadata.Format}" />
<Run Text="-" />
<Run Text="{Binding CivitFile.Metadata.Size}" />
<Run Text="-" />
<Run Text="{Binding CivitFile.Metadata.Fp}" />
<Run Text="-" />
<Run Text="{Binding CivitFile.FullFilesSize, Mode=OneWay}" />
</TextBlock>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Expander Grid.Column="0"
Grid.ColumnSpan="3"
Grid.Row="1"
Header="{x:Static lang:Resources.Label_ModelDescription}"
ExpandDirection="Down"
Margin="8, 16">
<ScrollViewer MaxHeight="200">
<TextBlock Text="{Binding Description}"
TextWrapping="Wrap"
Margin="4"/>
</ScrollViewer>
</Expander>
<StackPanel Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="2"
Orientation="Horizontal"
Margin="0,8,0,0"
HorizontalAlignment="Center">
<Button
Content="{x:Static lang:Resources.Action_Cancel}"
HorizontalAlignment="Center"
Command="{Binding Cancel}"
Margin="8, 0" />
<Button
Margin="8, 0"
Content="{x:Static lang:Resources.Action_Import}"
Command="{Binding Import}"
IsEnabled="{Binding IsImportEnabled}"
IsVisible="{Binding !SelectedFile.IsInstalled, TargetNullValue=True, FallbackValue=True}"
ToolTip.Tip="{Binding ImportTooltip}"
markupExtensions:ShowDisabledTooltipExtension.ShowOnDisabled="True"
Classes="accent" />
<Button
Margin="8, 0"
Command="{Binding Delete}"
Content="{x:Static lang:Resources.Action_Delete}"
IsVisible="{Binding SelectedFile.IsInstalled, TargetNullValue=False, FallbackValue=False}"
Classes="danger" />
</StackPanel>
</Grid>
</UserControl>