本文整理汇总了C#中IResourceResolver.OpenResource方法的典型用法代码示例。如果您正苦于以下问题:C# IResourceResolver.OpenResource方法的具体用法?C# IResourceResolver.OpenResource怎么用?C# IResourceResolver.OpenResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IResourceResolver
的用法示例。
在下文中一共展示了IResourceResolver.OpenResource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FromEmbeddedResource
/// <summary>
/// Instantiates an active template from an embedded resource.
/// </summary>
/// <param name="resource"></param>
/// <param name="resolver"></param>
/// <returns></returns>
public static ActiveTemplate FromEmbeddedResource(string resource, IResourceResolver resolver)
{
using (var stream = resolver.OpenResource(resource))
{
using (var reader = new StreamReader(stream))
{
return new ActiveTemplate(reader);
}
}
}
示例2: FlashOverlayController
/// <summary>
/// Constructs a controller that uses the 32-bit colour ARGB bitmap specified by the resource name and resource resolver.
/// </summary>
/// <param name="resourceName">The partially or fully qualified name of the resource to access.</param>
/// <param name="resourceResolver">A resource resolver for the resource.</param>
public FlashOverlayController(string resourceName, IResourceResolver resourceResolver) : this()
{
using (Bitmap bitmap = new Bitmap(resourceResolver.OpenResource(resourceName)))
{
BitmapData data = bitmap.LockBits(new Rectangle(Point.Empty, bitmap.Size), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
try
{
int length = data.Stride*data.Height;
_pixelData = new byte[length];
_rows = data.Height;
_columns = data.Width;
Marshal.Copy(data.Scan0, _pixelData, 0, length);
}
finally
{
bitmap.UnlockBits(data);
}
}
}
示例3: FromCursorResource
private static CursorWrapper FromCursorResource(string cursorResource, IResourceResolver resolver)
{
return new CursorWrapper(new Cursor(resolver.OpenResource(cursorResource)), true);
}
示例4: FromImageResource
private static CursorWrapper FromImageResource(string imageResource, IResourceResolver resolver)
{
Bitmap bitmap = new Bitmap(resolver.OpenResource(imageResource));
IntPtr hIcon = bitmap.GetHicon();
//we can dispose of the bitmap right away because the icon is a separate resource.
bitmap.Dispose();
Cursor cursor = new Cursor(hIcon);
return new CursorWrapper(cursor, hIcon);
}
示例5: CreateIcon
/// <summary>
/// Attempts to create an icon using the specified image resource and resource resolver.
/// </summary>
/// <param name="resource">The name of the image resource</param>
/// <param name="resolver">A resource resolver</param>
/// <returns>a bitmap constructed from the specified image resource</returns>
public static Bitmap CreateIcon(string resource, IResourceResolver resolver)
{
return new Bitmap(resolver.OpenResource(resource));
}
示例6: FlashOverlayController
/// <summary>
/// Constructs a controller that uses the 32-bit colour ARGB bitmap specified by the resource name and resource resolver.
/// </summary>
/// <param name="resourceName">The partially or fully qualified name of the resource to access.</param>
/// <param name="resourceResolver">A resource resolver for the resource.</param>
/// <exception cref="ArgumentNullException">Thrown if <paramref name="resourceName"/> is empty or NULL, or <paramref name="resourceResolver"/> is NULL.</exception>
public FlashOverlayController(string resourceName, IResourceResolver resourceResolver)
: this()
{
Platform.CheckForEmptyString(resourceName, "resourceName");
Platform.CheckForNullReference(resourceResolver, "resourceResolver");
using (Bitmap bitmap = new Bitmap(resourceResolver.OpenResource(resourceName)))
{
_pixelData = ExtractBitmap(bitmap, out _rows, out _columns);
}
}