Browse Source

Fix checkpoint folder cards scroll

pull/5/head
Ionite 1 year ago
parent
commit
8ec2753677
No known key found for this signature in database
  1. 103
      StabilityMatrix/CheckpointManagerPage.xaml
  2. 22
      StabilityMatrix/CheckpointManagerPage.xaml.cs

103
StabilityMatrix/CheckpointManagerPage.xaml

@ -18,54 +18,35 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources> <Page.Resources>
<DataTemplate DataType="{x:Type models:CheckpointFile}" x:Key="CheckpointCardDataTemplate"> <DataTemplate DataType="{x:Type models:CheckpointFile}" x:Key="CheckpointFileDataTemplate">
<ui:Card Width="256"> <ui:CardAction Height="96" Width="240">
<Grid> <StackPanel Orientation="Vertical">
<Grid.ColumnDefinitions> <ui:Image
<ColumnDefinition Width="*" /> CornerRadius="4"
<ColumnDefinition Width="0.2*" /> Margin="4,4,4,8"
</Grid.ColumnDefinitions> MinHeight="256"
<StackPanel Orientation="Vertical"> MinWidth="200"
<ui:Image Source="{Binding PreviewImage}"
CornerRadius="4" Stretch="UniformToFill"
Margin="4,4,4,8" Visibility="Collapsed"
MinHeight="256" Width="128" />
MinWidth="200" <TextBlock
Source="{Binding PreviewImage}" Foreground="{DynamicResource TextFillColorPrimaryBrush}"
Stretch="UniformToFill" Margin="0,0,0,0"
Visibility="Collapsed" Text="{Binding Title}"
Width="128" /> VerticalAlignment="Center" />
<TextBlock <TextBlock
Foreground="{DynamicResource TextFillColorPrimaryBrush}" FontSize="11"
Margin="0,0,0,0" Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Text="{Binding Title}" Margin="0,2,0,0"
VerticalAlignment="Center" /> Text="{Binding FileName}"
<TextBlock VerticalAlignment="Center" />
FontSize="11" </StackPanel>
Foreground="{DynamicResource TextFillColorTertiaryBrush}" </ui:CardAction>
Margin="0,2,0,0"
Text="{Binding FileName}"
VerticalAlignment="Center" />
</StackPanel>
<ui:DropDownButton Grid.Column="1" Margin="16,0,0,0">
<ui:DropDownButton.Style>
<Style BasedOn="{StaticResource {x:Type ui:DropDownButton}}" TargetType="{x:Type ui:DropDownButton}">
<Setter Property="Visibility" Value="Hidden" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ui:Card}}}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</ui:DropDownButton.Style>
<ui:SymbolIcon Symbol="ChevronDown24" />
</ui:DropDownButton>
</Grid>
</ui:Card>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderCardGridDataTemplate"> <DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderGridDataTemplate">
<ui:CardExpander <Expander
AllowDrop="True" AllowDrop="True"
Drop="FolderCard_OnDrop" Drop="FolderCard_OnDrop"
Header="{Binding Title}" Header="{Binding Title}"
@ -76,28 +57,38 @@
PreviewDragOver="FolderCard_OnPreviewDragOver" PreviewDragOver="FolderCard_OnPreviewDragOver"
PreviewDrop="FolderCard_OnPreviewDrop"> PreviewDrop="FolderCard_OnPreviewDrop">
<ui:VirtualizingGridView <ui:VirtualizingGridView
ItemTemplate="{StaticResource CheckpointCardDataTemplate}" ItemTemplate="{StaticResource CheckpointFileDataTemplate}"
ItemsSource="{Binding CheckpointFiles}" ItemsSource="{Binding CheckpointFiles}"
Padding="5" Padding="5"
PreviewMouseWheel="VirtualizingGridView_OnPreviewMouseWheel"
SpacingMode="StartAndEndOnly" /> SpacingMode="StartAndEndOnly" />
</ui:CardExpander> </Expander>
</DataTemplate> </DataTemplate>
<DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderCardDataTemplate"> <DataTemplate DataType="{x:Type models:CheckpointFolder}" x:Key="CheckpointFolderDataTemplate">
<ContentControl Content="{Binding}"> <ContentControl Content="{Binding}">
<ContentControl.Style> <ContentControl.Style>
<Style TargetType="{x:Type ContentControl}"> <Style TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate" Value="{StaticResource CheckpointFolderCardGridDataTemplate}" /> <Setter Property="ContentTemplate" Value="{StaticResource CheckpointFolderGridDataTemplate}" />
</Style> </Style>
</ContentControl.Style> </ContentControl.Style>
</ContentControl> </ContentControl>
</DataTemplate> </DataTemplate>
</Page.Resources> </Page.Resources>
<!-- Option Cards --> <!-- Folder Cards -->
<ItemsControl <ui:DynamicScrollViewer
HorizontalAlignment="Stretch" CanContentScroll="True"
ItemTemplate="{StaticResource CheckpointFolderCardGridDataTemplate}" HorizontalScrollBarVisibility="Disabled"
ItemsSource="{Binding CheckpointFolders}" VerticalScrollBarVisibility="Auto">
Margin="16,16,16,16" /> <Grid>
<StackPanel Orientation="Vertical">
<ItemsControl
HorizontalAlignment="Stretch"
ItemTemplate="{StaticResource CheckpointFolderGridDataTemplate}"
ItemsSource="{Binding CheckpointFolders, Mode=OneWay}"
Margin="16,16,16,16" />
</StackPanel>
</Grid>
</ui:DynamicScrollViewer>
</Page> </Page>

22
StabilityMatrix/CheckpointManagerPage.xaml.cs

@ -2,6 +2,7 @@
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Effects; using System.Windows.Media.Effects;
using StabilityMatrix.ViewModels; using StabilityMatrix.ViewModels;
@ -74,4 +75,25 @@ public partial class CheckpointManagerPage : Page
{ {
await viewModel.OnLoaded(); await viewModel.OnLoaded();
} }
/// <summary>
/// Bubbles the mouse wheel event up to the parent.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void VirtualizingGridView_OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Handled) return;
e.Handled = true;
var eventArg = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta)
{
RoutedEvent = MouseWheelEvent,
Source = sender
};
if (((Control)sender).Parent is UIElement parent)
{
parent.RaiseEvent(eventArg);
}
}
} }

Loading…
Cancel
Save