2008-09-18 98 views
0

我想为C#WinForms TreeList控件制作状态图标。状态是其他状态的组合(例如,用户节点可能处于不活动状态或被禁止状态,或者处于非活动状态并被禁止),状态图标由非重叠的小字形组成。如何从较小的组件图像构建C#ImageList图像?

我真的想避免手动生成所有可能的状态图标排列,如果我可以避免它。

是否有可能创建一个图像列表(或只是一堆位图资源或其他东西),我可以用它来编程生成ImageList?

我在围绕着System.Drawing类开玩笑,没有任何东西会跳出来。另外,我坚持使用.Net 2.0。

回答

1
Bitmap image1 = ... 
Bitmap image2 = ... 

Bitmap combined = new Bitmap(image1.Width, image1.Height); 
using (Graphics g = Graphics.FromImage(combined)) { 
    g.DrawImage(image1, new Point(0, 0)); 
    g.DrawImage(image2, new Point(0, 0); 
} 

imageList.Add(combined); 
0

只需使用ImageList中的ImageList添加个别图像即可。所以,像这样:


Image img = Image.FromStream(/*get stream from resources*/); 
ImageList1.Images.Add(img);