Browse Source

Fix issue where first click would scroll instead of doing button action

pull/5/head
JT 1 year ago
parent
commit
4e9e1bfa0b
  1. BIN
      StabilityMatrix/Assets/noimage.png
  2. 14
      StabilityMatrix/CheckpointBrowserPage.xaml
  3. 5
      StabilityMatrix/CheckpointBrowserPage.xaml.cs
  4. 10
      StabilityMatrix/DesignData/MockCheckpointBrowserViewModel.cs
  5. 1
      StabilityMatrix/MainWindow.xaml
  6. 4
      StabilityMatrix/StabilityMatrix.csproj
  7. 14
      StabilityMatrix/ViewModels/CheckpointBrowserCardViewModel.cs
  8. 5
      StabilityMatrix/ViewModels/OneClickInstallViewModel.cs

BIN
StabilityMatrix/Assets/noimage.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

14
StabilityMatrix/CheckpointBrowserPage.xaml

@ -29,7 +29,7 @@
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<DataTemplate DataType="{x:Type viewModels:CheckpointBrowserCardViewModel}" x:Key="CivitModelTemplate">
<ui:Card MaxHeight="450" Width="330">
<ui:Card MaxHeight="450" Width="330" Margin="8">
<StackPanel Orientation="Vertical">
<TextBlock
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
@ -46,7 +46,7 @@
<Image
Margin="0,8,0,8"
MaxHeight="300"
Source="{Binding CivitModel.ModelVersions[0].Images[0].Url, Converter={StaticResource UriToBitmapConverter}}"
Source="{Binding CardImage}"
Stretch="UniformToFill" />
<ui:Button
Appearance="Info"
@ -55,7 +55,10 @@
HorizontalAlignment="Right"
Margin="0,16,8,0"
VerticalAlignment="Top">
<ui:SymbolIcon Symbol="Open48" />
<ui:Button.Icon>
<ui:SymbolIcon Symbol="Open24" />
</ui:Button.Icon>
</ui:Button>
<Rectangle
@ -168,11 +171,10 @@
</StackPanel>
<ui:DynamicScrollViewer CanContentScroll="True" Grid.Row="1">
<ui:VirtualizingGridView
<ui:VirtualizingItemsControl RequestBringIntoView="FrameworkElement_OnRequestBringIntoView"
ItemTemplate="{StaticResource CivitModelTemplate}"
ItemsSource="{Binding ModelCards}"
PreviewMouseWheel="VirtualizingGridView_OnPreviewMouseWheel"
SpacingMode="StartAndEndOnly" />
PreviewMouseWheel="VirtualizingGridView_OnPreviewMouseWheel"/>
</ui:DynamicScrollViewer>
<StackPanel

5
StabilityMatrix/CheckpointBrowserPage.xaml.cs

@ -33,4 +33,9 @@ public partial class CheckpointBrowserPage : Page
parent.RaiseEvent(eventArg);
}
}
private void FrameworkElement_OnRequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
e.Handled = true;
}
}

10
StabilityMatrix/DesignData/MockCheckpointBrowserViewModel.cs

@ -1,5 +1,7 @@
using System.Collections.ObjectModel;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Media.Imaging;
using StabilityMatrix.Models.Api;
using StabilityMatrix.ViewModels;
@ -12,7 +14,7 @@ public class MockCheckpointBrowserViewModel : CheckpointBrowserViewModel
{
ModelCards = new ObservableCollection<CheckpointBrowserCardViewModel>
{
new (null!, null!, null!)
new(null!, null!, null!)
{
CivitModel = new()
{
@ -32,7 +34,9 @@ public class MockCheckpointBrowserViewModel : CheckpointBrowserViewModel
}
}
}
}
},
CardImage = new BitmapImage(new Uri(
"https://image.civitai.com/xG1nkqKTMzGDvpLrqFT7WA/1547f350-461a-4cd0-a753-0544aa81e4fc/width=450/00000-4137473915.jpeg"))
}
};
}

1
StabilityMatrix/MainWindow.xaml

@ -61,6 +61,7 @@
<ui:NavigationView
PaneClosed="RootNavigation_OnPaneClosed"
PaneOpened="RootNavigation_OnPaneOpened"
IsBackButtonVisible="Collapsed"
UseLayoutRounding="True"
x:Name="RootNavigation">
<ui:NavigationView.Header>

4
StabilityMatrix/StabilityMatrix.csproj

@ -64,6 +64,10 @@
<Content Include="Assets\7za - LICENSE.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Remove="Assets\noimage.png" />
<Resource Include="Assets\noimage.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Resource>
</ItemGroup>
<ItemGroup>

14
StabilityMatrix/ViewModels/CheckpointBrowserCardViewModel.cs

@ -1,8 +1,11 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.Logging;
using StabilityMatrix.Extensions;
@ -18,6 +21,7 @@ public partial class CheckpointBrowserCardViewModel : ProgressViewModel
private readonly IDownloadService downloadService;
private readonly ISnackbarService snackbarService;
public CivitModel CivitModel { get; init; }
public BitmapImage CardImage { get; init; }
public override Visibility ProgressVisibility => Value > 0 ? Visibility.Visible : Visibility.Collapsed;
public override Visibility TextVisibility => Value > 0 ? Visibility.Visible : Visibility.Collapsed;
@ -27,6 +31,16 @@ public partial class CheckpointBrowserCardViewModel : ProgressViewModel
this.downloadService = downloadService;
this.snackbarService = snackbarService;
CivitModel = civitModel;
if (civitModel.ModelVersions.Any() && civitModel.ModelVersions[0].Images.Any())
{
CardImage = new BitmapImage(new Uri(civitModel.ModelVersions[0].Images[0].Url));
}
else
{
CardImage = new BitmapImage(
new Uri("pack://application:,,,/StabilityMatrix;component/Assets/noimage.png"));
}
}
[RelayCommand]

5
StabilityMatrix/ViewModels/OneClickInstallViewModel.cs

@ -19,6 +19,7 @@ public partial class OneClickInstallViewModel : ObservableObject
private readonly IPrerequisiteHelper prerequisiteHelper;
private readonly ILogger<MainWindowViewModel> logger;
private readonly IPyRunner pyRunner;
private readonly ISharedFolders sharedFolders;
private const string DefaultPackageName = "stable-diffusion-webui";
[ObservableProperty] private string headerText;
@ -36,13 +37,15 @@ public partial class OneClickInstallViewModel : ObservableObject
OneClickInstallProgress > 0 || IsIndeterminate ? Visibility.Visible : Visibility.Collapsed;
public OneClickInstallViewModel(ISettingsManager settingsManager, IPackageFactory packageFactory,
IPrerequisiteHelper prerequisiteHelper, ILogger<MainWindowViewModel> logger, IPyRunner pyRunner)
IPrerequisiteHelper prerequisiteHelper, ILogger<MainWindowViewModel> logger, IPyRunner pyRunner,
ISharedFolders sharedFolders)
{
this.settingsManager = settingsManager;
this.packageFactory = packageFactory;
this.prerequisiteHelper = prerequisiteHelper;
this.logger = logger;
this.pyRunner = pyRunner;
this.sharedFolders = sharedFolders;
HeaderText = "Welcome to Stability Matrix!";
SubHeaderText =

Loading…
Cancel
Save