Changed: show loading file dialog
This commit is contained in:
parent
fa8f2c046d
commit
ac117cbfc4
12
FindForm.cs
12
FindForm.cs
@ -52,13 +52,13 @@ namespace bzit.bomg
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentForm.treeView1.Nodes.Count <= 0)
|
||||
if (parentForm.TreeView.Nodes.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
findNextNew = false;
|
||||
parentForm.treeView1.FindTextNode(parentForm.treeView1.Nodes[0], textBox1.Text?.Trim());
|
||||
parentForm.TreeView.FindTextNode(parentForm.TreeView.Nodes[0], textBox1.Text?.Trim());
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
@ -73,19 +73,19 @@ namespace bzit.bomg
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentForm.treeView1.Nodes.Count <= 0)
|
||||
if (parentForm.TreeView.Nodes.Count <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentForm.treeView1.SelectedNode == null)
|
||||
if (parentForm.TreeView.SelectedNode == null)
|
||||
{
|
||||
parentForm.treeView1.SelectedNode = parentForm.treeView1.Nodes[0];
|
||||
parentForm.TreeView.SelectedNode = parentForm.TreeView.Nodes[0];
|
||||
}
|
||||
|
||||
findNextNew = false;
|
||||
|
||||
bool rv = parentForm.treeView1.SNode.FindTextNode(textBox1.Text?.Trim());
|
||||
bool rv = parentForm.TreeView.SNode.FindTextNode(textBox1.Text?.Trim());
|
||||
if (!rv)
|
||||
{
|
||||
findNextNew = true;
|
||||
|
@ -7,11 +7,12 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using AppMode = bzit.bomg.MainForm.AppMode;
|
||||
using Form = System.Windows.Forms.Form;
|
||||
using Resources = bzit.bomg.Properties.Resources;
|
||||
|
||||
namespace bzit.bomg
|
||||
{
|
||||
@ -43,11 +44,13 @@ namespace bzit.bomg
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
protected async override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
|
||||
loadFile(sessionFilename);
|
||||
await loadFile(sessionFilename);
|
||||
|
||||
this.Close();
|
||||
}
|
||||
|
||||
protected bool IsBusy
|
||||
@ -63,76 +66,6 @@ namespace bzit.bomg
|
||||
}
|
||||
}
|
||||
|
||||
private async void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.IsBusy)
|
||||
{
|
||||
//requestCancel = true;
|
||||
//ThreadControl.SetText(button1, "&Cancelling...");
|
||||
return;
|
||||
}
|
||||
|
||||
this.IsBusy = true;
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
//ThreadControl.SetText(button1, "&Updating...");
|
||||
|
||||
//if (requestCancel)
|
||||
//{
|
||||
// this.IsBusy = false;
|
||||
|
||||
// ThreadControl.SetText(button1, "&Update");
|
||||
|
||||
// requestCancel = false;
|
||||
// return;
|
||||
//}
|
||||
|
||||
//List<TreeNode> nodeList = parentForm.treeView1.GetBookmarkNodeList();
|
||||
|
||||
//ThreadControl.SetValue(progressBar1, 0, nodeList.Count);
|
||||
|
||||
//for (int i = 0; i < nodeList.Count; i++)
|
||||
//{
|
||||
// if (requestCancel)
|
||||
// {
|
||||
// this.IsBusy = false;
|
||||
|
||||
// ThreadControl.SetText(button1, "&Update");
|
||||
|
||||
// requestCancel = false;
|
||||
// return;
|
||||
// }
|
||||
|
||||
// ThreadControl.SetValue(progressBar1, (i + 1));
|
||||
|
||||
// BookmarkItemViewModel viewModel = (BookmarkItemViewModel)nodeList[i].Tag;
|
||||
// BookmarkItemModel model = viewModel.ToModel();
|
||||
// bool rv = model.UpdateFavicon();
|
||||
// if (rv)
|
||||
// {
|
||||
// if (parentForm.treeView1.InvokeRequired)
|
||||
// {
|
||||
// parentForm.treeView1.Invoke(new MethodInvoker(() =>
|
||||
// {
|
||||
// parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel());
|
||||
// }));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel());
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
this.IsBusy = false;
|
||||
|
||||
//ThreadControl.SetText(button1, "&Update");
|
||||
|
||||
//requestCancel = false;
|
||||
});
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.IsBusy)
|
||||
@ -143,16 +76,19 @@ namespace bzit.bomg
|
||||
this.Close();
|
||||
}
|
||||
|
||||
|
||||
protected void loadFile(string filename)
|
||||
protected async Task loadFile(string filename)
|
||||
{
|
||||
parentForm.ClearSession();
|
||||
parentForm.TreeView.Clear();
|
||||
parentForm.TreeView.HasChanged = false;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ThreadControl.SetValue(progressBar1, 0, 0);
|
||||
|
||||
string password = string.Empty;
|
||||
|
||||
if (RyzStudio.IO.SharpZipLib.IsZipEncrypted(filename))
|
||||
@ -173,6 +109,11 @@ namespace bzit.bomg
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(password))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.IsBusy = true;
|
||||
@ -180,11 +121,11 @@ namespace bzit.bomg
|
||||
string ext = Path.GetExtension(filename).Trim('.').ToLower();
|
||||
if (ext.Equals("jsnx"))
|
||||
{
|
||||
loadJSNXBookmarkFile(filename, password);
|
||||
await loadJSNXBookmarkFile(filename, password);
|
||||
}
|
||||
else if (ext.Equals("ryz"))
|
||||
{
|
||||
//##loadFileType = LoadFileType.Ryz;
|
||||
await loadRYZBookmarkFile(filename, password);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -193,9 +134,14 @@ namespace bzit.bomg
|
||||
|
||||
this.IsBusy = false;
|
||||
parentForm.AllowSave = false;
|
||||
parentForm.TreeView.HasChanged = false;
|
||||
|
||||
if (parentForm.TreeView.Nodes.Count > 0) parentForm.TreeView.Nodes[0].Expand();
|
||||
}
|
||||
|
||||
protected void loadJSNXBookmarkFile(string filename, string password)
|
||||
protected async Task loadJSNXBookmarkFile(string filename, string password)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
int size = 2048;
|
||||
byte[] buffer = new byte[size];
|
||||
@ -254,160 +200,161 @@ namespace bzit.bomg
|
||||
readStream.Dispose();
|
||||
readStream = null;
|
||||
|
||||
parentForm.SetBookmarkItem(rs);
|
||||
// load bookmark items
|
||||
ThreadControl.SetValue(progressBar1, 0, rs.Count);
|
||||
|
||||
for (int i=0; i<rs.Count; i++)
|
||||
{
|
||||
ThreadControl.SetValue(progressBar1, (i + 1));
|
||||
|
||||
parentForm.TreeView.AddItem(rs[i]);
|
||||
}
|
||||
|
||||
parentForm.ApplicationMode = AppMode.Open;
|
||||
|
||||
//// RyzStudio.Windows.Forms.ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name);
|
||||
});
|
||||
}
|
||||
|
||||
//protected void loadBookmarkFile_ForRYZ(string filename, string password = "")
|
||||
//{
|
||||
// int size = 2048;
|
||||
// byte[] buffer = new byte[size];
|
||||
// int bufferSize = 0;
|
||||
protected async Task loadRYZBookmarkFile(string filename, string password)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
int size = 2048;
|
||||
byte[] buffer = new byte[size];
|
||||
int bufferSize = 0;
|
||||
|
||||
// List<BookmarkItemViewModel> rs = new List<BookmarkItemViewModel>();
|
||||
List<BookmarkItemViewModel> rs = new List<BookmarkItemViewModel>();
|
||||
|
||||
// ZipEntry readEntry = null;
|
||||
// ZipInputStream readStream = new ZipInputStream(File.OpenRead(filename));
|
||||
// readStream.Password = password;
|
||||
ZipEntry readEntry = null;
|
||||
ZipInputStream readStream = new ZipInputStream(File.OpenRead(filename));
|
||||
readStream.Password = password;
|
||||
|
||||
// while (true)
|
||||
// {
|
||||
// readEntry = readStream.GetNextEntry();
|
||||
// if (readEntry == null)
|
||||
// {
|
||||
while (true)
|
||||
{
|
||||
readEntry = readStream.GetNextEntry();
|
||||
if (readEntry == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(readEntry.Name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!readEntry.IsFile)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!readEntry.Name.Equals("bookmarks.xml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
buffer = new byte[size];
|
||||
bufferSize = 0;
|
||||
|
||||
do
|
||||
{
|
||||
bufferSize = readStream.Read(buffer, 0, buffer.Length);
|
||||
ms.Write(buffer, 0, bufferSize);
|
||||
}
|
||||
while (bufferSize > 0);
|
||||
|
||||
ms.Position = 0;
|
||||
|
||||
// read stream
|
||||
StreamReader sr = new StreamReader(ms);
|
||||
|
||||
// load xml
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.LoadXml(sr.ReadToEnd());
|
||||
|
||||
// parse
|
||||
XmlNode xnl = xmlDocument.SelectSingleNode("bomg/b/g");
|
||||
if (xnl == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
BookmarkItemViewModel viewModel = new BookmarkItemViewModel();
|
||||
|
||||
foreach (XmlNode xn2 in xn.ChildNodes)
|
||||
{
|
||||
switch (xn2.LocalName)
|
||||
{
|
||||
case "name":
|
||||
viewModel.SiteName = xn2.InnerText?.Trim();
|
||||
break;
|
||||
case "address":
|
||||
viewModel.SiteAddress = xn2.InnerText?.Trim();
|
||||
break;
|
||||
case "description":
|
||||
viewModel.SiteDescription = xn2.InnerText?.Trim();
|
||||
break;
|
||||
//case "created":
|
||||
// bi.Created = xn2.InnerText?.Trim();
|
||||
// break;
|
||||
// }
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(readEntry.Name))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// fix fullpath and name
|
||||
if (viewModel.SiteName.Contains("|"))
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("\\");
|
||||
sb.Append(System.Web.HttpUtility.UrlEncode(rootName));
|
||||
sb.Append("\\");
|
||||
|
||||
// if (!readEntry.IsFile)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
string[] pathParts = viewModel.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("\\");
|
||||
}
|
||||
|
||||
// if (!readEntry.Name.Equals("bookmarks.xml"))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
viewModel.SiteName = System.Web.HttpUtility.UrlDecode(pathParts[(pathParts.Length - 1)] ?? string.Empty);
|
||||
viewModel.TreeviewPath = sb.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
viewModel.SiteName = System.Web.HttpUtility.UrlDecode(viewModel.SiteName);
|
||||
viewModel.TreeviewPath = string.Format("\\{0}\\", System.Web.HttpUtility.UrlEncode(rootName));
|
||||
}
|
||||
|
||||
// MemoryStream ms = new MemoryStream();
|
||||
// buffer = new byte[size];
|
||||
// bufferSize = 0;
|
||||
rs.Add(viewModel);
|
||||
}
|
||||
|
||||
// do
|
||||
// {
|
||||
// bufferSize = readStream.Read(buffer, 0, buffer.Length);
|
||||
// ms.Write(buffer, 0, bufferSize);
|
||||
// }
|
||||
// while (bufferSize > 0);
|
||||
break;
|
||||
}
|
||||
|
||||
// ms.Position = 0;
|
||||
|
||||
// // read stream
|
||||
// StreamReader sr = new StreamReader(ms);
|
||||
|
||||
// // load xml
|
||||
// XmlDocument xmlDocument = new XmlDocument();
|
||||
// xmlDocument.LoadXml(sr.ReadToEnd());
|
||||
|
||||
// // parse
|
||||
// XmlNode xnl = xmlDocument.SelectSingleNode("bomg/b/g");
|
||||
// if (xnl == null)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// 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)
|
||||
// {
|
||||
// BookmarkItemViewModel viewModel = new BookmarkItemViewModel();
|
||||
|
||||
// foreach (XmlNode xn2 in xn.ChildNodes)
|
||||
// {
|
||||
// switch (xn2.LocalName)
|
||||
// {
|
||||
// case "name":
|
||||
// viewModel.SiteName = xn2.InnerText?.Trim();
|
||||
// break;
|
||||
// case "address":
|
||||
// viewModel.SiteAddress = xn2.InnerText?.Trim();
|
||||
// break;
|
||||
// case "description":
|
||||
// viewModel.SiteDescription = xn2.InnerText?.Trim();
|
||||
// break;
|
||||
// //case "created":
|
||||
// // bi.Created = xn2.InnerText?.Trim();
|
||||
// // break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // fix fullpath and name
|
||||
// if (viewModel.SiteName.Contains("|"))
|
||||
// {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.Append("\\");
|
||||
// sb.Append(System.Web.HttpUtility.UrlEncode(rootName));
|
||||
// sb.Append("\\");
|
||||
|
||||
// string[] pathParts = viewModel.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("\\");
|
||||
// }
|
||||
|
||||
// viewModel.SiteName = System.Web.HttpUtility.UrlDecode(pathParts[(pathParts.Length - 1)] ?? string.Empty);
|
||||
// viewModel.TreeviewPath = sb.ToString();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// viewModel.SiteName = System.Web.HttpUtility.UrlDecode(viewModel.SiteName);
|
||||
// viewModel.TreeviewPath = string.Format("\\{0}\\", System.Web.HttpUtility.UrlEncode(rootName));
|
||||
// }
|
||||
|
||||
// rs.Add(viewModel);
|
||||
// }
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
// readStream.Flush();
|
||||
// readStream.Close();
|
||||
// readStream.Dispose();
|
||||
// readStream = null;
|
||||
|
||||
// treeView1.AddItem(rs);
|
||||
|
||||
// sessionFilename = sessionPassword = null;
|
||||
// usePassword = !string.IsNullOrWhiteSpace(password);
|
||||
|
||||
// if (this.InvokeRequired)
|
||||
// {
|
||||
// this.Invoke(new MethodInvoker(() =>
|
||||
// {
|
||||
// this.ApplicationMode = AppMode.New;
|
||||
// }));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.ApplicationMode = AppMode.New;
|
||||
// }
|
||||
|
||||
// RyzStudio.Windows.Forms.ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name);
|
||||
//}
|
||||
readStream.Flush();
|
||||
readStream.Close();
|
||||
readStream.Dispose();
|
||||
readStream = null;
|
||||
|
||||
// load bookmark items
|
||||
ThreadControl.SetValue(progressBar1, 0, rs.Count);
|
||||
|
||||
for (int i = 0; i < rs.Count; i++)
|
||||
{
|
||||
ThreadControl.SetValue(progressBar1, (i + 1));
|
||||
|
||||
parentForm.TreeView.AddItem(rs[i]);
|
||||
}
|
||||
|
||||
parentForm.ClearSession();
|
||||
parentForm.ApplicationMode = AppMode.Open;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
4
MainForm.Designer.cs
generated
4
MainForm.Designer.cs
generated
@ -369,7 +369,7 @@ namespace bzit.bomg
|
||||
// optionsToolMenuItem
|
||||
//
|
||||
this.optionsToolMenuItem.Name = "optionsToolMenuItem";
|
||||
this.optionsToolMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.optionsToolMenuItem.Size = new System.Drawing.Size(161, 22);
|
||||
this.optionsToolMenuItem.Text = "&Update Favicons";
|
||||
this.optionsToolMenuItem.Click += new System.EventHandler(this.toolsOptionsMenuItem_Click);
|
||||
//
|
||||
@ -699,7 +699,6 @@ namespace bzit.bomg
|
||||
private System.Windows.Forms.ToolStripMenuItem closeFileMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
public BookmarkTreeView treeView1;
|
||||
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4;
|
||||
private System.Windows.Forms.OpenFileDialog openFileDialog;
|
||||
private System.Windows.Forms.ContextMenuStrip folderTreeNodeMenu;
|
||||
@ -733,6 +732,7 @@ namespace bzit.bomg
|
||||
private System.Windows.Forms.ToolStripMenuItem findEditMenuItem;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
|
||||
private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem1;
|
||||
private BookmarkTreeView treeView1;
|
||||
}
|
||||
}
|
||||
|
||||
|
355
MainForm.cs
355
MainForm.cs
@ -198,6 +198,16 @@ namespace bzit.bomg
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
public bool AllowSave
|
||||
{
|
||||
get => (saveMenuBarItem.Enabled || saveFileMenuItem.Enabled);
|
||||
set
|
||||
{
|
||||
ThreadControl.SetEnable(toolStrip1, saveMenuBarItem, value);
|
||||
ThreadControl.SetEnable(toolStrip1, saveFileMenuItem, value);
|
||||
}
|
||||
}
|
||||
|
||||
public AppMode ApplicationMode
|
||||
{
|
||||
get => appMode;
|
||||
@ -245,16 +255,6 @@ namespace bzit.bomg
|
||||
}
|
||||
}
|
||||
|
||||
public bool AllowSave
|
||||
{
|
||||
get => (saveMenuBarItem.Enabled || saveFileMenuItem.Enabled);
|
||||
set
|
||||
{
|
||||
ThreadControl.SetEnable(toolStrip1, saveMenuBarItem, value);
|
||||
ThreadControl.SetEnable(toolStrip1, saveFileMenuItem, value);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsBusy
|
||||
{
|
||||
get => isBusy;
|
||||
@ -264,6 +264,8 @@ namespace bzit.bomg
|
||||
}
|
||||
}
|
||||
|
||||
public RyzStudio.Windows.Forms.BookmarkTreeView TreeView { get => treeView1; set => treeView1 = value; }
|
||||
|
||||
#region toolbar
|
||||
|
||||
private void fileNewMenuItem_Click(object sender, EventArgs e)
|
||||
@ -663,285 +665,6 @@ namespace bzit.bomg
|
||||
|
||||
#endregion
|
||||
|
||||
//protected void loadBookmarkFile(string filename, int filterIndex)
|
||||
//{
|
||||
// sessionFilename = sessionPassword = null;
|
||||
// usePassword = false;
|
||||
|
||||
// //sessionFilename = filename;
|
||||
// //sessionPassword = null;
|
||||
// //usePassword = false;
|
||||
|
||||
// if (RyzStudio.IO.SharpZipLib.IsZipEncrypted(filename))
|
||||
// {
|
||||
// TextBoxForm passwordForm = new TextBoxForm("Password", "Password", true);
|
||||
// string password = string.Empty;
|
||||
|
||||
// while (true)
|
||||
// {
|
||||
// password = passwordForm.ShowDialog();
|
||||
// if (string.IsNullOrWhiteSpace(password))
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if (RyzStudio.IO.SharpZipLib.TestZipEncrypted(filename, password))
|
||||
// {
|
||||
// sessionFilename = filename;
|
||||
// sessionPassword = password;
|
||||
// usePassword = true;
|
||||
|
||||
// loadFileType = LoadFileType.Jsnx;
|
||||
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// switch (filterIndex)
|
||||
// {
|
||||
// case 1:
|
||||
// loadFileType = LoadFileType.Jsnx;
|
||||
// break;
|
||||
// case 2:
|
||||
// loadFileType = LoadFileType.Ryz;
|
||||
// break;
|
||||
// default:
|
||||
// loadFileType = LoadFileType.None;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(sessionFilename))
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// this.IsBusy = true;
|
||||
|
||||
// loadFileThread.RunWorkerAsync();
|
||||
//}
|
||||
|
||||
//protected void loadBookmarkFile_ForJSNX(string filename, string password = "")
|
||||
//{
|
||||
// int size = 2048;
|
||||
// byte[] buffer = new byte[size];
|
||||
// int bufferSize = 0;
|
||||
|
||||
// List<BookmarkItemViewModel> rs = null;
|
||||
|
||||
// ZipEntry readEntry = null;
|
||||
// ZipInputStream readStream = new ZipInputStream(File.OpenRead(filename));
|
||||
// readStream.Password = password;
|
||||
|
||||
// while (true)
|
||||
// {
|
||||
// readEntry = readStream.GetNextEntry();
|
||||
// if (readEntry == null)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(readEntry.Name))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (!readEntry.IsFile)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (!readEntry.Name.Equals("bookmarks.json"))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// MemoryStream ms = new MemoryStream();
|
||||
// buffer = new byte[size];
|
||||
// bufferSize = 0;
|
||||
|
||||
// do
|
||||
// {
|
||||
// bufferSize = readStream.Read(buffer, 0, buffer.Length);
|
||||
// ms.Write(buffer, 0, bufferSize);
|
||||
// }
|
||||
// while (bufferSize > 0);
|
||||
|
||||
// ms.Position = 0;
|
||||
|
||||
// StreamReader sr = new StreamReader(ms);
|
||||
// rs = JsonConvert.DeserializeObject<List<BookmarkItemViewModel>>(sr.ReadToEnd());
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
// readStream.Flush();
|
||||
// readStream.Close();
|
||||
// readStream.Dispose();
|
||||
// readStream = null;
|
||||
|
||||
// treeView1.AddItem(rs);
|
||||
|
||||
// if (this.InvokeRequired)
|
||||
// {
|
||||
// this.Invoke(new MethodInvoker(() =>
|
||||
// {
|
||||
// this.ApplicationMode = AppMode.Open;
|
||||
// }));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.ApplicationMode = AppMode.Open;
|
||||
// }
|
||||
|
||||
// RyzStudio.Windows.Forms.ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name);
|
||||
//}
|
||||
|
||||
//protected void loadBookmarkFile_ForRYZ(string filename, string password = "")
|
||||
//{
|
||||
// int size = 2048;
|
||||
// byte[] buffer = new byte[size];
|
||||
// int bufferSize = 0;
|
||||
|
||||
// List<BookmarkItemViewModel> rs = new List<BookmarkItemViewModel>();
|
||||
|
||||
// ZipEntry readEntry = null;
|
||||
// ZipInputStream readStream = new ZipInputStream(File.OpenRead(filename));
|
||||
// readStream.Password = password;
|
||||
|
||||
// while (true)
|
||||
// {
|
||||
// readEntry = readStream.GetNextEntry();
|
||||
// if (readEntry == null)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if (string.IsNullOrWhiteSpace(readEntry.Name))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (!readEntry.IsFile)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// if (!readEntry.Name.Equals("bookmarks.xml"))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
// MemoryStream ms = new MemoryStream();
|
||||
// buffer = new byte[size];
|
||||
// bufferSize = 0;
|
||||
|
||||
// do
|
||||
// {
|
||||
// bufferSize = readStream.Read(buffer, 0, buffer.Length);
|
||||
// ms.Write(buffer, 0, bufferSize);
|
||||
// }
|
||||
// while (bufferSize > 0);
|
||||
|
||||
// ms.Position = 0;
|
||||
|
||||
// // read stream
|
||||
// StreamReader sr = new StreamReader(ms);
|
||||
|
||||
// // load xml
|
||||
// XmlDocument xmlDocument = new XmlDocument();
|
||||
// xmlDocument.LoadXml(sr.ReadToEnd());
|
||||
|
||||
// // parse
|
||||
// XmlNode xnl = xmlDocument.SelectSingleNode("bomg/b/g");
|
||||
// if (xnl == null)
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
|
||||
// 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)
|
||||
// {
|
||||
// BookmarkItemViewModel viewModel = new BookmarkItemViewModel();
|
||||
|
||||
// foreach (XmlNode xn2 in xn.ChildNodes)
|
||||
// {
|
||||
// switch (xn2.LocalName)
|
||||
// {
|
||||
// case "name":
|
||||
// viewModel.SiteName = xn2.InnerText?.Trim();
|
||||
// break;
|
||||
// case "address":
|
||||
// viewModel.SiteAddress = xn2.InnerText?.Trim();
|
||||
// break;
|
||||
// case "description":
|
||||
// viewModel.SiteDescription = xn2.InnerText?.Trim();
|
||||
// break;
|
||||
// //case "created":
|
||||
// // bi.Created = xn2.InnerText?.Trim();
|
||||
// // break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// // fix fullpath and name
|
||||
// if (viewModel.SiteName.Contains("|"))
|
||||
// {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// sb.Append("\\");
|
||||
// sb.Append(System.Web.HttpUtility.UrlEncode(rootName));
|
||||
// sb.Append("\\");
|
||||
|
||||
// string[] pathParts = viewModel.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("\\");
|
||||
// }
|
||||
|
||||
// viewModel.SiteName = System.Web.HttpUtility.UrlDecode(pathParts[(pathParts.Length - 1)] ?? string.Empty);
|
||||
// viewModel.TreeviewPath = sb.ToString();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// viewModel.SiteName = System.Web.HttpUtility.UrlDecode(viewModel.SiteName);
|
||||
// viewModel.TreeviewPath = string.Format("\\{0}\\", System.Web.HttpUtility.UrlEncode(rootName));
|
||||
// }
|
||||
|
||||
// rs.Add(viewModel);
|
||||
// }
|
||||
|
||||
// break;
|
||||
// }
|
||||
|
||||
// readStream.Flush();
|
||||
// readStream.Close();
|
||||
// readStream.Dispose();
|
||||
// readStream = null;
|
||||
|
||||
// treeView1.AddItem(rs);
|
||||
|
||||
// sessionFilename = sessionPassword = null;
|
||||
// usePassword = !string.IsNullOrWhiteSpace(password);
|
||||
|
||||
// if (this.InvokeRequired)
|
||||
// {
|
||||
// this.Invoke(new MethodInvoker(() =>
|
||||
// {
|
||||
// this.ApplicationMode = AppMode.New;
|
||||
// }));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// this.ApplicationMode = AppMode.New;
|
||||
// }
|
||||
|
||||
// RyzStudio.Windows.Forms.ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(filename) + " - " + Resources.app_name);
|
||||
//}
|
||||
|
||||
protected void openBookmark(TreeNode node)
|
||||
{
|
||||
if (treeView1.GetNodeType(node) != RyzStudio.Windows.Forms.BookmarkTreeView.NodeType.Page)
|
||||
@ -1079,6 +802,20 @@ namespace bzit.bomg
|
||||
|
||||
protected void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) => openBookmark(e.Node);
|
||||
|
||||
protected void treeView1_OnNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() => {
|
||||
this.AllowSave = treeView1.HasChanged;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AllowSave = treeView1.HasChanged;
|
||||
}
|
||||
}
|
||||
|
||||
protected void treeView1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
|
||||
{
|
||||
TreeNode tn = treeView1.SelectedNode;
|
||||
@ -1186,21 +923,6 @@ namespace bzit.bomg
|
||||
|
||||
#endregion
|
||||
|
||||
protected void treeView1_OnNodeChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
this.Invoke(new MethodInvoker(() => {
|
||||
this.AllowSave = treeView1.HasChanged;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.AllowSave = treeView1.HasChanged;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ClearSession()
|
||||
{
|
||||
sessionFilename = sessionPassword = null;
|
||||
@ -1230,30 +952,5 @@ namespace bzit.bomg
|
||||
ThreadControl.SetText(this, Path.GetFileNameWithoutExtension(sessionFilename) + " - " + Resources.app_name);
|
||||
}
|
||||
|
||||
public void SetBookmarkItem(List<BookmarkItemViewModel> itmes)
|
||||
{
|
||||
treeView1.AddItem(itmes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//private void loadFileThread_DoWork(object sender, DoWorkEventArgs e)
|
||||
//{
|
||||
// if (loadFileType == LoadFileType.Jsnx)
|
||||
// {
|
||||
// loadBookmarkFile_ForJSNX(sessionFilename, sessionPassword ?? string.Empty);
|
||||
// }
|
||||
// else if (loadFileType == LoadFileType.Ryz)
|
||||
// {
|
||||
// loadBookmarkFile_ForRYZ(sessionFilename, sessionPassword ?? string.Empty);
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void loadFileThread_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
|
||||
//{
|
||||
// this.IsBusy = false;
|
||||
// saveMenuBarItem.Enabled = saveFileMenuItem.Enabled = false;
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.3.0.025")]
|
||||
[assembly: AssemblyVersion("0.3.0.030")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||
|
2
Properties/Resources.Designer.cs
generated
2
Properties/Resources.Designer.cs
generated
@ -89,7 +89,7 @@ namespace bzit.bomg.Properties {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to 0.3.0.025 beta.
|
||||
/// Looks up a localized string similar to 0.3.0.030 beta.
|
||||
/// </summary>
|
||||
internal static string app_version {
|
||||
get {
|
||||
|
@ -128,7 +128,7 @@
|
||||
<value>Bookmark Manager</value>
|
||||
</data>
|
||||
<data name="app_version" xml:space="preserve">
|
||||
<value>0.3.0.025 beta</value>
|
||||
<value>0.3.0.030 beta</value>
|
||||
</data>
|
||||
<data name="arrow_down_circle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\2\arrow-down-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
@ -72,7 +72,7 @@ namespace bzit.bomg
|
||||
return;
|
||||
}
|
||||
|
||||
List<TreeNode> nodeList = parentForm.treeView1.GetBookmarkNodeList();
|
||||
List<TreeNode> nodeList = parentForm.TreeView.GetBookmarkNodeList();
|
||||
|
||||
ThreadControl.SetValue(progressBar1, 0, nodeList.Count);
|
||||
|
||||
@ -95,16 +95,16 @@ namespace bzit.bomg
|
||||
bool rv = model.UpdateFavicon();
|
||||
if (rv)
|
||||
{
|
||||
if (parentForm.treeView1.InvokeRequired)
|
||||
if (parentForm.TreeView.InvokeRequired)
|
||||
{
|
||||
parentForm.treeView1.Invoke(new MethodInvoker(() =>
|
||||
parentForm.TreeView.Invoke(new MethodInvoker(() =>
|
||||
{
|
||||
parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel());
|
||||
parentForm.TreeView.UpdateItem(nodeList[i], model.ToViewModel());
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
parentForm.treeView1.UpdateItem(nodeList[i], model.ToViewModel());
|
||||
parentForm.TreeView.UpdateItem(nodeList[i], model.ToViewModel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user