The 2 implementations can now be switched

Added a bool property DiffView.UseChangeBlocks.
It's not bound from UI yet, but could be used for runtime switching between the two different implementations of prev/next change.
The buttons are now using the OnGoto[Prev|Next]Change Click-handler, regardless of implementation.
This commit is contained in:
goran-w 2024-11-16 18:39:04 +01:00
parent 636be4a7a8
commit 760e240db7
2 changed files with 34 additions and 16 deletions

View file

@ -36,7 +36,7 @@
<StackPanel Grid.Column="3" Margin="8,0,0,0" Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Grid.Column="3" Margin="8,0,0,0" Orientation="Horizontal" VerticalAlignment="Center">
<Button Classes="icon_button" <Button Classes="icon_button"
Width="28" Width="28"
Command="{Binding PrevChange}" Click="OnGotoPrevChange"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.Prev}"> ToolTip.Tip="{DynamicResource Text.Diff.Prev}">
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/> <Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
@ -51,7 +51,7 @@
<Button Classes="icon_button" <Button Classes="icon_button"
Width="28" Width="28"
Command="{Binding NextChange}" Click="OnGotoNextChange"
IsVisible="{Binding IsTextDiff}" IsVisible="{Binding IsTextDiff}"
ToolTip.Tip="{DynamicResource Text.Diff.Next}"> ToolTip.Tip="{DynamicResource Text.Diff.Next}">
<Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/> <Path Width="12" Height="12" Stretch="Uniform" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>

View file

@ -11,7 +11,16 @@ namespace SourceGit.Views
InitializeComponent(); InitializeComponent();
} }
public bool UseChangeBlocks { get; set; } = true;
private void OnGotoPrevChange(object _, RoutedEventArgs e) private void OnGotoPrevChange(object _, RoutedEventArgs e)
{
if (UseChangeBlocks)
{
if (DataContext is ViewModels.DiffContext diffCtx)
diffCtx.PrevChange();
}
else
{ {
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>(); var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
if (textDiff == null) if (textDiff == null)
@ -23,8 +32,16 @@ namespace SourceGit.Views
e.Handled = true; e.Handled = true;
} }
}
private void OnGotoNextChange(object _, RoutedEventArgs e) private void OnGotoNextChange(object _, RoutedEventArgs e)
{
if (UseChangeBlocks)
{
if (DataContext is ViewModels.DiffContext diffCtx)
diffCtx.NextChange();
}
else
{ {
var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>(); var textDiff = this.FindDescendantOfType<ThemedTextDiffPresenter>();
if (textDiff == null) if (textDiff == null)
@ -38,3 +55,4 @@ namespace SourceGit.Views
} }
} }
} }
}