Skip to main content

PixelSize Struct

Definition

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia

Represents a size in device pixels.

public struct PixelSize

Inheritance: ValueType -> PixelSize

Implements: IEquatable<PixelSize>

Constructors

NameDescription
PixelSizeInitializes a new instance of the Avalonia.PixelSize structure.

PixelSize Constructor

Initializes a new instance of the Avalonia.PixelSize structure.

public PixelSize(int width, int height)

Parameters

width int

The width.

height int

The height.

Methods

NameDescription
Equals (2 overloads)Returns a boolean indicating whether the size is equal to the other given size.
FromSize (2 overloads)Converts a Avalonia.Size to device pixels using the specified scaling factor.
FromSizeWithDpi (2 overloads)Converts a Avalonia.Size to device pixels using the specified dots per inch (DPI).
GetHashCodeReturns a hash code for a Avalonia.PixelSize.
ParseParses a Avalonia.PixelSize string.
ToSize (2 overloads)Converts the Avalonia.PixelSize to a device-independent Avalonia.Size using the specified scaling factor.
ToSizeWithDpi (2 overloads)Converts the Avalonia.PixelSize to a device-independent Avalonia.Size using the specified dots per inch (DPI).
ToStringReturns the string representation of the size.
TryParseNo summary available.
WithHeightReturns a new Avalonia.PixelSize with the same width and the specified height.
WithWidthReturns a new Avalonia.PixelSize with the same height and the specified width.

Equals overloads

Equals Method

Returns a boolean indicating whether the size is equal to the other given size.

public bool Equals(Avalonia.PixelSize other)
Parameters

other Avalonia.PixelSize

The other size to test equality against.

Returns

bool

True if this size is equal to other; False otherwise.

Equals Method

Checks for equality between a size and an object.

public bool Equals(object obj)
Parameters

obj object

The object.

Returns

bool

True if obj is a size that equals the current size.

FromSize overloads

FromSize Method

Converts a Avalonia.Size to device pixels using the specified scaling factor.

public Avalonia.PixelSize FromSize(Avalonia.Size size, Avalonia.Vector scale)
Parameters

size Avalonia.Size

The size.

scale Avalonia.Vector

The scaling factor.

Returns

Avalonia.PixelSize

The device-independent size.

FromSize Method

Converts a Avalonia.Size to device pixels using the specified scaling factor.

public Avalonia.PixelSize FromSize(Avalonia.Size size, double scale)
Parameters

size Avalonia.Size

The size.

scale double

The scaling factor.

Returns

Avalonia.PixelSize

The device-independent size.

FromSizeWithDpi overloads

FromSizeWithDpi Method

Converts a Avalonia.Size to device pixels using the specified dots per inch (DPI).

public Avalonia.PixelSize FromSizeWithDpi(Avalonia.Size size, Avalonia.Vector dpi)
Parameters

size Avalonia.Size

The size.

dpi Avalonia.Vector

The dots per inch.

Returns

Avalonia.PixelSize

The device-independent size.

FromSizeWithDpi Method

Converts a Avalonia.Size to device pixels using the specified dots per inch (DPI).

public Avalonia.PixelSize FromSizeWithDpi(Avalonia.Size size, double dpi)
Parameters

size Avalonia.Size

The size.

dpi double

The dots per inch.

Returns

Avalonia.PixelSize

The device-independent size.

GetHashCode Method

Returns a hash code for a Avalonia.PixelSize.

public int GetHashCode()

Returns

int

The hash code.

Parse Method

Parses a Avalonia.PixelSize string.

public Avalonia.PixelSize Parse(string s)

Parameters

s string

The string.

Returns

Avalonia.PixelSize

The Avalonia.PixelSize.

Exceptions

ToSize overloads

ToSize Method

Converts the Avalonia.PixelSize to a device-independent Avalonia.Size using the specified scaling factor.

public Avalonia.Size ToSize(Avalonia.Vector scale)
Parameters

scale Avalonia.Vector

The scaling factor.

Returns

Avalonia.Size

The device-independent size.

ToSize Method

Converts the Avalonia.PixelSize to a device-independent Avalonia.Size using the specified scaling factor.

public Avalonia.Size ToSize(double scale)
Parameters

scale double

The scaling factor.

Returns

Avalonia.Size

The device-independent size.

ToSizeWithDpi overloads

ToSizeWithDpi Method

Converts the Avalonia.PixelSize to a device-independent Avalonia.Size using the specified dots per inch (DPI).

public Avalonia.Size ToSizeWithDpi(Avalonia.Vector dpi)
Parameters

dpi Avalonia.Vector

The dots per inch.

Returns

Avalonia.Size

The device-independent size.

ToSizeWithDpi Method

Converts the Avalonia.PixelSize to a device-independent Avalonia.Size using the specified dots per inch (DPI).

public Avalonia.Size ToSizeWithDpi(double dpi)
Parameters

dpi double

The dots per inch.

Returns

Avalonia.Size

The device-independent size.

ToString Method

Returns the string representation of the size.

public string ToString()

Returns

string

The string representation of the size.

TryParse Method

public bool TryParse(string source, Avalonia.PixelSize& result)

Parameters

source string

result Avalonia.PixelSize&

Returns

bool

WithHeight Method

Returns a new Avalonia.PixelSize with the same width and the specified height.

public Avalonia.PixelSize WithHeight(int height)

Parameters

height int

The height.

Returns

Avalonia.PixelSize

The new Avalonia.PixelSize.

WithWidth Method

Returns a new Avalonia.PixelSize with the same height and the specified width.

public Avalonia.PixelSize WithWidth(int width)

Parameters

width int

The width.

Returns

Avalonia.PixelSize

The new Avalonia.PixelSize.

Properties

NameDescription
AspectRatioGets the aspect ratio of the size.
HeightGets the height.
WidthGets the width.

AspectRatio Property

Gets the aspect ratio of the size.

public double AspectRatio { get; set; }

Height Property

Gets the height.

public int Height { get; set; }

Width Property

Gets the width.

public int Width { get; set; }

Fields

NameDescription
EmptyA size representing zero

Empty Field

A size representing zero

public Avalonia.PixelSize Empty