mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
style<Welcome>: re-design layout for Welcome page
This commit is contained in:
parent
5712630235
commit
717772c62b
6 changed files with 1402 additions and 1443 deletions
|
@ -208,6 +208,7 @@ namespace SourceGit.Models {
|
|||
public WindowInfo Window { get; set; } = new WindowInfo();
|
||||
public List<Group> Groups { get; set; } = new List<Group>();
|
||||
public List<Repository> Repositories { get; set; } = new List<Repository>();
|
||||
public List<string> Recents { get; set; } = new List<string>();
|
||||
public RestoreTabs Restore { get; set; } = new RestoreTabs();
|
||||
#endregion
|
||||
|
||||
|
@ -355,5 +356,36 @@ namespace SourceGit.Models {
|
|||
if (removedIdx >= 0) Repositories.RemoveAt(removedIdx);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region RECENTS
|
||||
public void AddRecent(string path) {
|
||||
if (Recents.Count == 0) {
|
||||
Recents.Add(path);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < Recents.Count; i++) {
|
||||
if (Recents[i] == path) {
|
||||
if (i != 0) {
|
||||
Recents.RemoveAt(i);
|
||||
Recents.Insert(0, path);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Recents.Insert(0, path);
|
||||
}
|
||||
|
||||
public void RemoveRecent(string path) {
|
||||
for (int i = 0; i < Recents.Count; i++) {
|
||||
if (Recents[i] == path) {
|
||||
Recents.RemoveAt(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -298,8 +298,10 @@
|
|||
<sys:String x:Key="Text.Welcome.Title">SourceGit</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.OpenOrInit">Open Local Repository</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Clone">Clone Remote Repository</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Bookmarks">Bookmarks</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Histories">Histories</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.DragDrop">DRAG-DROP YOUR FOLDER</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Start">START</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Recent">RECENT OPENED</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Repositories">REPOSITORIES</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.NewFolder">Add Folder</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.NewSubFolder">Add Sub-Folder</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Rename">Rename</sys:String>
|
||||
|
|
|
@ -297,8 +297,10 @@
|
|||
<sys:String x:Key="Text.Welcome.Title">欢迎使用本软件</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.OpenOrInit">打开本地仓库</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Clone">克隆远程仓库</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Bookmarks">收藏/书签</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Histories">最近使用</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.DragDrop">支持拖放操作</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Start">开始使用</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Recent">最近使用</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Repositories">收藏/书签</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.NewFolder">新建分组</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.NewSubFolder">新建子分组</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Rename">重命名</sys:String>
|
||||
|
|
|
@ -315,6 +315,7 @@ namespace SourceGit.Views.Widgets {
|
|||
Models.Exception.Raise(App.Text("MissingBash"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (Models.Preference.Instance.General.UseWindowsTerminal) {
|
||||
Process.Start(new ProcessStartInfo {
|
||||
WorkingDirectory = repo.Path,
|
||||
|
@ -329,6 +330,7 @@ namespace SourceGit.Views.Widgets {
|
|||
UseShellExecute = true,
|
||||
});
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,164 +7,165 @@
|
|||
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="800" d:DesignWidth="800">
|
||||
<Grid Background="Transparent" AllowDrop="True" Drop="OnPageDrop" MouseMove="OnPageMouseMove" MouseDown="OnPageMouseDown">
|
||||
<Grid Background="Transparent" AllowDrop="True" DragEnter="OnPageDragEnter" DragLeave="OnPageDragLeave" Drop="OnPageDrop">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Orientation="Vertical" Width="420" HorizontalAlignment="Center">
|
||||
<!-- Logo -->
|
||||
<Path
|
||||
Margin="0,48,0,0"
|
||||
Width="100" Height="100"
|
||||
Data="{StaticResource Icon.Git}"
|
||||
Fill="{DynamicResource Brush.Logo}"/>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="900"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Welcome -->
|
||||
<TextBlock
|
||||
Margin="0,16"
|
||||
HorizontalAlignment="Center"
|
||||
Text="{DynamicResource Text.Welcome.Title}"
|
||||
FontSize="24pt"
|
||||
FontWeight="ExtraBold"
|
||||
TextOptions.TextFormattingMode="Ideal"
|
||||
TextOptions.TextRenderingMode="ClearType"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
<Grid Grid.Row="1" Margin="10,40" HorizontalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="32"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Page Title -->
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{DynamicResource Text.Welcome.Title}"
|
||||
FontSize="28pt"
|
||||
TextOptions.TextFormattingMode="Ideal"
|
||||
TextOptions.TextRenderingMode="ClearType"/>
|
||||
|
||||
<Grid x:Name="body" Grid.Row="2" Grid.Column="1" Margin="0,32" FocusManager.IsFocusScope="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="350"/>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="350"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="64"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="0" Click="OnOpenClicked" Height="28" Width="240">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icon.Folder.Open}"/>
|
||||
<TextBlock Margin="12,0,0,0" Text="{DynamicResource Text.Welcome.OpenOrInit}"/>
|
||||
<!-- Left Panel -->
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Options -->
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Text="{DynamicResource Text.Welcome.Start}"
|
||||
FontSize="13pt"/>
|
||||
<StackPanel Grid.Row="1" Margin="4,12,0,0" Orientation="Vertical">
|
||||
<Button Grid.Column="0" Grid.Row="0" Click="OnOpenClicked" Height="28" HorizontalAlignment="Left" BorderThickness="0" Opacity="1">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icon.Folder.Open}" Fill="{DynamicResource Brush.Accent1}"/>
|
||||
<TextBlock Margin="12,0,0,0" Text="{DynamicResource Text.Welcome.OpenOrInit}" Foreground="{DynamicResource Brush.Accent1}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Grid.Column="0" Grid.Row="1" Click="OnCloneClicked" Height="28" HorizontalAlignment="Left" BorderThickness="0" Opacity="1">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icon.Pull}" Fill="{DynamicResource Brush.Accent1}"/>
|
||||
<TextBlock Margin="12,0,0,0" Text="{DynamicResource Text.Welcome.Clone}" Foreground="{DynamicResource Brush.Accent1}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
|
||||
<Button Grid.Column="0" Grid.Row="1" Click="OnCloneClicked" Height="28" Width="240">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Path Width="16" Height="16" Data="{StaticResource Icon.Pull}"/>
|
||||
<TextBlock Margin="12,0,0,0" Text="{DynamicResource Text.Welcome.Clone}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<!-- Recents -->
|
||||
<TextBlock
|
||||
Grid.Row="2" Margin="0,32,0,0"
|
||||
Text="{DynamicResource Text.Welcome.Recent}"
|
||||
FontSize="13pt"/>
|
||||
<DataGrid
|
||||
Grid.Row="3"
|
||||
x:Name="list"
|
||||
Margin="0,12,0,0"
|
||||
SelectionUnit="FullRow"
|
||||
SelectionMode="Single"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
LostFocus="OnRecentLostFocus">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource Style.DataGridRow}" TargetType="{x:Type DataGridRow}">
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnRecentDoubleClick"/>
|
||||
<EventSetter Event="ContextMenuOpening" Handler="OnRecentContextMenuOpening"/>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Height="32" Margin="4,0,0,0" IsHitTestVisible="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="22"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- History -->
|
||||
<TextBlock
|
||||
Grid.Row="3"
|
||||
Grid.Column="0"
|
||||
Text="{DynamicResource Text.Welcome.Histories}"
|
||||
FontSize="13pt" FontWeight="ExtraBold"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<!-- History Tree -->
|
||||
<controls:Tree
|
||||
Grid.Row="4"
|
||||
Grid.Column="0"
|
||||
x:Name="treeHistory"
|
||||
Margin="0,4"
|
||||
TextElement.FontSize="14"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ContextMenuOpening="OnTreeContextMenuOpening">
|
||||
<controls:Tree.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type controls:TreeItem}" BasedOn="{StaticResource Style.TreeItem}">
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/>
|
||||
</Style>
|
||||
</controls:Tree.ItemContainerStyle>
|
||||
<controls:Bookmark
|
||||
Grid.Column="0"
|
||||
Margin="2,0,0,0"
|
||||
x:Name="BookmarkIcon"
|
||||
Width="16" Height="16"
|
||||
Color="{Binding Bookmark}"
|
||||
IsNewPage="False"/>
|
||||
|
||||
<controls:Tree.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<Border Height="32">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="22"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Margin="8,0" Text="{Binding Name}"/>
|
||||
<TextBlock x:Name="Path" Text="{Binding Path}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<controls:Bookmark
|
||||
Grid.Column="0"
|
||||
Margin="2,0,0,0"
|
||||
x:Name="BookmarkIcon"
|
||||
Width="16" Height="16"
|
||||
Color="{Binding Bookmark}"
|
||||
IsNewPage="False"/>
|
||||
<!-- Right Panel -->
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Column="1" x:Name="ContentsHistory" Orientation="Horizontal">
|
||||
<TextBlock Margin="8,0" Text="{Binding Name}"/>
|
||||
<TextBlock x:Name="Path" Text="{Binding Id}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Border>
|
||||
</HierarchicalDataTemplate>
|
||||
</controls:Tree.ItemTemplate>
|
||||
</controls:Tree>
|
||||
<!-- Repositories Label -->
|
||||
<Grid Grid.Row="0">
|
||||
<TextBlock
|
||||
Text="{DynamicResource Text.Welcome.Repositories}"
|
||||
FontSize="13pt"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
|
||||
<!-- Bookmark -->
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
Text="{DynamicResource Text.Welcome.Bookmarks}"
|
||||
FontSize="13pt" FontWeight="ExtraBold"
|
||||
HorizontalAlignment="Center"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
<TextBlock
|
||||
Text="{DynamicResource Text.Welcome.DragDrop}"
|
||||
FontSize="10pt"
|
||||
HorizontalAlignment="Right" VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</Grid>
|
||||
|
||||
<!-- Drop Area -->
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="4"
|
||||
Grid.Column="2"
|
||||
x:Name="dropArea"
|
||||
Margin="0,2"
|
||||
Stroke="{DynamicResource Brush.Border1}"
|
||||
StrokeThickness="2"
|
||||
StrokeDashArray="4,4"
|
||||
SnapsToDevicePixels="True"
|
||||
Visibility="Hidden"/>
|
||||
<controls:Tree
|
||||
Grid.Row="1"
|
||||
Grid.RowSpan="4"
|
||||
Grid.Column="2"
|
||||
x:Name="treeBookmarks"
|
||||
Margin="0,4"
|
||||
AllowDrop="True"
|
||||
TextElement.FontSize="14"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ContextMenuOpening="OnTreeContextMenuOpening"
|
||||
DragEnter="OnTreeBookmarksDragEnter"
|
||||
DragLeave="OnTreeBookmarksDragLeave"
|
||||
DragOver="OnTreeBookmarksDragOver"
|
||||
Drop="OnTreeBookmarksDrop">
|
||||
<controls:Tree.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type controls:TreeItem}" BasedOn="{StaticResource Style.TreeItem}">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
<!-- Repositories Tree -->
|
||||
<controls:Tree
|
||||
Grid.Row="1"
|
||||
x:Name="tree"
|
||||
Margin="0,8,0,0"
|
||||
AllowDrop="True"
|
||||
TextElement.FontSize="14"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ContextMenuOpening="OnTreeContextMenuOpening"
|
||||
MouseMove="OnTreeMouseMove"
|
||||
DragOver="OnTreeDragOver"
|
||||
Drop="OnTreeDrop"
|
||||
LostFocus="OnTreeLostFocus">
|
||||
<controls:Tree.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type controls:TreeItem}" BasedOn="{StaticResource Style.TreeItem}">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
|
||||
<EventSetter Event="Expanded" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="Collapsed" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/>
|
||||
</Style>
|
||||
</controls:Tree.ItemContainerStyle>
|
||||
<EventSetter Event="Expanded" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="Collapsed" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/>
|
||||
</Style>
|
||||
</controls:Tree.ItemContainerStyle>
|
||||
|
||||
<controls:Tree.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<Border Height="32">
|
||||
<Grid IsHitTestVisible="False">
|
||||
<controls:Tree.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<Grid Height="32" IsHitTestVisible="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
|
@ -199,33 +200,45 @@
|
|||
IsHitTestVisible="True"
|
||||
Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<HierarchicalDataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="True">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="False">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:TreeItem}}, Path=IsExpanded}" Value="True">
|
||||
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsEditing}" Value="True">
|
||||
<Setter TargetName="EditorBookmarks" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="ContentsBookmark" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
</HierarchicalDataTemplate.Triggers>
|
||||
</HierarchicalDataTemplate>
|
||||
</controls:Tree.ItemTemplate>
|
||||
</controls:Tree>
|
||||
<HierarchicalDataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="True">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="False">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:TreeItem}}, Path=IsExpanded}" Value="True">
|
||||
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsEditing}" Value="True">
|
||||
<Setter TargetName="EditorBookmarks" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="ContentsBookmark" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
</HierarchicalDataTemplate.Triggers>
|
||||
</HierarchicalDataTemplate>
|
||||
</controls:Tree.ItemTemplate>
|
||||
</controls:Tree>
|
||||
|
||||
<!-- Drop Area -->
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
x:Name="dropArea"
|
||||
Margin="0,4"
|
||||
Stroke="{DynamicResource Brush.Border1}"
|
||||
StrokeThickness="2"
|
||||
StrokeDashArray="4,4"
|
||||
SnapsToDevicePixels="True"
|
||||
Visibility="Hidden"
|
||||
IsHitTestVisible="False"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- Popup -->
|
||||
<widgets:PopupPanel x:Name="popup" Grid.Row="0" Grid.RowSpan="2"/>
|
||||
<widgets:PopupPanel x:Name="popup" Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" Grid.ColumnSpan="3"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -19,14 +19,8 @@ namespace SourceGit.Views.Widgets {
|
|||
/// 树节点数据
|
||||
/// </summary>
|
||||
public class Node : Controls.BindableBase {
|
||||
public string Id {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string ParentId {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string Id { get; set; }
|
||||
public string ParentId { get; set; }
|
||||
|
||||
private string name;
|
||||
public string Name {
|
||||
|
@ -34,10 +28,7 @@ namespace SourceGit.Views.Widgets {
|
|||
set => SetProperty(ref name, value);
|
||||
}
|
||||
|
||||
public bool IsGroup {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public bool IsGroup { get; set; }
|
||||
|
||||
private bool isEditing = false;
|
||||
public bool IsEditing {
|
||||
|
@ -45,10 +36,7 @@ namespace SourceGit.Views.Widgets {
|
|||
set => SetProperty(ref isEditing, value);
|
||||
}
|
||||
|
||||
public bool IsExpanded {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public bool IsExpanded { get; set; }
|
||||
|
||||
private int bookmark = 0;
|
||||
public int Bookmark {
|
||||
|
@ -56,10 +44,7 @@ namespace SourceGit.Views.Widgets {
|
|||
set => SetProperty(ref bookmark, value);
|
||||
}
|
||||
|
||||
public List<Node> Children {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public List<Node> Children { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -67,11 +52,10 @@ namespace SourceGit.Views.Widgets {
|
|||
/// </summary>
|
||||
public event Action<Node> OnNodeEdited;
|
||||
|
||||
private bool clearBookmark = false;
|
||||
|
||||
public Welcome() {
|
||||
InitializeComponent();
|
||||
UpdateTree();
|
||||
UpdateRecents();
|
||||
}
|
||||
|
||||
#region POPUP_CONTAINER
|
||||
|
@ -91,21 +75,52 @@ namespace SourceGit.Views.Widgets {
|
|||
#region FUNC_EVENTS
|
||||
private void OnOpenClicked(object sender, RoutedEventArgs e) {
|
||||
var dialog = new Controls.FolderDialog();
|
||||
|
||||
if (dialog.ShowDialog() == true) {
|
||||
CheckAndOpen(dialog.SelectedPath);
|
||||
}
|
||||
if (dialog.ShowDialog() == true) CheckAndOpen(dialog.SelectedPath);
|
||||
}
|
||||
|
||||
private void OnCloneClicked(object sender, RoutedEventArgs e) {
|
||||
if (MakeSureReady()) {
|
||||
new Popups.Clone().Show();
|
||||
if (MakeSureReady()) new Popups.Clone().Show();
|
||||
}
|
||||
|
||||
private void OnRecentContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
||||
var repo = (sender as DataGridRow).DataContext as Models.Repository;
|
||||
if (repo != null) {
|
||||
var remove = new MenuItem();
|
||||
remove.Header = App.Text("Welcome.Delete");
|
||||
remove.Click += (o, ev) => {
|
||||
Models.Preference.Instance.RemoveRecent(repo.Path);
|
||||
UpdateRecents();
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(remove);
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRecentDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||
var repo = (sender as DataGridRow).DataContext as Models.Repository;
|
||||
if (repo != null) CheckAndOpen(repo.Path);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnRecentLostFocus(object sender, RoutedEventArgs e) {
|
||||
list.UnselectAll();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTreeLostFocus(object sender, RoutedEventArgs e) {
|
||||
var child = FocusManager.GetFocusedElement(body);
|
||||
if (child == null) return;
|
||||
|
||||
if (!tree.IsAncestorOf(child as UIElement)) tree.UnselectAll();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTreeNodeStatusChange(object sender, RoutedEventArgs e) {
|
||||
var node = (sender as Controls.TreeItem).DataContext as Node;
|
||||
|
||||
if (node != null) {
|
||||
var group = Models.Preference.Instance.FindGroup(node.Id);
|
||||
group.IsExpanded = node.IsExpanded;
|
||||
|
@ -115,7 +130,6 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
private void OnTreeNodeDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||
var node = (sender as Controls.TreeItem).DataContext as Node;
|
||||
|
||||
if (node != null && !node.IsGroup) {
|
||||
CheckAndOpen(node.Id);
|
||||
e.Handled = true;
|
||||
|
@ -123,8 +137,7 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
private void OnTreeContextMenuOpening(object sender, ContextMenuEventArgs e) {
|
||||
var item = treeHistory.FindItem(e.OriginalSource as DependencyObject);
|
||||
|
||||
var item = tree.FindItem(e.OriginalSource as DependencyObject);
|
||||
if (item == null) {
|
||||
var addFolder = new MenuItem();
|
||||
addFolder.Header = App.Text("Welcome.NewFolder");
|
||||
|
@ -133,20 +146,16 @@ namespace SourceGit.Views.Widgets {
|
|||
UpdateTree(group.Id);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var menu = new ContextMenu();
|
||||
menu.Items.Add(addFolder);
|
||||
menu.IsOpen = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var node = item.DataContext as Node;
|
||||
|
||||
if (node == null) {
|
||||
return;
|
||||
}
|
||||
if (node == null) return;
|
||||
|
||||
var menu = new ContextMenu();
|
||||
|
||||
if (!node.IsGroup) {
|
||||
var open = new MenuItem();
|
||||
open.Header = App.Text("RepoCM.Open");
|
||||
|
@ -154,56 +163,57 @@ namespace SourceGit.Views.Widgets {
|
|||
CheckAndOpen(node.Id);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var explore = new MenuItem();
|
||||
explore.Header = App.Text("RepoCM.Explore");
|
||||
explore.Click += (o, ev) => {
|
||||
Process.Start("explorer", node.Id);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var iconBookmark = FindResource("Icon.Bookmark") as Geometry;
|
||||
var bookmark = new MenuItem();
|
||||
bookmark.Header = App.Text("RepoCM.Bookmark");
|
||||
|
||||
for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) {
|
||||
var icon = new System.Windows.Shapes.Path();
|
||||
icon.Data = iconBookmark;
|
||||
icon.Fill = Controls.Bookmark.COLORS[i];
|
||||
icon.Width = 8;
|
||||
|
||||
var mark = new MenuItem();
|
||||
mark.Icon = icon;
|
||||
mark.Header = $"{i}";
|
||||
|
||||
var refIdx = i;
|
||||
mark.Click += (o, ev) => {
|
||||
var repo = Models.Preference.Instance.FindRepository(node.Id);
|
||||
|
||||
if (repo != null) {
|
||||
repo.Bookmark = refIdx;
|
||||
UpdateTree();
|
||||
node.Bookmark = refIdx;
|
||||
UpdateRecents();
|
||||
OnNodeEdited?.Invoke(node);
|
||||
}
|
||||
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
bookmark.Items.Add(mark);
|
||||
}
|
||||
|
||||
menu.Items.Add(open);
|
||||
menu.Items.Add(explore);
|
||||
menu.Items.Add(bookmark);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
var addSubFolder = new MenuItem();
|
||||
addSubFolder.Header = App.Text("Welcome.NewSubFolder");
|
||||
addSubFolder.Click += (o, ev) => {
|
||||
var parent = Models.Preference.Instance.FindGroup(node.Id);
|
||||
|
||||
if (parent != null) {
|
||||
parent.IsExpanded = true;
|
||||
}
|
||||
if (parent != null) parent.IsExpanded = true;
|
||||
|
||||
var group = Models.Preference.Instance.AddGroup("New Group", node.Id);
|
||||
UpdateTree(group.Id);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(addSubFolder);
|
||||
}
|
||||
|
||||
|
@ -213,12 +223,14 @@ namespace SourceGit.Views.Widgets {
|
|||
UpdateTree(node.Id);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
var delete = new MenuItem();
|
||||
delete.Header = App.Text("Welcome.Delete");
|
||||
delete.Click += (o, ev) => {
|
||||
DeleteNode(node);
|
||||
ev.Handled = true;
|
||||
};
|
||||
|
||||
menu.Items.Add(rename);
|
||||
menu.Items.Add(delete);
|
||||
menu.IsOpen = true;
|
||||
|
@ -228,185 +240,106 @@ namespace SourceGit.Views.Widgets {
|
|||
#endregion
|
||||
|
||||
#region DRAP_DROP_EVENTS
|
||||
private void OnPageMouseDown(object sender, MouseButtonEventArgs e) {
|
||||
var itemHistory = treeHistory.FindItem(e.OriginalSource as DependencyObject);
|
||||
|
||||
if (itemHistory == null) {
|
||||
treeHistory.UnselectAll();
|
||||
}
|
||||
|
||||
var itemBookmark = treeBookmarks.FindItem(e.OriginalSource as DependencyObject);
|
||||
|
||||
if (itemBookmark == null) {
|
||||
treeBookmarks.UnselectAll();
|
||||
}
|
||||
|
||||
clearBookmark = false;
|
||||
}
|
||||
|
||||
private void OnPageMouseMove(object sender, MouseEventArgs e) {
|
||||
if (e.LeftButton != MouseButtonState.Pressed) {
|
||||
return;
|
||||
}
|
||||
|
||||
var item = treeHistory.FindItem(e.OriginalSource as DependencyObject);
|
||||
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
treeHistory.UnselectAll();
|
||||
var adorner = new Controls.DragDropAdorner(item);
|
||||
DragDrop.DoDragDrop(item, item.DataContext, DragDropEffects.Move);
|
||||
adorner.Remove();
|
||||
}
|
||||
|
||||
private void OnPageDrop(object sender, DragEventArgs e) {
|
||||
bool rebuild = false;
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
||||
if (!MakeSureReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var paths = e.Data.GetData(DataFormats.FileDrop) as string[];
|
||||
|
||||
foreach (var path in paths) {
|
||||
var dir = new Commands.QueryGitDir(path).Result();
|
||||
|
||||
if (dir != null) {
|
||||
var root = new Commands.GetRepositoryRootPath(path).Result();
|
||||
Models.Preference.Instance.AddRepository(root, dir, "");
|
||||
CheckAndOpen(path);
|
||||
rebuild = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Data.GetDataPresent(typeof(Node))) {
|
||||
var node = e.Data.GetData(typeof(Node)) as Node;
|
||||
|
||||
if (node.IsGroup) {
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
var repo = Models.Preference.Instance.FindRepository(node.Id);
|
||||
|
||||
if (repo != null && repo.Bookmark != 0 && clearBookmark) {
|
||||
repo.Bookmark = 0;
|
||||
}
|
||||
clearBookmark = false;
|
||||
rebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (rebuild) {
|
||||
UpdateTree();
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTreeBookmarksDragEnter(object sender, DragEventArgs e) {
|
||||
private void OnPageDragEnter(object sender, DragEventArgs e) {
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop) || e.Data.GetDataPresent(typeof(Node))) {
|
||||
dropArea.Visibility = Visibility.Visible;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTreeBookmarksDragLeave(object sender, DragEventArgs e) {
|
||||
private void OnPageDragLeave(object sender, DragEventArgs e) {
|
||||
dropArea.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void OnTreeBookmarksDragOver(object sender, DragEventArgs e) {
|
||||
if (!e.Data.GetDataPresent(DataFormats.FileDrop) && !e.Data.GetDataPresent(typeof(Node))) {
|
||||
return;
|
||||
}
|
||||
private void OnPageDrop(object sender, DragEventArgs e) {
|
||||
dropArea.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
var item = treeBookmarks.FindItem(e.OriginalSource as DependencyObject);
|
||||
private void OnTreeMouseMove(object sender, MouseEventArgs e) {
|
||||
if (e.LeftButton != MouseButtonState.Pressed) return;
|
||||
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
var item = tree.FindItem(e.OriginalSource as DependencyObject);
|
||||
if (item == null) return;
|
||||
|
||||
tree.UnselectAll();
|
||||
|
||||
var adorner = new Controls.DragDropAdorner(item);
|
||||
DragDrop.DoDragDrop(item, item.DataContext, DragDropEffects.Move);
|
||||
adorner.Remove();
|
||||
}
|
||||
|
||||
private void OnTreeDragOver(object sender, DragEventArgs e) {
|
||||
if (!e.Data.GetDataPresent(DataFormats.FileDrop) && !e.Data.GetDataPresent(typeof(Node))) return;
|
||||
|
||||
var item = tree.FindItem(e.OriginalSource as DependencyObject);
|
||||
if (item == null) return;
|
||||
|
||||
var node = item.DataContext as Node;
|
||||
|
||||
if (node.IsGroup && !item.IsExpanded) {
|
||||
item.IsExpanded = true;
|
||||
}
|
||||
|
||||
clearBookmark = true;
|
||||
|
||||
if (node.IsGroup && !item.IsExpanded) item.IsExpanded = true;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnTreeBookmarksDrop(object sender, DragEventArgs e) {
|
||||
private void OnTreeDrop(object sender, DragEventArgs e) {
|
||||
bool rebuild = false;
|
||||
var parent = "";
|
||||
|
||||
clearBookmark = false;
|
||||
dropArea.Visibility = Visibility.Hidden;
|
||||
var to = treeBookmarks.FindItem(e.OriginalSource as DependencyObject);
|
||||
|
||||
var parent = "";
|
||||
var to = tree.FindItem(e.OriginalSource as DependencyObject);
|
||||
if (to != null) {
|
||||
var dst = to.DataContext as Node;
|
||||
parent = dst.IsGroup ? dst.Id : dst.ParentId;
|
||||
}
|
||||
|
||||
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
||||
if (!MakeSureReady()) {
|
||||
return;
|
||||
}
|
||||
if (!MakeSureReady()) return;
|
||||
|
||||
var paths = e.Data.GetData(DataFormats.FileDrop) as string[];
|
||||
|
||||
foreach (var path in paths) {
|
||||
var dir = new Commands.QueryGitDir(path).Result();
|
||||
|
||||
if (dir != null) {
|
||||
var root = new Commands.GetRepositoryRootPath(path).Result();
|
||||
Models.Preference.Instance.AddRepository(root, dir, parent).Bookmark = 1; // 默认添加的标签;
|
||||
// CheckAndOpen(path);
|
||||
Models.Preference.Instance.AddRepository(root, dir, parent);
|
||||
rebuild = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Data.GetDataPresent(typeof(Node))) {
|
||||
var node = e.Data.GetData(typeof(Node)) as Node;
|
||||
|
||||
if (node.IsGroup) {
|
||||
if (!Models.Preference.Instance.IsSubGroup(node.Id, parent)) {
|
||||
Models.Preference.Instance.FindGroup(node.Id).Parent = parent;
|
||||
} else if (e.Data.GetDataPresent(typeof(Node))) {
|
||||
var src = e.Data.GetData(typeof(Node)) as Node;
|
||||
if (src.IsGroup) {
|
||||
if (!Models.Preference.Instance.IsSubGroup(src.Id, parent)) {
|
||||
Models.Preference.Instance.FindGroup(src.Id).Parent = parent;
|
||||
rebuild = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var repo = Models.Preference.Instance.FindRepository(node.Id);
|
||||
|
||||
if (repo != null) {
|
||||
repo.GroupId = parent;
|
||||
|
||||
if (repo.Bookmark == 0) {
|
||||
repo.Bookmark = 1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
Models.Preference.Instance.FindRepository(src.Id).GroupId = parent;
|
||||
rebuild = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (rebuild) {
|
||||
UpdateTree();
|
||||
}
|
||||
|
||||
if (rebuild) UpdateTree();
|
||||
e.Handled = true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DATA
|
||||
private void UpdateRecents() {
|
||||
var repos = new List<Models.Repository>();
|
||||
var dirty = new List<string>();
|
||||
|
||||
foreach (var path in Models.Preference.Instance.Recents) {
|
||||
var repo = Models.Preference.Instance.FindRepository(path);
|
||||
if (repo != null) {
|
||||
repos.Add(repo);
|
||||
} else {
|
||||
dirty.Add(path);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var path in dirty) Models.Preference.Instance.RemoveRecent(path);
|
||||
list.ItemsSource = repos;
|
||||
}
|
||||
|
||||
private void UpdateTree(string editingNodeId = null) {
|
||||
var groupNodes = new Dictionary<string, Node>();
|
||||
var nodesHistory = new List<Node>();
|
||||
var nodesBookmarks = new List<Node>();
|
||||
var nodes = new List<Node>();
|
||||
|
||||
foreach (var group in Models.Preference.Instance.Groups) {
|
||||
Node node = new Node() {
|
||||
|
@ -419,15 +352,17 @@ namespace SourceGit.Views.Widgets {
|
|||
Bookmark = 0,
|
||||
Children = new List<Node>(),
|
||||
};
|
||||
|
||||
groupNodes.Add(node.Id, node);
|
||||
}
|
||||
|
||||
nodes.Clear();
|
||||
|
||||
foreach (var kv in groupNodes) {
|
||||
if (groupNodes.ContainsKey(kv.Value.ParentId)) {
|
||||
groupNodes[kv.Value.ParentId].Children.Add(kv.Value);
|
||||
}
|
||||
else {
|
||||
nodesBookmarks.Add(kv.Value);
|
||||
} else {
|
||||
nodes.Add(kv.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -442,33 +377,26 @@ namespace SourceGit.Views.Widgets {
|
|||
Bookmark = repo.Bookmark,
|
||||
Children = new List<Node>(),
|
||||
};
|
||||
nodesHistory.Add(node);
|
||||
|
||||
if (repo.Bookmark != 0) {
|
||||
if (groupNodes.ContainsKey(repo.GroupId)) {
|
||||
groupNodes[repo.GroupId].Children.Add(node);
|
||||
}
|
||||
else {
|
||||
nodesBookmarks.Add(node);
|
||||
}
|
||||
if (groupNodes.ContainsKey(repo.GroupId)) {
|
||||
groupNodes[repo.GroupId].Children.Add(node);
|
||||
} else {
|
||||
nodes.Add(node);
|
||||
}
|
||||
|
||||
OnNodeEdited?.Invoke(node);
|
||||
}
|
||||
|
||||
treeHistory.ItemsSource = nodesHistory;
|
||||
treeBookmarks.ItemsSource = nodesBookmarks;
|
||||
tree.ItemsSource = nodes;
|
||||
}
|
||||
|
||||
private void DeleteNode(Node node) {
|
||||
if (node.IsGroup) {
|
||||
Models.Preference.Instance.RemoveGroup(node.Id);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Models.Preference.Instance.RemoveRepository(node.Id);
|
||||
}
|
||||
|
||||
UpdateTree();
|
||||
UpdateRecents();
|
||||
}
|
||||
|
||||
private bool MakeSureReady() {
|
||||
|
@ -476,14 +404,11 @@ namespace SourceGit.Views.Widgets {
|
|||
Models.Exception.Raise(App.Text("NotConfigured"));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckAndOpen(string path) {
|
||||
if (!MakeSureReady()) {
|
||||
return;
|
||||
}
|
||||
if (!MakeSureReady()) return;
|
||||
|
||||
if (!Directory.Exists(path)) {
|
||||
Models.Exception.Raise(App.Text("PathNotFound", path));
|
||||
|
@ -491,7 +416,6 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
var root = new Commands.GetRepositoryRootPath(path).Result();
|
||||
|
||||
if (root == null) {
|
||||
new Popups.Init(path).Show();
|
||||
return;
|
||||
|
@ -500,24 +424,18 @@ namespace SourceGit.Views.Widgets {
|
|||
var gitDir = new Commands.QueryGitDir(root).Result();
|
||||
var repo = Models.Preference.Instance.AddRepository(root, gitDir, "");
|
||||
Models.Watcher.Open(repo);
|
||||
treeHistory.UnselectAll();
|
||||
treeBookmarks.UnselectAll();
|
||||
Models.Preference.Instance.AddRecent(repo.Path);
|
||||
}
|
||||
|
||||
public void UpdateNodes(string id, int bookmark, IEnumerable<Node> nodes = null) {
|
||||
if (nodes == null) {
|
||||
nodes = treeHistory.ItemsSource.OfType<Node>();
|
||||
}
|
||||
|
||||
if (nodes == null) nodes = tree.ItemsSource.OfType<Node>();
|
||||
foreach (var node in nodes) {
|
||||
if (!node.IsGroup) {
|
||||
if (node.Id == id) {
|
||||
Models.Preference.Instance.FindRepository(node.Id).Bookmark = bookmark;
|
||||
UpdateTree();
|
||||
node.Bookmark = bookmark;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (node.Children.Count > 0) {
|
||||
} else if (node.Children.Count > 0) {
|
||||
UpdateNodes(id, bookmark, node.Children);
|
||||
}
|
||||
}
|
||||
|
@ -527,10 +445,7 @@ namespace SourceGit.Views.Widgets {
|
|||
#region RENAME_NODES
|
||||
private void RenameStart(object sender, RoutedEventArgs e) {
|
||||
var edit = sender as Controls.TextEdit;
|
||||
|
||||
if (edit == null || !edit.IsVisible) {
|
||||
return;
|
||||
}
|
||||
if (edit == null || !edit.IsVisible) return;
|
||||
|
||||
edit.SelectAll();
|
||||
edit.Focus();
|
||||
|
@ -540,8 +455,7 @@ namespace SourceGit.Views.Widgets {
|
|||
if (e.Key == Key.Escape) {
|
||||
UpdateTree();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Enter) {
|
||||
} else if (e.Key == Key.Enter) {
|
||||
RenameEnd(sender, e);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
@ -549,10 +463,7 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
private void RenameEnd(object sender, RoutedEventArgs e) {
|
||||
var edit = sender as Controls.TextEdit;
|
||||
|
||||
if (edit == null) {
|
||||
return;
|
||||
}
|
||||
if (edit == null) return;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(edit.Text)) {
|
||||
UpdateTree();
|
||||
|
@ -561,19 +472,16 @@ namespace SourceGit.Views.Widgets {
|
|||
}
|
||||
|
||||
var node = edit.DataContext as Node;
|
||||
|
||||
if (node != null) {
|
||||
node.Name = edit.Text;
|
||||
node.IsEditing = false;
|
||||
|
||||
if (node.IsGroup) {
|
||||
Models.Preference.Instance.RenameGroup(node.Id, edit.Text);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Models.Preference.Instance.RenameRepository(node.Id, node.Name);
|
||||
UpdateRecents();
|
||||
OnNodeEdited?.Invoke(node);
|
||||
}
|
||||
|
||||
e.Handled = false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue