From 25681bcbbd2e7da64aa5b4cb0ff3378e29f74cd7 Mon Sep 17 00:00:00 2001 From: Kim Knight Date: Sun, 22 Sep 2024 00:26:26 +1000 Subject: [PATCH] *All* app icons were previously (re)loaded from file every time an app is created or edited. Now icons are *individually* reloaded only when an app is added/edited, significantly improving performance. Addresses issue #136 --- remoteapp-tool/RemoteAppEditWindow.vb | 1 - remoteapp-tool/RemoteAppMainWindow.vb | 22 +++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/remoteapp-tool/RemoteAppEditWindow.vb b/remoteapp-tool/RemoteAppEditWindow.vb index bad12b3..28c9d21 100644 --- a/remoteapp-tool/RemoteAppEditWindow.vb +++ b/remoteapp-tool/RemoteAppEditWindow.vb @@ -12,7 +12,6 @@ Public Class RemoteAppEditWindow HelpSystem.SetupTips(Me) Me.LoadValues() Dim dlgResult = Me.ShowDialog() - RemoteAppMainWindow.ReloadApps() Me.Dispose() Return RemoteApp End Function diff --git a/remoteapp-tool/RemoteAppMainWindow.vb b/remoteapp-tool/RemoteAppMainWindow.vb index 0a8a4eb..72bfe23 100644 --- a/remoteapp-tool/RemoteAppMainWindow.vb +++ b/remoteapp-tool/RemoteAppMainWindow.vb @@ -52,13 +52,16 @@ Public Class RemoteAppMainWindow Apps = SystemApps.GetAll For Each App As RemoteApp In Apps - SmallIcons.Images.RemoveByKey(App.Name) - Dim TheBitmap = GetAppBitmap(App.Name) + ' Check if the image is already present in SmallIcons before adding it + If Not Me.SmallIcons.Images.ContainsKey(App.Name) Then + Dim TheBitmap = GetAppBitmap(App.Name) + Me.SmallIcons.Images.Add(App.Name, TheBitmap) + End If + + ' Create the ListView item Dim AppItem As New ListViewItem(App.Name) AppItem.ToolTipText = App.FullName - AppItem.ImageIndex = 0 - Me.SmallIcons.Images.Add(App.Name, TheBitmap) - AppItem.ImageKey = App.Name + AppItem.ImageKey = App.Name ' Use the ImageKey as it was set AppList.Items.Add(AppItem) Next @@ -116,10 +119,19 @@ Public Class RemoteAppMainWindow Private Sub EditRemoteApp(AppName As String) Dim sra As New SystemRemoteApps RemoteAppEditWindow.EditRemoteApp(sra.GetApp(AppName)) + DeleteImage(AppName) + ReloadApps() + End Sub + + Private Sub DeleteImage(AppName) + If Me.SmallIcons.Images.ContainsKey(AppName) Then + Me.SmallIcons.Images.RemoveByKey(AppName) + End If End Sub Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click DeleteRemoteApp(AppList.SelectedItems(0).Text) + DeleteImage(AppList.SelectedItems(0).Text) ReloadApps() End Sub