ClassResourceHelper
Provides utility methods for loading and manipulating embedded assembly resources.
Definition
Namespace:Telerik.WinControls
Assembly:Telerik.WinControls.dll
Syntax:
public static class ResourceHelper
Inheritance: objectResourceHelper
Methods
CursorFromResource(Type, string)
Creates a new cursor from an embedded resource in the assembly containing the specified type.
Declaration
public static Cursor CursorFromResource(Type type, string resourceName)
Parameters
type
A type from the assembly that contains the embedded resource.
resourceName
The fully qualified name of the embedded cursor resource (including namespace).
Returns
A new Cursor instance loaded from the embedded resource, or null if the resource
could not be found or loaded.
Remarks
This method safely loads a cursor from an embedded manifest resource by:
- Obtaining the assembly from the specified type
- Opening a stream to the manifest resource
- Creating a cursor directly from the stream
- Ensuring proper resource disposal regardless of outcome
The resource should be a valid cursor file (.cur) embedded as a manifest resource. The resource name should include the full namespace path, similar to other embedded resources.
Exception handling ensures that any loading errors are logged to debug output for
troubleshooting, while maintaining application stability by returning null on failure.
ImageFromResource(Type, string)
Creates a new bitmap image from an embedded resource in the assembly containing the specified type.
Declaration
public static Bitmap ImageFromResource(Type type, string resourceName)
Parameters
type
A type from the assembly that contains the embedded resource.
resourceName
The fully qualified name of the embedded resource (including namespace).
Returns
A new Bitmap instance loaded from the embedded resource, or null if the resource
could not be found or loaded.
Remarks
This method safely loads a bitmap image from an embedded manifest resource by:
- Obtaining the assembly from the specified type
- Opening a stream to the manifest resource
- Creating a temporary bitmap from the stream
- Creating a new bitmap copy to ensure proper memory management
- Disposing of temporary resources and streams
The resource name should include the full namespace path. For example, if an image is in the "Resources" folder of a project with namespace "MyProject", the resource name would be "MyProject.Resources.image.png".
Exception handling ensures that any loading errors are logged to debug output, and all resources are properly disposed of regardless of success or failure.