-
Notifications
You must be signed in to change notification settings - Fork 394
Expand file tree
/
Copy pathBranchTree.axaml
More file actions
177 lines (158 loc) · 8.95 KB
/
BranchTree.axaml
File metadata and controls
177 lines (158 loc) · 8.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="using:SourceGit.Models"
xmlns:c="using:SourceGit.Converters"
xmlns:v="using:SourceGit.Views"
xmlns:vm="using:SourceGit.ViewModels"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SourceGit.Views.BranchTree"
x:Name="ThisControl">
<ListBox x:Name="BranchesPresenter"
Classes="repo_left_content_list"
ItemsSource="{Binding #ThisControl.Rows}"
SelectionMode="Multiple"
SelectionChanged="OnNodesSelectionChanged"
KeyDown="OnTreeKeyDown"
Padding="0,0,2,0"
ContextRequested="OnTreeContextRequested">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Vertical"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.Styles>
<Style Selector="ListBoxItem" x:DataType="vm:BranchTreeNode">
<Setter Property="CornerRadius" Value="{Binding CornerRadius}"/>
</Style>
<Style Selector="ListBoxItem:pointerover v|FilterModeSwitchButton">
<Setter Property="IsNoneVisible" Value="True"/>
</Style>
</ListBox.Styles>
<ListBox.ItemTemplate>
<DataTemplate DataType="vm:BranchTreeNode">
<Border Background="Transparent"
PointerPressed="OnNodePointerPressed"
ToolTip.Tip="{Binding Backend}"
ToolTip.Placement="Right">
<Border.DataTemplates>
<DataTemplate DataType="m:Branch">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.Branch}"/>
<TextBlock FontWeight="Bold" VerticalAlignment="Center" Margin="4,0,0,0" Text="{Binding FriendlyName}"/>
<Border Background="Green" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center" IsVisible="{Binding !IsLocal}">
<TextBlock Text="{DynamicResource Text.BranchTree.Remote}" FontSize="12" Margin="4,0" Foreground="White" VerticalAlignment="Center"/>
</Border>
</StackPanel>
<Grid RowDefinitions="Auto,Auto,Auto" ColumnDefinitions="Auto,Auto" Margin="0,8,0,0" IsVisible="{Binding IsLocal, Mode=OneWay}">
<TextBlock Grid.Row="0" Grid.Column="0"
Classes="info_label"
HorizontalAlignment="Left" VerticalAlignment="Center"
Text="{DynamicResource Text.BranchTree.Tracking}"/>
<StackPanel Grid.Row="0" Grid.Column="1"
Margin="8,0,0,0"
Orientation="Horizontal">
<TextBlock Text="{Binding Upstream, Mode=OneWay, Converter={x:Static c:StringConverters.ToFriendlyUpstream}}"
IsVisible="{Binding Upstream, Mode=OneWay, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
<TextBlock IsVisible="{Binding Upstream, Mode=OneWay, Converter={x:Static StringConverters.IsNullOrEmpty}}">
<Run Text="---"/>
<Run Text="(none)" Foreground="{DynamicResource Brush.FG2}"/>
</TextBlock>
<Border Background="OrangeRed" Margin="4,0,0,0" CornerRadius="4" VerticalAlignment="Center" IsVisible="{Binding IsUpstreamGone}">
<TextBlock Text="{DynamicResource Text.BranchTree.InvalidUpstream}" FontSize="12" Margin="4,1" Foreground="White" VerticalAlignment="Center"/>
</Border>
</StackPanel>
<TextBlock Grid.Row="1" Grid.Column="0"
Classes="info_label"
Margin="0,4,0,0"
HorizontalAlignment="Left" VerticalAlignment="Center"
Text="{DynamicResource Text.BranchTree.Status}"
IsVisible="{Binding IsTrackStatusVisible, Mode=OneWay}"/>
<v:BranchTreeNodeTrackStatusTooltip Grid.Row="1" Grid.Column="1"
Margin="8,4,0,0"/>
<TextBlock Grid.Row="2" Grid.Column="0"
Classes="info_label"
Margin="0,4,0,0"
HorizontalAlignment="Left" VerticalAlignment="Center"
Text="{DynamicResource Text.BranchTree.Worktree}"
IsVisible="{Binding HasWorktree}"/>
<TextBlock Grid.Row="2" Grid.Column="1"
Margin="8,4,0,0"
Text="{Binding WorktreePath, Mode=OneWay}"
IsVisible="{Binding HasWorktree}"/>
</Grid>
<v:BranchTreeNodeDescription Margin="0,8,0,0"/>
</StackPanel>
</DataTemplate>
<DataTemplate DataType="m:Remote">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<Path Width="12" Height="12" Data="{StaticResource Icons.Remote}"/>
<TextBlock FontWeight="Bold" VerticalAlignment="Center" Text="{Binding Name}" Margin="8,0,0,0"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
<TextBlock Classes="info_label"
HorizontalAlignment="Left" VerticalAlignment="Center"
Text="{DynamicResource Text.BranchTree.URL}"/>
<TextBlock Margin="6,0,0,0" Foreground="{DynamicResource Brush.Link}" Text="{Binding URL, Mode=OneWay}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</Border.DataTemplates>
<Grid Height="24"
Margin="{Binding Depth, Converter={x:Static c:IntConverters.ToTreeMargin}}"
ColumnDefinitions="16,*">
<!-- Tree Expander -->
<v:BranchTreeNodeToggleButton Grid.Column="0"
Classes="tree_expander"
Focusable="False"
HorizontalAlignment="Center"
IsChecked="{Binding IsExpanded, Mode=OneWay}"
IsVisible="{Binding !IsBranch}"/>
<!-- Content Area (allows double-clicking) -->
<Grid Grid.Column="1"
Height="24"
Background="Transparent"
ColumnDefinitions="18,*,Auto,Auto,Auto"
DoubleTapped="OnDoubleTappedBranchNode">
<!-- Icon -->
<v:BranchTreeNodeIcon Grid.Column="0"
Width="18" Height="18"
VerticalAlignment="Center"
IsExpanded="{Binding IsExpanded}"/>
<!-- Name -->
<TextBlock Grid.Column="1"
FontWeight="{Binding IsCurrent, Converter={x:Static c:BoolConverters.IsBoldToFontWeight}}"
TextTrimming="CharacterEllipsis">
<Run Text="{Binding Name}"/>
<Run Text="{Binding BranchesCount}" Foreground="{DynamicResource Brush.FG2}"/>
</TextBlock>
<!-- Upstream invalid tip -->
<Border Grid.Column="2"
Width="12" Height="12"
Margin="8,0"
Background="Transparent"
IsVisible="{Binding ShowUpstreamGoneTip}">
<Path Data="{StaticResource Icons.Error}" Fill="DarkOrange"/>
</Border>
<!-- Tracking status -->
<v:BranchTreeNodeTrackStatusPresenter Grid.Column="3"
VerticalAlignment="Center"
FontFamily="{DynamicResource Fonts.Monospace}"
FontSize="10"
Foreground="{DynamicResource Brush.BadgeFG}"
Background="{DynamicResource Brush.Badge}"/>
<!-- Filter Mode Switcher -->
<v:FilterModeSwitchButton Grid.Column="4"
Width="12"
Margin="4,0,8,0"
Mode="{Binding FilterMode}"/>
</Grid>
</Grid>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</UserControl>