I have a Client and a Server. The Server retrieves a list of applications (Each containing a Path, Name and Icon) from it’s desktop. It then sends the Application back to the Client, to be displayed in a ListView with LargeIcons so that the client can then double click on the desktop icons in the listview and have that application open on the server. (This works 100% when being done with the below bug…)
However, there is a Microsoft bug in which a serialized Icon will be degraded when deserialized (http://support.microsoft.com/kb/814735)
I’m trying to follow the advice given there in order to bring back over high quality icons.
Here is what I’m doing:
//Get the list of Applications, which will include an icon, which we'll ignore due to the bug.
List<App> apps = client.ServiceProxy.getDesktopShortcuts();
// Get the ImageListStreamer (The serializable portion of the ImageList) and assign it to our Image List
ImageListStreamer il = client.ServiceProxy.getDesktopIcons();
foreach (App app in apps){
ListViewItem item = new ListViewItem(app.name);
item.ImageKey = app.path;
lv.Items.Add(item);
}
When I add the icons to the ImageList in getDesktopIcons(), I do it as follows:
il.Images.Add(app.path, app.icon);
So as to have the Applications’ path be it’s key. However, I believe when I send just the image stream back to the client, it loses that key information. I have the app’s path in each App object, so how can I associate them back, in order, with their respective icon in the imagelist?
Answer was simple. Since both my List and ImageList are being constructed in the same order, it’s safe to assume when I loop through the apps I’ve been given, then Apps[0] will correspond to ImageList[0].
Therefore, I need simply to use
with the index of the image to set (Corresponding to the application).