Well, I can't wait for lobby with 'Delete' button and some other management optionsCarRepairer wrote:Well thank you for coming up with the idea and working on it. What I was hinting at was that it would be more useful for lobby clients to handle the management of maps and mods, but it couldn't hurt to have this too. It would certainly help in some scenarios.

As for now I've managed to find proper thumbnail interfaces (IThumbnailProvider for Vista and 7 or IExtractImage for 2000/ME, XP, Vista, not sure about 7) and Vista support interfaces IInitializeWithFile, IInitializeWithStream, IInitializeWithItem in Vista and 7. So far, not so bad - I've managed to make custom previews using Stream as input but:
- I have some problems using IInitializeWithFile (would be better to communicate with unitsync) with IThumbnailProvider - can't have both of interfaces working.
- I got some problems loading unmanaged code libraries (as unitsync.dll - can't locate after compiling). Never tried to do it before, any ideas?
- Can't find any way to get any mod pic.
Below easy code that demonstrates how to use interfaces:
Code: Select all
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Thumbnailer{
[ComVisible(true), ClassInterface(ClassInterfaceType.None)]
[ProgId("Cogwheel.StateThumbnailProvider"), Guid("53a13663-b80b-4ab5-9c61-9d0d05ce389a")]
public class ThumbnailProvider : IThumbnailProvider, IInitializeWithStream{
public void Initialize(IStream stream, int grfMode){}
public void GetThumbnail(int squareLength, out IntPtr hBitmap, out WTS_ALPHATYPE bitmapType){
using (var Thumbnail = new Bitmap(squareLength, squareLength)){
using (var G = Graphics.FromImage(Thumbnail)) G.Clear(Color.Red);
hBitmap = Thumbnail.GetHbitmap();}
bitmapType = WTS_ALPHATYPE.WTSAT_UNKNOWN;}
}
public enum WTS_ALPHATYPE{
WTSAT_UNKNOWN = 0,
WTSAT_RGB = 1,
WTSAT_ARGB = 2
}
[ComVisible(true), Guid("e357fccd-a995-4576-b01f-234630154e96"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IThumbnailProvider{
void GetThumbnail(int cx, out IntPtr hBitmap, out WTS_ALPHATYPE bitmapType);
}
[ComVisible(true), Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IInitializeWithStream{
void Initialize(IStream stream, int grfMode);
}
}
Code: Select all
[ComVisible(true), InterfaceType(ComInterfaceType.InterfaceIsIUnknown, Guid("b7d14566-0509-4cce-a71f-0a554233bd9b")]
interface IInitializeWithFile{
void Initialize([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, uint grfMode);}
Code: Select all
[DllImport("unitsync.dll")]
static extern IntPtr GetMinimap(StringBuilder filename, int miplevel);
Code: Select all
// int squareLength provided as GetThumbnail() parameter
Bitmap b = new Bitmap(squareLength, squareLength, 2, System.Drawing.Imaging.PixelFormat.Format16bppRgb565, GetMinimap(...));
To register component you need to update registry (hope haven't forgotten anything):
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\spring.sdz_archive\shellex\{e357fccd-a995-4576-b01f-234630154e96}]
@="{53a13663-b80b-4ab5-9c61-9d0d05ce389a}"
[HKEY_CLASSES_ROOT\spring.sd7_archive\shellex\{e357fccd-a995-4576-b01f-234630154e96}]
@="{53a13663-b80b-4ab5-9c61-9d0d05ce389a}"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved]
"{53a13663-b80b-4ab5-9c61-9d0d05ce389a}"="anything you want as description :)"
Code: Select all
%windir%\Microsoft.NET\Framework\v2.0.50727\RegAsm /codebase Thumbnailer.dll

If anybody have got any ideas how to fix problems I encountered - it would be awesome for some feedback before I get to work again - I'm not very skilled with C# + Windows interfaces + Spring interfaces.
References: