*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

This commit is contained in:
Kim Knight 2024-09-22 00:26:26 +10:00
parent fb4e4c03e1
commit 25681bcbbd
2 changed files with 17 additions and 6 deletions

View File

@ -12,7 +12,6 @@ Public Class RemoteAppEditWindow
HelpSystem.SetupTips(Me) HelpSystem.SetupTips(Me)
Me.LoadValues() Me.LoadValues()
Dim dlgResult = Me.ShowDialog() Dim dlgResult = Me.ShowDialog()
RemoteAppMainWindow.ReloadApps()
Me.Dispose() Me.Dispose()
Return RemoteApp Return RemoteApp
End Function End Function

View File

@ -52,13 +52,16 @@ Public Class RemoteAppMainWindow
Apps = SystemApps.GetAll Apps = SystemApps.GetAll
For Each App As RemoteApp In Apps For Each App As RemoteApp In Apps
SmallIcons.Images.RemoveByKey(App.Name) ' Check if the image is already present in SmallIcons before adding it
Dim TheBitmap = GetAppBitmap(App.Name) 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) Dim AppItem As New ListViewItem(App.Name)
AppItem.ToolTipText = App.FullName AppItem.ToolTipText = App.FullName
AppItem.ImageIndex = 0 AppItem.ImageKey = App.Name ' Use the ImageKey as it was set
Me.SmallIcons.Images.Add(App.Name, TheBitmap)
AppItem.ImageKey = App.Name
AppList.Items.Add(AppItem) AppList.Items.Add(AppItem)
Next Next
@ -116,10 +119,19 @@ Public Class RemoteAppMainWindow
Private Sub EditRemoteApp(AppName As String) Private Sub EditRemoteApp(AppName As String)
Dim sra As New SystemRemoteApps Dim sra As New SystemRemoteApps
RemoteAppEditWindow.EditRemoteApp(sra.GetApp(AppName)) 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 End Sub
Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click Private Sub DeleteButton_Click(sender As Object, e As EventArgs) Handles DeleteButton.Click
DeleteRemoteApp(AppList.SelectedItems(0).Text) DeleteRemoteApp(AppList.SelectedItems(0).Text)
DeleteImage(AppList.SelectedItems(0).Text)
ReloadApps() ReloadApps()
End Sub End Sub