Added: load support for ryz filetype
This commit is contained in:
parent
2fe74fe29d
commit
fd087d2d0e
@ -19,7 +19,6 @@ namespace BookmarkManager
|
|||||||
|
|
||||||
public override bool IsEncryptionSupported { get; set; } = true;
|
public override bool IsEncryptionSupported { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
public override bool IsEncrypted(string filename) => SharpZipLib.IsZipEncrypted(filename);
|
public override bool IsEncrypted(string filename) => SharpZipLib.IsZipEncrypted(filename);
|
||||||
|
|
||||||
public override Result Load(BookmarkTreeView treeview, string filename, string password)
|
public override Result Load(BookmarkTreeView treeview, string filename, string password)
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
using RyzStudio.IO;
|
using bzit.bomg.Models;
|
||||||
|
using RyzStudio.IO;
|
||||||
using RyzStudio.Windows.Forms;
|
using RyzStudio.Windows.Forms;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace BookmarkManager
|
namespace BookmarkManager
|
||||||
{
|
{
|
||||||
@ -16,12 +20,100 @@ namespace BookmarkManager
|
|||||||
|
|
||||||
public override bool IsEncryptionSupported { get; set; } = true;
|
public override bool IsEncryptionSupported { get; set; } = true;
|
||||||
|
|
||||||
|
|
||||||
public override bool IsEncrypted(string filename) => SharpZipLib.IsZipEncrypted(filename);
|
public override bool IsEncrypted(string filename) => SharpZipLib.IsZipEncrypted(filename);
|
||||||
|
|
||||||
public override Result Load(BookmarkTreeView treeview, string filename, string password)
|
public override Result Load(BookmarkTreeView treeview, string filename, string password)
|
||||||
{
|
{
|
||||||
return Result.Create(false);
|
treeview.Clear();
|
||||||
|
|
||||||
|
if (!SharpZipLib.TestArchive(filename, password))
|
||||||
|
{
|
||||||
|
return Result.Create(false, "Could not read file, is password correct?");
|
||||||
|
}
|
||||||
|
|
||||||
|
string sourceCode = SharpZipLib.ReadSingle(filename, password, "bookmarks.xml");
|
||||||
|
if (string.IsNullOrWhiteSpace(sourceCode))
|
||||||
|
{
|
||||||
|
return Result.Create(false, "Could not read file, unexpected format");
|
||||||
|
}
|
||||||
|
|
||||||
|
// load xml
|
||||||
|
XmlDocument xmlDocument = new XmlDocument();
|
||||||
|
xmlDocument.LoadXml(sourceCode);
|
||||||
|
|
||||||
|
// parse
|
||||||
|
XmlNode xnl = xmlDocument.SelectSingleNode("bomg/b/g");
|
||||||
|
if (xnl == null)
|
||||||
|
{
|
||||||
|
return Result.Create(false, "Could not load file, unexpected format");
|
||||||
|
}
|
||||||
|
|
||||||
|
string rootName = (xnl.Attributes["name"] == null) ? "Bookmarks" : (string.IsNullOrWhiteSpace(xnl.Attributes["name"].InnerText) ? "Bookmarks" : xnl.Attributes["name"].InnerText.Trim());
|
||||||
|
|
||||||
|
foreach (XmlNode xn in xnl.ChildNodes)
|
||||||
|
{
|
||||||
|
BookmarkItem item = new BookmarkItem();
|
||||||
|
|
||||||
|
foreach (XmlNode xn2 in xn.ChildNodes)
|
||||||
|
{
|
||||||
|
switch (xn2.LocalName)
|
||||||
|
{
|
||||||
|
case "name":
|
||||||
|
item.SiteName = xn2.InnerText?.Trim();
|
||||||
|
break;
|
||||||
|
case "address":
|
||||||
|
item.SiteAddress = xn2.InnerText?.Trim();
|
||||||
|
break;
|
||||||
|
case "description":
|
||||||
|
item.SiteDescription = xn2.InnerText?.Trim();
|
||||||
|
break;
|
||||||
|
//case "created":
|
||||||
|
// bi.Created = xn2.InnerText?.Trim();
|
||||||
|
// break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// fix fullpath and name
|
||||||
|
if (item.SiteName.Contains("|"))
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.Append("\\");
|
||||||
|
sb.Append(System.Web.HttpUtility.UrlEncode(rootName));
|
||||||
|
sb.Append("\\");
|
||||||
|
|
||||||
|
string[] pathParts = item.SiteName.Split('|');
|
||||||
|
for (int i = 0; i < (pathParts.Length - 1); i++)
|
||||||
|
{
|
||||||
|
sb.Append(pathParts[i]);
|
||||||
|
//sb.Append(System.Web.HttpUtility.UrlDecode(pathParts[i]));
|
||||||
|
sb.Append("\\");
|
||||||
|
}
|
||||||
|
|
||||||
|
item.SiteName = System.Web.HttpUtility.UrlDecode(pathParts[(pathParts.Length - 1)] ?? string.Empty);
|
||||||
|
item.TreeviewPath = sb.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.SiteName = System.Web.HttpUtility.UrlDecode(item.SiteName);
|
||||||
|
item.TreeviewPath = string.Format("\\{0}\\", System.Web.HttpUtility.UrlEncode(rootName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (treeview.InvokeRequired)
|
||||||
|
{
|
||||||
|
treeview.Invoke(new MethodInvoker(() =>
|
||||||
|
{
|
||||||
|
treeview.AddItem(item);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
treeview.AddItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.Create(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Result Save(BookmarkTreeView treeview, string filename, string password)
|
public override Result Save(BookmarkTreeView treeview, string filename, string password)
|
||||||
|
23
MainForm.Designer.cs
generated
23
MainForm.Designer.cs
generated
@ -130,7 +130,7 @@
|
|||||||
this.newToolStripMenuItem.Image = global::BookmarkManager.UIResource.file2;
|
this.newToolStripMenuItem.Image = global::BookmarkManager.UIResource.file2;
|
||||||
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
|
this.newToolStripMenuItem.Name = "newToolStripMenuItem";
|
||||||
this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
|
this.newToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N)));
|
||||||
this.newToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.newToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
|
||||||
this.newToolStripMenuItem.Text = "&New";
|
this.newToolStripMenuItem.Text = "&New";
|
||||||
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
|
this.newToolStripMenuItem.Click += new System.EventHandler(this.newToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -139,52 +139,52 @@
|
|||||||
this.openToolStripMenuItem.Image = global::BookmarkManager.UIResource.folder2;
|
this.openToolStripMenuItem.Image = global::BookmarkManager.UIResource.folder2;
|
||||||
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
|
||||||
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
|
||||||
this.openToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.openToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
|
||||||
this.openToolStripMenuItem.Text = "&Open";
|
this.openToolStripMenuItem.Text = "&Open";
|
||||||
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// toolStripMenuItem13
|
// toolStripMenuItem13
|
||||||
//
|
//
|
||||||
this.toolStripMenuItem13.Name = "toolStripMenuItem13";
|
this.toolStripMenuItem13.Name = "toolStripMenuItem13";
|
||||||
this.toolStripMenuItem13.Size = new System.Drawing.Size(177, 6);
|
this.toolStripMenuItem13.Size = new System.Drawing.Size(143, 6);
|
||||||
//
|
//
|
||||||
// closeToolStripMenuItem
|
// closeToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
|
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
|
||||||
this.closeToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.closeToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
|
||||||
this.closeToolStripMenuItem.Text = "&Close";
|
this.closeToolStripMenuItem.Text = "&Close";
|
||||||
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
|
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// toolStripMenuItem14
|
// toolStripMenuItem14
|
||||||
//
|
//
|
||||||
this.toolStripMenuItem14.Name = "toolStripMenuItem14";
|
this.toolStripMenuItem14.Name = "toolStripMenuItem14";
|
||||||
this.toolStripMenuItem14.Size = new System.Drawing.Size(177, 6);
|
this.toolStripMenuItem14.Size = new System.Drawing.Size(143, 6);
|
||||||
//
|
//
|
||||||
// saveToolStripMenuItem
|
// saveToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.saveToolStripMenuItem.Image = global::BookmarkManager.UIResource.disk2;
|
this.saveToolStripMenuItem.Image = global::BookmarkManager.UIResource.disk2;
|
||||||
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));
|
||||||
this.saveToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
|
||||||
this.saveToolStripMenuItem.Text = "&Save";
|
this.saveToolStripMenuItem.Text = "&Save";
|
||||||
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// saveAsToolStripMenuItem
|
// saveAsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
|
||||||
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
|
||||||
this.saveAsToolStripMenuItem.Text = "Save &As...";
|
this.saveAsToolStripMenuItem.Text = "Save &As...";
|
||||||
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// toolStripMenuItem15
|
// toolStripMenuItem15
|
||||||
//
|
//
|
||||||
this.toolStripMenuItem15.Name = "toolStripMenuItem15";
|
this.toolStripMenuItem15.Name = "toolStripMenuItem15";
|
||||||
this.toolStripMenuItem15.Size = new System.Drawing.Size(177, 6);
|
this.toolStripMenuItem15.Size = new System.Drawing.Size(143, 6);
|
||||||
//
|
//
|
||||||
// exitToolStripMenuItem2
|
// exitToolStripMenuItem2
|
||||||
//
|
//
|
||||||
this.exitToolStripMenuItem2.Name = "exitToolStripMenuItem2";
|
this.exitToolStripMenuItem2.Name = "exitToolStripMenuItem2";
|
||||||
this.exitToolStripMenuItem2.Size = new System.Drawing.Size(180, 22);
|
this.exitToolStripMenuItem2.Size = new System.Drawing.Size(146, 22);
|
||||||
this.exitToolStripMenuItem2.Text = "E&xit";
|
this.exitToolStripMenuItem2.Text = "E&xit";
|
||||||
this.exitToolStripMenuItem2.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
this.exitToolStripMenuItem2.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -201,7 +201,7 @@
|
|||||||
this.findToolStripMenuItem.Image = global::BookmarkManager.UIResource.search2;
|
this.findToolStripMenuItem.Image = global::BookmarkManager.UIResource.search2;
|
||||||
this.findToolStripMenuItem.Name = "findToolStripMenuItem";
|
this.findToolStripMenuItem.Name = "findToolStripMenuItem";
|
||||||
this.findToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
|
this.findToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F)));
|
||||||
this.findToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.findToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
|
||||||
this.findToolStripMenuItem.Text = "&Find";
|
this.findToolStripMenuItem.Text = "&Find";
|
||||||
this.findToolStripMenuItem.Click += new System.EventHandler(this.findToolStripMenuItem_Click);
|
this.findToolStripMenuItem.Click += new System.EventHandler(this.findToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -302,7 +302,8 @@
|
|||||||
// openFileDialog1
|
// openFileDialog1
|
||||||
//
|
//
|
||||||
this.openFileDialog1.DefaultExt = "jsnx";
|
this.openFileDialog1.DefaultExt = "jsnx";
|
||||||
this.openFileDialog1.Filter = "Bookmarks files (*.jsnx)|*.jsnx|Bookmarks files (*.ryz)|*.ryz";
|
this.openFileDialog1.Filter = "All supported files (*.jsnx;*.ryz)|*.jsnx;*.ryz|Bookmarks files (*.jsnx)|*.jsnx|B" +
|
||||||
|
"ookmarks files (*.ryz)|*.ryz";
|
||||||
this.openFileDialog1.Title = "Open bookmarks file";
|
this.openFileDialog1.Title = "Open bookmarks file";
|
||||||
//
|
//
|
||||||
// rootContextMenu
|
// rootContextMenu
|
||||||
|
Loading…
Reference in New Issue
Block a user