mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-03 18:15:01 +00:00
feature: supports to show submodules as tree or list (#1307)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
d299469613
commit
ed1351b1f7
10 changed files with 302 additions and 152 deletions
|
@ -269,7 +269,7 @@
|
|||
<Run Text="{Binding Tags, Converter={x:Static c:ListConverters.ToCount}}"/>
|
||||
</TextBlock>
|
||||
<ToggleButton Grid.Column="2"
|
||||
Classes="tag_display_mode"
|
||||
Classes="show_as_tree"
|
||||
Width="14"
|
||||
IsChecked="{Binding Source={x:Static vm:Preferences.Instance}, Path=ShowTagsAsTree, Mode=TwoWay}"
|
||||
ToolTip.Tip="{DynamicResource Text.Repository.ShowTagsAsTree}"/>
|
||||
|
@ -305,13 +305,19 @@
|
|||
|
||||
<!-- Submodules -->
|
||||
<ToggleButton Grid.Row="6" Classes="group_expander" IsChecked="{Binding IsSubmoduleGroupExpanded, Mode=TwoWay}">
|
||||
<Grid ColumnDefinitions="16,*,Auto,Auto">
|
||||
<Grid ColumnDefinitions="16,*,Auto,Auto,Auto">
|
||||
<Path Grid.Column="0" Width="10" Height="10" Margin="2,0,0,0" HorizontalAlignment="Left" Data="{StaticResource Icons.Submodules}" Fill="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock Grid.Column="1" Classes="group_header_label" Margin="0">
|
||||
<Run Text="{DynamicResource Text.Repository.Submodules}"/>
|
||||
<Run Text="{Binding Submodules, Converter={x:Static c:ListConverters.ToCount}}"/>
|
||||
</TextBlock>
|
||||
<Button Grid.Column="2"
|
||||
<ToggleButton Grid.Column="2"
|
||||
Classes="show_as_tree"
|
||||
Width="14"
|
||||
IsChecked="{Binding ShowSubmodulesAsTree, Mode=TwoWay}"
|
||||
IsVisible="{Binding Submodules, Converter={x:Static c:ListConverters.IsNotNullOrEmpty}}"
|
||||
ToolTip.Tip="{DynamicResource Text.Repository.ShowSubmodulesAsTree}"/>
|
||||
<Button Grid.Column="3"
|
||||
Classes="icon_button"
|
||||
Width="14"
|
||||
Margin="8,0"
|
||||
|
@ -320,7 +326,7 @@
|
|||
ToolTip.Tip="{DynamicResource Text.Repository.Submodules.Update}">
|
||||
<Path Width="12" Height="12" Data="{StaticResource Icons.Loading}"/>
|
||||
</Button>
|
||||
<Button Grid.Column="3"
|
||||
<Button Grid.Column="4"
|
||||
Classes="icon_button"
|
||||
Width="14"
|
||||
Margin="0,0,8,0"
|
||||
|
@ -334,7 +340,7 @@
|
|||
x:Name="SubmoduleList"
|
||||
Height="0"
|
||||
Margin="8,0,4,0"
|
||||
Submodules="{Binding VisibleSubmodules}"
|
||||
Content="{Binding VisibleSubmodules}"
|
||||
RowsChanged="OnSubmodulesRowsChanged"
|
||||
Focusable="False"
|
||||
IsVisible="{Binding IsSubmoduleGroupExpanded, Mode=OneWay}"/>
|
||||
|
|
|
@ -7,119 +7,217 @@
|
|||
xmlns:vm="using:SourceGit.ViewModels"
|
||||
xmlns:c="using:SourceGit.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.SubmodulesView"
|
||||
x:Name="ThisControl">
|
||||
x:Class="SourceGit.Views.SubmodulesView">
|
||||
<UserControl.DataTemplates>
|
||||
<DataTemplate DataType="m:Submodule">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="10" Height="10" Data="{StaticResource Icons.Submodule}"/>
|
||||
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Path}"/>
|
||||
</StackPanel>
|
||||
<DataTemplate DataType="vm:SubmoduleCollectionAsTree">
|
||||
<ListBox Classes="repo_left_content_list" ItemsSource="{Binding Rows}" SelectionMode="Single">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="CornerRadius" Value="4"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
|
||||
<Grid RowDefinitions="24,24" ColumnDefinitions="Auto,Auto" Margin="0,8,0,0">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Classes="info_label"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.CommitDetail.Info.SHA}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
Margin="8,0,0,0">
|
||||
<TextBlock Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
VerticalAlignment="Center"/>
|
||||
<ListBox.DataTemplates>
|
||||
<DataTemplate DataType="m:Submodule">
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="10" Height="10" Data="{StaticResource Icons.Submodule}"/>
|
||||
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Path}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Path Margin="6,0,0,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Width="12" Height="12"
|
||||
Data="{StaticResource Icons.Check}"
|
||||
Fill="Green"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}"/>
|
||||
<Border Height="16"
|
||||
Margin="6,0,0,0" Padding="4,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Background="DarkOrange"
|
||||
CornerRadius="4"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}">
|
||||
<Grid>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.NotInited}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.NotInited}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.Modified}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Modified}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.RevisionChanged}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.RevisionChanged}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.Unmerged}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Unmerged}}"/>
|
||||
<Grid RowDefinitions="24,24" ColumnDefinitions="Auto,Auto" Margin="0,8,0,0">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Classes="info_label"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.CommitDetail.Info.SHA}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
Margin="8,0,0,0">
|
||||
<TextBlock Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<Path Margin="6,0,0,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Width="12" Height="12"
|
||||
Data="{StaticResource Icons.Check}"
|
||||
Fill="Green"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}"/>
|
||||
<Border Height="16"
|
||||
Margin="6,0,0,0" Padding="4,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Background="DarkOrange"
|
||||
CornerRadius="4"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}">
|
||||
<Grid>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.NotInited}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.NotInited}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.Modified}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Modified}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.RevisionChanged}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.RevisionChanged}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.Unmerged}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Unmerged}}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
Classes="info_label"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.URL}"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||
Margin="8,0,0,0"
|
||||
Text="{Binding URL}"
|
||||
Foreground="{DynamicResource Brush.Link}"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.DataTemplates>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="vm:SubmoduleTreeNode">
|
||||
<Border Height="24"
|
||||
Background="Transparent"
|
||||
DoubleTapped="OnItemDoubleTapped"
|
||||
ContextRequested="OnItemContextRequested"
|
||||
ToolTip.Tip="{Binding Module}"
|
||||
ToolTip.Placement="Right">
|
||||
<Grid ColumnDefinitions="16,Auto,*,Auto,Auto"
|
||||
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
||||
VerticalAlignment="Center">
|
||||
<v:SubmoduleTreeNodeToggleButton Grid.Column="0"
|
||||
Classes="tree_expander"
|
||||
Focusable="False"
|
||||
HorizontalAlignment="Center"
|
||||
IsChecked="{Binding IsExpanded, Mode=OneWay}"
|
||||
IsVisible="{Binding IsFolder}"/>
|
||||
|
||||
<v:SubmoduleTreeNodeIcon Grid.Column="1"
|
||||
IsExpanded="{Binding IsExpanded, Mode=OneWay}"/>
|
||||
|
||||
<TextBlock Grid.Column="2"
|
||||
Classes="primary"
|
||||
Margin="8,0,0,0"
|
||||
TextTrimming="CharacterEllipsis">
|
||||
<Run Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"/>
|
||||
<Run Text="{Binding ChildCounter}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</TextBlock>
|
||||
|
||||
<Path Grid.Column="3"
|
||||
Width="8" Height="8"
|
||||
Margin="0,0,12,0"
|
||||
Fill="Goldenrod"
|
||||
Data="{StaticResource Icons.Modified}"
|
||||
IsVisible="{Binding IsDirty}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DataTemplate>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
Classes="info_label"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.URL}"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||
Margin="8,0,0,0"
|
||||
Text="{Binding URL}"
|
||||
Foreground="{DynamicResource Brush.Link}"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<DataTemplate DataType="vm:SubmoduleCollectionAsList">
|
||||
<ListBox Classes="repo_left_content_list" ItemsSource="{Binding Submodules}" SelectionMode="Single">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="CornerRadius" Value="4"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="m:Submodule">
|
||||
<Border Height="24"
|
||||
Background="Transparent"
|
||||
DoubleTapped="OnItemDoubleTapped"
|
||||
ContextRequested="OnItemContextRequested"
|
||||
ToolTip.Placement="Right">
|
||||
<ToolTip.Tip>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="10" Height="10" Data="{StaticResource Icons.Submodule}"/>
|
||||
<TextBlock FontWeight="Bold" Margin="4,0,0,0" Text="{Binding Path}"/>
|
||||
</StackPanel>
|
||||
|
||||
<Grid RowDefinitions="24,24" ColumnDefinitions="Auto,Auto" Margin="0,8,0,0">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||
Classes="info_label"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.CommitDetail.Info.SHA}"/>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1"
|
||||
Orientation="Horizontal"
|
||||
Margin="8,0,0,0">
|
||||
<TextBlock Text="{Binding SHA, Converter={x:Static c:StringConverters.ToShortSHA}}"
|
||||
VerticalAlignment="Center"/>
|
||||
|
||||
<Path Margin="6,0,0,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Width="12" Height="12"
|
||||
Data="{StaticResource Icons.Check}"
|
||||
Fill="Green"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}"/>
|
||||
<Border Height="16"
|
||||
Margin="6,0,0,0" Padding="4,0"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Background="DarkOrange"
|
||||
CornerRadius="4"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.NotEqual}, ConverterParameter={x:Static m:SubmoduleStatus.Normal}}">
|
||||
<Grid>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.NotInited}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.NotInited}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.Modified}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Modified}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.RevisionChanged}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.RevisionChanged}}"/>
|
||||
<TextBlock VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.Status.Unmerged}"
|
||||
Foreground="White"
|
||||
IsVisible="{Binding Status, Converter={x:Static ObjectConverters.Equal}, ConverterParameter={x:Static m:SubmoduleStatus.Unmerged}}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0"
|
||||
Classes="info_label"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Text="{DynamicResource Text.Submodule.URL}"/>
|
||||
<TextBlock Grid.Row="1" Grid.Column="1"
|
||||
Margin="8,0,0,0"
|
||||
Text="{Binding URL}"
|
||||
Foreground="{DynamicResource Brush.Link}"
|
||||
VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ToolTip.Tip>
|
||||
|
||||
<Grid ColumnDefinitions="16,*,Auto" Margin="8,0,0,0" VerticalAlignment="Center">
|
||||
<Path Grid.Column="0" Width="10" Height="10" Margin="8,0" Data="{StaticResource Icons.Submodule}"/>
|
||||
<TextBlock Grid.Column="1" Text="{Binding Path}" ClipToBounds="True" Classes="primary" TextTrimming="CharacterEllipsis"/>
|
||||
<Path Grid.Column="2"
|
||||
Width="8" Height="8"
|
||||
Margin="8,0,12,0"
|
||||
Fill="Goldenrod"
|
||||
Data="{StaticResource Icons.Modified}"
|
||||
IsVisible="{Binding IsDirty}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DataTemplate>
|
||||
</UserControl.DataTemplates>
|
||||
|
||||
<ListBox Classes="repo_left_content_list" ItemsSource="{Binding #ThisControl.Submodules.Rows}" SelectionMode="Single">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="CornerRadius" Value="4"/>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="vm:SubmoduleTreeNode">
|
||||
<Border Height="24"
|
||||
Background="Transparent"
|
||||
DoubleTapped="OnDoubleTappedNode"
|
||||
ContextRequested="OnRowContextRequested"
|
||||
ToolTip.Tip="{Binding Module}"
|
||||
ToolTip.Placement="Right">
|
||||
<Grid ColumnDefinitions="16,Auto,*,Auto,Auto"
|
||||
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
|
||||
VerticalAlignment="Center">
|
||||
<v:SubmoduleTreeNodeToggleButton Grid.Column="0"
|
||||
Classes="tree_expander"
|
||||
Focusable="False"
|
||||
HorizontalAlignment="Center"
|
||||
IsChecked="{Binding IsExpanded, Mode=OneWay}"
|
||||
IsVisible="{Binding IsFolder}"/>
|
||||
|
||||
<v:SubmoduleTreeNodeIcon Grid.Column="1"
|
||||
IsExpanded="{Binding IsExpanded, Mode=OneWay}"/>
|
||||
|
||||
<TextBlock Grid.Column="2"
|
||||
Classes="primary"
|
||||
Margin="8,0,0,0"
|
||||
TextTrimming="CharacterEllipsis">
|
||||
<Run Text="{Binding FullPath, Converter={x:Static c:PathConverters.PureFileName}}"/>
|
||||
<Run Text="{Binding ChildCounter}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</TextBlock>
|
||||
|
||||
<Path Grid.Column="3"
|
||||
Width="8" Height="8"
|
||||
Margin="0,0,12,0"
|
||||
Fill="Goldenrod"
|
||||
Data="{StaticResource Icons.Modified}"
|
||||
IsVisible="{Binding IsDirty}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</UserControl>
|
||||
|
|
|
@ -89,15 +89,6 @@ namespace SourceGit.Views
|
|||
|
||||
public partial class SubmodulesView : UserControl
|
||||
{
|
||||
public static readonly StyledProperty<ViewModels.SubmoduleCollection> SubmodulesProperty =
|
||||
AvaloniaProperty.Register<SubmodulesView, ViewModels.SubmoduleCollection>(nameof(Submodules));
|
||||
|
||||
public ViewModels.SubmoduleCollection Submodules
|
||||
{
|
||||
get => GetValue(SubmodulesProperty);
|
||||
set => SetValue(SubmodulesProperty, value);
|
||||
}
|
||||
|
||||
public static readonly RoutedEvent<RoutedEventArgs> RowsChangedEvent =
|
||||
RoutedEvent.Register<TagsView, RoutedEventArgs>(nameof(RowsChanged), RoutingStrategies.Tunnel | RoutingStrategies.Bubble);
|
||||
|
||||
|
@ -120,11 +111,10 @@ namespace SourceGit.Views
|
|||
|
||||
public void ToggleNodeIsExpanded(ViewModels.SubmoduleTreeNode node)
|
||||
{
|
||||
var submodules = Submodules;
|
||||
if (submodules != null)
|
||||
if (Content is ViewModels.SubmoduleCollectionAsTree tree)
|
||||
{
|
||||
submodules.ToggleExpand(node);
|
||||
Rows = submodules.Rows.Count;
|
||||
tree.ToggleExpand(node);
|
||||
Rows = tree.Rows.Count;
|
||||
RaiseEvent(new RoutedEventArgs(RowsChangedEvent));
|
||||
}
|
||||
}
|
||||
|
@ -133,9 +123,15 @@ namespace SourceGit.Views
|
|||
{
|
||||
base.OnPropertyChanged(change);
|
||||
|
||||
if (change.Property == SubmodulesProperty)
|
||||
if (change.Property == ContentProperty)
|
||||
{
|
||||
Rows = Submodules?.Rows.Count ?? 0;
|
||||
if (Content is ViewModels.SubmoduleCollectionAsTree tree)
|
||||
Rows = tree.Rows.Count;
|
||||
else if (Content is ViewModels.SubmoduleCollectionAsList list)
|
||||
Rows = list.Submodules.Count;
|
||||
else
|
||||
Rows = 0;
|
||||
|
||||
RaiseEvent(new RoutedEventArgs(RowsChangedEvent));
|
||||
}
|
||||
else if (change.Property == IsVisibleProperty)
|
||||
|
@ -144,28 +140,40 @@ namespace SourceGit.Views
|
|||
}
|
||||
}
|
||||
|
||||
private void OnDoubleTappedNode(object sender, TappedEventArgs e)
|
||||
private void OnItemDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (sender is Control { DataContext: ViewModels.SubmoduleTreeNode node } &&
|
||||
DataContext is ViewModels.Repository repo)
|
||||
if (sender is Control control && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
if (node.IsFolder)
|
||||
ToggleNodeIsExpanded(node);
|
||||
else if (node.Module.Status != Models.SubmoduleStatus.NotInited)
|
||||
repo.OpenSubmodule(node.Module.Path);
|
||||
if (control.DataContext is ViewModels.SubmoduleTreeNode node)
|
||||
{
|
||||
if (node.IsFolder)
|
||||
ToggleNodeIsExpanded(node);
|
||||
else if (node.Module.Status != Models.SubmoduleStatus.NotInited)
|
||||
repo.OpenSubmodule(node.Module.Path);
|
||||
}
|
||||
else if (control.DataContext is Models.Submodule m && m.Status != Models.SubmoduleStatus.NotInited)
|
||||
{
|
||||
repo.OpenSubmodule(m.Path);
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnRowContextRequested(object sender, ContextRequestedEventArgs e)
|
||||
private void OnItemContextRequested(object sender, ContextRequestedEventArgs e)
|
||||
{
|
||||
if (sender is Control { DataContext: ViewModels.SubmoduleTreeNode node } control &&
|
||||
node.Module != null &&
|
||||
DataContext is ViewModels.Repository repo)
|
||||
if (sender is Control control && DataContext is ViewModels.Repository repo)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForSubmodule(node.Module);
|
||||
menu?.Open(control);
|
||||
if (control.DataContext is ViewModels.SubmoduleTreeNode node && node.Module != null)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForSubmodule(node.Module);
|
||||
menu?.Open(control);
|
||||
}
|
||||
else if (control.DataContext is Models.Submodule m)
|
||||
{
|
||||
var menu = repo.CreateContextMenuForSubmodule(m);
|
||||
menu?.Open(control);
|
||||
}
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue