mirror of
https://github.com/Hofknecht/SystemTrayMenu.git
synced 2024-09-30 09:06:32 +13:00
ReadIcon will automatically update ColumnIcon
Freeze of ImageSource required to become accessible for UI thread as it may be created in background worker
This commit is contained in:
parent
6346b513d8
commit
f7fff25ba7
2 changed files with 10 additions and 13 deletions
|
@ -150,8 +150,6 @@ namespace SystemTrayMenu.DataClasses
|
|||
}
|
||||
}
|
||||
|
||||
internal Icon? Icon { get; private set; }
|
||||
|
||||
internal FileInfo FileInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -209,27 +207,32 @@ namespace SystemTrayMenu.DataClasses
|
|||
internal void ReadIcon(bool updateIconInBackground)
|
||||
{
|
||||
bool loading;
|
||||
Icon? icon;
|
||||
|
||||
if (IsPointingToFolder)
|
||||
{
|
||||
Icon = IconReader.GetFolderIconWithCache(Path, ShowOverlay, updateIconInBackground, Level == 0, out loading);
|
||||
icon = IconReader.GetFolderIconWithCache(Path, ShowOverlay, updateIconInBackground, Level == 0, out loading);
|
||||
}
|
||||
else
|
||||
{
|
||||
Icon = IconReader.GetFileIconWithCache(Path, ResolvedPath, ShowOverlay, updateIconInBackground, Level == 0, out loading);
|
||||
icon = IconReader.GetFileIconWithCache(Path, ResolvedPath, ShowOverlay, updateIconInBackground, Level == 0, out loading);
|
||||
}
|
||||
|
||||
IconLoading = loading;
|
||||
if (!IconLoading)
|
||||
{
|
||||
if (Icon == null)
|
||||
if (icon == null)
|
||||
{
|
||||
Icon = Resources.NotFound;
|
||||
icon = Resources.NotFound;
|
||||
}
|
||||
else if (HiddenEntry)
|
||||
{
|
||||
Icon = IconReader.AddIconOverlay(Icon, Resources.White50Percentage);
|
||||
icon = IconReader.AddIconOverlay(icon, Resources.White50Percentage);
|
||||
}
|
||||
}
|
||||
|
||||
ColumnIcon = icon?.ToImageSource();
|
||||
ColumnIcon?.Freeze();
|
||||
}
|
||||
|
||||
internal void OpenItem(int clickCount)
|
||||
|
|
|
@ -443,7 +443,6 @@ namespace SystemTrayMenu.UserInterface
|
|||
|
||||
rowData.RowIndex = index;
|
||||
rowData.Owner = this;
|
||||
rowData.ColumnIcon = (rowData.HiddenEntry ? IconReader.AddIconOverlay(rowData.Icon, Properties.Resources.White50Percentage) : rowData.Icon)?.ToImageSource();
|
||||
rowData.ColumnText = rowData.Text;
|
||||
rowData.SortIndex = rowData.IsAdditionalItem && Settings.Default.ShowOnlyAsSearchResult ? 99 : 0;
|
||||
}
|
||||
|
@ -1142,11 +1141,6 @@ namespace SystemTrayMenu.UserInterface
|
|||
{
|
||||
iconsToUpdate++;
|
||||
rowData.ReadIcon(false);
|
||||
if (rowData.Icon != null)
|
||||
{
|
||||
// TODO: Merge ColumnIcon and Icon, should be no need to separate them
|
||||
rowData.ColumnIcon = rowData.Icon.ToImageSource();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue