From 49223ba8f0a2bf9aec3af8b0a0eafbeb73890dfd Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 31 Dec 2024 17:47:25 +0000 Subject: [PATCH 1/2] Added support for directories --- MainForm.cs | 32 +++++++++------- Models/AppOptions.cs | 2 + Windows/Forms/BookmarkTreeView.cs | 64 +++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 13 deletions(-) diff --git a/MainForm.cs b/MainForm.cs index a07d333..cdd7796 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -6,6 +6,7 @@ using System.Drawing.Imaging; using System.IO; using System.IO.Compression; using System.Linq; +using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; using BookmarkManager; @@ -748,9 +749,21 @@ namespace FizzyLauncher InvalidateOptions(); - // Load items + // Clear treeview treeView1.Clear("New Session"); + // Load directories + foreach (var item in this.CurrentSession.Directories ?? new List()) + { + if (string.IsNullOrWhiteSpace(item)) + { + continue; + } + + treeView1.CreateNodePath(item, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2); + } + + // Load bookmarks foreach (var item in this.CurrentSession.Items ?? new List()) { treeView1.AddNode(item); @@ -798,18 +811,11 @@ namespace FizzyLauncher this.CurrentSession.Width = this.Width; this.CurrentSession.Height = this.Height; - var nodeList = treeView1.ToNodeList() ?? new List>(); - foreach (var node in nodeList) - { - node.Value.Path = treeView1.GetNodePath(node.Key); + var directoryList = treeView1.GetAllDirectories(); + var bookmarkList = treeView1.GetAllNodes(); - if (node.Value.Path.Contains('\n')) - { - node.Value.Path = node.Value.Path.Substring(0, node.Value.Path.LastIndexOf('\n')); - } - } - - this.CurrentSession.Items = nodeList.Select(x => x.Value).ToList(); + this.CurrentSession.Directories = directoryList ?? new List(); + this.CurrentSession.Items = bookmarkList.Select(x => x.Value)?.ToList() ?? new List(); var result = GenericResult.Create(); @@ -825,7 +831,7 @@ namespace FizzyLauncher if (result.IsSuccess) { // Add icons to save file - var result2 = AddImagesToZipFile(filename, nodeList); + var result2 = AddImagesToZipFile(filename, bookmarkList); if (!result2.IsSuccess) { if (showNotices) diff --git a/Models/AppOptions.cs b/Models/AppOptions.cs index 7483a9b..7089cd8 100644 --- a/Models/AppOptions.cs +++ b/Models/AppOptions.cs @@ -20,6 +20,8 @@ namespace FizzyLauncher.Models public int Height { get; set; } = 0; + public List Directories { get; set; } = new List(); + public List Items { get; set; } = new List(); } diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs index 528b987..e299a1a 100644 --- a/Windows/Forms/BookmarkTreeView.cs +++ b/Windows/Forms/BookmarkTreeView.cs @@ -1,10 +1,14 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; +using System.Linq; using System.Reflection; +using System.Threading.Tasks; using System.Windows.Forms; using bzit.bomg.Models; using FizzyLauncher; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; using Resources = BookmarkManager.AppResource; namespace RyzStudio.Windows.Forms @@ -421,6 +425,53 @@ namespace RyzStudio.Windows.Forms this.HasChanged = true; } + public List GetAllDirectories() + { + var nodes = GetAllTreeNodes(); + nodes = nodes.Where(x => this.GetNodeType(x) == NodeType.Folder)?.ToList() ?? new List(); + + var result = new List(); + + foreach (var item in nodes) + { + result.Add(this.GetNodePath(item)); + } + + return result; + } + + public List> GetAllNodes() + { + var result = this.ToNodeList() ?? new List>(); + foreach (var node in result) + { + node.Value.Path = this.GetNodePath(node.Key); + + if (node.Value.Path.Contains('\n')) + { + node.Value.Path = node.Value.Path.Substring(0, node.Value.Path.LastIndexOf('\n')); + } + } + + return result; + } + + public List GetAllTreeNodes() + { + var result = new List(); + if (this.Nodes.Count <= 0) + { + return result; + } + + foreach (TreeNode node in this.Nodes) + { + TraverseNodeTree(result, node); + } + + return result; + } + private void ClearImageList() { @@ -468,5 +519,18 @@ namespace RyzStudio.Windows.Forms return this.ImageList.Images.IndexOfKey(key); } + protected void TraverseNodeTree(List result, TreeNode node) + { + foreach (TreeNode node2 in node.Nodes) + { + result.Add(node2); + + foreach (TreeNode node3 in node2.Nodes) + { + result.Add(node3); + } + } + } + } } \ No newline at end of file From 32bd4a9142c6486ad72eedd5d1424f48df730b8d Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 31 Dec 2024 17:50:34 +0000 Subject: [PATCH 2/2] Changed build no. --- BookmarkManager.csproj | 2 +- MainForm.cs | 1 - Windows/Forms/BookmarkTreeView.cs | 3 --- build-installer.iss | 8 ++++---- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/BookmarkManager.csproj b/BookmarkManager.csproj index 7f050a1..c8c1c61 100644 --- a/BookmarkManager.csproj +++ b/BookmarkManager.csproj @@ -14,7 +14,7 @@ Ray Lam 1.0.0.0 1.0.0.0 - 0.6.2.092 + 0.6.3.048 bukkubuddy True 8.0 diff --git a/MainForm.cs b/MainForm.cs index cdd7796..3c180b3 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -6,7 +6,6 @@ using System.Drawing.Imaging; using System.IO; using System.IO.Compression; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using System.Windows.Forms; using BookmarkManager; diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs index e299a1a..c1f4955 100644 --- a/Windows/Forms/BookmarkTreeView.cs +++ b/Windows/Forms/BookmarkTreeView.cs @@ -3,12 +3,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; -using System.Reflection; -using System.Threading.Tasks; using System.Windows.Forms; using bzit.bomg.Models; using FizzyLauncher; -using static System.Windows.Forms.VisualStyles.VisualStyleElement; using Resources = BookmarkManager.AppResource; namespace RyzStudio.Windows.Forms diff --git a/build-installer.iss b/build-installer.iss index 341125e..058679e 100644 --- a/build-installer.iss +++ b/build-installer.iss @@ -2,13 +2,13 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "BukkuBuddy Bookmark Manager" -#define MyAppVersion "0.6.2.092" +#define MyAppVersion "0.6.3.048" #define MyAppPublisher "Hi, I'm Ray" -#define MyAppURL "https://www.hiimray.co.uk/software-bookmark-manager" +#define MyAppURL "https://www.hiimray.co.uk/software-bukkubuddy-bookmark-manager" #define MyAppExeName "bukkubuddy.exe" -#define AppSourcePath "L:\gitea-hiimray\bookmark-manager-r4\bin" -#define AppReleasePath "L:\gitea-hiimray\bookmark-manager-r4\bin" +#define AppSourcePath "L:\gitea-hiimray\bukkubuddy-bookmark-manager\bin" +#define AppReleasePath "L:\gitea-hiimray\bukkubuddy-bookmark-manager\bin" #define AppReleaseName "bukkubuddy-installer" [Setup]