Changed: improved source code parsing for title, description and favicon

This commit is contained in:
Ray 2019-04-07 18:29:33 +01:00
parent 6e951b6fa5
commit aecc5ac043
12 changed files with 558 additions and 394 deletions

View File

@ -64,7 +64,7 @@ namespace bzit.bomg
this.tbxAddress.MaxLength = 4096; this.tbxAddress.MaxLength = 4096;
this.tbxAddress.Name = "tbxAddress"; this.tbxAddress.Name = "tbxAddress";
this.tbxAddress.Size = new System.Drawing.Size(240, 22); this.tbxAddress.Size = new System.Drawing.Size(240, 22);
this.tbxAddress.TabIndex = 0; this.tbxAddress.TabIndex = 1;
this.tbxAddress.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox_PreviewKeyDown); this.tbxAddress.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox_PreviewKeyDown);
// //
// tbxName // tbxName
@ -76,7 +76,7 @@ namespace bzit.bomg
this.tbxName.MaxLength = 4096; this.tbxName.MaxLength = 4096;
this.tbxName.Name = "tbxName"; this.tbxName.Name = "tbxName";
this.tbxName.Size = new System.Drawing.Size(212, 22); this.tbxName.Size = new System.Drawing.Size(212, 22);
this.tbxName.TabIndex = 1; this.tbxName.TabIndex = 0;
this.tbxName.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox_PreviewKeyDown); this.tbxName.PreviewKeyDown += new System.Windows.Forms.PreviewKeyDownEventHandler(this.textBox_PreviewKeyDown);
// //
// label2 // label2
@ -157,7 +157,7 @@ namespace bzit.bomg
this.button1.Name = "button1"; this.button1.Name = "button1";
this.button1.Padding = new System.Windows.Forms.Padding(4); this.button1.Padding = new System.Windows.Forms.Padding(4);
this.button1.Size = new System.Drawing.Size(32, 32); this.button1.Size = new System.Drawing.Size(32, 32);
this.button1.TabIndex = 4; this.button1.TabIndex = 3;
this.button1.Value = ""; this.button1.Value = "";
this.button1.Click += new System.EventHandler(this.btnRetrievePage_Click); this.button1.Click += new System.EventHandler(this.btnRetrievePage_Click);
// //
@ -171,7 +171,7 @@ namespace bzit.bomg
this.btnSave.Name = "btnSave"; this.btnSave.Name = "btnSave";
this.btnSave.Padding = new System.Windows.Forms.Padding(4); this.btnSave.Padding = new System.Windows.Forms.Padding(4);
this.btnSave.Size = new System.Drawing.Size(96, 32); this.btnSave.Size = new System.Drawing.Size(96, 32);
this.btnSave.TabIndex = 3; this.btnSave.TabIndex = 4;
this.btnSave.Value = "&OK"; this.btnSave.Value = "&OK";
this.btnSave.Click += new System.EventHandler(this.btnSave_Click); this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
// //

View File

@ -36,7 +36,7 @@ namespace bzit.bomg
{ {
bookmarkItem = (BookmarkItem)parentNode.Tag; bookmarkItem = (BookmarkItem)parentNode.Tag;
tbxName.Text = bookmarkItem.GetName(); tbxName.Text = bookmarkItem.GetName();
tbxAddress.Text = bookmarkItem.Address; tbxAddress.Text = bookmarkItem.SiteAddress;
tbxDescription.Text = bookmarkItem.Description; tbxDescription.Text = bookmarkItem.Description;
if (parentNode.TreeView.ImageList != null) if (parentNode.TreeView.ImageList != null)
@ -125,12 +125,12 @@ namespace bzit.bomg
} }
bookmarkItem.ChangeName(tbxName.Text.Trim()); bookmarkItem.ChangeName(tbxName.Text.Trim());
bookmarkItem.Address = tbxAddress.Text.Trim(); bookmarkItem.SiteAddress = tbxAddress.Text.Trim();
bookmarkItem.Description = tbxDescription.Text.Trim(); bookmarkItem.Description = tbxDescription.Text.Trim();
parentNode.Text = tbxName.Text.Trim(); parentNode.Text = tbxName.Text.Trim();
//// parentNode.ImageIndex = parentNode.SelectedImageIndex = 3; //// parentNode.ImageIndex = parentNode.SelectedImageIndex = 3;
parentNode.ToolTipText = string.Concat(bookmarkItem.Address, Environment.NewLine, bookmarkItem.Description).Trim(); parentNode.ToolTipText = string.Concat(bookmarkItem.SiteAddress, Environment.NewLine, bookmarkItem.Description).Trim();
parentNode.Tag = bookmarkItem; parentNode.Tag = bookmarkItem;
BookmarkTreeView bookmarkTreeView = (BookmarkTreeView)parentNode.TreeView; BookmarkTreeView bookmarkTreeView = (BookmarkTreeView)parentNode.TreeView;
@ -144,13 +144,13 @@ namespace bzit.bomg
protected void bookmarkItem_OnRetrieveCompleted(BookmarkItem sender, bool hasError, string message) protected void bookmarkItem_OnRetrieveCompleted(BookmarkItem sender, bool hasError, string message)
{ {
if (string.IsNullOrEmpty(sender.TempName)) if (string.IsNullOrEmpty(sender.SiteName))
{ {
if (MessageBox.Show("The page could not be retrieved or the title is blank. Do you want to keep your original title?", "Keep original?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) if (MessageBox.Show("The page could not be retrieved or the title is blank. Do you want to keep your original title?", "Keep original?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
{ {
bookmarkItem.TempName = sender.TempName; bookmarkItem.SiteName = sender.SiteName;
tbxName.Text = bookmarkItem.TempName; tbxName.Text = bookmarkItem.SiteName;
// don't replace with blank // don't replace with blank
if (!string.IsNullOrEmpty(sender.Description)) if (!string.IsNullOrEmpty(sender.Description))
@ -161,9 +161,9 @@ namespace bzit.bomg
} }
else else
{ {
bookmarkItem.TempName = sender.TempName; bookmarkItem.SiteName = sender.SiteName;
tbxName.Text = bookmarkItem.TempName; tbxName.Text = bookmarkItem.SiteName;
// don't replace with blank // don't replace with blank
if (!string.IsNullOrEmpty(sender.Description)) if (!string.IsNullOrEmpty(sender.Description))

View File

@ -1,9 +1,11 @@
using System; using HtmlAgilityPack;
using System;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Windows.Forms; using System.Windows.Forms;
using HtmlDocument = HtmlAgilityPack.HtmlDocument;
namespace bzit.bomg namespace bzit.bomg
{ {
@ -11,9 +13,22 @@ namespace bzit.bomg
{ {
public delegate void RetrieveCompleted(BookmarkItem sender, bool hasError, string message); public delegate void RetrieveCompleted(BookmarkItem sender, bool hasError, string message);
public RetrieveCompleted OnRetrieveCompleted { get; set; } = null;
public TreeNode TreeViewNode { get; protected set; }
public byte[] IconData { get; set; } = null;
public string SiteName { get; set; } = null;
public string SiteAddress { get; set; }
public string Description { get; set; }
public string IconAddress { get; protected set; }
public string Fullpath { get; set; }
public string Created { get; set; }
protected const char pathSeparator = '|'; protected const char pathSeparator = '|';
protected TreeNode treeNode = null; //protected TreeNode treeNode = null;
protected BackgroundWorker mainThread = null; protected BackgroundWorker mainThread = null;
protected bool hasRetrieveError = false; protected bool hasRetrieveError = false;
@ -28,7 +43,7 @@ namespace bzit.bomg
{ {
string rv = ""; string rv = "";
rv += "Name=" + this.Fullpath + Environment.NewLine; rv += "Name=" + this.Fullpath + Environment.NewLine;
rv += "Address=" + this.Address + Environment.NewLine; rv += "Address=" + this.SiteAddress + Environment.NewLine;
rv += "Description=" + this.Description + Environment.NewLine; rv += "Description=" + this.Description + Environment.NewLine;
rv += "Created=" + this.Created?.Trim(); rv += "Created=" + this.Created?.Trim();
@ -37,18 +52,18 @@ namespace bzit.bomg
#region public properties #region public properties
public TreeNode TreeViewNode
{
get
{
return this.treeNode;
}
set //{
{ // get
this.treeNode = value; // {
} // return this.treeNode;
} // }
// set
// {
// this.treeNode = value;
// }
//}
public Bitmap Icon public Bitmap Icon
{ {
@ -71,20 +86,7 @@ namespace bzit.bomg
} }
} }
[DefaultValue(null)]
public byte[] IconData { get; set; }
public string Created { get; set; }
public string TempName { get; set; }
public string Fullpath { get; set; }
public string IconAddress { get; set; }
public string Address { get; set; }
public string Description { get; set; }
#endregion #endregion
@ -93,7 +95,7 @@ namespace bzit.bomg
public void Clear() public void Clear()
{ {
this.Fullpath = string.Empty; this.Fullpath = string.Empty;
this.Address = string.Empty; this.SiteAddress = string.Empty;
this.Description = string.Empty; this.Description = string.Empty;
this.Created = string.Empty; this.Created = string.Empty;
@ -110,17 +112,17 @@ namespace bzit.bomg
{ {
if (this.Fullpath.Contains(pathSeparator.ToString())) if (this.Fullpath.Contains(pathSeparator.ToString()))
{ {
return PathDecode(this.Fullpath.Substring(this.Fullpath.LastIndexOf(pathSeparator) + 1)).Trim(); return decodePath(this.Fullpath.Substring(this.Fullpath.LastIndexOf(pathSeparator) + 1)).Trim();
} }
return PathDecode(this.Fullpath).Trim(); return decodePath(this.Fullpath).Trim();
} }
public void ChangeName(string newName) public void ChangeName(string newName)
{ {
string prefix = (this.Fullpath.Contains(pathSeparator.ToString()) ? this.Fullpath.Substring(0, this.Fullpath.IndexOf(pathSeparator)).Trim() : string.Empty); string prefix = (this.Fullpath.Contains(pathSeparator.ToString()) ? this.Fullpath.Substring(0, this.Fullpath.IndexOf(pathSeparator)).Trim() : string.Empty);
this.Fullpath = string.Concat(prefix, pathSeparator, PathEncode(newName.Trim())); this.Fullpath = string.Concat(prefix, pathSeparator, encodePath(newName.Trim()));
} }
public void GetFaviconAddress() public void GetFaviconAddress()
@ -137,7 +139,7 @@ namespace bzit.bomg
try try
{ {
sourceCode = webClient.DownloadString(this.Address); sourceCode = webClient.DownloadString(this.SiteAddress);
} }
catch (Exception exc) catch (Exception exc)
{ {
@ -149,51 +151,19 @@ namespace bzit.bomg
HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument();
document.LoadHtml(sourceCode); document.LoadHtml(sourceCode);
// parse icon // favicon
HtmlAgilityPack.HtmlNodeCollection hnc = document.DocumentNode.SelectNodes("//link"); this.IconAddress = parseSiteIcon(document);
if (hnc != null) if (!string.IsNullOrWhiteSpace(this.IconAddress))
{ {
foreach (HtmlAgilityPack.HtmlNode node in hnc) Uri iconAddressURI;
{ bool rv = Uri.TryCreate(new Uri(this.SiteAddress), this.IconAddress, out iconAddressURI);
if (node.Attributes["rel"] == null)
{
continue;
}
string nodeAttr = node.Attributes["rel"].Value.Trim();
if (nodeAttr.ToLower().Contains("icon"))
{
if (!string.IsNullOrEmpty(this.IconAddress))
{
continue;
}
if (node.Attributes["href"] != null)
{
Uri iconPath;
bool rv = Uri.TryCreate(new Uri(this.Address), WebUtility.HtmlDecode(node.Attributes["href"].Value).Trim(), out iconPath);
if (rv) if (rv)
{ {
this.IconAddress = iconPath.ToString(); this.IconAddress = iconAddressURI.ToString();
}
break;
}
}
} }
} }
// default favicon // load favicon image
if (string.IsNullOrEmpty(this.IconAddress))
{
Uri iconPath;
if (Uri.TryCreate(new Uri(this.Address), "/favicon.ico", out iconPath))
{
this.IconAddress = iconPath.ToString();
}
}
// load icon image
if (!string.IsNullOrEmpty(this.IconAddress)) if (!string.IsNullOrEmpty(this.IconAddress))
{ {
try try
@ -207,9 +177,72 @@ namespace bzit.bomg
} }
catch catch
{ {
// do nothing this.IconData = null;
this.IconAddress = null;
} }
} }
//// parse icon
//HtmlAgilityPack.HtmlNodeCollection hnc = document.DocumentNode.SelectNodes("//link");
// if (hnc != null)
// {
// foreach (HtmlAgilityPack.HtmlNode node in hnc)
// {
// if (node.Attributes["rel"] == null)
// {
// continue;
// }
// string nodeAttr = node.Attributes["rel"].Value.Trim();
// if (nodeAttr.ToLower().Contains("icon"))
// {
// if (!string.IsNullOrEmpty(this.IconAddress))
// {
// continue;
// }
// if (node.Attributes["href"] != null)
// {
// Uri iconPath;
// bool rv = Uri.TryCreate(new Uri(this.SiteAddress), WebUtility.HtmlDecode(node.Attributes["href"].Value).Trim(), out iconPath);
// if (rv)
// {
// this.IconAddress = iconPath.ToString();
// }
// break;
// }
// }
// }
// }
// // default favicon
// if (string.IsNullOrEmpty(this.IconAddress))
// {
// Uri iconPath;
// if (Uri.TryCreate(new Uri(this.SiteAddress), "/favicon.ico", out iconPath))
// {
// this.IconAddress = iconPath.ToString();
// }
// }
// // load icon image
// if (!string.IsNullOrEmpty(this.IconAddress))
// {
// try
// {
// this.IconData = webClient.DownloadData(this.IconAddress);
// if (!RyzStudio.IO.FileType.IsImage(this.IconData))
// {
// this.IconData = null;
// }
// }
// catch
// {
// // do nothing
// }
// }
} }
public void RetrieveAsync() public void RetrieveAsync()
@ -229,17 +262,12 @@ namespace bzit.bomg
return; return;
} }
this.Address = address; this.SiteAddress = address;
this.mainThread.RunWorkerAsync(); this.mainThread.RunWorkerAsync();
} }
#endregion #endregion
#region events & delegate
public RetrieveCompleted OnRetrieveCompleted = null;
#endregion
protected void retrieveWorker_DoWork(object sender, DoWorkEventArgs e) protected void retrieveWorker_DoWork(object sender, DoWorkEventArgs e)
{ {
@ -258,7 +286,7 @@ namespace bzit.bomg
try try
{ {
sourceCode = webClient.DownloadString(this.Address); sourceCode = webClient.DownloadString(this.SiteAddress);
} }
catch (Exception exc) catch (Exception exc)
{ {
@ -267,92 +295,28 @@ namespace bzit.bomg
return; return;
} }
HtmlAgilityPack.HtmlDocument document = new HtmlAgilityPack.HtmlDocument(); HtmlDocument document = new HtmlDocument();
document.LoadHtml(sourceCode); document.LoadHtml(sourceCode);
// parse title // title
HtmlAgilityPack.HtmlNodeCollection hnc = document.DocumentNode.SelectNodes("//title"); this.SiteName = parseSiteTitle(document);
if (hnc != null)
{
if (hnc.Count > 0)
{
this.TempName = WebUtility.HtmlDecode(hnc[0].InnerHtml).Trim();
}
}
// parse description // description
hnc = document.DocumentNode.SelectNodes("//meta"); this.Description = parseSiteDescription(document);
if (hnc != null)
{
foreach (HtmlAgilityPack.HtmlNode node in hnc)
{
if (node.Attributes["name"] == null)
{
continue;
}
string nodeAttr = node.Attributes["name"].Value.Trim(); // favicon
if (nodeAttr.Equals("description", StringComparison.CurrentCultureIgnoreCase)) this.IconAddress = parseSiteIcon(document);
if (!string.IsNullOrWhiteSpace(this.IconAddress))
{ {
if (!string.IsNullOrEmpty(this.Description)) Uri iconAddressURI;
{ bool rv = Uri.TryCreate(new Uri(this.SiteAddress), this.IconAddress, out iconAddressURI);
continue;
}
if (node.Attributes["content"] != null)
{
this.Description = WebUtility.HtmlDecode(node.Attributes["content"].Value).Trim();
break;
}
}
}
}
// parse icon
hnc = document.DocumentNode.SelectNodes("//link");
if (hnc != null)
{
foreach (HtmlAgilityPack.HtmlNode node in hnc)
{
if (node.Attributes["rel"] == null)
{
continue;
}
string nodeAttr = node.Attributes["rel"].Value.Trim();
if (nodeAttr.ToLower().Contains("icon"))
{
if (!string.IsNullOrEmpty(this.IconAddress))
{
continue;
}
if (node.Attributes["href"] != null)
{
Uri iconPath;
bool rv = Uri.TryCreate(new Uri(this.Address), WebUtility.HtmlDecode(node.Attributes["href"].Value).Trim(), out iconPath);
if (rv) if (rv)
{ {
this.IconAddress = iconPath.ToString(); this.IconAddress = iconAddressURI.ToString();
}
break;
}
}
} }
} }
// default favicon // load favicon image
if (string.IsNullOrEmpty(this.IconAddress))
{
Uri iconPath;
if (Uri.TryCreate(new Uri(this.Address), "/favicon.ico", out iconPath))
{
this.IconAddress = iconPath.ToString();
}
}
// load icon image
if (!string.IsNullOrEmpty(this.IconAddress)) if (!string.IsNullOrEmpty(this.IconAddress))
{ {
try try
@ -366,7 +330,8 @@ namespace bzit.bomg
} }
catch catch
{ {
// do nothing this.IconData = null;
this.IconAddress = null;
} }
} }
} }
@ -376,11 +341,184 @@ namespace bzit.bomg
this.OnRetrieveCompleted?.Invoke(this, hasRetrieveError, retrieveErrorMessage); this.OnRetrieveCompleted?.Invoke(this, hasRetrieveError, retrieveErrorMessage);
} }
// protected string CustomDecode(string text) { return WebUtility.HtmlDecode(text); } protected string encodePath(string text) => System.Web.HttpUtility.UrlEncode(text);
protected string decodePath(string text) => System.Web.HttpUtility.UrlDecode(text);
protected string parseTagValue(HtmlDocument doc, string xpath, string defaultValue = "")
{
HtmlNodeCollection hnc = doc.DocumentNode.SelectNodes(xpath);
if (hnc == null)
{
return defaultValue;
}
if (hnc.Count <= 0)
{
return defaultValue;
}
foreach (HtmlNode hn in hnc)
{
if (string.IsNullOrWhiteSpace(hn.InnerHtml))
{
continue;
}
string rs = WebUtility.HtmlDecode(hn.InnerHtml)?.Replace("\r", "")?.Replace("\n", " ")?.Trim();
if (string.IsNullOrWhiteSpace(rs))
{
continue;
}
return rs;
}
return defaultValue;
}
protected string parseTagValue_Attr(HtmlDocument doc, string xpath, string attr, string defaultValue = "")
{
HtmlNodeCollection hnc = doc.DocumentNode.SelectNodes(xpath);
if (hnc == null)
{
return defaultValue;
}
if (hnc.Count <= 0)
{
return defaultValue;
}
foreach (HtmlNode hn in hnc)
{
if (hn.Attributes[attr] == null)
{
continue;
}
if (string.IsNullOrWhiteSpace(hn.Attributes[attr].Value))
{
continue;
}
return System.Web.HttpUtility.HtmlDecode(hn.Attributes[attr].Value?.Trim());
}
return defaultValue;
}
protected string parseSiteTitle(HtmlDocument doc)
{
string rs = null;
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue(doc, "//title", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@property='og:title']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@name='twitter:title']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@property='og:site_name']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@itemprop='name']", "content", string.Empty);
}
return rs;
}
protected string parseSiteDescription(HtmlDocument doc)
{
string rs = null;
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@name='description']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@property='og:description']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@name='twitter:description']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@property='og:description']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@itemprop='description']", "content", string.Empty);
}
return rs;
}
protected string parseSiteIcon(HtmlDocument doc)
{
string rs = null;
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//link[@rel='shortcut icon']", "href", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//link[@rel='icon']", "href", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//link[@rel='apple-touch-icon']", "href", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//link[@rel='apple-touch-icon-precomposed']", "href", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@property='og:image']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@name='twitter:image']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@property='og:image']", "content", string.Empty);
}
if (string.IsNullOrWhiteSpace(rs))
{
rs = parseTagValue_Attr(doc, "//meta[@itemprop='image']", "content", string.Empty);
}
return rs;
}
////protected string PathEncode(string text) { return RyzStudio.String.EncodeTo64(text); }
////protected string PathDecode(string text) { return RyzStudio.String.DecodeFrom64(text); }
protected string PathEncode(string text) { return System.Web.HttpUtility.UrlEncodeUnicode(text); }
protected string PathDecode(string text) { return System.Web.HttpUtility.UrlDecode(text); }
} }
} }

View File

@ -67,18 +67,18 @@ namespace bzit.bomg
TreeNode tn = AddBookmarkPageFullPath(name.Trim(), 3); TreeNode tn = AddBookmarkPageFullPath(name.Trim(), 3);
tn.Tag = tag; tn.Tag = tag;
tn.ToolTipText = tag.Address + Environment.NewLine + tag.Description; tn.ToolTipText = tag.SiteAddress + Environment.NewLine + tag.Description;
// load icon // load icon
if (this.IconDatabase.HasIcon(tag.Address)) if (this.IconDatabase.HasIcon(tag.SiteAddress))
{ {
try try
{ {
Image icon = this.IconDatabase.GetIcon(tag.Address); Image icon = this.IconDatabase.GetIcon(tag.SiteAddress);
if (icon != null) if (icon != null)
{ {
tn.TreeView.ImageList.Images.Add(tag.Address, icon); tn.TreeView.ImageList.Images.Add(tag.SiteAddress, icon);
tn.ImageKey = tn.SelectedImageKey = tag.Address; tn.ImageKey = tn.SelectedImageKey = tag.SiteAddress;
} }
} }
catch catch
@ -91,13 +91,13 @@ namespace bzit.bomg
public int AddToIconList(BookmarkItem sender) public int AddToIconList(BookmarkItem sender)
{ {
Image rs = null; Image rs = null;
if (this.IconDatabase.HasIcon(sender.Address)) if (this.IconDatabase.HasIcon(sender.SiteAddress))
{ {
rs = this.IconDatabase.GetIcon(sender.Address); rs = this.IconDatabase.GetIcon(sender.SiteAddress);
} }
else else
{ {
if (this.IconDatabase.AddIcon(sender.Address, sender.IconData)) if (this.IconDatabase.AddIcon(sender.SiteAddress, sender.IconData))
{ {
rs = sender.Icon; rs = sender.Icon;
} }
@ -105,8 +105,8 @@ namespace bzit.bomg
if (rs != null) if (rs != null)
{ {
this.ImageList.Images.Add(sender.Address, rs); this.ImageList.Images.Add(sender.SiteAddress, rs);
return this.ImageList.Images.IndexOfKey(sender.Address); return this.ImageList.Images.IndexOfKey(sender.SiteAddress);
} }
return 3; return 3;
@ -114,12 +114,12 @@ namespace bzit.bomg
public void AddIcon(BookmarkItem sender) public void AddIcon(BookmarkItem sender)
{ {
if (this.IconDatabase.HasIcon(sender.Address)) if (this.IconDatabase.HasIcon(sender.SiteAddress))
{ {
return; return;
} }
this.IconDatabase.AddIcon(sender.Address, sender.IconData); this.IconDatabase.AddIcon(sender.SiteAddress, sender.IconData);
} }
} }
} }

View File

@ -743,14 +743,14 @@ namespace bzit.bomg
return; return;
} }
if (string.IsNullOrEmpty(bookmarkItem.Address)) if (string.IsNullOrEmpty(bookmarkItem.SiteAddress))
{ {
return; return;
} }
try try
{ {
Clipboard.SetText(bookmarkItem.Address.Trim()); Clipboard.SetText(bookmarkItem.SiteAddress.Trim());
} }
catch catch
{ {
@ -788,7 +788,7 @@ namespace bzit.bomg
return; return;
} }
if (string.IsNullOrEmpty(item.Address)) if (string.IsNullOrEmpty(item.SiteAddress))
{ {
return; return;
} }
@ -810,8 +810,8 @@ namespace bzit.bomg
return; return;
} }
bookmarkCustom1 = bookmarkCustom1.Replace("%1", item.Address); bookmarkCustom1 = bookmarkCustom1.Replace("%1", item.SiteAddress);
bookmarkCustom2 = bookmarkCustom2.Replace("%1", item.Address); bookmarkCustom2 = bookmarkCustom2.Replace("%1", item.SiteAddress);
try try
{ {
@ -826,7 +826,7 @@ namespace bzit.bomg
default: default:
try try
{ {
System.Diagnostics.Process.Start(item.Address); System.Diagnostics.Process.Start(item.SiteAddress);
} }
catch catch
{ {

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.2.0.083")] [assembly: AssemblyVersion("0.2.1.001")]
[assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyFileVersion("0.1.0.0")]

View File

@ -89,7 +89,7 @@ namespace bzit.bomg.Properties {
} }
/// <summary> /// <summary>
/// Looks up a localized string similar to 0.2.0.083 beta. /// Looks up a localized string similar to 0.2.1.001 beta.
/// </summary> /// </summary>
internal static string app_version { internal static string app_version {
get { get {

View File

@ -128,7 +128,7 @@
<value>Bookmark Manager</value> <value>Bookmark Manager</value>
</data> </data>
<data name="app_version" xml:space="preserve"> <data name="app_version" xml:space="preserve">
<value>0.2.0.083 beta</value> <value>0.2.1.001 beta</value>
</data> </data>
<data name="cog" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="cog" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\cog.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\cog.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>

View File

@ -40,7 +40,7 @@ namespace bzit.bomg
bi.Fullpath = xn2.InnerText?.Trim(); bi.Fullpath = xn2.InnerText?.Trim();
break; break;
case "address": case "address":
bi.Address = xn2.InnerText?.Trim(); bi.SiteAddress = xn2.InnerText?.Trim();
break; break;
case "description": case "description":
bi.Description = xn2.InnerText?.Trim(); bi.Description = xn2.InnerText?.Trim();
@ -78,7 +78,7 @@ namespace bzit.bomg
writer.WriteStartElement("m"); writer.WriteStartElement("m");
writer.WriteElementString("name", parentForm.treeView1.GetNodeFullPath(tn)); writer.WriteElementString("name", parentForm.treeView1.GetNodeFullPath(tn));
writer.WriteElementString("address", bi.Address); writer.WriteElementString("address", bi.SiteAddress);
writer.WriteElementString("description", bi.Description); writer.WriteElementString("description", bi.Description);
writer.WriteElementString("created", bi.Created.ToString()); writer.WriteElementString("created", bi.Created.ToString());
writer.WriteEndElement(); writer.WriteEndElement();

View File

@ -1,3 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/></startup></configuration>

View File

@ -206,7 +206,6 @@
<EmbeddedResource Include="RyzStudio\Windows\Forms\BigButton.resx"> <EmbeddedResource Include="RyzStudio\Windows\Forms\BigButton.resx">
<DependentUpon>BigButton.cs</DependentUpon> <DependentUpon>BigButton.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
@ -219,7 +218,6 @@
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="bomg-2.ico" />
<Content Include="bomg-4.ico" /> <Content Include="bomg-4.ico" />
<None Include="Resources\page_white_world_bw.png" /> <None Include="Resources\page_white_world_bw.png" />
<None Include="Resources\page_white_gray_green.png" /> <None Include="Resources\page_white_gray_green.png" />

31
bomg.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.168
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bomg", "bomg.csproj", "{594B03D6-3F17-4AE9-911D-C338EBD99FDF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Debug|x86.ActiveCfg = Debug|x86
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Debug|x86.Build.0 = Debug|x86
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Release|Any CPU.Build.0 = Release|Any CPU
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Release|x86.ActiveCfg = Release|x86
{594B03D6-3F17-4AE9-911D-C338EBD99FDF}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3FF38EC6-A04F-4999-AA1C-771FA6DAC156}
EndGlobalSection
EndGlobal