Browse Source

Add checkpoint manager page and models

pull/5/head
Ionite 1 year ago
parent
commit
5d6ef1082f
No known key found for this signature in database
  1. 84
      StabilityMatrix/CheckpointManagerPage.xaml
  2. 13
      StabilityMatrix/CheckpointManagerPage.xaml.cs
  3. 16
      StabilityMatrix/Models/CheckpointCard.cs
  4. 19
      StabilityMatrix/Models/CheckpointFolderCard.cs
  5. 20
      StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs

84
StabilityMatrix/CheckpointManagerPage.xaml

@ -0,0 +1,84 @@
<Page
Background="{DynamicResource ApplicationBackgroundBrush}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
d:DataContext="{d:DesignInstance Type=viewModels:CheckpointManagerViewModel,
IsDesignTimeCreatable=True}"
d:DesignHeight="450"
d:DesignWidth="700"
mc:Ignorable="d"
x:Class="StabilityMatrix.CheckpointManagerPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:models="clr-namespace:StabilityMatrix.Models"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:viewModels="clr-namespace:StabilityMatrix.ViewModels"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<d:DesignProperties.DataContext>
<viewModels:CheckpointManagerViewModel>
<viewModels:CheckpointManagerViewModel.CheckpointFolderCards>
<models:CheckpointFolderCard Name="hi" />
<models:CheckpointFolderCard Name="hi" />
<models:CheckpointFolderCard Name="hi" />
</viewModels:CheckpointManagerViewModel.CheckpointFolderCards>
</viewModels:CheckpointManagerViewModel>
</d:DesignProperties.DataContext>
<Page.Resources>
<DataTemplate DataType="{x:Type models:CheckpointFolderCard}" x:Key="CheckpointFolderCardGridDataTemplate">
<ui:CardExpander Header="{Binding Name}" IsExpanded="True">
<ui:VirtualizingGridView>
<ItemsControl ItemsSource="{Binding CheckpointCards}">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type models:CheckpointCard}">
<ui:Card Margin="8">
<VirtualizingStackPanel Orientation="Vertical">
<ui:Image
CornerRadius="4"
Margin="4,4,4,8"
MinHeight="256"
MinWidth="200"
Source="{Binding Image}"
Stretch="UniformToFill"
Visibility="Collapsed"
Width="128" />
<TextBlock
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Margin="0,0,0,0"
Text="{Binding Name}"
VerticalAlignment="Center" />
<TextBlock
FontSize="11"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Margin="0,2,0,0"
Text="{Binding FileName}"
VerticalAlignment="Center" />
</VirtualizingStackPanel>
</ui:Card>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ui:VirtualizingGridView>
</ui:CardExpander>
</DataTemplate>
<DataTemplate DataType="{x:Type models:CheckpointFolderCard}" x:Key="CheckpointFolderCardDataTemplate">
<ContentControl Content="{Binding}">
<ContentControl.Style>
<Style TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate" Value="{StaticResource CheckpointFolderCardGridDataTemplate}" />
</Style>
</ContentControl.Style>
</ContentControl>
</DataTemplate>
</Page.Resources>
<!-- Option Cards -->
<ItemsControl
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Center"
ItemTemplate="{StaticResource CheckpointFolderCardDataTemplate}"
ItemsSource="{Binding CheckpointFolderCards}"
Margin="16,0,0,0" />
</Page>

13
StabilityMatrix/CheckpointManagerPage.xaml.cs

@ -0,0 +1,13 @@
using System.Windows.Controls;
using StabilityMatrix.ViewModels;
namespace StabilityMatrix;
public partial class CheckpointManagerPage : Page
{
public CheckpointManagerPage(CheckpointManagerViewModel viewModel)
{
InitializeComponent();
DataContext = viewModel;
}
}

16
StabilityMatrix/Models/CheckpointCard.cs

@ -0,0 +1,16 @@
using System.Windows.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
namespace StabilityMatrix.Models;
public partial class CheckpointCard : ObservableObject
{
[ObservableProperty]
private BitmapImage? image;
[ObservableProperty]
private string name;
[ObservableProperty]
private string fileName;
}

19
StabilityMatrix/Models/CheckpointFolderCard.cs

@ -0,0 +1,19 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
namespace StabilityMatrix.Models;
public partial class CheckpointFolderCard : ObservableObject
{
[ObservableProperty]
private string name;
public ObservableCollection<CheckpointCard> CheckpointCards { get; set; } = new()
{
new CheckpointCard
{
Name = "",
FileName = "",
}
};
}

20
StabilityMatrix/ViewModels/CheckpointManagerViewModel.cs

@ -0,0 +1,20 @@
using System.Collections.ObjectModel;
using CommunityToolkit.Mvvm.ComponentModel;
using StabilityMatrix.Models;
namespace StabilityMatrix.ViewModels;
public partial class CheckpointManagerViewModel : ObservableObject
{
public ObservableCollection<CheckpointFolderCard> CheckpointFolderCards { get; set; } = new()
{
new()
{
Name = "Stable Diffusion"
},
new()
{
Name = "Lora"
}
};
}
Loading…
Cancel
Save