style<Welcome,PageTabBar>: re-design the style for Welcome page

This commit is contained in:
leo 2022-10-14 20:38:53 +08:00
parent c2517701cc
commit b43044a7bf
19 changed files with 319 additions and 833 deletions

View file

@ -1,12 +0,0 @@
namespace SourceGit.Models {
/// <summary>
/// 仓库列表分组
/// </summary>
public class Group {
public string Id { get; set; } = "";
public string Name { get; set; } = "";
public string Parent { get; set; } = "";
public bool IsExpanded { get; set; } = false;
}
}

View file

@ -212,9 +212,7 @@ namespace SourceGit.Models {
public GitInfo Git { get; set; } = new GitInfo();
public MergeToolInfo MergeTool { get; set; } = new MergeToolInfo();
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
@ -251,71 +249,8 @@ namespace SourceGit.Models {
}
#endregion
#region METHOD_ON_GROUPS
public Group AddGroup(string name, string parentId) {
var group = new Group() {
Name = name,
Id = Guid.NewGuid().ToString(),
Parent = parentId,
IsExpanded = false,
};
Groups.Add(group);
Groups.Sort((l, r) => l.Name.CompareTo(r.Name));
return group;
}
public Group FindGroup(string id) {
foreach (var group in Groups) {
if (group.Id == id) return group;
}
return null;
}
public void RenameGroup(string id, string newName) {
foreach (var group in Groups) {
if (group.Id == id) {
group.Name = newName;
break;
}
}
Groups.Sort((l, r) => l.Name.CompareTo(r.Name));
}
public void RemoveGroup(string id) {
int removedIdx = -1;
for (int i = 0; i < Groups.Count; i++) {
if (Groups[i].Id == id) {
removedIdx = i;
break;
}
}
if (removedIdx >= 0) Groups.RemoveAt(removedIdx);
}
public bool IsSubGroup(string parent, string subId) {
if (string.IsNullOrEmpty(parent)) return false;
if (parent == subId) return true;
var g = FindGroup(subId);
if (g == null) return false;
g = FindGroup(g.Parent);
while (g != null) {
if (g.Id == parent) return true;
g = FindGroup(g.Parent);
}
return false;
}
#endregion
#region METHOD_ON_REPOSITORIES
public Repository AddRepository(string path, string gitDir, string groupId) {
public Repository AddRepository(string path, string gitDir) {
var repo = FindRepository(path);
if (repo != null) return repo;
@ -323,8 +258,7 @@ namespace SourceGit.Models {
repo = new Repository() {
Path = dir.FullName,
GitDir = gitDir,
Name = dir.Name,
GroupId = groupId,
Name = dir.Name
};
Repositories.Add(repo);
@ -340,14 +274,6 @@ namespace SourceGit.Models {
return null;
}
public void RenameRepository(string path, string newName) {
var repo = FindRepository(path);
if (repo == null) return;
repo.Name = newName;
Repositories.Sort((l, r) => l.Name.CompareTo(r.Name));
}
public void RemoveRepository(string path) {
var dir = new DirectoryInfo(path);
var removedIdx = -1;
@ -362,36 +288,5 @@ 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
}
}

View file

@ -27,7 +27,6 @@ namespace SourceGit.Models {
public string Name { get; set; } = "";
public string Path { get; set; } = "";
public string GitDir { get; set; } = "";
public string GroupId { get; set; } = "";
public int Bookmark { get; set; } = 0;
public List<SubTree> SubTrees { get; set; } = new List<SubTree>();
public List<string> Filters { get; set; } = new List<string>();