当前位置: 首页>>代码示例>>C#>>正文


C# ImageList.ImageSize属性代码示例

本文整理汇总了C#中System.Windows.Forms.ImageList.ImageSize属性的典型用法代码示例。如果您正苦于以下问题:C# ImageList.ImageSize属性的具体用法?C# ImageList.ImageSize怎么用?C# ImageList.ImageSize使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在System.Windows.Forms.ImageList的用法示例。


在下文中一共展示了ImageList.ImageSize属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Button1_Click

internal System.Windows.Forms.ImageList ImageList1;

// Create an ImageList Object, populate it, and display
// the images it contains.
private void Button1_Click(System.Object sender, 
    System.EventArgs e)
{

    // Construct the ImageList.
    ImageList1 = new ImageList();

    // Set the ImageSize property to a larger size 
    // (the default is 16 x 16).
    ImageList1.ImageSize = new Size(112, 112);

    // Add two images to the list.
    ImageList1.Images.Add(
        Image.FromFile("c:\\windows\\FeatherTexture.bmp"));
    ImageList1.Images.Add(
        Image.FromFile("C:\\windows\\Gone Fishing.bmp"));

    // Get a Graphics object from the form's handle.
    Graphics theGraphics = Graphics.FromHwnd(this.Handle);

    // Loop through the images in the list, drawing each image.
    for(int count = 0; count < ImageList1.Images.Count; count++)
    {
        ImageList1.Draw(theGraphics, new Point(85, 85), count);

        // Call Application.DoEvents to force a repaint of the form.
        Application.DoEvents();

        // Call the Sleep method to allow the user to see the image.
        System.Threading.Thread.Sleep(1000);
    }
}
开发者ID:.NET开发者,项目名称:System.Windows.Forms,代码行数:36,代码来源:ImageList.ImageSize

示例2: Form1

//引入命名空间
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

public class Form1 : Form
{
    private System.Windows.Forms.Button cmdFillImageList;
    private System.Windows.Forms.Button cmdPaintImages;
    private System.Windows.Forms.ImageList iconImages;

  public Form1() {
        InitializeComponent();
  }

    private void cmdFillImageList_Click(object sender, EventArgs e)
    {
        iconImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
        iconImages.ImageSize = new System.Drawing.Size(16, 16);

        string[] iconFiles = Directory.GetFiles(Application.StartupPath, "*.ico");

        foreach (string iconFile in iconFiles)
        {
            Icon newIcon = new Icon(iconFile);
            iconImages.Images.Add(newIcon);
        }
    }

    private void cmdPaintImages_Click(object sender, EventArgs e)
    {
        Graphics g = this.CreateGraphics();

        for (int i = 0; i < iconImages.Images.Count; i++)
        {
            iconImages.Draw(g, 30 + i * 30, 30, i);
        }
        g.Dispose();

    }
    private void InitializeComponent()
    {
        this.cmdFillImageList = new System.Windows.Forms.Button();
        this.cmdPaintImages = new System.Windows.Forms.Button();
        this.iconImages = new System.Windows.Forms.ImageList(new System.ComponentModel.Container());
        this.SuspendLayout();
        // 
        // cmdFillImageList
        // 
        this.cmdFillImageList.Location = new System.Drawing.Point(29, 217);
        this.cmdFillImageList.Name = "cmdFillImageList";
        this.cmdFillImageList.Size = new System.Drawing.Size(118, 23);
        this.cmdFillImageList.TabIndex = 0;
        this.cmdFillImageList.Text = "Fill Image List";
        this.cmdFillImageList.UseVisualStyleBackColor = true;
        this.cmdFillImageList.Click += new System.EventHandler(this.cmdFillImageList_Click);
        // 
        // cmdPaintImages
        // 
        this.cmdPaintImages.Location = new System.Drawing.Point(153, 217);
        this.cmdPaintImages.Name = "cmdPaintImages";
        this.cmdPaintImages.Size = new System.Drawing.Size(112, 23);
        this.cmdPaintImages.TabIndex = 1;
        this.cmdPaintImages.Text = "Paint Images";
        this.cmdPaintImages.UseVisualStyleBackColor = true;
        this.cmdPaintImages.Click += new System.EventHandler(this.cmdPaintImages_Click);
        // 
        // iconImages
        // 
        this.iconImages.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
        this.iconImages.ImageSize = new System.Drawing.Size(16, 16);
        this.iconImages.TransparentColor = System.Drawing.Color.Transparent;
        // 
        // ImageListTest
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(292, 266);
        this.Controls.Add(this.cmdPaintImages);
        this.Controls.Add(this.cmdFillImageList);
        this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
        this.Name = "ImageListTest";
        this.Text = "ImageListTest";
        this.ResumeLayout(false);

    }
  [STAThread]
  static void Main()
  {
    Application.EnableVisualStyles();
    Application.Run(new Form1());
  }

}
开发者ID:C#程序员,项目名称:System.Windows.Forms,代码行数:99,代码来源:ImageList.ImageSize


注:本文中的System.Windows.Forms.ImageList.ImageSize属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。