WIP: icon db
This commit is contained in:
parent
253365d25e
commit
4c031108f0
@ -237,7 +237,6 @@ namespace BookmarkManager
|
|||||||
protected byte[] ImageToBytes(Image image)
|
protected byte[] ImageToBytes(Image image)
|
||||||
{
|
{
|
||||||
MemoryStream stream = new MemoryStream();
|
MemoryStream stream = new MemoryStream();
|
||||||
//image.Save(stream, ((image.RawFormat == null) ? ImageFormat.Bmp : new ImageFormat(image.RawFormat.Guid)));
|
|
||||||
image.Save(stream, ImageFormat.Bmp);
|
image.Save(stream, ImageFormat.Bmp);
|
||||||
stream.Close();
|
stream.Close();
|
||||||
|
|
||||||
|
@ -143,10 +143,10 @@ namespace BookmarkManager
|
|||||||
rs = parseTagValue_Attr(doc, "//meta[translate(@itemprop, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'image']", "content", string.Empty);
|
rs = parseTagValue_Attr(doc, "//meta[translate(@itemprop, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz') = 'image']", "content", string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (string.IsNullOrWhiteSpace(rs))
|
if (string.IsNullOrWhiteSpace(rs))
|
||||||
//{
|
{
|
||||||
// rs = "/favicon.ico";
|
rs = "/favicon.ico";
|
||||||
//}
|
}
|
||||||
|
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
87
MainForm.cs
87
MainForm.cs
@ -686,17 +686,20 @@ namespace FizzyLauncher
|
|||||||
case Keys.F2:
|
case Keys.F2:
|
||||||
if (nodeType == BookmarkTreeView.NodeType.Page)
|
if (nodeType == BookmarkTreeView.NodeType.Page)
|
||||||
{
|
{
|
||||||
BookmarkForm bookmarkForm = new BookmarkForm(treeView1.GetNodeModel(), null);
|
UpdateBookmarkNode(false);
|
||||||
if (bookmarkForm.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
string iconID = Crypto.GetSHA256Hash(bookmarkForm.Model.Item?.SiteName);
|
|
||||||
if (!string.IsNullOrWhiteSpace(iconID))
|
|
||||||
{
|
|
||||||
iconDatabase.AddIcon(iconID, bookmarkForm.Model.Icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
treeView1.UpdateItem(treeView1.SelectedNode, bookmarkForm.Model.Item);
|
//BookmarkForm bookmarkForm = new BookmarkForm(treeView1.GetNodeModel(), null);
|
||||||
}
|
//if (bookmarkForm.ShowDialog() == DialogResult.OK)
|
||||||
|
//{
|
||||||
|
// UpdateBookmarkNode(bookmarkForm);
|
||||||
|
// //string iconID = Crypto.GetSHA256Hash(bookmarkForm.Model.Item?.SiteName);
|
||||||
|
// //if (!string.IsNullOrWhiteSpace(iconID))
|
||||||
|
// //{
|
||||||
|
// // iconDatabase.AddIcon(iconID, bookmarkForm.Model.Icon);
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// //treeView1.UpdateItem(treeView1.SelectedNode, bookmarkForm.Model.Item);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -720,21 +723,25 @@ namespace FizzyLauncher
|
|||||||
node.EnsureVisible();
|
node.EnsureVisible();
|
||||||
treeView1.SelectedNode = node;
|
treeView1.SelectedNode = node;
|
||||||
|
|
||||||
BookmarkForm bookmarkForm = new BookmarkForm(treeView1.GetNodeModel(), null);
|
UpdateBookmarkNode(true);
|
||||||
if (bookmarkForm.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
string iconID = Crypto.GetSHA256Hash(bookmarkForm.Model.Item?.SiteName);
|
|
||||||
if (!string.IsNullOrWhiteSpace(iconID))
|
|
||||||
{
|
|
||||||
iconDatabase.AddIcon(iconID, bookmarkForm.Model.Icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
treeView1.UpdateItem(treeView1.SelectedNode, bookmarkForm.Model.Item);
|
//BookmarkForm bookmarkForm = new BookmarkForm(treeView1.GetNodeModel(), null);
|
||||||
}
|
//if (bookmarkForm.ShowDialog() == DialogResult.OK)
|
||||||
else
|
//{
|
||||||
{
|
// UpdateBookmarkNode(bookmarkForm);
|
||||||
node.Remove();
|
|
||||||
}
|
// //string iconID = Crypto.GetSHA256Hash(bookmarkForm.Model.Item?.SiteName);
|
||||||
|
// //if (!string.IsNullOrWhiteSpace(iconID))
|
||||||
|
// //{
|
||||||
|
// // iconDatabase.AddIcon(iconID, bookmarkForm.Model.Icon);
|
||||||
|
// //}
|
||||||
|
|
||||||
|
// //treeView1.UpdateItem(treeView1.SelectedNode, bookmarkForm.Model.Item);
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// node.Remove();
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1078,6 +1085,38 @@ namespace FizzyLauncher
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void UpdateBookmarkNode(bool deleteOnCancel)
|
||||||
|
{
|
||||||
|
BookmarkItem model = treeView1.GetNodeModel();
|
||||||
|
Image icon = null;
|
||||||
|
|
||||||
|
// retrieve icon from DB
|
||||||
|
if (!string.IsNullOrWhiteSpace(model.SiteName))
|
||||||
|
{
|
||||||
|
string iconID = Crypto.GetSHA256Hash(model?.SiteName);
|
||||||
|
|
||||||
|
icon = iconDatabase.FindIcon(iconID);
|
||||||
|
}
|
||||||
|
|
||||||
|
BookmarkForm bookmarkForm = new BookmarkForm(model, icon);
|
||||||
|
if (bookmarkForm.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
string iconID = Crypto.GetSHA256Hash(bookmarkForm.Model.Item?.SiteName);
|
||||||
|
if (!string.IsNullOrWhiteSpace(iconID))
|
||||||
|
{
|
||||||
|
iconDatabase.AddIcon(iconID, bookmarkForm.Model.Icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
treeView1.UpdateItem(treeView1.SelectedNode, bookmarkForm.Model.Item);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (deleteOnCancel)
|
||||||
|
{
|
||||||
|
treeView1.SelectedNode.Remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user