IconContext

References
public sealed class IconContext
Context used during the rendering of icons. It encodes both the transformation from icon to render space, as well as the estimated background colour.

Constructors

IconContext

#
public IconContext(Context context, RectangleF frame, Color background, IconPalette palette, Func<Color, Color> filter)
Create a new icon context.
context (Context)Graphics context.
frame (RectangleF)Target frame.
background (Color)Background colour estimate.
palette (IconPalette)Palette to use.
filter (Func<Color, Color>)Colour filter to use.

IconContext

#
public IconContext(Context context, RectangleF frame, Color background)
Create a new icon context.
context (Context)Graphics context.
frame (RectangleF)Target frame.
background (Color)Background colour estimate.

Properties

Background

#
public Color Background { get; }
Gets the average/estimated background colour for this icon.

Context

#
public Context Context { get; }
Gets the graphics context for this draw event.

Filter

#
public Func<Color, Color> Filter { get; }
Gets the filter to apply to icon colours. Note that this may not affect all colours used by icons.

Frame

#
public RectangleF Frame { get; }
Gets the dimensions of the target frame.

FrameVisualSize

#
public float FrameVisualSize { get; }
Gets the smallest visual dimensions of the frame. This equals the Min(Width, Height) multiplied by the zoom.

Palette

#
public IconPalette Palette { get; }
Gets the icon palette tied to this context.

Scaling

#
public float Scaling { get; }
Gets the scaling factor for the current context state. The scaling is computed by dividing the Frame size by the icon size as part of SetupTransform(SizeF).

Zoom

#
public float Zoom { get; }
Gets the zoom factor of the frame graphics. Typically you do not need to do anything with this, but some vector graphics elements may choose to alter their display based on their final physical size.

Methods

AddSpecialColoursToMenu

#
public static void AddSpecialColoursToMenu(MenuItemCollection menu, EventHandler<EventArgs> handler, SpecialColour current = SpecialColour.None)
Add all defined special icon colours to a menu.
menu (MenuItemCollection)Menu collection to append to.
handler (EventHandler<EventArgs>)CLick handler. The sender will be a Command and the argument will be a SpecialColour.
current (SpecialColour = SpecialColour.None)Current special colour, used to set a check mark.

MakeSpecialColour

#
public static Color MakeSpecialColour(SpecialColour code)
Create an ARGB colour which hints at a special colour.
code (SpecialColour)Code.
ARGB colour.

Modify

#
public IconContext Modify(RectangleF? newFrame = null, Color? newBackground = null)
Modify this context.
newFrame (RectangleF? = null)If specified, the new framing.
newBackground (Color? = null)If specified, the new background.

ResolveSpecialColour

#
public Color ResolveSpecialColour(Color colour)
Resolve a special colour, leave regular colours unmolested.
colour (Color)Special colour to resolve.
Resolved colour or original colour.

ResolveSpecialColour

#
public Color ResolveSpecialColour(SpecialColour specialColour)
Resolve a special colour.
specialColour (SpecialColour)Special colour to resolve.
Actual colour associated with the special code.

SetupTransform

#
public void SetupTransform(SizeF iconSize)
Set up the required transformation details for a specific icon. This method *must* be called before any of the Transform methods are invoked.
iconSize (SizeF)Size of icon.

Transform

#
public ArcF Transform(ArcF value)
Transform an arc into frame space.
value (ArcF)Arc to transform.
Transformed arc.

Transform

#
public BezierF Transform(BezierF value)
Transform a bezier curve into frame space.
value (BezierF)Bezier to transform.
Transformed bezier.

Transform

#
public CircleF Transform(CircleF value)
Transform a circle into frame space.
value (CircleF)Circle to transform.
Transformed circle.

Transform

#
public EllipseF Transform(EllipseF value)
Transform an ellipse into frame space.
value (EllipseF)Ellipse to transform.
Transformed ellipse.

Transform

#
public float Transform(float value)
Transform a numeric value into frame space.
value (float)Value to transform.
Transformed value.

Transform

#
public LineF Transform(LineF value)
Transform a line into frame space.
value (LineF)Line to transform.
Transformed line.

Transform

#
public PointF Transform(PointF value)
Transform a point into frame space.
value (PointF)Point to transform.
Transformed point.

Transform

#
public PointF[] Transform(PointF[] values)
Transform a bunch of points into frame space.
values (PointF[])Points to transform.
Transformed points.

Transform

#
public RectangleF Transform(RectangleF value)
Transform a rectangle into frame space.
value (RectangleF)Rectangle to transform.
Transformed rectangle.

Transform

#
public SizeF Transform(SizeF value)
Transform a size into frame space.
value (SizeF)Size to transform.
Transformed size.

WithDisabledFilter

#
public IconContext WithDisabledFilter()
Modify the filter of this context to the standard disabled filter.

WithFadingFilter

#
public IconContext WithFadingFilter(Color background, float factor)
Modify the filter of this context to the standard blending filter.
background (Color)
factor (float)

WithFilter

#
public IconContext WithFilter(Func<Color, Color> filter)
Modify the filter of this context.
filter (Func<Color, Color>)

WithGreyscaleFilter

#
public IconContext WithGreyscaleFilter()
Modify the filter of this context to the standard disabled filter.

WithPalette

#
public IconContext WithPalette(IconPalette palette)
Assign a new icon palette to this context.
palette (IconPalette)