Show / Hide Table of Contents

Class IconComponent

Inheritance
object
IconComponent
Implements
IIconComponent
IPalComponent
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: OpenTK.Platform.Native.Windows
Assembly: OpenTK.Platform.dll
Syntax
public class IconComponent : IIconComponent, IPalComponent

Properties

CanLoadSystemIcons

If common system icons can be created. If this is true then Create(SystemIconType) will work, otherwise an exception will be thrown.

Declaration
public bool CanLoadSystemIcons { get; }
Property Value
Type Description
bool
See Also
Create(SystemIconType)

Logger

The logger that this component uses to log diagnostic messages.

Declaration
public ILogger? Logger { get; set; }
Property Value
Type Description
ILogger
See Also
ILogger
Logger

Name

Name of the abstraction layer component.

Declaration
public string Name { get; }
Property Value
Type Description
string

Provides

Specifies which PAL components this object provides.

Declaration
public PalComponents Provides { get; }
Property Value
Type Description
PalComponents

Methods

Create(SystemIconType)

Load a system icon. Only works if CanLoadSystemIcons is true.

Declaration
public IconHandle Create(SystemIconType systemIcon)
Parameters
Type Name Description
SystemIconType systemIcon

The system icon to create.

Returns
Type Description
IconHandle

A handle to the created system icon.

Exceptions
Type Condition
PlatformNotSupportedException

Platform does not implement this function. See CanLoadSystemIcons.

See Also
CanLoadSystemIcons

Create(int, int, ReadOnlySpan<byte>)

Load an icon object with image data.

Declaration
public IconHandle Create(int width, int height, ReadOnlySpan<byte> data)
Parameters
Type Name Description
int width

Width of the bitmap.

int height

Height of the bitmap.

ReadOnlySpan<byte> data

Image data to load into icon in RGBA format.

Returns
Type Description
IconHandle

A handle to the created icon.

Exceptions
Type Condition
ArgumentOutOfRangeException

If width, or height are negative.

ArgumentException

data is smaller than specified dimensions.

CreateFromIcoFile(string)

Creates an icon from a windows .ico file.

Declaration
public IconHandle CreateFromIcoFile(string file)
Parameters
Type Name Description
string file

The icon file to load.

Returns
Type Description
IconHandle
Remarks

This icon will have a dynamic resolution.

CreateFromIcoResource(byte[])

Creates an icon from resx ico resource data.

Declaration
public IconHandle CreateFromIcoResource(byte[] resource)
Parameters
Type Name Description
byte[] resource

The ico resource data to load.

Returns
Type Description
IconHandle
Remarks

This icon will not have a dynamic resoltion. The icon will only have one resolution. To get an icon with a dynamic resoltion, use CreateFromIcoFile(string) or CreateFromIcoResource(string).

CreateFromIcoResource(string)

Creates an icon from a resource name.

Declaration
public IconHandle CreateFromIcoResource(string resourceName)
Parameters
Type Name Description
string resourceName

The name of the icon resource to load.

Returns
Type Description
IconHandle
Remarks

This icon will have a dynamic resolution.

To use this function you need to create and include a resource file in your exe. To do this, first create a .rc resource definition file and include your icon. Then you need to compile that file into a .res file using rc.exe, the resource compiler. Lastly you need to include that .res file in your csproj using the <Win32Resource> property. FIXME: Write a guide on how to compile .rc files and include a .res file using <Win32Resource>.

Destroy(IconHandle)

Destroy an icon object.

Declaration
public void Destroy(IconHandle handle)
Parameters
Type Name Description
IconHandle handle

Handle to the icon object to destroy.

See Also
Create(SystemIconType)
Create(int, int, ReadOnlySpan<byte>)

GetBitmapByteSize(IconHandle)

Declaration
public int GetBitmapByteSize(IconHandle handle)
Parameters
Type Name Description
IconHandle handle
Returns
Type Description
int

GetBitmapData(IconHandle, Span<byte>)

Declaration
public void GetBitmapData(IconHandle handle, Span<byte> data)
Parameters
Type Name Description
IconHandle handle
Span<byte> data

GetSize(IconHandle, out int, out int)

Get the dimensions of a icon object.

Declaration
public void GetSize(IconHandle handle, out int width, out int height)
Parameters
Type Name Description
IconHandle handle

Handle to icon object.

int width

Width of the icon.

int height

Height of icon.

Initialize(ToolkitOptions)

Initialize the component.

Declaration
public void Initialize(ToolkitOptions options)
Parameters
Type Name Description
ToolkitOptions options

The options to initialize the component with.

See Also
ToolkitOptions
Init(ToolkitOptions)

Uninitialize()

Uninitialize the component. Frees any native resources used by the component.

Declaration
public void Uninitialize()
See Also
Uninit()

Implements

IIconComponent
IPalComponent
In this article
Back to top Generated by DocFX