Setup

  1. Include Z.IconLibrary.dll library to your project reference

Methods

Following method can be used in a WinForm project:

  • [Icon].GetBitmap16()
  • [Icon].GetBitmap32()
  • [Icon].GetIcon16()
  • [Icon].GetIcon32()
  • [Icon].GetImage16()
  • [Icon].GetImage32()
  • [Icon].GetStream16()
  • [Icon].GetStream32()

WinForm Examples

Download source code to try Web/WinForm example.



using System;
using System.Drawing;
using System.Windows.Forms;
using Icon = Z.IconLibrary.Icon;

namespace Z.Examples.WinForm
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            uiIcon.DataSource = Enum.GetValues(typeof(Icon));

            // SET static icon
            uiImage16.Image = IconLibrary.Icon.Accept.GetImage16();
            uiImage32.Image = IconLibrary.Icon.Accept.GetImage32();
            uiIcon16.Image = IconLibrary.Icon.Accept.GetIcon16().ToBitmap();
            uiIcon32.Image = IconLibrary.Icon.Accept.GetIcon32().ToBitmap();
            uiBitmap16.Image = IconLibrary.Icon.Accept.GetBitmap16();
            uiBitmap32.Image = IconLibrary.Icon.Accept.GetBitmap32();
            using (var stream = IconLibrary.Icon.Accept.GetStream16())
            {
                uiStream16.Image = new Bitmap(stream);
            }
            using (var stream = IconLibrary.Icon.Accept.GetStream32())
            {
                uiStream32.Image = new Bitmap(stream);
            }
        }

        private void uiIcon_SelectedIndexChanged(object sender, EventArgs e)
        {
            var dynamicIcon = (Icon)Enum.Parse(typeof(Icon), uiIcon.SelectedValue.ToString());
            uiDynamicImage16.Image = dynamicIcon.GetImage16();
            uiDynamicImage32.Image = dynamicIcon.GetImage32();
            uiDynamicIcon16.Image = dynamicIcon.GetIcon16().ToBitmap();
            uiDynamicIcon32.Image = dynamicIcon.GetIcon32().ToBitmap();
            uiDynamicBitmap16.Image = dynamicIcon.GetBitmap16();
            uiDynamicBitmap32.Image = dynamicIcon.GetBitmap32();
            using (var stream = dynamicIcon.GetStream16())
            {
                uiDynamicStream16.Image = new Bitmap(stream);
            }
            using (var stream = dynamicIcon.GetStream32())
            {
                uiDynamicStream32.Image = new Bitmap(stream);
            }
        }
    }
}

 

Last edited Feb 15, 2014 at 11:38 AM by Jonathan_Magnan, version 14