mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07: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"/>
|
<Rectangle Grid.Row="1" Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}" VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- Change List -->
|
<!-- Change List -->
|
||||||
<Grid Grid.Row="2" ColumnDefinitions="96,*" Margin="0,0,8,16">
|
<DataGrid Grid.Row="2"
|
||||||
<TextBlock Grid.Column="0"
|
Background="Transparent"
|
||||||
Classes="group_header_label"
|
ItemsSource="{Binding Changes}"
|
||||||
Margin="0"
|
SelectionMode="Single"
|
||||||
HorizontalAlignment="Right"
|
CanUserReorderColumns="False"
|
||||||
VerticalAlignment="Top"
|
CanUserResizeColumns="False"
|
||||||
Text="{DynamicResource Text.CommitDetail.Changes}"/>
|
CanUserSortColumns="False"
|
||||||
|
IsReadOnly="True"
|
||||||
|
HeadersVisibility="None"
|
||||||
|
Focusable="False"
|
||||||
|
RowHeight="26"
|
||||||
|
Margin="80,0,8,16"
|
||||||
|
HorizontalScrollBarVisibility="Disabled"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
ContextRequested="OnChangeListContextRequested"
|
||||||
|
DoubleTapped="OnChangeListDoubleTapped">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTemplateColumn Header="ICON">
|
||||||
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<v:ChangeStatusIcon Width="14" Height="14" IsWorkingCopyChange="False" Change="{Binding}"/>
|
||||||
|
</DataTemplate>
|
||||||
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
|
</DataGridTemplateColumn>
|
||||||
|
|
||||||
<v:ChangeCollectionView Grid.Column="1"
|
<DataGridTemplateColumn Width="*" Header="PATH">
|
||||||
IsWorkingCopyChange="False"
|
<DataGridTemplateColumn.CellTemplate>
|
||||||
Margin="8,0,0,0"
|
<DataTemplate>
|
||||||
ViewMode="List"
|
<TextBlock Classes="monospace" Text="{Binding Path}" Margin="8,0,0,0"/>
|
||||||
Changes="{Binding Changes}"
|
</DataTemplate>
|
||||||
ContextRequested="OnChangeListContextRequested"
|
</DataGridTemplateColumn.CellTemplate>
|
||||||
ChangeDoubleTapped="OnChangeDoubleTapped">
|
</DataGridTemplateColumn>
|
||||||
<v:ChangeCollectionView.Styles>
|
</DataGrid.Columns>
|
||||||
<Style Selector="TreeDataGrid">
|
</DataGrid>
|
||||||
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
|
|
||||||
</Style>
|
|
||||||
</v:ChangeCollectionView.Styles>
|
|
||||||
</v:ChangeCollectionView>
|
|
||||||
</Grid>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Input;
|
||||||
|
|
||||||
namespace SourceGit.Views
|
namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
|
@ -10,31 +10,33 @@ namespace SourceGit.Views
|
||||||
InitializeComponent();
|
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;
|
var datagrid = sender as DataGrid;
|
||||||
if (selected != null && selected.Count == 1)
|
detail.ActivePageIndex = 1;
|
||||||
{
|
detail.SelectedChanges = new () { datagrid.SelectedItem as Models.Change };
|
||||||
var menu = vm.CreateChangeContextMenu(selected[0]);
|
|
||||||
view.OpenContextMenu(menu);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
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;
|
var datagrid = sender as DataGrid;
|
||||||
if (selected != null && selected.Count == 1)
|
if (datagrid.SelectedItem == null)
|
||||||
{
|
{
|
||||||
vm.ActivePageIndex = 1;
|
e.Handled = true;
|
||||||
vm.SelectedChanges = new() { selected[0] };
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var menu = detail.CreateChangeContextMenu(datagrid.SelectedItem as Models.Change);
|
||||||
|
datagrid.OpenContextMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue