2017-07-30 11:59:34 +00:00
|
|
|
using System.Xml;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
namespace bzit.bomg
|
|
|
|
{
|
|
|
|
public class SessionFileFormat : RyzStudio.IO.SessionFileFormatBase
|
|
|
|
{
|
|
|
|
private MainForm parentForm = null;
|
|
|
|
|
|
|
|
public SessionFileFormat(MainForm parent_form)
|
|
|
|
{
|
|
|
|
base.CONST_PRODUCT = "bomg";
|
|
|
|
base.CONST_STREAM_FILE_NAME = "bookmarks.xml";
|
|
|
|
base.CONST_KEYPASS = "";
|
|
|
|
base.enableErrorReporting = true;
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
parentForm = parent_form;
|
|
|
|
}
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
protected override void loadFromXmlDocument(ref XmlDocument xml_doc)
|
|
|
|
{
|
|
|
|
XmlNodeList xnl = xml_doc.SelectNodes("bomg/b/g");
|
|
|
|
if (xnl.Count <= 0)
|
|
|
|
{
|
|
|
|
MessageBox.Show("No bookmarks found.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
return;
|
|
|
|
}
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
parentForm.treeView1.Clear();
|
2019-04-16 20:57:31 +00:00
|
|
|
TreeNode tn = parentForm.treeView1.Nodes.Add("", xnl.Item(0).Attributes["name"].InnerText, 0, 0);
|
2017-07-30 11:59:34 +00:00
|
|
|
foreach (XmlNode xn in xnl.Item(0))
|
|
|
|
{
|
|
|
|
BookmarkItem bi = new BookmarkItem();
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
foreach (XmlNode xn2 in xn.ChildNodes)
|
|
|
|
{
|
|
|
|
switch (xn2.LocalName)
|
|
|
|
{
|
|
|
|
case "name":
|
|
|
|
bi.Fullpath = xn2.InnerText?.Trim();
|
|
|
|
break;
|
|
|
|
case "address":
|
2019-04-07 17:29:33 +00:00
|
|
|
bi.SiteAddress = xn2.InnerText?.Trim();
|
2017-07-30 11:59:34 +00:00
|
|
|
break;
|
|
|
|
case "description":
|
|
|
|
bi.Description = xn2.InnerText?.Trim();
|
|
|
|
break;
|
|
|
|
case "created":
|
|
|
|
bi.Created = xn2.InnerText?.Trim();
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2019-04-16 20:57:31 +00:00
|
|
|
|
|
|
|
//##parentForm.treeView1.AddBookmarkItem(bi.Fullpath, bi);
|
2017-07-30 11:59:34 +00:00
|
|
|
}
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2017-07-30 11:59:34 +00:00
|
|
|
tn.Expand();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void saveToXmlTextWriter(ref XmlTextWriter writer)
|
|
|
|
{
|
2019-04-20 16:05:55 +00:00
|
|
|
//if (parentForm.treeView1.Nodes.Count <= 0)
|
|
|
|
//{
|
|
|
|
// return;
|
|
|
|
//}
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2019-04-20 16:05:55 +00:00
|
|
|
//writer.Formatting = Formatting.Indented;
|
|
|
|
//writer.WriteStartDocument();
|
|
|
|
//writer.WriteStartElement(CONST_PRODUCT);
|
|
|
|
//writer.WriteStartElement("b");
|
|
|
|
//writer.WriteStartElement("g");
|
|
|
|
//writer.WriteAttributeString("name", parentForm.treeView1.Nodes[0].Text);
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2019-04-20 16:05:55 +00:00
|
|
|
//foreach (TreeNode tn in parentForm.treeView1.NodeList)
|
|
|
|
//{
|
|
|
|
// BookmarkItem bi = (BookmarkItem)tn.Tag;
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2019-04-20 16:05:55 +00:00
|
|
|
// writer.WriteStartElement("m");
|
|
|
|
// writer.WriteElementString("name", parentForm.treeView1.GetNodeFullPath(tn));
|
|
|
|
// writer.WriteElementString("address", bi.SiteAddress);
|
|
|
|
// writer.WriteElementString("description", bi.Description);
|
|
|
|
// writer.WriteElementString("created", bi.Created.ToString());
|
|
|
|
// writer.WriteEndElement();
|
|
|
|
//}
|
2019-04-16 20:57:31 +00:00
|
|
|
|
2019-04-20 16:05:55 +00:00
|
|
|
//writer.WriteEndElement();
|
|
|
|
//writer.WriteEndElement();
|
|
|
|
//writer.WriteEndElement();
|
|
|
|
//writer.WriteEndDocument();
|
2017-07-30 11:59:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|