AbstractIcon

References
public abstract class AbstractIcon : IIcon
Abstract implementation of IIcon. Consider deriving from this base class rather than implementing IIcon from scratch. This class also has many static creation methods for creating IIcon instances from a variety of data.

Constructors

AbstractIcon

#
protected AbstractIcon(IconType type)
Abstract base class constructor.
type (IconType)Icon type.

Properties

States

#
public IEnumerable<IconState> States { get; }
Enumerate over all state names.
States

Type

#
public IconType Type { get; }
Gets the type of icon.
Type

Methods

AddState

#
protected void AddState(IconState state)
Add a state to this icon. This method ought to be called from the constructor of derived types only.
state (IconState)State to add.

Draw

#
public void Draw(IconContext context)
Render this icon into a graphics context.
context (IconContext)Graphics context for icon.
Draw

DrawDropShadow

#
public Bitmap DrawDropShadow(Size size, int blur, float strength)
Create a bitmap containing the drop shadow of this icon.
size (Size)Size of the icon in pixels.
blur (int)Amount of blurring.
strength (float)Darkness of shadow.
A bitmap with only black pixels and varying transparencies. The size of this bitmap is the provided size plus padding to cater for the blurring.

DrawInternal

#
protected abstract void DrawInternal(IconContext context)
Render the icon.
context (IconContext)

DrawToBitmap

#
public Bitmap DrawToBitmap(Size size, int padding, Color background)
Render the icon to a bitmap.
size (Size)Size of bitmap.
padding (int)Number of padding pixels around entire image.
background (Color)Icon background colour. Note that the actual bitmap will be drawn on a Transparent background. This argument merely informs those parts of icon that case about background/foreground contrast.
Rendered bitmap.
DrawToBitmap

FindState

#
public IconState FindState(string name)
Find the icon state with the specified name.
name (string)Name to search for.
Icon state with given name or null.
FindState

FromBitmap

#
public static IIcon FromBitmap(params Bitmap[] bitmaps)
Create an image from an Eto bitmap.
bitmaps (params Bitmap[])Bitmap.
Image.

FromFile

#
public static IIcon FromFile(string fileName)
Create an icon from a grasshopper icon file (*.ghicon).
fileName (string)Filename.
Image or null if file is not a valid image file.

FromResource

#
public static IIcon FromResource(string name, Assembly assembly)
Create an icon from named, embedded resources in the supplied assembly.
name (string)Name or full path of resource. Missing '.ghicon' suffixes will be automatically included.
assembly (Assembly)Assembly containing the resource.

FromResource

#
public static IIcon FromResource(string name, Type type)
Create an icon from named, embedded resources in the assembly associated with the supplied type.
name (string)Name or full path of resource. Missing '.ghicon' suffixes will be automatically included.
type (Type)Type associated with assembly containing the resource.

FromResource

#
public static IIcon FromResource(Type type)
Create an icon from named, embedded resources in the assembly associated with the supplied type.
type (Type)Type associated with both the name of the icon and the assembly containing the resource.

FromStream

#
public static IIcon FromStream(Stream stream)
Create an icon from a stream of data. The stream must contain data written by a IStorable type. VectorIcon is but one example of such a type.
stream (Stream)Stream.
Icon or null if stream cannot be parsed.

HandleStateChange

#
protected virtual void HandleStateChange(IconState state)
Override this method if you need to respond to state changes as they happen.
state (IconState)

MoveState

#
public void MoveState(double value, string name = null, Duration? duration = null, Motion? motion = null)
Move a named state to a new value over time.
value (double)State value to assign.
name (string = null)Name of state. Leave blank to set the default state.
duration (Duration? = null)Animation duration. Leave blank to re-use the previous duration.
motion (Motion? = null)Animation motion. Leave blank to re-use the previous motion.
MoveState

SetState

#
public void SetState(double value, string name = null)
Set the value of a named state immediately.
value (double)State value to assign.
name (string = null)Name of state. Leave blank to set the default state.
SetState