Skip to content

Commit

Permalink
space bar to toggle selected items in pending changes window
Browse files Browse the repository at this point in the history
  • Loading branch information
yysun committed Jul 9, 2012
1 parent 1b6692f commit f5408e2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 2 additions & 2 deletions GitUI/UI/PendingChanges.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@
<DataGrid AutoGenerateColumns="False" Grid.Row="3" HorizontalAlignment="Stretch" Margin="10,0,10,10" Name="dataGrid1" VerticalAlignment="Stretch"
GridLinesVisibility="None" Foreground="#FF333333" Sorting="dataGrid1_Sorting" IsReadOnly="True" SelectedValuePath="FileName"
SelectionMode="Extended" SelectionChanged="dataGrid1_SelectionChanged" ContextMenuOpening="dataGrid1_ContextMenuOpening"
CanUserResizeRows="False" CanUserDeleteRows="False" CanUserAddRows="False" CanUserReorderColumns="False" RowHeaderWidth="0">
CanUserResizeRows="False" CanUserDeleteRows="False" CanUserAddRows="False" CanUserReorderColumns="False" RowHeaderWidth="0" KeyDown="dataGrid1_KeyDown">

<DataGrid.Columns>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Staged" CanUserResize="False">
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
Expand Down
13 changes: 12 additions & 1 deletion GitUI/UI/PendingChanges.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using GitScc;
using System.Diagnostics;

namespace GitUI.UI
{
Expand Down Expand Up @@ -38,7 +39,17 @@ private void dataGrid1_Sorting(object sender, DataGridSortingEventArgs e)
sortMemberPath = e.Column.SortMemberPath;
sortDirection = e.Column.SortDirection != ListSortDirection.Ascending ?
ListSortDirection.Ascending : ListSortDirection.Descending;
}

private void dataGrid1_KeyDown(object sender, KeyEventArgs e)
{
var selectedItem = this.dataGrid1.SelectedItem as GitFile;
if (selectedItem == null || e.Key != Key.Space) return;
var selected = !selectedItem.IsSelected;
foreach (var item in this.dataGrid1.SelectedItems)
{
((GitFile)item).IsSelected = selected;
}
}

private void checkBoxSelected_Click(object sender, RoutedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion PendingChangesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<DataGrid AutoGenerateColumns="False" Grid.Row="3" HorizontalAlignment="Stretch" Margin="10,0,10,10" Name="dataGrid1" VerticalAlignment="Stretch"
GridLinesVisibility="None" Foreground="#FF333333" Sorting="dataGrid1_Sorting" IsReadOnly="True" SelectedValuePath="FileName"
SelectionMode="Extended" SelectionChanged="dataGrid1_SelectionChanged" MouseDoubleClick="dataGrid1_MouseDoubleClick" ContextMenuOpening="dataGrid1_ContextMenuOpening"
CanUserResizeRows="False" CanUserDeleteRows="False" CanUserAddRows="False" CanUserReorderColumns="False" RowHeaderWidth="0">
CanUserResizeRows="False" CanUserDeleteRows="False" CanUserAddRows="False" CanUserReorderColumns="False" RowHeaderWidth="0" KeyDown="dataGrid1_KeyDown">

<DataGrid.Columns>
<DataGridTemplateColumn Header="Staged" CanUserResize="False">
Expand Down
15 changes: 11 additions & 4 deletions PendingChangesView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
Expand All @@ -10,10 +11,7 @@
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using Microsoft.VisualStudio.TextManager.Interop;
using NGit.Api;
using GitScc.UI;
using System.Diagnostics;

namespace GitScc
{
Expand Down Expand Up @@ -42,9 +40,18 @@ private void dataGrid1_Sorting(object sender, DataGridSortingEventArgs e)
sortMemberPath = e.Column.SortMemberPath;
sortDirection = e.Column.SortDirection != ListSortDirection.Ascending ?
ListSortDirection.Ascending : ListSortDirection.Descending;

}

private void dataGrid1_KeyDown(object sender, KeyEventArgs e)
{
var selectedItem = this.dataGrid1.SelectedItem as GitFile;
if (selectedItem == null || e.Key != Key.Space) return;
var selected = !selectedItem.IsSelected;
foreach (var item in this.dataGrid1.SelectedItems)
{
((GitFile)item).IsSelected = selected;
}
}

private void checkBoxSelected_Click(object sender, RoutedEventArgs e)
{
Expand Down

0 comments on commit f5408e2

Please sign in to comment.