using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Reflection; namespace ControlsDraw { public partial class IconDialog : Form { public static Icon myIcon; public bool m_IsConfim = true; public bool IsConfim { get { return m_IsConfim; } } public IconDialog() { InitializeComponent(); } private void IconDialog_Load(object sender, EventArgs e) { Type type = typeof(SystemIcons); foreach(PropertyInfo pi in type.GetProperties()) { listIcon.Items.Add((Icon)pi.GetValue(null,null)); } } private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { ListBox myList = (ListBox)sender; if (e.Index == -1 || sender == null) { return; } string c = listIcon.Items[e.Index].ToString(); e.DrawBackground(); e.DrawFocusRectangle(); Rectangle rect = e.Bounds; rect.Offset(10, 2); rect.Width = 30; rect.Height -= 10; rect.Offset(1, 1); e.Graphics.DrawIcon((Icon)myList.Items[e.Index], rect); } private void btnConfim_Click(object sender, EventArgs e) { if (listIcon.SelectedItem != null) { myIcon = (Icon)listIcon.SelectedItem; m_IsConfim = true; } else { m_IsConfim = false; } this.Close(); } private void btnCancel_Click(object sender, EventArgs e) { m_IsConfim = false; this.Close(); } } }
制作IconDialog
最新推荐文章于 2019-07-10 09:35:14 发布