mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
optimize<Manager>: simplify Manager page
This commit is contained in:
parent
eac212737c
commit
dc17bb4b12
5 changed files with 162 additions and 436 deletions
|
@ -191,6 +191,27 @@ namespace SourceGit {
|
||||||
|
|
||||||
if (removedIdx >= 0) Groups.RemoveAt(removedIdx);
|
if (removedIdx >= 0) Groups.RemoveAt(removedIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if given group has relations.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parentId"></param>
|
||||||
|
/// <param name="subId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool IsSubGroup(string parentId, string subId) {
|
||||||
|
if (string.IsNullOrEmpty(parentId)) return false;
|
||||||
|
|
||||||
|
var g = FindGroup(subId);
|
||||||
|
if (g == null) return false;
|
||||||
|
|
||||||
|
g = FindGroup(g.ParentId);
|
||||||
|
while (g != null) {
|
||||||
|
if (g.Id == parentId) return true;
|
||||||
|
g = FindGroup(g.ParentId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region METHODS_ON_REPOS
|
#region METHODS_ON_REPOS
|
||||||
|
@ -209,7 +230,6 @@ namespace SourceGit {
|
||||||
Path = dir.FullName,
|
Path = dir.FullName,
|
||||||
Name = dir.Name,
|
Name = dir.Name,
|
||||||
GroupId = groupId,
|
GroupId = groupId,
|
||||||
LastOpenTime = 0,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Repositories.Add(repo);
|
Repositories.Add(repo);
|
||||||
|
|
|
@ -43,10 +43,6 @@ namespace SourceGit.Git {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Color { get; set; } = 0;
|
public int Color { get; set; } = 0;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Last open time(File time format).
|
|
||||||
/// </summary>
|
|
||||||
public long LastOpenTime { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Expand tags.
|
/// Expand tags.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ExpandTags { get; set; }
|
public bool ExpandTags { get; set; }
|
||||||
|
@ -255,7 +251,6 @@ namespace SourceGit.Git {
|
||||||
/// Open repository.
|
/// Open repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Open() {
|
public void Open() {
|
||||||
LastOpenTime = DateTime.Now.ToFileTime();
|
|
||||||
isWatcherDisabled = false;
|
isWatcherDisabled = false;
|
||||||
|
|
||||||
GitDir = ".git";
|
GitDir = ".git";
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
public string Title {
|
public string Title {
|
||||||
get {
|
get {
|
||||||
if (Repo == null) return "Repositories";
|
if (Repo == null) return "New Page";
|
||||||
return Repo.Parent == null ? Repo.Name : $"{Repo.Parent.Name} : {Repo.Name}";
|
return Repo.Parent == null ? Repo.Name : $"{Repo.Parent.Name} : {Repo.Name}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:SourceGit.UI"
|
xmlns:local="clr-namespace:SourceGit.UI"
|
||||||
xmlns:git="clr-namespace:SourceGit.Git"
|
|
||||||
xmlns:converters="clr-namespace:SourceGit.Converters"
|
xmlns:converters="clr-namespace:SourceGit.Converters"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="450" d:DesignWidth="800">
|
d:DesignHeight="450" d:DesignWidth="800">
|
||||||
|
@ -13,108 +12,73 @@
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<converters:IntToRepoColor x:Key="IntToRepoColor"/>
|
<converters:IntToRepoColor x:Key="IntToRepoColor"/>
|
||||||
<converters:BoolToCollapsed x:Key="BoolToCollapsed"/>
|
<converters:BoolToCollapsed x:Key="BoolToCollapsed"/>
|
||||||
|
<converters:InverseBoolToCollapsed x:Key="InverseBoolToCollapsed"/>
|
||||||
|
<converters:InverseBool x:Key="InverseBool"/>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- Main Body -->
|
<!-- Main Body -->
|
||||||
<Grid>
|
<Grid Background="{StaticResource Brush.BG1}" HorizontalAlignment="Center" MinWidth="420" TextElement.FontFamily="Consolas">
|
||||||
<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>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="32"/>
|
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="32"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Recent Opened Repositories -->
|
<!-- Welcome -->
|
||||||
<Label Grid.Row="0" Margin="8,8,0,0" Content="RECENTLY OPENED" Style="{StaticResource Style.Label.GroupHeader}"/>
|
<StackPanel Orientation="Vertical" Margin="0,64,0,0">
|
||||||
<ListView
|
<Path Width="72" Height="72" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}" Fill="#FFF05133"/>
|
||||||
x:Name="recentOpened"
|
<TextBlock Grid.Column="0" Margin="0,16" HorizontalAlignment="Center" Text="Welcome to SourceGit :)" FontSize="26" FontWeight="ExtraBold" Foreground="{StaticResource Brush.FG2}"/>
|
||||||
Grid.Row="1"
|
<Grid Margin="0,0,0,36">
|
||||||
Height="Auto"
|
|
||||||
Margin="0,4"
|
|
||||||
Background="Transparent"
|
|
||||||
BorderThickness="0"
|
|
||||||
Style="{StaticResource Style.ListView.Borderless}"
|
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
|
||||||
GotFocus="RecentsGotFocus"
|
|
||||||
SelectionChanged="RecentsSelectionChanged"
|
|
||||||
MouseDoubleClick="RecentsMouseDoubleClick">
|
|
||||||
<ListView.ItemContainerStyle>
|
|
||||||
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource Style.ListViewItem.Borderless}">
|
|
||||||
<EventSetter Event="ContextMenuOpening" Handler="RecentsContextMenuOpening"/>
|
|
||||||
</Style>
|
|
||||||
</ListView.ItemContainerStyle>
|
|
||||||
|
|
||||||
<ListView.ItemTemplate>
|
|
||||||
<DataTemplate DataType="{x:Type git:Repository}">
|
|
||||||
<Grid Height="24">
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="8"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
<Button Click="OpenOrAddRepo" Grid.Column="0" Style="{StaticResource Style.Button.Bordered}">
|
||||||
<Path Grid.Column="0" Width="12" Margin="16,0,0,0" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Path Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder}"/>
|
||||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
<Label Margin="4,0,0,0" Content="Open Local Repository"/>
|
||||||
<TextBlock Margin="4,0" Text="{Binding Name}" VerticalAlignment="Center" Foreground="{StaticResource Brush.FG}"/>
|
</StackPanel>
|
||||||
<TextBlock FontSize="10" Text="{Binding Path}" VerticalAlignment="Center" Foreground="{StaticResource Brush.FG2}"/>
|
</Button>
|
||||||
|
<Button Click="CloneRepo" Grid.Column="2" Style="{StaticResource Style.Button.Bordered}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Path Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Pull}"/>
|
||||||
|
<Label Margin="4,0,0,0" Content="Clone Remote Repository"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
<Rectangle Height=".5" Fill="{StaticResource Brush.Border1}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Path
|
|
||||||
Grid.Column="2"
|
|
||||||
Width="12" Height="12" Margin="4,0"
|
|
||||||
Style="{StaticResource Style.Icon}"
|
|
||||||
Data="{StaticResource Icon.Bookmark}"
|
|
||||||
Fill="{Binding Color, Converter={StaticResource IntToRepoColor}}"/>
|
|
||||||
</Grid>
|
|
||||||
</DataTemplate>
|
|
||||||
</ListView.ItemTemplate>
|
|
||||||
</ListView>
|
|
||||||
|
|
||||||
<!-- Repositories' tree -->
|
<!-- Repositories' tree -->
|
||||||
<Grid Grid.Row="2" Margin="8,8,0,0">
|
<Grid Grid.Row="1" Margin="0,8,0,0">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Grid.Column="0" Content="REPOSITORIES" Style="{StaticResource Style.Label.GroupHeader}"/>
|
<TextBlock Grid.Column="0" Text="REPOSITORIES" FontSize="18" FontWeight="ExtraBold" Foreground="{StaticResource Brush.FG2}"/>
|
||||||
|
<TextBlock Grid.Column="2" Text="DRAG-DROP YOUR FOLDER" FontSize="14" Foreground="{StaticResource Brush.FG2}" VerticalAlignment="Center"/>
|
||||||
<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,4,0" ToolTip="Open Local Repository">
|
|
||||||
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Folder.Open}" Opacity=".8"/>
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<TreeView
|
<TreeView
|
||||||
x:Name="repositories"
|
x:Name="repositories"
|
||||||
Grid.Row="3"
|
Grid.Row="2"
|
||||||
Margin="0,4"
|
Margin="0,4"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
AllowDrop="True"
|
AllowDrop="True"
|
||||||
ContextMenuOpening="TreeContextMenuOpening"
|
TextElement.FontSize="14"
|
||||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||||
|
ContextMenuOpening="TreeContextMenuOpening"
|
||||||
Drop="TreeDrop"
|
Drop="TreeDrop"
|
||||||
GotFocus="TreeGotFocus"
|
|
||||||
MouseMove="TreeMouseMove">
|
MouseMove="TreeMouseMove">
|
||||||
|
|
||||||
<TreeView.ItemContainerStyle>
|
<TreeView.ItemContainerStyle>
|
||||||
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource Style.TreeView.ItemContainerStyle}">
|
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource Style.TreeView.ItemContainerStyle}">
|
||||||
<Setter Property="IsExpanded" Value="{Binding IsExpended, Mode=TwoWay}"/>
|
<Setter Property="IsExpanded" Value="{Binding IsExpended, Mode=TwoWay}"/>
|
||||||
|
<Setter Property="AllowDrop" Value="{Binding IsRepo, Converter={StaticResource InverseBool}}"/>
|
||||||
|
|
||||||
<EventSetter Event="Selected" Handler="TreeNodeSelected"/>
|
|
||||||
<EventSetter Event="DragOver" Handler="TreeNodeDragOver"/>
|
<EventSetter Event="DragOver" Handler="TreeNodeDragOver"/>
|
||||||
<EventSetter Event="Drop" Handler="TreeNodeDrop"/>
|
<EventSetter Event="Drop" Handler="TreeNodeDrop"/>
|
||||||
<EventSetter Event="Expanded" Handler="TreeNodeIsExpandedChanged"/>
|
<EventSetter Event="Expanded" Handler="TreeNodeIsExpandedChanged"/>
|
||||||
|
@ -127,7 +91,7 @@
|
||||||
|
|
||||||
<TreeView.ItemTemplate>
|
<TreeView.ItemTemplate>
|
||||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||||
<Grid Height="26">
|
<Grid Height="32">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
|
@ -137,17 +101,27 @@
|
||||||
<Path
|
<Path
|
||||||
x:Name="icon"
|
x:Name="icon"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Width="14" Height="14"
|
Width="16" Height="16"
|
||||||
Style="{StaticResource Style.Icon}"
|
Style="{StaticResource Style.Icon}"
|
||||||
Data="{StaticResource Icon.Folder.Fill}"/>
|
Data="{StaticResource Icon.Folder.Fill}"/>
|
||||||
|
|
||||||
<TextBlock
|
<StackPanel
|
||||||
x:Name="name"
|
x:Name="name"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="4,0,0,0"
|
Orientation="Horizontal"
|
||||||
|
Visibility="{Binding IsEditing, Converter={StaticResource InverseBoolToCollapsed}}">
|
||||||
|
<TextBlock
|
||||||
|
Margin="8,0,0,0"
|
||||||
Text="{Binding Name}"
|
Text="{Binding Name}"
|
||||||
Foreground="{StaticResource Brush.FG}"
|
Foreground="{StaticResource Brush.FG}"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
<TextBlock
|
||||||
|
Margin="8,0,0,0"
|
||||||
|
Text="{Binding Id}"
|
||||||
|
Foreground="{StaticResource Brush.FG2}"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Visibility="{Binding IsRepo, Converter={StaticResource BoolToCollapsed}}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="editName"
|
x:Name="editName"
|
||||||
|
@ -156,7 +130,8 @@
|
||||||
Text="{Binding Name}"
|
Text="{Binding Name}"
|
||||||
Loaded="TreeNodeRenameStart"
|
Loaded="TreeNodeRenameStart"
|
||||||
KeyDown="TreeNodeRenameKeyDown"
|
KeyDown="TreeNodeRenameKeyDown"
|
||||||
LostFocus="TreeNodeRenameEnd"/>
|
LostFocus="TreeNodeRenameEnd"
|
||||||
|
Visibility="{Binding IsEditing, Converter={StaticResource BoolToCollapsed}}"/>
|
||||||
|
|
||||||
<Path
|
<Path
|
||||||
x:Name="bookmark"
|
x:Name="bookmark"
|
||||||
|
@ -176,83 +151,12 @@
|
||||||
<DataTrigger Binding="{Binding IsRepo}" Value="True">
|
<DataTrigger Binding="{Binding IsRepo}" Value="True">
|
||||||
<Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Git}"/>
|
<Setter TargetName="icon" Property="Data" Value="{StaticResource Icon.Git}"/>
|
||||||
</DataTrigger>
|
</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.Triggers>
|
||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
</TreeView.ItemTemplate>
|
</TreeView.ItemTemplate>
|
||||||
</TreeView>
|
</TreeView>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" Background="{StaticResource Brush.BG3}"/>
|
|
||||||
|
|
||||||
<!-- 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 -->
|
|
||||||
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
|
||||||
<TextBlock x:Name="repoName" Margin="4,0,0,0" FontSize="28" FontWeight="Bold" FontFamily="Consolas" Foreground="{StaticResource Brush.FG}" VerticalAlignment="Center"/>
|
|
||||||
<Border Background="{StaticResource Brush.BG4}" Margin="16,0,0,0" Height="26" CornerRadius="4" VerticalAlignment="Center">
|
|
||||||
<TextBlock x:Name="repoPath" FontSize="20" Margin="8,0" FontWeight="Light" FontFamily="Consolas" Foreground="{StaticResource Brush.FG2}" VerticalAlignment="Center"/>
|
|
||||||
</Border>
|
|
||||||
</StackPanel>
|
|
||||||
|
|
||||||
<!-- 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>
|
|
||||||
<TextBlock x:Name="lastCommit" Margin="4,0,0,0" FontFamily="Consolas" Foreground="{StaticResource Brush.FG}" VerticalAlignment="Center"/>
|
|
||||||
</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 -->
|
<!-- Popup -->
|
||||||
<local:PopupManager x:Name="popupManager"/>
|
<local:PopupManager x:Name="popupManager"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
@ -14,7 +12,6 @@ namespace SourceGit.UI {
|
||||||
/// Repository manager.
|
/// Repository manager.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Manager : UserControl {
|
public partial class Manager : UserControl {
|
||||||
private TreeViewItem selectedTreeViewItem = null;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to build tree
|
/// Used to build tree
|
||||||
|
@ -35,7 +32,6 @@ namespace SourceGit.UI {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Manager() {
|
public Manager() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
UpdateTree();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,105 +55,13 @@ namespace SourceGit.UI {
|
||||||
private void CloneRepo(object sender, RoutedEventArgs e) {
|
private void CloneRepo(object sender, RoutedEventArgs e) {
|
||||||
if (MakeSureReady()) {
|
if (MakeSureReady()) {
|
||||||
popupManager.Show(new Clone(popupManager, () => {
|
popupManager.Show(new Clone(popupManager, () => {
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
UpdateTree();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EVENT_RECENT_LISTVIEW
|
|
||||||
private void RecentsGotFocus(object sender, RoutedEventArgs e) {
|
|
||||||
if (selectedTreeViewItem != null) selectedTreeViewItem.IsSelected = false;
|
|
||||||
selectedTreeViewItem = null;
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RecentsSelectionChanged(object sender, SelectionChangedEventArgs e) {
|
|
||||||
var recent = recentOpened.SelectedItem as Git.Repository;
|
|
||||||
if (recent != null) ShowBrief(recent);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RecentsMouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
|
||||||
var list = sender as ListView;
|
|
||||||
var recent = list.SelectedItem as Git.Repository;
|
|
||||||
|
|
||||||
if (recent != null) {
|
|
||||||
CheckAndOpenRepo(recent.Path);
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RecentsContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
|
||||||
var repo = (sender as ListViewItem).DataContext as Git.Repository;
|
|
||||||
if (repo == null) return;
|
|
||||||
|
|
||||||
var open = new MenuItem();
|
|
||||||
open.Header = "Open";
|
|
||||||
open.Click += (o, ev) => {
|
|
||||||
CheckAndOpenRepo(repo.Path);
|
|
||||||
ev.Handled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var explore = new MenuItem();
|
|
||||||
explore.Header = "Open Container Folder";
|
|
||||||
explore.Click += (o, ev) => {
|
|
||||||
Process.Start("explorer", repo.Path);
|
|
||||||
ev.Handled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var iconBookmark = FindResource("Icon.Bookmark") as Geometry;
|
|
||||||
var bookmark = new MenuItem();
|
|
||||||
bookmark.Header = "Bookmark";
|
|
||||||
for (int i = 0; i < Converters.IntToRepoColor.Colors.Length; i++) {
|
|
||||||
var icon = new System.Windows.Shapes.Path();
|
|
||||||
icon.Style = FindResource("Style.Icon") as Style;
|
|
||||||
icon.Data = iconBookmark;
|
|
||||||
icon.Fill = Converters.IntToRepoColor.Colors[i];
|
|
||||||
icon.Width = 8;
|
|
||||||
|
|
||||||
var mark = new MenuItem();
|
|
||||||
mark.Icon = icon;
|
|
||||||
mark.Header = $"{i}";
|
|
||||||
|
|
||||||
var refIdx = i;
|
|
||||||
mark.Click += (o, e) => {
|
|
||||||
repo.Color = refIdx;
|
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
|
||||||
e.Handled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
bookmark.Items.Add(mark);
|
|
||||||
}
|
|
||||||
|
|
||||||
var delete = new MenuItem();
|
|
||||||
delete.Header = "Delete";
|
|
||||||
delete.Click += (o, ev) => {
|
|
||||||
App.Setting.RemoveRepository(repo.Path);
|
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
|
||||||
HideBrief();
|
|
||||||
ev.Handled = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
|
||||||
menu.Items.Add(open);
|
|
||||||
menu.Items.Add(explore);
|
|
||||||
menu.Items.Add(bookmark);
|
|
||||||
menu.Items.Add(delete);
|
|
||||||
menu.IsOpen = true;
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region EVENT_TREEVIEW
|
#region EVENT_TREEVIEW
|
||||||
private void TreeGotFocus(object sender, RoutedEventArgs e) {
|
|
||||||
recentOpened.SelectedItems.Clear();
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TreeContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
private void TreeContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
||||||
var addFolder = new MenuItem();
|
var addFolder = new MenuItem();
|
||||||
addFolder.Header = "Add Folder";
|
addFolder.Header = "Add Folder";
|
||||||
|
@ -175,13 +79,8 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
private void TreeMouseMove(object sender, MouseEventArgs e) {
|
private void TreeMouseMove(object sender, MouseEventArgs e) {
|
||||||
if (e.LeftButton != MouseButtonState.Pressed) return;
|
if (e.LeftButton != MouseButtonState.Pressed) return;
|
||||||
|
if (repositories.SelectedItem == null) return;
|
||||||
if (selectedTreeViewItem == null) return;
|
DragDrop.DoDragDrop(repositories, repositories.SelectedItem, DragDropEffects.Move);
|
||||||
|
|
||||||
var node = selectedTreeViewItem.DataContext as Node;
|
|
||||||
if (node == null || !node.IsRepo) return;
|
|
||||||
|
|
||||||
DragDrop.DoDragDrop(repositories, selectedTreeViewItem, DragDropEffects.Move);
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,15 +103,19 @@ namespace SourceGit.UI {
|
||||||
needRebuild = true;
|
needRebuild = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e.Data.GetDataPresent(typeof(TreeViewItem))) {
|
} else if (e.Data.GetDataPresent(typeof(Node))) {
|
||||||
var item = e.Data.GetData(typeof(TreeViewItem)) as TreeViewItem;
|
var node = e.Data.GetData(typeof(Node)) as Node;
|
||||||
var node = item.DataContext as Node;
|
if (node == null) return;
|
||||||
if (node == null || !node.IsRepo) return;
|
|
||||||
|
|
||||||
var group = "";
|
|
||||||
var to = (sender as TreeViewItem)?.DataContext as Node;
|
var to = (sender as TreeViewItem)?.DataContext as Node;
|
||||||
if (to != null) group = to.IsRepo ? to.ParentId : to.Id;
|
var parent = to != null ? to.Id : "";
|
||||||
App.Setting.FindRepository(node.Id).GroupId = group;
|
|
||||||
|
if (node.IsRepo) {
|
||||||
|
App.Setting.FindRepository(node.Id).GroupId = to != null ? to.Id : "";
|
||||||
|
} else if (!App.Setting.IsSubGroup(node.Id, parent)) {
|
||||||
|
App.Setting.FindGroup(node.Id).ParentId = parent;
|
||||||
|
}
|
||||||
|
|
||||||
needRebuild = true;
|
needRebuild = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,19 +125,6 @@ namespace SourceGit.UI {
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EVENT_TREEVIEWITEM
|
#region EVENT_TREEVIEWITEM
|
||||||
private void TreeNodeSelected(object sender, RoutedEventArgs e) {
|
|
||||||
selectedTreeViewItem = sender as TreeViewItem;
|
|
||||||
|
|
||||||
var node = selectedTreeViewItem.DataContext as Node;
|
|
||||||
if (node.IsRepo) {
|
|
||||||
ShowBrief(App.Setting.FindRepository(node.Id));
|
|
||||||
} else {
|
|
||||||
HideBrief();
|
|
||||||
}
|
|
||||||
|
|
||||||
e.Handled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TreeNodeDoubleClick(object sender, MouseButtonEventArgs e) {
|
private void TreeNodeDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||||
var node = (sender as TreeViewItem).DataContext as Node;
|
var node = (sender as TreeViewItem).DataContext as Node;
|
||||||
if (node != null && node.IsRepo) {
|
if (node != null && node.IsRepo) {
|
||||||
|
@ -308,7 +198,6 @@ namespace SourceGit.UI {
|
||||||
App.Setting.RenameGroup(node.Id, text.Text);
|
App.Setting.RenameGroup(node.Id, text.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
UpdateTree();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +242,6 @@ namespace SourceGit.UI {
|
||||||
var repo = App.Setting.FindRepository(node.Id);
|
var repo = App.Setting.FindRepository(node.Id);
|
||||||
if (repo != null) {
|
if (repo != null) {
|
||||||
repo.Color = refIdx;
|
repo.Color = refIdx;
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
UpdateTree();
|
||||||
}
|
}
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
|
@ -391,7 +279,6 @@ namespace SourceGit.UI {
|
||||||
delete.Header = "Delete";
|
delete.Header = "Delete";
|
||||||
delete.Click += (o, ev) => {
|
delete.Click += (o, ev) => {
|
||||||
DeleteNode(node);
|
DeleteNode(node);
|
||||||
HideBrief();
|
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -402,66 +289,6 @@ namespace SourceGit.UI {
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region EVENT_BRIEF
|
|
||||||
private void ShowBrief(Git.Repository repo) {
|
|
||||||
if (repo == null || !Git.Repository.IsValid(repo.Path)) {
|
|
||||||
if (Directory.Exists(repo.Path)) {
|
|
||||||
popupManager.Show(new Init(popupManager, repo.Path, () => {
|
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
App.RaiseError("Path is NOT valid git repository or has been removed.");
|
|
||||||
App.Setting.RemoveRepository(repo.Path);
|
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
briefMask.Visibility = Visibility.Hidden;
|
|
||||||
|
|
||||||
repoName.Text = repo.Name;
|
|
||||||
repoPath.Text = repo.Path;
|
|
||||||
|
|
||||||
Task.Run(() => {
|
|
||||||
var changes = repo.LocalChanges();
|
|
||||||
var count = changes.Count;
|
|
||||||
Dispatcher.Invoke(() => localChanges.Content = count);
|
|
||||||
});
|
|
||||||
|
|
||||||
Task.Run(() => {
|
|
||||||
var count = repo.TotalCommits();
|
|
||||||
Dispatcher.Invoke(() => totalCommits.Content = count);
|
|
||||||
});
|
|
||||||
|
|
||||||
Task.Run(() => {
|
|
||||||
var commits = repo.Commits("-n 1");
|
|
||||||
Dispatcher.Invoke(() => {
|
|
||||||
if (commits.Count > 0) {
|
|
||||||
var c = commits[0];
|
|
||||||
lastCommitId.Content = c.ShortSHA;
|
|
||||||
lastCommit.Text = c.Subject;
|
|
||||||
} else {
|
|
||||||
lastCommitId.Content = "---";
|
|
||||||
lastCommit.Text = "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
if (File.Exists(repo.Path + "/README.md")) {
|
|
||||||
readme.Text = File.ReadAllText(repo.Path + "/README.md");
|
|
||||||
} else {
|
|
||||||
readme.Text = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HideBrief() {
|
|
||||||
briefMask.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region PRIVATES
|
#region PRIVATES
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make sure git is configured.
|
/// Make sure git is configured.
|
||||||
|
@ -485,10 +312,7 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
if (!Git.Repository.IsValid(path)) {
|
if (!Git.Repository.IsValid(path)) {
|
||||||
if (Directory.Exists(path)) {
|
if (Directory.Exists(path)) {
|
||||||
popupManager.Show(new Init(popupManager, path, () => {
|
popupManager.Show(new Init(popupManager, path, () => UpdateTree()));
|
||||||
UpdateRecentOpened();
|
|
||||||
UpdateTree();
|
|
||||||
}));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -498,22 +322,6 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
var repo = App.Setting.AddRepository(path, "");
|
var repo = App.Setting.AddRepository(path, "");
|
||||||
App.Open(repo);
|
App.Open(repo);
|
||||||
UpdateRecentOpened();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Update recent opened repositories.
|
|
||||||
/// </summary>
|
|
||||||
private void UpdateRecentOpened() {
|
|
||||||
var sorted = App.Setting.Repositories.OrderByDescending(a => a.LastOpenTime).ToList();
|
|
||||||
var top5 = new List<Git.Repository>();
|
|
||||||
|
|
||||||
for (int i = 0; i < sorted.Count && i < 5; i++) {
|
|
||||||
if (sorted[i].LastOpenTime <= 0) break;
|
|
||||||
top5.Add(sorted[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
recentOpened.ItemsSource = top5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -576,7 +384,6 @@ namespace SourceGit.UI {
|
||||||
private void DeleteNode(Node node) {
|
private void DeleteNode(Node node) {
|
||||||
if (node.IsRepo) {
|
if (node.IsRepo) {
|
||||||
App.Setting.RemoveRepository(node.Id);
|
App.Setting.RemoveRepository(node.Id);
|
||||||
UpdateRecentOpened();
|
|
||||||
} else {
|
} else {
|
||||||
App.Setting.RemoveGroup(node.Id);
|
App.Setting.RemoveGroup(node.Id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue