sourcegit/UI/Manager.xaml
2020-07-03 15:24:31 +08:00

231 lines
13 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>
<Grid.RowDefinitions>
<RowDefinition Height="32"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Toolbar -->
<Grid Grid.Row="0" Panel.ZIndex="9999">
<Border Background="{StaticResource Brush.BG1}">
<Border.Effect>
<DropShadowEffect ShadowDepth="2" Direction="270" Opacity=".3"/>
</Border.Effect>
</Border>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!-- Navigation -->
<StackPanel Grid.Column="0" Margin="8,0,0,0" Orientation="Horizontal">
<Path Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Manager}"/>
<Label Content="Repositories"/>
</StackPanel>
<!-- Options -->
<StackPanel Grid.Column="1" Orientation="Horizontal">
<Button Click="OpenOrAddRepo" Style="{StaticResource Style.Button}">
<StackPanel Orientation="Horizontal">
<Path Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder.Open}"/>
<Label Content="Open Folder"/>
</StackPanel>
</Button>
<Button Click="CloneRepo" Style="{StaticResource Style.Button}" Margin="8,0,0,0">
<StackPanel Orientation="Horizontal">
<Path Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Clone}"/>
<Label Content="Clone"/>
</StackPanel>
</Button>
</StackPanel>
</Grid>
</Grid>
<!-- Main Body -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" MinWidth="200" MaxWidth="360"/>
<ColumnDefinition Width="2"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Left panel -->
<Grid Grid.Column="0">
<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}"/>
<Label Margin="4,0,0,0" Content="{Binding Name}"/>
<Label FontSize="11" Content="{Binding Path}" Opacity=".5"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<!-- Repositories' tree -->
<Label Grid.Row="2" Margin="8,8,0,0" Content="REPOSITORIES" Style="{StaticResource Style.Label.GroupHeader}"/>
<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>
<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}"/>
<Label x:Name="name" Grid.Column="1" Margin="4,0,0,0" Content="{Binding Name}" />
<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="Transparent"/>
<!-- 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.Book}"/>
<Label Margin="0,8,0,0" Content="DRAG &amp; DROP FOLDER TO LEFT" FontSize="24" FontWeight="UltraBold" HorizontalAlignment="Center"/>
</StackPanel>
</Border>
</Grid>
</Grid>
<!-- Popups -->
<local:PopupManager Grid.Row="1"/>
</Grid>
</UserControl>