本文整理匯總了C#中System.Drawing.Icon.GetToolkitImage方法的典型用法代碼示例。如果您正苦於以下問題:C# Icon.GetToolkitImage方法的具體用法?C# Icon.GetToolkitImage怎麽用?C# Icon.GetToolkitImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Icon
的用法示例。
在下文中一共展示了Icon.GetToolkitImage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DrawIcon
// Draw an icon.
public void DrawIcon(Icon icon, Rectangle targetRect)
{
if(icon == null)
{
throw new ArgumentNullException("icon");
}
if(targetRect.Width == icon.Width &&
targetRect.Height == icon.Height)
{
// This is the easy case.
ToolkitDrawIcon(icon, targetRect.X, targetRect.Y);
}
else
{
// Stretch and draw the image.
Point[] src = ConvertUnits
(0, 0, icon.Width, icon.Height, GraphicsUnit.Pixel);
Point[] dest = ConvertRectangle3
(targetRect.X, targetRect.Y,
targetRect.Width, targetRect.Height, pageUnit);
BaseOffsetPoints(dest);
lock(this)
{
IToolkitImage toolkitImage = icon.GetToolkitImage(this);
if(toolkitImage != null)
{
ToolkitGraphics.DrawImage
(toolkitImage, src, dest);
}
}
}
}
示例2: DrawIconUnstretched
public void DrawIconUnstretched(Icon icon, Rectangle targetRect)
{
if(icon == null)
{
throw new ArgumentNullException("icon");
}
int width = icon.Width;
int height = icon.Height;
if(width <= targetRect.Width && height <= targetRect.Height)
{
// No truncation is necessary, so use the easy case.
ToolkitDrawIcon(icon, targetRect.X, targetRect.Y);
}
else
{
// Only draw as much as will fit in the target rectangle.
if(width > targetRect.Width)
{
width = targetRect.Width;
}
if(height > targetRect.Height)
{
height = targetRect.Height;
}
Point[] src = ConvertUnits
(0, 0, width, height, GraphicsUnit.Pixel);
Point[] dest = ConvertRectangle3
(targetRect.X, targetRect.Y, width, height, pageUnit);
BaseOffsetPoints(dest);
lock(this)
{
IToolkitImage toolkitImage = icon.GetToolkitImage(this);
if(toolkitImage != null)
{
ToolkitGraphics.DrawImage
(toolkitImage, src, dest);
}
}
}
}
示例3: ToolkitDrawIcon
// Draw an unstretched complete icon via the toolkit.
private void ToolkitDrawIcon(Icon icon, int x, int y)
{
lock(this)
{
IToolkitImage toolkitImage = icon.GetToolkitImage(this);
if(toolkitImage != null)
{
ConvertPoint(ref x, ref y, pageUnit);
ToolkitGraphics.DrawImage
(toolkitImage, x + baseWindow.X,
y + baseWindow.Y);
}
}
}