Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Panel refactorings.

  • Loading branch information...
commit 8d21c6bdb2d5af874a3a1001bfdde82034c5bb3d 1 parent 22337bd
@kaisellgren authored
View
45 Converters/GenericVisibilityConverter.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.ObjectModel;
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace GG.Converters
+{
+ public class GenericVisibilityConverter : IValueConverter
+ {
+ #region Implementation of IValueConverter
+
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ // Whether to invert the visibility.
+ var invert = (string) parameter == "not" ? true : false;
+
+ // int 0
+ if (value is int && (int) value == 0)
+ return invert ? Visibility.Visible : Visibility.Collapsed;
+
+ // int > 0
+ if (value is int && (int) value > 0)
+ return invert ? Visibility.Collapsed : Visibility.Visible;
+
+ // null || bool == false
+ if (value == null || (value is bool && (bool) value == false))
+ return invert ? Visibility.Visible : Visibility.Collapsed;
+
+ // bool == true
+ if (value is bool && (bool) value == true)
+ return invert ? Visibility.Collapsed : Visibility.Visible;
+
+ // Fall back to "visible".
+ return invert ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+
+ #endregion
+ }
+}
View
6 Converters/StatusToColorConverter.cs
@@ -27,10 +27,10 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
if (value == null)
return COLOR_RED;
- LibGit2Sharp.FileStatus status = (LibGit2Sharp.FileStatus) value;
+ var status = (LibGit2Sharp.FileStatus) value;
// Whether to use darker colors (for text).
- bool darkerColors = (string) parameter == "dark";
+ var darkerColors = (string) parameter == "dark";
// Removed & Missing = red.
if (status.HasFlag(LibGit2Sharp.FileStatus.Removed) || status.HasFlag(LibGit2Sharp.FileStatus.Missing))
@@ -48,7 +48,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
if (status.HasFlag(LibGit2Sharp.FileStatus.Untracked))
return darkerColors ? COLOR_DARK_GRAY : COLOR_GRAY;
- throw new Exception("Could not convert status " + status.ToString() + " to a SolidColorBrush!");
+ throw new Exception("Could not convert status " + status + " to a SolidColorBrush!");
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
View
8 Git-GUI.csproj
@@ -156,8 +156,12 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
+ <Compile Include="Converters\GenericVisibilityConverter.cs" />
<Compile Include="Converters\GetDataGridContentHeightConverter.cs" />
<Compile Include="Libraries\Observable.cs" />
+ <Compile Include="UserControls\CenterArea.xaml.cs">
+ <DependentUpon>CenterArea.xaml</DependentUpon>
+ </Compile>
<Compile Include="UserControls\Dialogs\ConfirmDialog.xaml.cs">
<DependentUpon>ConfirmDialog.xaml</DependentUpon>
</Compile>
@@ -240,6 +244,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
+ <Page Include="UserControls\CenterArea.xaml">
+ <SubType>Designer</SubType>
+ <Generator>MSBuild:Compile</Generator>
+ </Page>
<Page Include="UserControls\Dialogs\ConfirmDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
View
8 Libraries/EnhancedObservableCollection.cs
@@ -63,6 +63,14 @@ public void AddRange(IEnumerable<T> collection)
OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
}
+ /// <summary>
+ /// Returns true if the collection is empty.
+ /// </summary>
+ public bool IsEmpty
+ {
+ get { return Count == 0; }
+ }
+
/// <summary>
/// Initializes a new instance of the System.Collections.ObjectModel.ObservableCollection(Of T) class.
/// </summary>
View
66 UserControls/CommitPanel.xaml
@@ -3,20 +3,74 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:controls="clr-namespace:GG.UserControls"
+ xmlns:userControls="clr-namespace:GG.UserControls"
+ xmlns:converters="clr-namespace:GG.Converters"
mc:Ignorable="d"
d:DesignHeight="480" d:DesignWidth="640">
+
+ <UserControl.Resources>
+ <converters:NullToVisibilityConverter x:Key="nullToVisibilityConverter" />
+
+ <DataTemplate x:Key="Test">
+ <TextBlock x:Name="FooBarBaz">Foo bar baz</TextBlock>
+ </DataTemplate>
+ </UserControl.Resources>
+
<DockPanel>
- <!-- TODO: Panel should be a reusable component... I've only made the title to be reusable, the rest is hard-coded as Commit Panel stuff in Panel XAML... move it in here... -->
- <controls:Panel>
- <controls:Panel.Header>
+ <userControls:Panel Header="{StaticResource Test}">
+ <!--<userControls:Panel.Header>
<WrapPanel>
<TextBlock Text="Parent: (" />
<TextBlock Text="{Binding Head.Tip.HashShort}" />
<TextBlock Text=") " />
<TextBlock Text="{Binding Head.Tip.ShortDescription}" />
</WrapPanel>
- </controls:Panel.Header>
- </controls:Panel>
+ </userControls:Panel.Header>-->
+
+ <userControls:Panel.HeaderButtons>
+ <WrapPanel HorizontalAlignment="Right">
+ <Grid>
+ <ComboBox ToolTip="Copy a previous commit message. The entire message will be copied."
+ ItemsSource="{Binding RecentCommitMessages}"
+ DisplayMemberPath="CroppedMessage"
+ Loaded="ComboBoxLoaded"
+ SelectionChanged="OnRecentCommitMessagesSelectionChanged"
+ Width="135" Margin="0,4,4,4">
+ </ComboBox>
+ <WrapPanel Margin="8,9,0,0" Visibility="{Binding SelectedItem, ElementName=RecentCommitMessages, Converter={StaticResource nullToVisibilityConverter}}">
+ <Image Source="../Resources/Icons/MessageWrite.png" Stretch="None" Margin="0,0,4,0" />
+ <TextBlock IsHitTestVisible="False" Text="Copy a message" Foreground="#333" />
+ </WrapPanel>
+ </Grid>
+ <Button Margin="0,3,3,3" Command="{Binding CommitCommand}" CommandParameter="{Binding Text, ElementName=CommitMessageTextBox}">
+ <WrapPanel>
+ <Image Source="../Resources/Icons/RepositoryWrite.png" Width="16" Margin="0,0,4,0" />
+ <TextBlock>Commit</TextBlock>
+ </WrapPanel>
+ </Button>
+ </WrapPanel>
+ </userControls:Panel.HeaderButtons>
+
+ <userControls:Panel.Body>
+ <StackPanel Margin="4">
+ <TextBox Loaded="TextBoxLoaded"
+ ToolTip="Enter your commit message."
+ FontSize="12"
+ FontFamily="Courier New"
+ Height="38pt">
+
+ <TextBox.InputBindings>
+ <KeyBinding Key="Enter"
+ Modifiers="Control"
+ Command="{Binding CommitCommand}"
+ CommandParameter="{Binding Text, ElementName=CommitMessageTextBox}" />
+ </TextBox.InputBindings>
+ </TextBox>
+
+ <userControls:DiffPanel DockPanel.Dock="Bottom" Margin="0,4,0,0" />
+ </StackPanel>
+ </userControls:Panel.Body>
+
+ </userControls:Panel>
</DockPanel>
</UserControl>
View
43 UserControls/CommitPanel.xaml.cs
@@ -1,16 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Windows;
+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.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
+using GG.Libraries;
+using GG.Models;
namespace GG.UserControls
{
@@ -23,5 +14,33 @@ public CommitPanel()
{
InitializeComponent();
}
+
+ private void TextBoxLoaded(object sender, RoutedEventArgs e)
+ {
+ ((TextBox) sender).Name = "CommitMessageTextBox";
+ }
+
+ private void OnRecentCommitMessagesSelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ // Retrieve elements.
+ var recentCommitMessages = UIHelper.FindChild<ComboBox>(this, "RecentCommitMessages");
+ var commitMessageBox = UIHelper.FindChild<TextBox>(this, "CommitMessageTextBox");
+
+ var selectedRecentCommitMessage = recentCommitMessages.SelectedItem as RecentCommitMessage;
+
+ if (selectedRecentCommitMessage == null)
+ return;
+
+ // Set the commit text box value.
+ commitMessageBox.Text = selectedRecentCommitMessage.FullMessage;
+
+ // Reset the drop down menu.
+ recentCommitMessages.SelectedIndex = -1;
+ }
+
+ private void ComboBoxLoaded(object sender, RoutedEventArgs e)
+ {
+ ((ComboBox) sender).Name = "RecentCommitMessages";
+ }
}
}
View
1  UserControls/DiffPanel.xaml
@@ -8,7 +8,6 @@
<TextBox HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
- Margin="4"
Padding="4,6"
Background="White"
BorderThickness="0"
View
48 UserControls/Panel.xaml
@@ -2,17 +2,11 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- xmlns:local="clr-namespace:GG"
xmlns:userControls="clr-namespace:GG.UserControls"
- xmlns:converters="clr-namespace:GG.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="600">
- <UserControl.Resources>
- <converters:NullToVisibilityConverter x:Key="nullToVisibilityConverter" />
- </UserControl.Resources>
-
<UserControl.Template>
<ControlTemplate>
<DockPanel>
@@ -20,48 +14,12 @@
<Border BorderBrush="#7ea3be" BorderThickness="1">
<DockPanel Style="{StaticResource PanelHeaderStyle}">
<ContentPresenter DockPanel.Dock="Left" Style="{StaticResource PanelHeaderTitleStyle}" Content="{TemplateBinding userControls:Panel.Header}" />
- <WrapPanel DockPanel.Dock="Right" HorizontalAlignment="Right">
- <Grid>
- <ComboBox ToolTip="Copy a previous commit message. The entire message will be copied."
- ItemsSource="{Binding RecentCommitMessages}"
- DisplayMemberPath="CroppedMessage"
- Name="RecentCommitMessages"
- SelectionChanged="OnRecentCommitMessagesSelectionChanged"
- Width="135" Margin="0,4,4,4">
- </ComboBox>
- <WrapPanel Margin="8,9,0,0" Visibility="{Binding SelectedItem, ElementName=RecentCommitMessages, Converter={StaticResource nullToVisibilityConverter}}">
- <Image Source="../Resources/Icons/MessageWrite.png" Stretch="None" Margin="0,0,4,0" />
- <TextBlock IsHitTestVisible="False" Text="Copy a message" Foreground="#333" />
- </WrapPanel>
- </Grid>
- <Button Margin="0,3,3,3"
- Command="{Binding CommitCommand}" CommandParameter="{Binding Text, ElementName=CommitMessageTextBox}">
- <WrapPanel>
- <Image Source="../Resources/Icons/RepositoryWrite.png" Width="16" Margin="0,0,4,0" />
- <TextBlock>Commit</TextBlock>
- </WrapPanel>
- </Button>
- </WrapPanel>
+ <ContentPresenter DockPanel.Dock="Right" Content="{TemplateBinding userControls:Panel.HeaderButtons}" />
</DockPanel>
</Border>
- <Grid>
- <StackPanel Margin="4">
- <TextBox Name="CommitMessageTextBox"
- ToolTip="Enter your commit message."
- FontSize="12"
- FontFamily="Courier New"
- Height="38pt">
- <TextBox.InputBindings>
- <KeyBinding Key="Enter"
- Modifiers="Control"
- Command="{Binding CommitCommand}"
- CommandParameter="{Binding Text, ElementName=CommitMessageTextBox}" />
- </TextBox.InputBindings>
- </TextBox>
- </StackPanel>
- </Grid>
</StackPanel>
- <userControls:DiffPanel DockPanel.Dock="Bottom" />
+
+ <ContentPresenter DockPanel.Dock="Bottom" Content="{TemplateBinding userControls:Panel.Body}" />
</DockPanel>
</ControlTemplate>
</UserControl.Template>
View
67 UserControls/Panel.xaml.cs
@@ -31,11 +31,10 @@ public object Header
set { SetValue(HeaderProperty, value); }
}
- public static DependencyProperty HeaderProperty =
- DependencyProperty.Register("Header",
- typeof(object),
- typeof(Panel),
- new PropertyMetadata(null));
+ public static DependencyProperty HeaderProperty = DependencyProperty.Register("Header",
+ typeof(object),
+ typeof(Panel),
+ new PropertyMetadata(null));
private static void HeaderPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
@@ -47,27 +46,59 @@ private static void HeaderPropertyChanged(DependencyObject d, DependencyProperty
}
#endregion
- public Panel()
+ #region Body property.
+ /// <summary>
+ /// The text or content to use for the body.
+ /// </summary>
+ public object Body
{
- InitializeComponent();
+ get { return (object) GetValue(BodyProperty); }
+ set { SetValue(BodyProperty, value); }
}
- private void OnRecentCommitMessagesSelectionChanged(object sender, SelectionChangedEventArgs e)
+ public static DependencyProperty BodyProperty = DependencyProperty.Register("Body",
+ typeof(object),
+ typeof(Panel),
+ new PropertyMetadata(null));
+
+ private static void BodyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var control = d as Panel;
+ if (control != null)
+ {
+ control.Body = (object) e.NewValue;
+ }
+ }
+ #endregion
+
+ #region Header buttons property.
+ /// <summary>
+ /// The text or content to use for the header buttons.
+ /// </summary>
+ public object HeaderButtons
{
- // Retrieve elements.
- var recentCommitMessages = UIHelper.FindChild<ComboBox>(this, "RecentCommitMessages");
- var commitMessageBox = UIHelper.FindChild<TextBox>(this, "CommitMessageTextBox");
+ get { return (object) GetValue(HeaderButtonsProperty); }
+ set { SetValue(HeaderButtonsProperty, value); }
+ }
- var selectedRecentCommitMessage = recentCommitMessages.SelectedItem as RecentCommitMessage;
+ public static DependencyProperty HeaderButtonsProperty = DependencyProperty.Register("HeaderButtons",
+ typeof(object),
+ typeof(Panel),
+ new PropertyMetadata(null));
- if (selectedRecentCommitMessage != null)
+ private static void HeaderButtonsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ var control = d as Panel;
+ if (control != null)
{
- // Set the commit text box value.
- commitMessageBox.Text = selectedRecentCommitMessage.FullMessage;
-
- // Reset the drop down menu.
- recentCommitMessages.SelectedIndex = -1;
+ control.HeaderButtons = (object) e.NewValue;
}
}
+ #endregion
+
+ public Panel()
+ {
+ InitializeComponent();
+ }
}
}
View
200 UserControls/StatusGrid.xaml
@@ -11,7 +11,7 @@
<converters:StatusToColorConverter x:Key="statusToColorConverter" />
<converters:StatusToCharacterConverter x:Key="statusToCharacterConverter" />
<converters:ExtensionToImageConverter x:Key="extensionToImageConverter" />
- <converters:StatusGridGroupToColorConverter x:Key="statusGridGroupToColorConverter" />
+ <converters:GenericVisibilityConverter x:Key="genericVisibilityConverter" />
<userControls:StatusGridContextMenu x:Key="statusGridContextMenu" />
<!-- Status template. -->
@@ -19,17 +19,17 @@
<WrapPanel HorizontalAlignment="Center">
<Border BorderThickness="0" CornerRadius="4" Background="{Binding Path=Status, Converter={StaticResource statusToColorConverter}}">
<TextBlock
- Width="16"
- VerticalAlignment="Stretch"
- HorizontalAlignment="Center"
- TextAlignment="Center"
- Foreground="White"
- FontFamily="Arial"
- FontSize="12"
- FontWeight="Bold"
- TextOptions.TextFormattingMode="Display"
- TextOptions.TextRenderingMode="ClearType"
- Text="{Binding Status, Converter={StaticResource statusToCharacterConverter}}" />
+ Width="16"
+ VerticalAlignment="Stretch"
+ HorizontalAlignment="Center"
+ TextAlignment="Center"
+ Foreground="White"
+ FontFamily="Arial"
+ FontSize="12"
+ FontWeight="Bold"
+ TextOptions.TextFormattingMode="Display"
+ TextOptions.TextRenderingMode="ClearType"
+ Text="{Binding Status, Converter={StaticResource statusToCharacterConverter}}" />
</Border>
</WrapPanel>
</ItemContainerTemplate>
@@ -39,7 +39,7 @@
<WrapPanel>
<Image Source="{Binding Extension, Converter={StaticResource extensionToImageConverter}}" Stretch="None" Margin="0,0,3,0" />
<TextBlock Text="{Binding Path=Filename}"
- Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
+ Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
</WrapPanel>
</ItemContainerTemplate>
@@ -60,92 +60,100 @@
<Grid>
<Grid.RowDefinitions>
- <RowDefinition Height="*" />
- <RowDefinition Height="*" />
+ <RowDefinition Height="*" MinHeight="72" />
+ <RowDefinition Height="6" />
+ <RowDefinition Height="*" MinHeight="72" />
</Grid.RowDefinitions>
- <DataGrid Grid.Row="0"
- ItemsSource="{Binding StatusItemsStaged}"
- SelectionChanged="StatusGridElement_SelectionChanged"
- Tag="{Binding}">
- <DataGrid.InputBindings>
- <KeyBinding Command="{Binding StageUnstageCommand}"
- CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
- Gesture="Enter" />
- <KeyBinding Command="{Binding StageUnstageCommand}"
- CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
- Gesture="Delete" />
- </DataGrid.InputBindings>
+ <userControls:Panel Grid.Row="0">
+ <userControls:Panel.Header>
+ <WrapPanel Margin="0,4,0,4">
+ <TextBlock>Staged</TextBlock>
+ <TextBlock xml:space="preserve">: </TextBlock>
+ <TextBlock Text="{Binding StatusItemsStaged.Count}" />
+ </WrapPanel>
+ </userControls:Panel.Header>
+ <userControls:Panel.Body>
+ <Grid>
+ <TextBlock Margin="8"
+ Foreground="#222"
+ Visibility="{Binding StatusItemsStaged.Count, Converter={StaticResource genericVisibilityConverter}, ConverterParameter=not}">Nothing to commit.</TextBlock>
+
+ <DataGrid
+ ItemsSource="{Binding StatusItemsStaged}"
+ SelectionChanged="StatusGridSelectionChanged"
+ BorderThickness="0"
+ Visibility="{Binding StatusItemsStaged.Count, Converter={StaticResource genericVisibilityConverter}}"
+ Tag="{Binding}">
+ <DataGrid.InputBindings>
+ <KeyBinding Command="{Binding StageUnstageCommand}"
+ CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
+ Gesture="Enter" />
+ <KeyBinding Command="{Binding StageUnstageCommand}"
+ CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
+ Gesture="Delete" />
+ </DataGrid.InputBindings>
- <DataGrid.Columns>
- <DataGridTemplateColumn Header="St" CellTemplate="{StaticResource StatusGridStatusTemplate}" />
- <DataGridTemplateColumn Header="Filename" Width="*" CellTemplate="{StaticResource StatusGridFilenameTemplate}" />
- <DataGridTextColumn Binding="{Binding Path=Size}"
- Header="Size"
- Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
- <DataGridTextColumn Binding="{Binding Path=IsBinary}"
- Header="Binary"
- Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
- </DataGrid.Columns>
- </DataGrid>
+ <DataGrid.Columns>
+ <DataGridTemplateColumn Header="St" CellTemplate="{StaticResource StatusGridStatusTemplate}" />
+ <DataGridTemplateColumn Header="Filename" Width="*" CellTemplate="{StaticResource StatusGridFilenameTemplate}" />
+ <DataGridTextColumn Binding="{Binding Path=Size}"
+ Header="Size"
+ Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
+ <DataGridTextColumn Binding="{Binding Path=IsBinary}"
+ Header="Binary"
+ Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
+ </DataGrid.Columns>
+ </DataGrid>
+ </Grid>
+ </userControls:Panel.Body>
+ </userControls:Panel>
- <DataGrid Grid.Row="1"
- ItemsSource="{Binding StatusItemsUnstaged}"
- SelectionChanged="StatusGridElement_SelectionChanged"
- Tag="{Binding}">
- <DataGrid.InputBindings>
- <KeyBinding Command="{Binding StageUnstageCommand}"
- CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
- Gesture="Enter" />
- <KeyBinding Command="{Binding StageUnstageCommand}"
- CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
- Gesture="Delete" />
- </DataGrid.InputBindings>
+ <GridSplitter Grid.Row="1" Style="{StaticResource GridSplitterVerticalStyle}" />
+
+ <userControls:Panel Grid.Row="2">
+ <userControls:Panel.Header>
+ <WrapPanel Margin="0,4,0,4">
+ <TextBlock>Unstaged</TextBlock>
+ <TextBlock xml:space="preserve">: </TextBlock>
+ <TextBlock Text="{Binding StatusItemsUnstaged.Count}" />
+ </WrapPanel>
+ </userControls:Panel.Header>
+ <userControls:Panel.Body>
+
+ <Grid>
+ <TextBlock Margin="8"
+ Foreground="#222"
+ Visibility="{Binding StatusItemsUnstaged.Count, Converter={StaticResource genericVisibilityConverter}, ConverterParameter=not}">Nothing to stage.</TextBlock>
+
+ <DataGrid
+ ItemsSource="{Binding StatusItemsUnstaged}"
+ SelectionChanged="StatusGridSelectionChanged"
+ BorderThickness="0"
+ Visibility="{Binding StatusItemsUnstaged.Count, Converter={StaticResource genericVisibilityConverter}}"
+ Tag="{Binding}">
+ <DataGrid.InputBindings>
+ <KeyBinding Command="{Binding StageUnstageCommand}"
+ CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
+ Gesture="Enter" />
+ <KeyBinding Command="{Binding StageUnstageCommand}"
+ CommandParameter="{Binding SelectedItems, RelativeSource={RelativeSource AncestorType=DataGrid}}"
+ Gesture="Delete" />
+ </DataGrid.InputBindings>
- <DataGrid.Columns>
- <DataGridTemplateColumn Header="St" CellTemplate="{StaticResource StatusGridStatusTemplate}" />
- <DataGridTemplateColumn Header="Filename" Width="*" CellTemplate="{StaticResource StatusGridFilenameTemplate}" />
- <DataGridTextColumn Binding="{Binding Path=Size}"
- Header="Size"
- Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
- <DataGridTextColumn Binding="{Binding Path=IsBinary}"
- Header="Binary"
- Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
- </DataGrid.Columns>
- </DataGrid>
+ <DataGrid.Columns>
+ <DataGridTemplateColumn Header="St" CellTemplate="{StaticResource StatusGridStatusTemplate}" />
+ <DataGridTemplateColumn Header="Filename" Width="*" CellTemplate="{StaticResource StatusGridFilenameTemplate}" />
+ <DataGridTextColumn Binding="{Binding Path=Size}"
+ Header="Size"
+ Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
+ <DataGridTextColumn Binding="{Binding Path=IsBinary}"
+ Header="Binary"
+ Foreground="{Binding Path=Status, Converter={StaticResource statusToColorConverter}, ConverterParameter=dark}" />
+ </DataGrid.Columns>
+ </DataGrid>
+ </Grid>
+ </userControls:Panel.Body>
+ </userControls:Panel>
</Grid>
-</UserControl>
-<!--<DataGrid.GroupStyle>
- <GroupStyle>
- <GroupStyle.HeaderTemplate>
- <DataTemplate>
- <StackPanel>
- <TextBlock Text="{Binding Name}" />
- </StackPanel>
- </DataTemplate>
- </GroupStyle.HeaderTemplate>
- <GroupStyle.ContainerStyle>
- <Style TargetType="{x:Type GroupItem}">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type GroupItem}">
- <StackPanel>
- <Border BorderBrush="#aaa" BorderThickness="0,1,0,1">
- <Grid Style="{StaticResource DataGridGroupItemStyle}">
- <StackPanel Orientation="Horizontal" Margin="4,3,0,3">
- <TextBlock Text="{Binding Name}" Foreground="{Binding Path=Name, Converter={StaticResource statusGridGroupToColorConverter}}" />
- <TextBlock xml:space="preserve" Foreground="{Binding Path=Name, Converter={StaticResource statusGridGroupToColorConverter}}">: </TextBlock>
- <TextBlock Text="{Binding ItemCount}" Foreground="{Binding Path=Name, Converter={StaticResource statusGridGroupToColorConverter}}" />
- </StackPanel>
- </Grid>
- </Border>
-
- <ItemsPresenter />
- </StackPanel>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </GroupStyle.ContainerStyle>
- </GroupStyle>
- </DataGrid.GroupStyle>-->
+</UserControl>
View
7 UserControls/StatusGrid.xaml.cs
@@ -25,15 +25,16 @@ public StatusGrid()
InitializeComponent();
}
- private void StatusGridElement_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ private void StatusGridSelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Retrieve repository view model.
var repositoryTabs = UIHelper.FindChild<TabControl>(Application.Current.MainWindow, "RepositoryTabs");
var repositoryViewModel = repositoryTabs.SelectedItem as RepositoryViewModel;
+ var dataGrid = (DataGrid) sender;
// Tell repository view model to update status item diff.
- //if (repositoryViewModel is RepositoryViewModel)
- //repositoryViewModel.UpdateStatusItemDiff(StatusGridElement.SelectedItems);
+ if (repositoryViewModel != null)
+ repositoryViewModel.UpdateStatusItemDiff(dataGrid.SelectedItems);
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.