本文整理匯總了C#中ColorValue.ToArgb方法的典型用法代碼示例。如果您正苦於以下問題:C# ColorValue.ToArgb方法的具體用法?C# ColorValue.ToArgb怎麽用?C# ColorValue.ToArgb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ColorValue
的用法示例。
在下文中一共展示了ColorValue.ToArgb方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DrawRectangle
/// <summary>Draw a rectangle</summary>
public void DrawRectangle(System.Drawing.Rectangle rect, ColorValue color)
{
// Offset the rectangle
rect.Offset(dialogX, dialogY);
// If caption is enabled, offset the Y position by its height
if (hasCaption)
rect.Offset(0, captionHeight);
// Get the integer value of the color
int realColor = color.ToArgb();
// Create some vertices
CustomVertex.TransformedColoredTextured[] verts = {
new CustomVertex.TransformedColoredTextured((float)rect.Left - 0.5f, (float)rect.Top -0.5f, 0.5f, 1.0f, realColor, 0, 0),
new CustomVertex.TransformedColoredTextured((float)rect.Right - 0.5f, (float)rect.Top -0.5f, 0.5f, 1.0f, realColor, 0, 0),
new CustomVertex.TransformedColoredTextured((float)rect.Right - 0.5f, (float)rect.Bottom -0.5f, 0.5f, 1.0f, realColor, 0, 0),
new CustomVertex.TransformedColoredTextured((float)rect.Left - 0.5f, (float)rect.Bottom -0.5f, 0.5f, 1.0f, realColor, 0, 0),
};
// Get the device
Device device = SampleFramework.Device;
// Since we're doing our own drawing here, we need to flush the sprites
DialogResourceManager.GetGlobalInstance().Sprite.Flush();
// Preserve the devices current vertex declaration
using (VertexDeclaration decl = device.VertexDeclaration)
{
// Set the vertex format
device.VertexFormat = CustomVertex.TransformedColoredTextured.Format;
// Set some texture states
device.TextureState[0].ColorOperation = TextureOperation.SelectArg2;
device.TextureState[0].AlphaOperation = TextureOperation.SelectArg2;
// Draw the rectangle
device.DrawUserPrimitives(PrimitiveType.TriangleFan, 2, verts);
// Reset some texture states
device.TextureState[0].ColorOperation = TextureOperation.Modulate;
device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
// Restore the vertex declaration
device.VertexDeclaration = decl;
}
}