diff --git a/AppResource.Designer.cs b/AppResource.Designer.cs
index 38ef02f..7cb009e 100644
--- a/AppResource.Designer.cs
+++ b/AppResource.Designer.cs
@@ -126,16 +126,6 @@ namespace BookmarkManager {
}
}
- ///
- /// Looks up a localized resource of type System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap file {
- get {
- object obj = ResourceManager.GetObject("file", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -166,16 +156,6 @@ namespace BookmarkManager {
}
}
- ///
- /// Looks up a localized resource of type System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap help_circle {
- get {
- object obj = ResourceManager.GetObject("help_circle", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -196,36 +176,6 @@ namespace BookmarkManager {
}
}
- ///
- /// Looks up a localized resource of type System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap save {
- get {
- object obj = ResourceManager.GetObject("save", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Looks up a localized resource of type System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap search {
- get {
- object obj = ResourceManager.GetObject("search", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
- ///
- /// Looks up a localized resource of type System.Drawing.Bitmap.
- ///
- internal static System.Drawing.Bitmap settings {
- get {
- object obj = ResourceManager.GetObject("settings", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
diff --git a/AppResource.resx b/AppResource.resx
index 1626454..6581710 100644
--- a/AppResource.resx
+++ b/AppResource.resx
@@ -139,9 +139,6 @@
Resources\bookmark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- Resources\file.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
Resources\file-text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -151,24 +148,12 @@
Resources\folder_explore.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- Resources\help-circle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
Resources\hexagon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Resources\icon-64.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- Resources\save.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\search.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
-
- Resources\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
Resources\trash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/BookmarkManager.csproj b/BookmarkManager.csproj
index 4db039c..5cefae5 100644
--- a/BookmarkManager.csproj
+++ b/BookmarkManager.csproj
@@ -14,7 +14,7 @@
Ray Lam
1.0.0.0
1.0.0.0
- 0.6.0.1042
+ 0.6.1.0249
bukkubuddy
True
8.0
@@ -120,8 +120,8 @@
-
-
+
+
\ No newline at end of file
diff --git a/EditBookmarkForm.cs b/EditBookmarkForm.cs
index f90c8c5..08d53f3 100644
--- a/EditBookmarkForm.cs
+++ b/EditBookmarkForm.cs
@@ -1,6 +1,7 @@
using System;
using System.ComponentModel;
using System.Drawing;
+using System.Threading.Tasks;
using System.Windows.Forms;
using BookmarkManager.Services;
using bzit.bomg.Models;
@@ -54,11 +55,19 @@ namespace FizzyLauncher
try
{
+ if (model.Icon != null)
+ {
+ if (model.Icon.Width > 16)
+ {
+ model.Icon = RyzStudio.Drawing.ImageEditor.Resize(model.Icon, 16, 16);
+ }
+ }
+
pictureBox1.Image = model.Icon;
}
catch (Exception)
{
- // do nothing
+ pictureBox1.Image = model.Icon = null;
}
memoBox1.Text = model.Notes?.Trim() ?? string.Empty;
@@ -200,6 +209,7 @@ namespace FizzyLauncher
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
pictureBox1.TabIndex = 201;
pictureBox1.TabStop = false;
+ pictureBox1.MouseClick += pictureBox1_MouseClick;
pictureBox1.MouseDoubleClick += pictureBox1_MouseDoubleClick;
//
// textBox3
@@ -343,7 +353,30 @@ namespace FizzyLauncher
private async void textBox2_OnButtonClick(object sender, EventArgs e)
{
- if (string.IsNullOrWhiteSpace(textBox2.Text))
+ await InvalidateWebPage(textBox2.Text, true, true, true);
+
+ textBox2.Focus();
+ }
+
+ private async void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left)
+ {
+ await InvalidateWebPage(textBox2.Text, false, false, true);
+ }
+ }
+
+ private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Right)
+ {
+ pictureBox1.Image = null;
+ }
+ }
+
+ private async Task InvalidateWebPage(string url, bool updateTitle, bool updateDescription, bool updateIcon)
+ {
+ if (string.IsNullOrWhiteSpace(url))
{
return;
}
@@ -355,59 +388,48 @@ namespace FizzyLauncher
this.IsBusy = true;
- if (!textBox2.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !textBox2.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
+ if (!url.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !url.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
{
- textBox2.Text = "http://" + textBox2.Text;
+ url = "http://" + url;
}
- var document = await _webProvider.RetrieveHtmlDocument(textBox2.Text);
+ var document = await _webProvider.RetrieveHtmlDocument(url);
if (document == null)
{
this.IsBusy = false;
return;
}
- textBox1.Text = _webProvider.ParseTitle(document);
- textBox3.Text = _webProvider.ParseMetaDescription(document);
- pictureBox1.Image = await _webProvider.RetrieveImage(document);
+ if (updateTitle)
+ {
+ textBox1.Text = _webProvider.ParseTitle(document);
+ }
+
+ if (updateDescription)
+ {
+ textBox3.Text = _webProvider.ParseMetaDescription(document);
+ }
+
+ if (updateIcon)
+ {
+ try
+ {
+ pictureBox1.Image = await _webProvider.RetrieveImage(document);
+ if (pictureBox1.Image != null)
+ {
+ if (pictureBox1.Image.Width > 16)
+ {
+ pictureBox1.Image = RyzStudio.Drawing.ImageEditor.Resize(pictureBox1.Image, 16, 16);
+ }
+ }
+ }
+ catch (Exception)
+ {
+ pictureBox1.Image = null;
+ }
+ }
this.IsBusy = false;
-
- textBox2.Focus();
- }
-
- private async void pictureBox1_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left)
- {
- if (string.IsNullOrWhiteSpace(textBox2.Text))
- {
- return;
- }
-
- if (this.IsBusy)
- {
- return;
- }
-
- this.IsBusy = true;
-
- if (!textBox2.Text.StartsWith("http://", StringComparison.CurrentCultureIgnoreCase) && !textBox2.Text.StartsWith("https://", StringComparison.CurrentCultureIgnoreCase))
- {
- textBox2.Text = "http://" + textBox2.Text;
- }
-
- var document = await _webProvider.RetrieveHtmlDocument(textBox2.Text);
- if (document == null)
- {
- this.IsBusy = false;
- return;
- }
-
- pictureBox1.Image = await _webProvider.RetrieveImage(document);
-
- this.IsBusy = false;
- }
}
}
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index f0c2781..e98c264 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -120,7 +120,7 @@ namespace FizzyLauncher
//
// newToolStripMenuItem
//
- newToolStripMenuItem.Image = BookmarkManager.AppResource.file;
+ newToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
newToolStripMenuItem.Name = "newToolStripMenuItem";
newToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N;
newToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@@ -129,7 +129,7 @@ namespace FizzyLauncher
//
// openToolStripMenuItem
//
- openToolStripMenuItem.Image = BookmarkManager.AppResource.folder;
+ openToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
openToolStripMenuItem.Name = "openToolStripMenuItem";
openToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O;
openToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@@ -155,7 +155,7 @@ namespace FizzyLauncher
//
// saveToolStripMenuItem
//
- saveToolStripMenuItem.Image = BookmarkManager.AppResource.save;
+ saveToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
saveToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S;
saveToolStripMenuItem.Size = new System.Drawing.Size(146, 22);
@@ -190,10 +190,10 @@ namespace FizzyLauncher
//
// findToolStripMenuItem
//
- findToolStripMenuItem.Image = BookmarkManager.AppResource.search;
+ findToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
findToolStripMenuItem.Name = "findToolStripMenuItem";
findToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F;
- findToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
+ findToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
findToolStripMenuItem.Text = "&Find";
findToolStripMenuItem.Click += findToolStripMenuItem_Click;
//
@@ -207,26 +207,26 @@ namespace FizzyLauncher
// expandAllToolStripMenuItem
//
expandAllToolStripMenuItem.Name = "expandAllToolStripMenuItem";
- expandAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ expandAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
expandAllToolStripMenuItem.Text = "&Expand All";
expandAllToolStripMenuItem.Click += expandAllToolStripMenuItem_Click;
//
// collapseAllToolStripMenuItem
//
collapseAllToolStripMenuItem.Name = "collapseAllToolStripMenuItem";
- collapseAllToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ collapseAllToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
collapseAllToolStripMenuItem.Text = "&Collapse All";
collapseAllToolStripMenuItem.Click += collapseAllToolStripMenuItem_Click;
//
// toolStripSeparator1
//
toolStripSeparator1.Name = "toolStripSeparator1";
- toolStripSeparator1.Size = new System.Drawing.Size(149, 6);
+ toolStripSeparator1.Size = new System.Drawing.Size(177, 6);
//
// alwaysOnTopToolStripMenuItem
//
alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem";
- alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
alwaysOnTopToolStripMenuItem.Text = "Always On &Top";
alwaysOnTopToolStripMenuItem.Click += alwaysOnTopToolStripMenuItem_Click;
//
@@ -240,21 +240,21 @@ namespace FizzyLauncher
// toolStripMenuItem9
//
toolStripMenuItem9.Name = "toolStripMenuItem9";
- toolStripMenuItem9.Size = new System.Drawing.Size(168, 22);
+ toolStripMenuItem9.Size = new System.Drawing.Size(180, 22);
toolStripMenuItem9.Text = "Update &Icons";
toolStripMenuItem9.Click += toolStripMenuItem9_Click;
//
// toolStripSeparator2
//
toolStripSeparator2.Name = "toolStripSeparator2";
- toolStripSeparator2.Size = new System.Drawing.Size(165, 6);
+ toolStripSeparator2.Size = new System.Drawing.Size(177, 6);
//
// optionsToolStripMenuItem
//
- optionsToolStripMenuItem.Image = BookmarkManager.AppResource.settings;
+ optionsToolStripMenuItem.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
optionsToolStripMenuItem.ShortcutKeys = System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F12;
- optionsToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
+ optionsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
optionsToolStripMenuItem.Text = "&Options";
optionsToolStripMenuItem.Click += optionsToolStripMenuItem_Click;
//
@@ -267,22 +267,22 @@ namespace FizzyLauncher
//
// viewHelpToolStripMenuItem1
//
- viewHelpToolStripMenuItem1.Image = BookmarkManager.AppResource.help_circle;
+ viewHelpToolStripMenuItem1.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;
viewHelpToolStripMenuItem1.Name = "viewHelpToolStripMenuItem1";
viewHelpToolStripMenuItem1.ShortcutKeys = System.Windows.Forms.Keys.F1;
- viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(146, 22);
+ viewHelpToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
viewHelpToolStripMenuItem1.Text = "&View Help";
viewHelpToolStripMenuItem1.Click += viewHelpToolStripMenuItem1_Click;
//
// toolStripMenuItem16
//
toolStripMenuItem16.Name = "toolStripMenuItem16";
- toolStripMenuItem16.Size = new System.Drawing.Size(143, 6);
+ toolStripMenuItem16.Size = new System.Drawing.Size(177, 6);
//
// aboutToolStripMenuItem1
//
aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1";
- aboutToolStripMenuItem1.Size = new System.Drawing.Size(146, 22);
+ aboutToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
aboutToolStripMenuItem1.Text = "&About";
aboutToolStripMenuItem1.Click += aboutToolStripMenuItem1_Click;
//
diff --git a/MainForm.cs b/MainForm.cs
index 88affdd..305fc89 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -15,6 +15,7 @@ using FizzyLauncher.Models;
using RyzStudio;
using RyzStudio.Windows.Forms;
using RyzStudio.Windows.ThemedForms;
+using static RyzStudio.Windows.Forms.BookmarkTreeView;
namespace FizzyLauncher
{
@@ -31,6 +32,14 @@ namespace FizzyLauncher
this.Text = Application.ProductName;
+ newToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("a", Color.Black, 2);
+ openToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("b", Color.Black, 2);
+ saveToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("c", Color.Black, 2);
+ findToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("d", Color.Black, 2);
+ optionsToolStripMenuItem.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("i", Color.Black, 2);
+ viewHelpToolStripMenuItem1.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("j", Color.Black, 2);
+ //aboutToolStripMenuItem1.Image = RyzStudio.Windows.ThemedForms.DefaultVisualStyle.GetImage("k", Color.Black, 2);
+
_fileSessionManager = new FileSessionManager();
_fileSessionManager.OpenFileDialog = openFileDialog1;
_fileSessionManager.SaveFileDialog = saveFileDialog1;
@@ -776,7 +785,7 @@ namespace FizzyLauncher
if (result.IsSuccess)
{
// Add icons to save file
- var result2 = AddImagesToZipFile(filename, this.CurrentSession.Items);
+ var result2 = AddImagesToZipFile(filename, nodeList);
if (!result2.IsSuccess)
{
if (showNotices)
@@ -970,7 +979,7 @@ namespace FizzyLauncher
});
}
- private GenericResult AddImagesToZipFile(string zipFilename, List items)
+ private GenericResult AddImagesToZipFile(string zipFilename, List> items)
{
if (string.IsNullOrWhiteSpace(zipFilename))
{
@@ -998,14 +1007,38 @@ namespace FizzyLauncher
{
foreach (var item in items)
{
- var key = "icon\\" + item.Id.ToString() + ".png";
+ var key = "icon\\" + item.Value.Id.ToString() + ".png";
+
var zipEntry = archive.GetEntry(key);
if (zipEntry != null)
{
zipEntry.Delete();
}
- if (item.Icon == null)
+ if (item.Key.ImageIndex == (int)NodeIcon.Default)
+ {
+ continue;
+ }
+
+ if (!treeView1.ImageList.Images.ContainsKey(item.Value.Id.ToString()))
+ {
+ continue;
+ }
+
+ var icon = treeView1.ImageList.Images[item.Value.Id.ToString()];
+ if (icon == null)
+ {
+ continue;
+ }
+
+ try
+ {
+ if (icon.Width <= 0)
+ {
+ continue;
+ }
+ }
+ catch (Exception)
{
continue;
}
@@ -1016,7 +1049,7 @@ namespace FizzyLauncher
{
using (Stream entryStream = zipEntry.Open())
{
- using (Image image = item.Icon)
+ using (Image image = icon)
{
image.Save(entryStream, ImageFormat.Png);
}
@@ -1024,6 +1057,8 @@ namespace FizzyLauncher
}
catch (Exception)
{
+ zipEntry.Delete();
+
continue;
}
}
diff --git a/UpdateIconsForm.cs b/UpdateIconsForm.cs
index 8f5ca55..91477cc 100644
--- a/UpdateIconsForm.cs
+++ b/UpdateIconsForm.cs
@@ -356,14 +356,25 @@ namespace FizzyLauncher
break;
}
- var image = await _webProvider.RetrieveImage(document);
- if (image == null)
- {
- continue;
- }
-
var newModel = item.Value;
- newModel.Icon = image;
+
+ try
+ {
+ var image = await _webProvider.RetrieveImage(document);
+ if (image != null)
+ {
+ if (image.Width > 16)
+ {
+ image = RyzStudio.Drawing.ImageEditor.Resize(image, 16, 16);
+ }
+ }
+
+ newModel.Icon = image;
+ }
+ catch (Exception)
+ {
+ newModel.Icon = null;
+ }
_treeView.UpdateNode(item.Key, newModel);
}
diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs
index 12d5ce4..528b987 100644
--- a/Windows/Forms/BookmarkTreeView.cs
+++ b/Windows/Forms/BookmarkTreeView.cs
@@ -1,5 +1,7 @@
-using System.ComponentModel;
+using System;
+using System.ComponentModel;
using System.Drawing;
+using System.Reflection;
using System.Windows.Forms;
using bzit.bomg.Models;
using FizzyLauncher;
@@ -125,6 +127,8 @@ namespace RyzStudio.Windows.Forms
if (MessageBox.Show("Delete?", "Delete?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.DeleteNode();
+
+ this.HasChanged = true;
}
}
@@ -243,6 +247,8 @@ namespace RyzStudio.Windows.Forms
this.EditNode(treeNode);
}
+ this.HasChanged = true;
+
return treeNode;
}
@@ -272,6 +278,8 @@ namespace RyzStudio.Windows.Forms
this.SelectedNode = newNode;
+ this.HasChanged = true;
+
return newNode;
}
}
@@ -282,29 +290,11 @@ namespace RyzStudio.Windows.Forms
public TreeNode AddNode(BookmarkModel model)
{
var parentNode = this.CreateNodePath(model?.Path?.Trim() ?? string.Empty, (int)NodeIcon.Folder1, (int)NodeIcon.Folder2);
- int iconIndex = (int)NodeIcon.Default;
// Add custom favicon
- if (model.Icon != null)
- {
- var iconKey = model.Id.ToString();
- if (!string.IsNullOrWhiteSpace(iconKey))
- {
- if (this.ImageList.Images.ContainsKey(iconKey))
- {
- this.ImageList.Images.RemoveByKey(iconKey);
- }
+ var n = AddImage(model.Id.ToString(), model.Icon);
- UIControl.Invoke(this, (x) =>
- {
- this.ImageList.Images.Add(iconKey, model.Icon);
- });
-
- iconIndex = this.ImageList.Images.IndexOfKey(iconKey);
- }
- }
-
- TreeNode newNode = new TreeNode(model?.Title?.Trim() ?? string.Empty, iconIndex, iconIndex);
+ TreeNode newNode = new TreeNode(model?.Title?.Trim() ?? string.Empty, n, n);
newNode.Tag = model;
newNode.ToolTipText = model.ToString();
@@ -404,10 +394,6 @@ namespace RyzStudio.Windows.Forms
if (node == null)
{
node = this.SelectedNode;
- }
-
- if (node == null)
- {
return;
}
@@ -416,36 +402,18 @@ namespace RyzStudio.Windows.Forms
return;
}
- var iconIndex = (int)NodeIcon.Default;
+ if (model.Id == Guid.Empty)
+ {
+ return;
+ }
// Update custom favicon
- var iconKey = model.Id.ToString();
- if (!string.IsNullOrWhiteSpace(iconKey))
- {
- UIControl.Invoke(this, (x) =>
- {
- if (this.ImageList.Images.ContainsKey(iconKey))
- {
- this.ImageList.Images.RemoveByKey(iconKey);
- }
- });
-
- if (model.Icon != null)
- {
- UIControl.Invoke(this, (x) =>
- {
- this.ImageList.Images.Add(iconKey, model.Icon);
- });
-
- iconIndex = this.ImageList.Images.IndexOfKey(iconKey);
- }
- }
+ var n = AddImage(model.Id.ToString(), model.Icon);
UIControl.Invoke(this, (x) =>
{
node.Text = model.Title;
- node.ImageIndex = iconIndex;
- node.SelectedImageIndex = iconIndex;
+ node.ImageIndex = node.SelectedImageIndex = n;
node.Tag = model;
node.ToolTipText = model.ToString();
});
@@ -462,9 +430,43 @@ namespace RyzStudio.Windows.Forms
this.ImageList.Images.Add(Resources.hexagon);
this.ImageList.Images.Add(Resources.folder);
this.ImageList.Images.Add(Resources.folder_explore);
- this.ImageList.Images.Add(Resources.file_text);
+ this.ImageList.Images.Add("default", Resources.file_text);
});
}
+ private int AddImage(string key, Image image)
+ {
+ if (image == null)
+ {
+ return (int)NodeIcon.Default;
+ }
+
+ try
+ {
+ if (image.Width <= 0)
+ {
+ return (int)NodeIcon.Default;
+ }
+ }
+ catch (Exception)
+ {
+ return (int)NodeIcon.Default;
+ }
+
+ UIControl.Invoke(this, (x) =>
+ {
+ if (this.ImageList.Images.ContainsKey(key))
+ {
+ var n = this.ImageList.Images.IndexOfKey(key);
+
+ this.ImageList.Images.SetKeyName(n, ".deleted");
+ }
+
+ this.ImageList.Images.Add(key, image);
+ });
+
+ return this.ImageList.Images.IndexOfKey(key);
+ }
+
}
}
\ No newline at end of file