Fixed icon updates not working correctly
This commit is contained in:
parent
0a7bf62bff
commit
ce54eb7ce4
@ -54,11 +54,14 @@ namespace FizzyLauncher
|
||||
textBox3.Text = model.Description?.Trim() ?? string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
if (model.Icon != null)
|
||||
{
|
||||
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,12 +415,14 @@ namespace FizzyLauncher
|
||||
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;
|
||||
|
@ -361,15 +361,13 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
newModel.Icon = image;
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user