mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
ux: use DataGrid instead of ChangeCollectionView for changes in INFORMATION page
This commit is contained in:
parent
49ce07443e
commit
0e6a08860a
2 changed files with 51 additions and 37 deletions
|
@ -25,28 +25,40 @@
|
|||
<Rectangle Grid.Row="1" Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>
|
||||
|
||||
<!-- Change List -->
|
||||
<Grid Grid.Row="2" ColumnDefinitions="96,*" Margin="0,0,8,16">
|
||||
<TextBlock Grid.Column="0"
|
||||
Classes="group_header_label"
|
||||
Margin="0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Top"
|
||||
Text="{DynamicResource Text.CommitDetail.Changes}"/>
|
||||
|
||||
<v:ChangeCollectionView Grid.Column="1"
|
||||
IsWorkingCopyChange="False"
|
||||
Margin="8,0,0,0"
|
||||
ViewMode="List"
|
||||
Changes="{Binding Changes}"
|
||||
<DataGrid Grid.Row="2"
|
||||
Background="Transparent"
|
||||
ItemsSource="{Binding Changes}"
|
||||
SelectionMode="Single"
|
||||
CanUserReorderColumns="False"
|
||||
CanUserResizeColumns="False"
|
||||
CanUserSortColumns="False"
|
||||
IsReadOnly="True"
|
||||
HeadersVisibility="None"
|
||||
Focusable="False"
|
||||
RowHeight="26"
|
||||
Margin="80,0,8,16"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
ContextRequested="OnChangeListContextRequested"
|
||||
ChangeDoubleTapped="OnChangeDoubleTapped">
|
||||
<v:ChangeCollectionView.Styles>
|
||||
<Style Selector="TreeDataGrid">
|
||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
|
||||
</Style>
|
||||
</v:ChangeCollectionView.Styles>
|
||||
</v:ChangeCollectionView>
|
||||
</Grid>
|
||||
DoubleTapped="OnChangeListDoubleTapped">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="ICON">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<v:ChangeStatusIcon Width="14" Height="14" IsWorkingCopyChange="False" Change="{Binding}"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Width="*" Header="PATH">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Classes="monospace" Text="{Binding Path}" Margin="8,0,0,0"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</TabItem>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
|
@ -10,31 +10,33 @@ namespace SourceGit.Views
|
|||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnChangeListContextRequested(object sender, ContextRequestedEventArgs e)
|
||||
private void OnChangeListDoubleTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.CommitDetail vm && sender is ChangeCollectionView view)
|
||||
if (DataContext is ViewModels.CommitDetail detail)
|
||||
{
|
||||
var selected = view.SelectedChanges;
|
||||
if (selected != null && selected.Count == 1)
|
||||
{
|
||||
var menu = vm.CreateChangeContextMenu(selected[0]);
|
||||
view.OpenContextMenu(menu);
|
||||
}
|
||||
var datagrid = sender as DataGrid;
|
||||
detail.ActivePageIndex = 1;
|
||||
detail.SelectedChanges = new () { datagrid.SelectedItem as Models.Change };
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnChangeDoubleTapped(object sender, RoutedEventArgs e)
|
||||
private void OnChangeListContextRequested(object sender, ContextRequestedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.CommitDetail vm && sender is ChangeCollectionView view)
|
||||
if (DataContext is ViewModels.CommitDetail detail)
|
||||
{
|
||||
var selected = view.SelectedChanges;
|
||||
if (selected != null && selected.Count == 1)
|
||||
var datagrid = sender as DataGrid;
|
||||
if (datagrid.SelectedItem == null)
|
||||
{
|
||||
vm.ActivePageIndex = 1;
|
||||
vm.SelectedChanges = new() { selected[0] };
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
|
||||
datagrid.OpenContextMenu(menu);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue