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.
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.
|
CSharpUtilities::MultiIcon::MultiIcon | ( | String | filepath | ) | [inline] |
Construct from a String specifying the path to the icon file.
filepath | Path pointing to the chosen icon file. |
CSharpUtilities::MultiIcon::MultiIcon | ( | Stream | stream | ) | [inline] |
Construct from an object Stream holding the icons.
stream | Stream holding the icon data. |
CSharpUtilities::MultiIcon::MultiIcon | ( | Icon[] | icons | ) | [inline] |
Construct from an array of icons.
icons | Array of icons to module as a MultiIcon. |
CSharpUtilities::MultiIcon::MultiIcon | ( | Bitmap | bitmap | ) | [inline] |
Construct from a single bitmap.
bitmap | Single bitmap to module as a MultiIcon. |
CSharpUtilities::MultiIcon::MultiIcon | ( | Icon | icon | ) | [inline] |
Construct from a single Icon.
icon | Single icon to module as a MultiIcon. |
Icon CSharpUtilities::MultiIcon::GetLargestIcon | ( | ) | [inline] |
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())
Icon CSharpUtilities::MultiIcon::GetSmallestIcon | ( | ) | [inline] |
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())
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.
maximumSize | The constraint size. The returned Icon must fit in this size. |
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)).
maximumSize | The constraint size. The returned Icon must fit in this size. |
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.
minimumSize | The constraint size. Each of the icon's dimensions must be greater than or equal to the corresponding dimension from this Size. |
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)).
minimumSize | The constraint size. Each of the icon's dimensions must be greater than or equal to the corresponding dimension from this Size. |
static Image CSharpUtilities::MultiIcon::ConvertIconToImage | ( | Icon | icon | ) | [inline, static] |
Converts the given Icon to a bitmap image.
icon | Icon to convert to an Image. |
static Icon CSharpUtilities::MultiIcon::ScaleIcon | ( | Icon | originalIcon, |
Size | finalSize | ||
) | [inline, static] |
Scales the given Icon to finalSize, producing a new Icon instance.
originalIcon | The original Icon to resize. This Icon instance will not be affected. |
finalSize | The desired final size for the resulting scaled Icon. |
Icon [] CSharpUtilities::MultiIcon::Icons
[get] |
The list of Icons contained in this MultiIcon.