sourcegit/SourceGit/UI/Manager.xaml
2020-08-03 19:25:36 +08:00

204 lines
12 KiB
XML

<UserControl
x:Class="SourceGit.UI.Manager"
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:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SourceGit.UI"
xmlns:git="clr-namespace:SourceGit.Git"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<!-- Main Body -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" MinWidth="200" MaxWidth="360"/>
<ColumnDefinition Width="2"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Left panel -->
<Grid Grid.Column="0" Background="{StaticResource Brush.BG1}">
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Recent Opened Repositories -->
<Label Grid.Row="0" Margin="8,8,0,0" Content="RECENTLY OPENED" Style="{StaticResource Style.Label.GroupHeader}"/>
<ListView
x:Name="recentOpened"
Grid.Row="1"
Height="Auto"
Margin="0,4"
Background="Transparent"
BorderThickness="0"
Style="{StaticResource Style.ListView.Borderless}"
ItemContainerStyle="{StaticResource Style.ListViewItem.Borderless}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
GotFocus="RecentsGotFocus"
SelectionChanged="RecentsSelectionChanged"
MouseDoubleClick="RecentsMouseDoubleClick">
<ListView.ItemTemplate>
<DataTemplate DataType="{x:Type git:Repository}">
<StackPanel Orientation="Horizontal" Height="24">
<Path Height="12" Margin="16,0,0,0" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/>
<TextBlock Margin="4,0" Text="{Binding Name}" VerticalAlignment="Center" Foreground="{StaticResource Brush.FG}"/>
<TextBlock FontSize="10" Text="{Binding Path}" VerticalAlignment="Center" Foreground="{StaticResource Brush.FG2}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- Repositories' tree -->
<Grid Grid.Row="2" Margin="8,8,0,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="REPOSITORIES" Style="{StaticResource Style.Label.GroupHeader}"/>
<Button Grid.Column="1" Click="CloneRepo" Style="{StaticResource Style.Button}" ToolTip="Clone Remote Repository">
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Pull}" Opacity=".8"/>
</Button>
<Button Grid.Column="2" Click="OpenOrAddRepo" Style="{StaticResource Style.Button}" Margin="8,0,2,0" ToolTip="Open Local Repository">
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder.Open}" Opacity=".8"/>
</Button>
</Grid>
<TreeView
x:Name="repositories"
Grid.Row="3"
Margin="0, 4"
AllowDrop="True"
ContextMenuOpening="TreeContextMenuOpening"
Drop="TreeDrop"
GotFocus="TreeGotFocus"
MouseMove="TreeMouseMove">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource Style.TreeView.ItemContainerStyle}">
<Setter Property="IsExpanded" Value="{Binding IsExpended, Mode=TwoWay}"/>
<EventSetter Event="Selected" Handler="TreeNodeSelected"/>
<EventSetter Event="DragOver" Handler="TreeNodeDragOver"/>
<EventSetter Event="Drop" Handler="TreeNodeDrop"/>
<EventSetter Event="Expanded" Handler="TreeNodeIsExpandedChanged"/>
<EventSetter Event="Collapsed" Handler="TreeNodeIsExpandedChanged"/>
<EventSetter Event="KeyDown" Handler="TreeNodeKeyDown"/>
<EventSetter Event="ContextMenuOpening" Handler="TreeNodeContextMenuOpening"/>
<EventSetter Event="MouseDoubleClick" Handler="TreeNodeDoubleClick"/>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
<Grid Height="26">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="16"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Path x:Name="icon" Grid.Column="0" Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder.Fill}"/>
<TextBlock x:Name="name" Grid.Column="1" Margin="4,0,0,0" Text="{Binding Name}" Foreground="{StaticResource Brush.FG}" VerticalAlignment="Center"/>
<TextBox x:Name="editName" Grid.Column="1" Margin="4,0,0,0" Text="{Binding Name}" Loaded="TreeNodeRenameStart" KeyDown="TreeNodeRenameKeyDown" LostFocus="TreeNodeRenameEnd"/>
</Grid>
<HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding IsExpended}" Value="True">
<Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsRepo}" Value="True">
<Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Git}"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsEditing}" Value="True">
<Setter TargetName="name" Property="Visibility" Value="Hidden"/>
<Setter TargetName="editName" Property="Visibility" Value="Visible"/>
</DataTrigger>
<DataTrigger Binding="{Binding IsEditing}" Value="False">
<Setter TargetName="name" Property="Visibility" Value="Visible"/>
<Setter TargetName="editName" Property="Visibility" Value="Hidden"/>
</DataTrigger>
</HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Grid>
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" Background="{StaticResource Brush.BG1}"/>
<!-- Right Panel -->
<Grid Grid.Column="2" Background="{StaticResource Brush.BG3}">
<!-- Brief -->
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Name & Path & OpenButton -->
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" x:Name="repoName" FontSize="20" FontWeight="Bold"/>
<Label Grid.Column="1" x:Name="repoPath" FontSize="20" FontWeight="Light" Opacity="0.5" VerticalAlignment="Center"/>
<Button Grid.Column="3" Click="OpenRepo" ToolTip="Open">
<Path Width="20" Height="20" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>
</Button>
</Grid>
<!-- Status of selected repository -->
<Label Grid.Row="1" Content="STATUS" FontSize="16" Margin="0,16,0,4" FontWeight="Bold" Opacity=".8"/>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<Label Content="Local Changes :" Opacity=".5" FontWeight="Bold"/>
<Label x:Name="localChanges" Margin="2,0,0,0"/>
<Label Content="Total Commits :" Opacity=".5" FontWeight="Bold"/>
<Label x:Name="totalCommits" Margin="2,0,0,0"/>
<Label Content="Last Commit :" Opacity=".5" FontWeight="Bold"/>
<Border Background="{StaticResource Brush.BG4}" Height="18" CornerRadius="4" VerticalAlignment="Center">
<Label x:Name="lastCommitId" Foreground="{StaticResource Brush.FG2}" FontFamily="Consolas" Padding="4,0" VerticalAlignment="Center"/>
</Border>
<Label x:Name="lastCommit" Margin="2,0,0,0"/>
</StackPanel>
<!-- README.md -->
<Label Grid.Row="3" Content="README" FontSize="16" Margin="0,16,0,4" FontWeight="Bold" Opacity=".8"/>
<Border Grid.Row="4" Margin="6,0,0,0" BorderBrush="{StaticResource Brush.BG4}" BorderThickness="1">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<TextBlock FontSize="10pt"
FontFamily="Consolas"
Padding="8"
Opacity="0.8"
Background="{StaticResource Brush.BG2}"
Foreground="{StaticResource Brush.FG}"
x:Name="readme"/>
</ScrollViewer>
</Border>
</Grid>
<!-- Mask -->
<Border x:Name="briefMask" Background="{StaticResource Brush.BG3}" IsHitTestVisible="False">
<StackPanel Orientation="Vertical" VerticalAlignment="Center" Opacity=".2">
<Path Width="160" Height="160" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/>
<Label Margin="0,32,0,0" Content="WELCOME TO SOURCE GIT :-)" FontSize="24" FontWeight="UltraBold" HorizontalAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Grid>
<!-- Popup -->
<local:PopupManager x:Name="popupManager"/>
</Grid>
</UserControl>