From 646db1de567bef5a4642f60fe1aafb2b690c3232 Mon Sep 17 00:00:00 2001 From: Ray Date: Wed, 29 Sep 2021 01:58:02 +0100 Subject: [PATCH] Added: extra file type support --- Classes/SupportedFile/JSNXSupportedFile.cs | 4 ++ Classes/SupportedFile/RYZSupportedFile.cs | 53 +++++++++++++++++++++- MainForm.cs | 3 +- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Classes/SupportedFile/JSNXSupportedFile.cs b/Classes/SupportedFile/JSNXSupportedFile.cs index a02b396..c57e926 100644 --- a/Classes/SupportedFile/JSNXSupportedFile.cs +++ b/Classes/SupportedFile/JSNXSupportedFile.cs @@ -69,6 +69,10 @@ namespace BookmarkManager public override Result Save(BookmarkTreeView treeview, string filename, string password) { List rs = treeview.GetBookmarkList(); + if (rs.Count <= 0) + { + return Result.Create(false, "No bookmarks to save"); + } bool rv = SharpZipLib.CreateSingle(filename, password, "bookmarks.json", JsonConvert.SerializeObject(rs)); diff --git a/Classes/SupportedFile/RYZSupportedFile.cs b/Classes/SupportedFile/RYZSupportedFile.cs index 484b07b..34dbbd2 100644 --- a/Classes/SupportedFile/RYZSupportedFile.cs +++ b/Classes/SupportedFile/RYZSupportedFile.cs @@ -2,6 +2,7 @@ using RyzStudio.IO; using RyzStudio.Windows.Forms; using System.Collections.Generic; +using System.IO; using System.Text; using System.Windows.Forms; using System.Xml; @@ -67,6 +68,9 @@ namespace BookmarkManager case "description": item.SiteDescription = xn2.InnerText?.Trim(); break; + case "notes": + item.Notes = xn2.InnerText?.Trim(); + break; //case "created": // bi.Created = xn2.InnerText?.Trim(); // break; @@ -118,7 +122,54 @@ namespace BookmarkManager public override Result Save(BookmarkTreeView treeview, string filename, string password) { - return Result.Create(false); + List rs = treeview.GetBookmarkList(); + if (rs.Count <= 0) + { + return Result.Create(false, "No bookmarks to save"); + } + + return Result.Create(false, "Saving in this format is no longer supported"); + + //MemoryStream ms = new MemoryStream(); + //XmlTextWriter writer = new XmlTextWriter(ms, Encoding.UTF8); + + //writer.Formatting = Formatting.Indented; + //writer.WriteStartDocument(); + //writer.WriteStartElement("bomg"); + //writer.WriteStartElement("b"); + //writer.WriteStartElement("g"); + //writer.WriteAttributeString("name", treeview.Nodes[0].Text); + + //foreach (BookmarkItem item in rs) + //{ + // writer.WriteStartElement("m"); + // writer.WriteElementString("name", item.TreeviewPath); + // writer.WriteElementString("address", item.SiteAddress); + // writer.WriteElementString("description", item.SiteDescription); + // writer.WriteElementString("created", "200101010000"); + // writer.WriteEndElement(); + //} + + //writer.WriteEndElement(); + //writer.WriteEndElement(); + //writer.WriteEndElement(); + //writer.WriteEndDocument(); + //writer.Flush(); + + //ms.Position = 0; + //StreamReader sr = new StreamReader(ms); + + //string sourceCode = sr.ReadToEnd(); + + //sr.Close(); + //sr.Dispose(); + + //writer.Close(); + //writer.Dispose(); + + //bool rv = SharpZipLib.CreateSingle(filename, password, "bookmarks.xml", sourceCode); + + //return Result.Create(rv); } } diff --git a/MainForm.cs b/MainForm.cs index 7a63ed2..071ec09 100644 --- a/MainForm.cs +++ b/MainForm.cs @@ -24,6 +24,7 @@ namespace FizzyLauncher New } + protected IconDatabase iconDatabase = null; protected OptionsForm optionsForm = null; protected FindForm findForm = null; @@ -688,9 +689,9 @@ namespace FizzyLauncher /// private void moveDownToolStripMenuItem1_Click(object sender, EventArgs e) => treeView1.MoveDown(); - #endregion + private async void treeView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) { TreeNode tn = treeView1.SelectedNode;