Table of Contents

Class Extensions

Namespace
OFT.Rendering
Assembly
OFT.Rendering.dll

Helper extension methods of the rendering library: value comparison, stopwatch tick conversion and color helpers.

public static class Extensions
Inheritance
object
Extensions

Methods

Compare(RenderAdjustableArrowCap?, RenderAdjustableArrowCap?)

Compares two arrow caps by width and height; two null values are equal.

Added in ATAS 8.0.15.

public static bool Compare(this RenderAdjustableArrowCap? first, RenderAdjustableArrowCap? second)

Parameters

first RenderAdjustableArrowCap

First cap, can be null.

second RenderAdjustableArrowCap

Second cap, can be null.

Returns

bool

true when both are null or have the same size.

Compare(double, double)

Compares two values. The tolerance is double.Epsilon, so in practice only equal values match.

public static bool Compare(this double first, double second)

Parameters

first double

First value.

second double

Second value.

Returns

bool

true when the values are equal.

Compare(float, float)

Compares two values. The tolerance is float.Epsilon, so in practice only equal values match.

public static bool Compare(this float first, float second)

Parameters

first float

First value.

second float

Second value.

Returns

bool

true when the values are equal.

Compare(float[]?, float[]?)

Compares two arrays element by element with Compare(float, float); two null arrays are equal.

Added in ATAS 8.0.15.

public static bool Compare(this float[]? first, float[]? second)

Parameters

first float[]

First array, can be null.

second float[]

Second array, can be null.

Returns

bool

true when both are null or have the same length and values.

ConvertTicksToMSec(long)

Converts System.Diagnostics.Stopwatch ticks to whole milliseconds (truncated).

public static long ConvertTicksToMSec(this long value)

Parameters

value long

Elapsed System.Diagnostics.Stopwatch ticks.

Returns

long

The elapsed time in milliseconds.

ConvertTicksToSec(long)

Converts System.Diagnostics.Stopwatch ticks to seconds.

public static double ConvertTicksToSec(this long value)

Parameters

value long

Elapsed System.Diagnostics.Stopwatch ticks.

Returns

double

The elapsed time in seconds.

GetContrastingColor(Color)

Specifies a color (black or white) for better readability on a given background.

public static Color GetContrastingColor(this Color backgroundColor)

Parameters

backgroundColor Color

Background color.

Returns

Color

The resulting color (black or white).

GetContrastingColor(Color, Color)

Specifies a color (black or white) for better readability on a semi-transparent foreground drawn over an opaque background.

Not in ATAS 8.0.15 yet: available from the next version.

public static Color GetContrastingColor(this Color foreground, Color background)

Parameters

foreground Color

Foreground color, may be semi-transparent.

background Color

Background color the foreground is drawn over.

Returns

Color

The resulting color (black or white).

SetTransparency(Color, decimal)

Returns color with the alpha channel set from a transparency level; the original alpha is ignored.

public static Color SetTransparency(this Color color, decimal transparencyLevel)

Parameters

color Color

Source color.

transparencyLevel decimal

Transparency from 0 (opaque) to 1 (fully transparent); values outside the range are clamped.

Returns

Color

The color with the new alpha channel.

ToTextRenderingHint(RenderTextRenderingHint)

Converts a text anti-aliasing mode to the GDI+ text rendering hint: Aliased becomes SingleBitPerPixelGridFit, any other value AntiAlias.

public static TextRenderingHint ToTextRenderingHint(this RenderTextRenderingHint textRenderingHint)

Parameters

textRenderingHint RenderTextRenderingHint

Mode to convert.

Returns

TextRenderingHint

The GDI+ text rendering hint.