Fixed icon updates not working correctly

This commit is contained in:
Ray committed 2024-08-04 04:11:19 +01:00
1 parent 0a7bf62bff
commit ce54eb7ce4
3 files changed
+32 -28

No files matched your search

+8 -16
View File
@@ -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);
});
}