Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c0faec8

Browse files
Added tag related functionality.
1 parent 9916947 commit c0faec8

14 files changed

Lines changed: 321 additions & 144 deletions
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using System;
2+
using System.Linq;
3+
using System.Globalization;
4+
using System.Windows.Controls;
5+
using System.Windows.Data;
6+
7+
namespace GG.Converters
8+
{
9+
/// <summary>
10+
/// Returns the height of the body (data grid actual height - column header height).
11+
/// </summary>
12+
class GetSelectedTreeViewItemConverter : IValueConverter
13+
{
14+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
15+
{
16+
return ((TreeView) value).SelectedItem;
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20+
{
21+
return null;
22+
}
23+
}
24+
}

‎Git-GUI.csproj‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,17 @@
161161
</ApplicationDefinition>
162162
<Compile Include="Converters\GenericVisibilityConverter.cs" />
163163
<Compile Include="Converters\GetDataGridContentHeightConverter.cs" />
164+
<Compile Include="Converters\GetSelectedTreeViewItemConverter.cs" />
164165
<Compile Include="Libraries\Observable.cs" />
165166
<Compile Include="UserControls\CenterArea.xaml.cs">
166167
<DependentUpon>CenterArea.xaml</DependentUpon>
167168
</Compile>
168169
<Compile Include="UserControls\Dialogs\ConfirmDialog.xaml.cs">
169170
<DependentUpon>ConfirmDialog.xaml</DependentUpon>
170171
</Compile>
172+
<Compile Include="UserControls\LeftToolbarContextMenus\TagContextMenu.xaml.cs">
173+
<DependentUpon>TagContextMenu.xaml</DependentUpon>
174+
</Compile>
171175
<Compile Include="Views\About.xaml.cs">
172176
<DependentUpon>About.xaml</DependentUpon>
173177
</Compile>
@@ -255,6 +259,10 @@
255259
<SubType>Designer</SubType>
256260
<Generator>MSBuild:Compile</Generator>
257261
</Page>
262+
<Page Include="UserControls\LeftToolbarContextMenus\TagContextMenu.xaml">
263+
<SubType>Designer</SubType>
264+
<Generator>MSBuild:Compile</Generator>
265+
</Page>
258266
<Page Include="Views\About.xaml">
259267
<SubType>Designer</SubType>
260268
<Generator>MSBuild:Compile</Generator>

‎Models/Commit.cs‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Text;
4-
using System.Threading.Tasks;
53
using GG.Libraries;
64
using System.Linq;
75
using System.Collections.ObjectModel;
@@ -16,7 +14,7 @@ public class Commit
1614
public string Description { get; set; }
1715
public string ShortDescription { get; set; }
1816
public List<string> DisplayTags { get; set; }
19-
public List<string> Tags { get; set; }
17+
public ObservableCollection<Tag> Tags { get; set; }
2018
public string Hash { get; set; }
2119
public List<Branch> Branches { get; set; }
2220
public List<Branch> BranchesAround { get; set; }
@@ -79,34 +77,35 @@ public bool IsMergeCommit()
7977
/// </summary>
8078
/// <param name="repo"></param>
8179
/// <param name="commit"></param>
80+
/// <param name="tags"> </param>
8281
/// <returns></returns>
8382
public static Commit Create(LibGit2Sharp.Repository repo,
8483
LibGit2Sharp.Commit commit,
8584
ObservableCollection<Tag> tags)
8685
{
87-
Commit c = new Commit();
86+
var c = new Commit();
8887

8988
// Process Tags (Git tags to display next to the commit description).
90-
List<string> commitTags = new List<string>();
91-
foreach (Tag tag in tags)
89+
var commitTags = new ObservableCollection<Tag>();
90+
foreach (var tag in tags)
9291
{
93-
if (tag.TargetSha == commit.Sha.ToString())
92+
if (tag.TargetSha == commit.Sha)
9493
{
95-
commitTags.Add(tag.Name);
94+
commitTags.Add(tag);
9695
tag.Target = c;
9796
}
9897
}
9998

10099
// Process display tags.
101-
List<string> displayTags = new List<string>();
100+
var displayTags = new List<string>();
102101
if (repo.Head.Tip == commit)
103102
displayTags.Add("HEAD");
104103

105104
// Process ParentHashes.
106-
List<string> parentHashes = new List<string>();
107-
foreach (LibGit2Sharp.Commit parentCommit in commit.Parents)
105+
var parentHashes = new List<string>();
106+
foreach (var parentCommit in commit.Parents)
108107
{
109-
parentHashes.Add(parentCommit.Sha.ToString());
108+
parentHashes.Add(parentCommit.Sha);
110109
}
111110

112111
// Set properties.
@@ -118,7 +117,7 @@ public static Commit Create(LibGit2Sharp.Repository repo,
118117
c.DisplayTags = displayTags;
119118
c.Branches = new List<Branch>();
120119
c.Tags = commitTags;
121-
c.Hash = commit.Sha.ToString();
120+
c.Hash = commit.Sha;
122121
c.ParentHashes = parentHashes;
123122
c.ParentCount = commit.ParentsCount;
124123
c.Parents = new List<Commit>();

‎Styles/DataGrid.xaml‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
<GradientStop Color="#9fd3eb" Offset="1"/>
2828
</LinearGradientBrush>
2929

30+
<LinearGradientBrush x:Key="DataGridHighlightBlurBrush" StartPoint="0,0" EndPoint="0,1">
31+
<GradientStop Color="#fcfcfc" Offset="0"/>
32+
<GradientStop Color="#e3e3e3" Offset="0.1"/>
33+
<GradientStop Color="#d2d2d2" Offset="0.45"/>
34+
<GradientStop Color="#c8c8c8" Offset="0.9"/>
35+
<GradientStop Color="#ebebeb" Offset="1"/>
36+
</LinearGradientBrush>
37+
3038
<Style TargetType="{x:Type DataGrid}">
3139
<Setter Property="Background" Value="{StaticResource DefaultBackgroundBrush}" />
3240
<Setter Property="BorderBrush" Value="#bbb" />
@@ -225,17 +233,7 @@
225233
<Setter Property="BorderBrush" Value="#bebebe" />
226234
<Setter Property="BorderBrush" Value="#bebebe" TargetName="OuterBorder" />
227235
<Setter Property="Foreground" Value="#000" />
228-
<Setter Property="Background">
229-
<Setter.Value>
230-
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
231-
<GradientStop Color="#fcfcfc" Offset="0"/>
232-
<GradientStop Color="#e3e3e3" Offset="0.1"/>
233-
<GradientStop Color="#d2d2d2" Offset="0.45"/>
234-
<GradientStop Color="#c8c8c8" Offset="0.9"/>
235-
<GradientStop Color="#ebebeb" Offset="1"/>
236-
</LinearGradientBrush>
237-
</Setter.Value>
238-
</Setter>
236+
<Setter Property="Background" Value="{StaticResource DataGridHighlightBlurBrush}" />
239237
</MultiDataTrigger>
240238
<MultiDataTrigger>
241239
<MultiDataTrigger.Conditions>

‎Styles/TreeView.xaml‎

Lines changed: 100 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,113 @@
11
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
33

4+
<Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
5+
<Setter Property="Focusable" Value="False"/>
6+
<Setter Property="Template">
7+
<Setter.Value>
8+
<ControlTemplate TargetType="ToggleButton">
9+
<Grid Width="15" Height="13" Background="Transparent">
10+
<Path x:Name="ExpandPath" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="1,1,1,1" Fill="{StaticResource GlyphBrush}" Data="M 4 0 L 8 4 L 4 8 Z"/>
11+
</Grid>
12+
<ControlTemplate.Triggers>
13+
<Trigger Property="IsChecked" Value="True">
14+
<Setter Property="Data" TargetName="ExpandPath" Value="M 0 4 L 8 4 L 4 8 Z"/>
15+
</Trigger>
16+
</ControlTemplate.Triggers>
17+
</ControlTemplate>
18+
</Setter.Value>
19+
</Setter>
20+
</Style>
21+
<Style x:Key="TreeViewItemFocusVisual">
22+
<Setter Property="Control.Template">
23+
<Setter.Value>
24+
<ControlTemplate>
25+
<Border>
26+
<Rectangle Margin="0,0,0,0" StrokeThickness="5" Stroke="Black" StrokeDashArray="1 2" Opacity="0"/>
27+
</Border>
28+
</ControlTemplate>
29+
</Setter.Value>
30+
</Setter>
31+
</Style>
32+
433
<Style TargetType="{x:Type TreeViewItem}">
534
<Setter Property="BorderThickness" Value="1"/>
635
<Setter Property="Padding" Value="4,1,0,1" />
7-
<Style.Triggers>
8-
<Trigger Property="IsSelected" Value="True">
9-
<Setter Property="Foreground" Value="White" />
10-
<Setter Property="BorderBrush" Value="#7ea3be"/>
11-
</Trigger>
12-
<MultiDataTrigger>
13-
<MultiDataTrigger.Conditions>
14-
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True"/>
15-
<Condition Binding="{Binding IsKeyboardFocusWithin, RelativeSource={RelativeSource AncestorType=DataGrid}}" Value="False"/>
16-
</MultiDataTrigger.Conditions>
17-
<Setter Property="BorderBrush" Value="LightGray"/>
18-
<Setter Property="Foreground" Value="Gray" />
19-
</MultiDataTrigger>
20-
21-
<MultiDataTrigger>
22-
<MultiDataTrigger.Conditions>
23-
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True"/>
24-
<Condition Binding="{Binding ContextMenu.IsOpen, RelativeSource={RelativeSource AncestorType=DataGrid}}" Value="True"/>
25-
</MultiDataTrigger.Conditions>
26-
<Setter Property="Foreground" Value="White" />
27-
<Setter Property="BorderBrush" Value="#7ea3be"/>
28-
</MultiDataTrigger>
29-
</Style.Triggers>
36+
<Setter Property="Template">
37+
<Setter.Value>
38+
<ControlTemplate TargetType="{x:Type TreeViewItem}">
39+
<Grid>
40+
<Grid.ColumnDefinitions>
41+
<ColumnDefinition MinWidth="19" Width="Auto"/>
42+
<ColumnDefinition Width="Auto"/>
43+
<ColumnDefinition Width="*"/>
44+
</Grid.ColumnDefinitions>
45+
<Grid.RowDefinitions>
46+
<RowDefinition Height="Auto"/>
47+
<RowDefinition/>
48+
</Grid.RowDefinitions>
49+
<ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
50+
<Border Name="Bd" Grid.Column="1" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
51+
<ContentPresenter x:Name="PART_Header" ContentSource="Header" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
52+
</Border>
53+
<ItemsPresenter x:Name="ItemsHost" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
54+
</Grid>
55+
<ControlTemplate.Triggers>
56+
<Trigger Property="IsExpanded" Value="false">
57+
<Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
58+
</Trigger>
59+
<Trigger Property="HasItems" Value="false">
60+
<Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
61+
</Trigger>
62+
<MultiTrigger>
63+
<MultiTrigger.Conditions>
64+
<Condition Property="HasHeader" Value="false"/>
65+
<Condition Property="Width" Value="Auto"/>
66+
</MultiTrigger.Conditions>
67+
<Setter TargetName="PART_Header" Property="MinWidth" Value="75"/>
68+
</MultiTrigger>
69+
<MultiTrigger>
70+
<MultiTrigger.Conditions>
71+
<Condition Property="HasHeader" Value="false"/>
72+
<Condition Property="Height" Value="Auto"/>
73+
</MultiTrigger.Conditions>
74+
<Setter TargetName="PART_Header" Property="MinHeight" Value="19"/>
75+
</MultiTrigger>
76+
<Trigger Property="IsSelected" Value="true">
77+
<Setter TargetName="Bd" Property="Background" Value="{StaticResource DataGridHighlightBrush}"/>
78+
<Setter Property="Foreground" Value="#fff"/>
79+
<Setter TargetName="Bd" Property="BorderBrush" Value="#7ea3be"/>
80+
</Trigger>
81+
<MultiTrigger>
82+
<MultiTrigger.Conditions>
83+
<Condition Property="IsSelected" Value="true"/>
84+
<Condition Property="IsSelectionActive" Value="false"/>
85+
</MultiTrigger.Conditions>
86+
<Setter TargetName="Bd" Property="Background" Value="{StaticResource DataGridHighlightBlurBrush}"/>
87+
<Setter TargetName="Bd" Property="BorderBrush" Value="#bebebe"/>
88+
<Setter Property="Foreground" Value="#000"/>
89+
</MultiTrigger>
90+
<MultiDataTrigger>
91+
<MultiDataTrigger.Conditions>
92+
<Condition Binding="{Binding IsSelected, RelativeSource={RelativeSource Self}}" Value="True"/>
93+
<Condition Binding="{Binding ContextMenu.IsOpen, RelativeSource={RelativeSource AncestorType=TreeViewItem}}" Value="True"/>
94+
</MultiDataTrigger.Conditions>
95+
96+
<Setter TargetName="Bd" Property="Background" Value="{StaticResource DataGridHighlightBrush}"/>
97+
<Setter Property="Foreground" Value="#fff"/>
98+
<Setter TargetName="Bd" Property="BorderBrush" Value="#7ea3be"/>
99+
</MultiDataTrigger>
100+
<Trigger Property="IsEnabled" Value="false">
101+
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
102+
</Trigger>
103+
</ControlTemplate.Triggers>
104+
</ControlTemplate>
105+
</Setter.Value>
106+
</Setter>
30107
<Style.Resources>
31108
<Style TargetType="Border">
32109
<Setter Property="CornerRadius" Value="2" />
33110
</Style>
34111
</Style.Resources>
35112
</Style>
36-
37-
<LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0" >
38-
<GradientStop Color="#b3e5fc" Offset="0"/>
39-
<GradientStop Color="#8cc8e3" Offset="0.1"/>
40-
<GradientStop Color="#83bad2" Offset="0.45"/>
41-
<GradientStop Color="#609fbb" Offset="0.9"/>
42-
<GradientStop Color="#9fd3eb" Offset="1"/>
43-
</LinearGradientBrush>
44-
45-
<LinearGradientBrush x:Key="{x:Static SystemColors.ControlBrushKey}" EndPoint="0,1" StartPoint="0,0">
46-
<GradientStop Color="#fcfcfc" Offset="0"/>
47-
<GradientStop Color="#e3e3e3" Offset="0.1"/>
48-
<GradientStop Color="#d2d2d2" Offset="0.45"/>
49-
<GradientStop Color="#c8c8c8" Offset="0.9"/>
50-
<GradientStop Color="#ebebeb" Offset="1"/>
51-
</LinearGradientBrush>
52-
53-
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="#eee" />
54-
<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="#666" />
55113
</ResourceDictionary>

‎UserControls/ChangesetHistory.xaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<DataTemplate>
6060
<WrapPanel>
6161
<ListBox ItemsSource="{Binding DisplayTags}" Style="{StaticResource DisplayTagsBlueStyle}" IsHitTestVisible="False" />
62-
<ListBox ItemsSource="{Binding Tags}" Style="{StaticResource DisplayTagsOrangeStyle}" IsHitTestVisible="False" />
62+
<ListBox ItemsSource="{Binding Tags}" DisplayMemberPath="Name"Style="{StaticResource DisplayTagsOrangeStyle}" IsHitTestVisible="False" />
6363
<TextBlock Text="{Binding Path=ShortDescription}"
6464
VerticalAlignment="Center"
6565
FontWeight="{Binding IsHead, Converter={StaticResource isHeadToFontWeightConverter}}"

‎UserControls/ChangesetHistoryContextMenu.xaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
</MenuItem>
7070

7171
<MenuItem Header="Tag this commit..."
72-
Command="{Binding PlacementTarget.Tag.TagCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
72+
Command="{Binding PlacementTarget.Tag.CreateTagCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
7373
CommandParameter="{Binding PlacementTarget.SelectedItem, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
7474
<MenuItem.Icon>
7575
<Image Source="../Resources/Icons/Tag.png" Stretch="None" />

‎UserControls/ChangesetHistoryContextMenu.xaml.cs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using GG.Models;
8-
using System.Windows;
98
using GG.Libraries;
109
using System.Windows.Documents;
1110

@@ -64,10 +63,10 @@ private void OnOpened(object sender, System.Windows.RoutedEventArgs e)
6463

6564
// Add Checkout menu items. TODO: Add also non-branch-checkouts.
6665
var numberOfCheckoutItems = 0;
67-
foreach (Branch branch in commit.Branches)
66+
foreach (var branch in commit.Branches)
6867
{
6968
// Only if the right clicked commit is the tip of the branch, AND the branch is not already checkout out, continue.
70-
if (branch.Tip == commit && ((Branch)repositoryViewModel.Head) != branch && branch.IsRemote == false)
69+
if (branch.Tip == commit && (repositoryViewModel.Head) != branch && branch.IsRemote == false)
7170
{
7271
var text = new TextBlock();
7372
text.Inlines.AddRange(new Inline[]

‎UserControls/Dialogs/ConfirmDialog.xaml.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ public ConfirmDialog() : base()
4242
);
4343

4444
DataContext = this;
45+
46+
if (Buttons == null)
47+
ButtonSet = ButtonsSet.OK_CANCEL;
4548
}
4649

4750
/// <summary>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /