[译]ImageList向导
By robot-v1.0
本文链接 https://www.kyfws.com/applications/imagelist-wizard-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 3 分钟阅读 - 1076 个词 阅读量 0[译]ImageList向导
原文地址:https://www.codeproject.com/Articles/2368/ImageList-Wizard
原文作者:Gevik Babakhani
译文由本站 robot-v1.0 翻译
前言
A wizard application for creating ImageLists
用于创建ImageLists的向导应用程序
介绍(Introduction)
创建ImageLists是一项非常耗时的活动,尤其是在不使用VS.NET的情况下.ImageListMaker是一个由.NET驱动的向导,它将帮助开发人员创建ImageList程序集.(Creating ImageLists is a very time consuming activity especially when one isn’t using VS.NET.ImageList Maker is a .NET powered wizard that will help developers create ImageList Assemblies.)
使用此向导创建ImageList是一个非常简单直接的过程.该应用程序将创建一个C#源文件,并且在指定后还会创建并编译一个程序集.(Creating ImageLists with this wizard is a very easy and straight forward process.The application creates a C# source file and when specified it also creates and compiles an assembly.)
系统要求(System Requirements)
- Microsoft Windows 95 +/NT4 +(Microsoft Windows 95+ / NT4+)
- Microsoft .NET SDK(1.0版发行;不是Beta 1\2等)(Microsoft .NET SDK (version 1.0 release; not Beta 1, 2, etc))
- 幽默的态度.(A humoristic attitude.)
屏幕截图:(Screenshots:)
生成的源代码(Generated Source Code)
如果在向导中选择选项,此代码将自动为您编译为程序集DLL.(This code is automatically compiled to an assembly DLL for you if you choose the option in the wizard.)
namespace MyNamespace
{
using System;
using System.Resources;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;
using System.ComponentModel;
public class MyImageList
{
private ArrayList imgNames;
private ImageList _imageList;
// Get Set property for imagelist
public ImageList TheImageList
{
get
{
return(_imageList);
}
set
{
_imageList = value;
}
}
// Get property for image names
public ArrayList ImageNames
{
get
{
return imgNames;
}
}
// Constructor
public MyImageList()
{
_init();
}
// Retrives image index in this image list
// by saved filename
public int GetIndex(string iname)
{
return imgNames.IndexOf(iname);
}
// Initializing image list
private void _init()
{
// Creating a resource manager containing the images
ResourceManager Rm = new ResourceManager(
"TSIML_MyImageList", GetType().Assembly);
// General
_imageList = new ImageList();
_imageList.ImageSize = new Size(
(int) Rm.GetObject("IWIDTH"),
(int) Rm.GetObject("IHEIGHT"));
_imageList.TransparentColor =
(Color) Rm.GetObject("ITRANS");
_imageList.ColorDepth = ColorDepth.Depth32Bit;
// Getting image names;
imgNames = (ArrayList)Rm.GetObject("INAMES");
// Loadng images in the image list
foreach(object name in imgNames)
{
_imageList.Images.Add(
(Image)Rm.GetObject((string)name));
}
}
}
}
如何使用输出(How to use the output)
这是一个代码示例,向您展示如何使用ImageList Maker生成的源代码(Here is a code example to show you how to use the resulting source code by ImageList Maker)
// created on 31-5-2002 at 12:03
namespace TrueSoftware
{
using System;
using System.Windows.Forms;
using System.Resources;
using MyNamespace;
public class MyImageList_TestApp : Form
{
public MyImageList_TestApp()
{
// General
Width = 320;
Height = 200;
Text = "MyImageList Test Application " +
"by TrueSoftware";
StartPosition = FormStartPosition.CenterScreen;
// Creating and Populating a listview
MyImageList imgMyImageList = new MyImageList();
ListView lvTestView = new ListView();
// ********************************************
// Assigning the imgMyImageList.TheImageList to
// the listview's LargeImageList
lvTestView.LargeImageList =
imgMyImageList.TheImageList;
// Populating
foreach(object name in imgMyImageList.ImageNames)
{
lvTestView.Items.Add(
(string) name,
imgMyImageList.GetIndex((string)name));
}
// Setting some properties
lvTestView.Dock = DockStyle.Fill;
// Adding listview to the main form
Controls.Add(lvTestView);
}
public static void Main(string[] args) {
Application.Run(new MyImageList_TestApp() );
}
}
}
更新(Updates)
|2002年11月22日(22 Nov2002)|
-
更新的下载.(Updated downloads.)
2002年8月9日(09 Aug 2002) -
Beta源代码已添加到(Beta source code added to)Imlmaker.zip
-
最终源代码以及正在进行的文档(Final source code with documentation in progress) | |2002年6月1日(01 June 2002)|
-
长目录名的错误已解决.(Long directory names bug has been solved.) |
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C# C++ Win2K WinXP Windows .NET .NET1.0 Visual-Studio Dev 新闻 翻译