diff --git a/EditBookmarkForm.cs b/EditBookmarkForm.cs index 502ecab..08d53f3 100644 --- a/EditBookmarkForm.cs +++ b/EditBookmarkForm.cs @@ -55,9 +55,12 @@ namespace FizzyLauncher try { - if (model.Icon.Width > 16) + if (model.Icon != null) { - model.Icon = RyzStudio.Drawing.ImageEditor.Resize(model.Icon, 16, 16); + if (model.Icon.Width > 16) + { + model.Icon = RyzStudio.Drawing.ImageEditor.Resize(model.Icon, 16, 16); + } } pictureBox1.Image = model.Icon; @@ -206,6 +209,7 @@ namespace FizzyLauncher pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage; pictureBox1.TabIndex = 201; pictureBox1.TabStop = false; + pictureBox1.MouseClick += pictureBox1_MouseClick; pictureBox1.MouseDoubleClick += pictureBox1_MouseDoubleClick; // // textBox3 @@ -362,6 +366,14 @@ namespace FizzyLauncher } } + 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)) @@ -403,10 +415,12 @@ namespace FizzyLauncher try { pictureBox1.Image = await _webProvider.RetrieveImage(document); - - if (pictureBox1.Image.Width > 16) + if (pictureBox1.Image != null) { - pictureBox1.Image = RyzStudio.Drawing.ImageEditor.Resize(pictureBox1.Image, 16, 16); + if (pictureBox1.Image.Width > 16) + { + pictureBox1.Image = RyzStudio.Drawing.ImageEditor.Resize(pictureBox1.Image, 16, 16); + } } } catch (Exception) diff --git a/UpdateIconsForm.cs b/UpdateIconsForm.cs index 07489b6..91477cc 100644 --- a/UpdateIconsForm.cs +++ b/UpdateIconsForm.cs @@ -361,14 +361,12 @@ namespace FizzyLauncher try { var image = await _webProvider.RetrieveImage(document); - if (image == null) + if (image != null) { - continue; - } - - if (image.Width > 16) - { - image = RyzStudio.Drawing.ImageEditor.Resize(image, 16, 16); + if (image.Width > 16) + { + image = RyzStudio.Drawing.ImageEditor.Resize(image, 16, 16); + } } newModel.Icon = image; diff --git a/Windows/Forms/BookmarkTreeView.cs b/Windows/Forms/BookmarkTreeView.cs index 12d5ce4..5d3b3c3 100644 --- a/Windows/Forms/BookmarkTreeView.cs +++ b/Windows/Forms/BookmarkTreeView.cs @@ -416,36 +416,28 @@ namespace RyzStudio.Windows.Forms return; } - var iconIndex = (int)NodeIcon.Default; + var iconKey = "default"; // Update custom favicon - var iconKey = model.Id.ToString(); - if (!string.IsNullOrWhiteSpace(iconKey)) + var key = model.Id.ToString(); + if (!string.IsNullOrWhiteSpace(key)) { - 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); + this.ImageList.Images.Add(key, model.Icon); }); - iconIndex = this.ImageList.Images.IndexOfKey(iconKey); + iconKey = key; } } UIControl.Invoke(this, (x) => { node.Text = model.Title; - node.ImageIndex = iconIndex; - node.SelectedImageIndex = iconIndex; + node.ImageKey = iconKey; + node.SelectedImageKey = iconKey; node.Tag = model; node.ToolTipText = model.ToString(); }); @@ -462,7 +454,7 @@ 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); }); }