ux: layout of change collection view

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2026-03-30 14:59:38 +08:00
parent 0c37957a21
commit 0460b0dec6
2 changed files with 67 additions and 53 deletions

View File

@@ -37,38 +37,43 @@
SelectionChanged="OnRowSelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate DataType="vm:ChangeTreeNode">
<Grid ColumnDefinitions="16,16,Auto,*"
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
Background="Transparent"
DoubleTapped="OnRowDoubleTapped"
DataContextChanged="OnRowDataContextChanged">
<v:ChangeTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander"
Focusable="False"
HorizontalAlignment="Center"
IsChecked="{Binding IsExpanded, Mode=OneWay}"
IsVisible="{Binding IsFolder}"/>
<ToggleButton Grid.Column="1"
Classes="folder"
<StackPanel Orientation="Horizontal"
Height="24"
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
Background="Transparent"
DoubleTapped="OnRowDoubleTapped"
DataContextChanged="OnRowDataContextChanged">
<Border Width="16">
<v:ChangeTreeNodeToggleButton Classes="tree_expander"
Focusable="False"
HorizontalAlignment="Center"
IsChecked="{Binding IsExpanded, Mode=OneWay}"
IsVisible="{Binding IsFolder}"/>
</Border>
<ToggleButton Classes="folder"
Focusable="False"
Width="14" Height="14"
Margin="0,1,0,0"
Margin="1,1,1,0"
Foreground="Goldenrod"
IsChecked="{Binding IsExpanded}"
IsVisible="{Binding IsFolder}"/>
<v:ChangeStatusIcon Grid.Column="1"
Width="14" Height="14"
<v:ChangeStatusIcon Width="14" Height="14"
Margin="1,0"
IsUnstagedChange="{Binding #ThisControl.IsUnstagedChange}"
Change="{Binding Change}"
IsVisible="{Binding !IsFolder}"/>
<StackPanel Grid.Column="2" Orientation="Horizontal" Margin="4,0,0,0">
<TextBlock Text="{Binding ConflictMarker, Mode=OneWay}" Foreground="DarkOrange" FontWeight="Bold" Margin="0,0,4,0" IsVisible="{Binding ShowConflictMarker}"/>
<TextBlock Text="{Binding DisplayName, Mode=OneWay}"/>
</StackPanel>
</Grid>
<TextBlock Text="{Binding ConflictMarker, Mode=OneWay}"
Foreground="DarkOrange"
FontWeight="Bold"
Margin="4,0,0,0"
IsVisible="{Binding ShowConflictMarker}"/>
<TextBlock Text="{Binding DisplayName, Mode=OneWay}"
Margin="4,0,0,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</v:ChangeCollectionContainer>
@@ -82,25 +87,28 @@
SelectionChanged="OnRowSelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Change">
<Grid ColumnDefinitions="Auto,Auto,Auto,*"
Background="Transparent"
DoubleTapped="OnRowDoubleTapped"
DataContextChanged="OnRowDataContextChanged">
<v:ChangeStatusIcon Grid.Column="0"
Width="14" Height="14"
<StackPanel Orientation="Horizontal"
Height="24"
Background="Transparent"
DoubleTapped="OnRowDoubleTapped"
DataContextChanged="OnRowDataContextChanged">
<v:ChangeStatusIcon Width="14" Height="14"
Margin="4,0,0,0"
IsUnstagedChange="{Binding #ThisControl.IsUnstagedChange}"
Change="{Binding}" />
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="4,0">
<TextBlock Text="{Binding ConflictMarker}" Foreground="DarkOrange" FontWeight="Bold" Margin="0,0,4,0" IsVisible="{Binding IsConflicted}"/>
<TextBlock Text="{Binding Path, Converter={x:Static c:PathConverters.PureFileName}}"/>
</StackPanel>
<TextBlock Text="{Binding ConflictMarker}"
Foreground="DarkOrange"
FontWeight="Bold"
Margin="4,0,0,0" IsVisible="{Binding IsConflicted}"/>
<TextBlock Text="{Binding Path, Converter={x:Static c:PathConverters.PureFileName}}"
Margin="4,0,0,0"/>
<TextBlock Grid.Column="2"
Text="{Binding Path, Converter={x:Static c:PathConverters.PureDirectoryName}}"
Foreground="{DynamicResource Brush.FG2}"/>
</Grid>
<TextBlock Text="{Binding Path, Converter={x:Static c:PathConverters.PureDirectoryName}}"
Foreground="{DynamicResource Brush.FG2}"
Margin="4,0,0,0"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</v:ChangeCollectionContainer>
@@ -114,21 +122,25 @@
SelectionChanged="OnRowSelectionChanged">
<ListBox.ItemTemplate>
<DataTemplate DataType="m:Change">
<Grid ColumnDefinitions="Auto,Auto,*"
Background="Transparent"
DoubleTapped="OnRowDoubleTapped"
DataContextChanged="OnRowDataContextChanged">
<v:ChangeStatusIcon Grid.Column="0"
Width="14" Height="14"
<StackPanel Orientation="Horizontal"
Height="24"
Background="Transparent"
DoubleTapped="OnRowDoubleTapped"
DataContextChanged="OnRowDataContextChanged">
<v:ChangeStatusIcon Width="14" Height="14"
Margin="4,0,0,0"
IsUnstagedChange="{Binding #ThisControl.IsUnstagedChange}"
Change="{Binding}" />
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="4,0">
<TextBlock Text="{Binding ConflictMarker}" Foreground="DarkOrange" FontWeight="Bold" Margin="0,0,4,0" IsVisible="{Binding IsConflicted}"/>
<TextBlock Text="{Binding Path}"/>
</StackPanel>
</Grid>
<TextBlock Text="{Binding ConflictMarker}"
Foreground="DarkOrange"
FontWeight="Bold"
Margin="4,0,0,0"
IsVisible="{Binding IsConflicted}"/>
<TextBlock Margin="4,0,0,0"
Text="{Binding Path}"/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</v:ChangeCollectionContainer>

View File

@@ -231,17 +231,17 @@ namespace SourceGit.Views
private void OnRowDataContextChanged(object sender, EventArgs e)
{
if (sender is not Control control)
if (sender is not Control { DataContext: { } ctx } control)
return;
if (control.DataContext is ViewModels.ChangeTreeNode node)
if (ctx is ViewModels.ChangeTreeNode node)
{
if (node.Change is { } c)
UpdateRowTips(control, c);
else
ToolTip.SetTip(control, node.FullPath);
}
else if (control.DataContext is Models.Change change)
else if (ctx is Models.Change change)
{
UpdateRowTips(control, change);
}
@@ -253,8 +253,10 @@ namespace SourceGit.Views
private void OnRowDoubleTapped(object sender, TappedEventArgs e)
{
var grid = sender as Grid;
if (grid?.DataContext is ViewModels.ChangeTreeNode node)
if (sender is not Control { DataContext: { } ctx })
return;
if (ctx is ViewModels.ChangeTreeNode node)
{
if (node.IsFolder)
{
@@ -269,7 +271,7 @@ namespace SourceGit.Views
RaiseEvent(new RoutedEventArgs(ChangeDoubleTappedEvent));
}
}
else if (grid?.DataContext is Models.Change)
else if (ctx is Models.Change)
{
RaiseEvent(new RoutedEventArgs(ChangeDoubleTappedEvent));
}