CSharpUtilities::MultiIcon Class Reference


Detailed Description

MultiIcon is a reader and container for icon resources.

Although an .ico file may be authored to include multiple icons, the .NET Framework lacks any useful way to manage these files.

This implementation is inspired by this article on CodeProject: http://www.codeproject.com/dotnet/MultiIcon.asp The .ico file format is documented there as well.

CSharpUtilities.MultiIcon can be used as a ResXFileRef in a .resx file in C#, but it doesn't seem to work in C++/CLI. Until we solve that, the resource can be typed as a System.IO.MemoryStream in the resx file, and then the MultiIcon constructor will extract the icons from that stream.

List of all members.

Classes

class   SizeAreaComparer
  Helper IComparer class for comaparing two Sizes by area.

Public Member Functions

  MultiIcon (String filepath)
  Construct from a String specifying the path to the icon file.
  MultiIcon (Stream stream)
  Construct from an object Stream holding the icons.
  MultiIcon (Icon[] icons)
  Construct from an array of icons.
  MultiIcon (Bitmap bitmap)
  Construct from a single bitmap.
  MultiIcon (Icon icon)
  Construct from a single Icon.
Icon  GetLargestIcon ()
  Get the largest Icon contained in this MultiIcon.
Image  GetLargestImage ()
  Get the largest Icon contained in this MultiIcon, converted to an Image.
Icon  GetSmallestIcon ()
  Get the smallest Icon contained in this MultiIcon.
Image  GetSmallestImage ()
  Get the smallest Icon contained in this MultiIcon, converted to an Image.
Icon  GetLargestIconNotLargerThan (Size maximumSize)
  Get the largest Icon from this MultiIcon that fits within the given maximum Size.
Image  GetLargestImageNotLargerThan (Size maximumSize)
  Get the largest Icon from this MultiIcon that fits within the given maximum Size, converted to an Image.
Icon  GetSmallestIconNotSmallerThan (Size minimumSize)
  Get the smallest Icon from this MultiIcon that completely covers the given minimum Size.
Image  GetSmallestImageNotSmallerThan (Size minimumSize)
  Get the smallest Icon from this MultiIcon that completely covers the given minimum Size, converted to an Image.

Static Public Member Functions

static Image  ConvertIconToImage (Icon icon)
  Converts the given Icon to a bitmap image.
static Icon  ScaleIcon (Icon originalIcon, Size finalSize)
  Scales the given Icon to finalSize, producing a new Icon instance.

Properties

Icon[]  Icons [get]
  The list of Icons contained in this MultiIcon.

Constructor & Destructor Documentation

CSharpUtilities::MultiIcon::MultiIcon ( String  filepath ) [inline]

Construct from a String specifying the path to the icon file.

Parameters:
filepath Path pointing to the chosen icon file.
CSharpUtilities::MultiIcon::MultiIcon ( Stream  stream ) [inline]

Construct from an object Stream holding the icons.

Parameters:
stream Stream holding the icon data.
CSharpUtilities::MultiIcon::MultiIcon ( Icon[]  icons ) [inline]

Construct from an array of icons.

Parameters:
icons Array of icons to module as a MultiIcon.
CSharpUtilities::MultiIcon::MultiIcon ( Bitmap  bitmap ) [inline]

Construct from a single bitmap.

Parameters:
bitmap Single bitmap to module as a MultiIcon.
CSharpUtilities::MultiIcon::MultiIcon ( Icon  icon ) [inline]

Construct from a single Icon.

Parameters:
icon Single icon to module as a MultiIcon.

Member Function Documentation

Icon CSharpUtilities::MultiIcon::GetLargestIcon ( ) [inline]

Get the largest Icon contained in this MultiIcon.

The largest Icon size is determined by comparing the areas of each Icon.

Returns:
The largest Icon contained in this MultiIcon.
Image CSharpUtilities::MultiIcon::GetLargestImage ( ) [inline]

Get the largest Icon contained in this MultiIcon, converted to an Image.

The largest Icon size is determined by comparing the areas of each Icon. This method is equivalent to ConvertIconToImage(GetLargestIcon())

Returns:
The largest Icon contained in this MultiIcon, converted to an Image.
Icon CSharpUtilities::MultiIcon::GetSmallestIcon ( ) [inline]

Get the smallest Icon contained in this MultiIcon.

The smallest Icon size is determined by comparing the areas of each Icon.

Returns:
The smallest Icon contained in this MultiIcon.
Image CSharpUtilities::MultiIcon::GetSmallestImage ( ) [inline]

Get the smallest Icon contained in this MultiIcon, converted to an Image.

The smallest Icon size is determined by comparing the areas of each Icon. This method is equivalent to ConvertIconToImage(GetSmallestIcon())

Returns:
The smallest Icon contained in this MultiIcon, converted to an Image.
Icon CSharpUtilities::MultiIcon::GetLargestIconNotLargerThan ( Size  maximumSize ) [inline]

Get the largest Icon from this MultiIcon that fits within the given maximum Size.

"Fits" means that Icon.Width <= maximumSize.Width and Icon.Height <= maximumSize.Height.

Parameters:
maximumSize The constraint size. The returned Icon must fit in this size.
Returns:
The largest icon from this MultiIcon that fits within maximumSize, or null if no such Icon is found.
Image CSharpUtilities::MultiIcon::GetLargestImageNotLargerThan ( Size  maximumSize ) [inline]

Get the largest Icon from this MultiIcon that fits within the given maximum Size, converted to an Image.

"Fits" means that Icon.Width <= maximumSize.Width and Icon.Height <= maximumSize.Height. Equivalent to ConvertIconToImage(GetLargestIconNotLargerThan(maximumSize)).

Parameters:
maximumSize The constraint size. The returned Icon must fit in this size.
Returns:
The largest icon from this MultiIcon that fits within maximumSize, or null if no such Icon is found.
Icon CSharpUtilities::MultiIcon::GetSmallestIconNotSmallerThan ( Size  minimumSize ) [inline]

Get the smallest Icon from this MultiIcon that completely covers the given minimum Size.

Covering the minimum size means that minimumSize.Width <= Icon.Width and maximumSize.Height <= Icon.Height.

Parameters:
minimumSize The constraint size. Each of the icon's dimensions must be greater than or equal to the corresponding dimension from this Size.
Returns:
The smallest Icon from this MultiIcon that covers minimumSize, or null if no such Icon is found.
Image CSharpUtilities::MultiIcon::GetSmallestImageNotSmallerThan ( Size  minimumSize ) [inline]

Get the smallest Icon from this MultiIcon that completely covers the given minimum Size, converted to an Image.

Covering the minimum size means that minimumSize.Width <= Icon.Width and maximumSize.Height <= Icon.Height. This method is equivalent to ConvertIconToImage(GetSmallestIconNotSmallerThan(minimumSize)).

Parameters:
minimumSize The constraint size. Each of the icon's dimensions must be greater than or equal to the corresponding dimension from this Size.
Returns:
The smallest Icon from this MultiIcon that covers minimumSize, or null if no such Icon is found.
static Image CSharpUtilities::MultiIcon::ConvertIconToImage ( Icon  icon ) [inline, static]

Converts the given Icon to a bitmap image.

Parameters:
icon Icon to convert to an Image.
Returns:
Image created from the given icon.
static Icon CSharpUtilities::MultiIcon::ScaleIcon ( Icon  originalIcon,
Size  finalSize 
) [inline, static]

Scales the given Icon to finalSize, producing a new Icon instance.

Parameters:
originalIcon The original Icon to resize. This Icon instance will not be affected.
finalSize The desired final size for the resulting scaled Icon.
Returns:
A new Icon, created by scaling the originalIcon to finalSize.

Property Documentation

Icon [] CSharpUtilities::MultiIcon::Icons [get]

The list of Icons contained in this MultiIcon.


CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon
CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon CSharpUtilities::MultiIcon