本文整理汇总了C#中System.Drawing.Rectangle.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.GetHashCode方法的具体用法?C# Rectangle.GetHashCode怎么用?C# Rectangle.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.GetHashCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Paint
/// <summary>
/// render the key onto a graphics object surface
/// </summary>
/// <param name="g">graphics instance to use, usually from Paint callback</param>
/// <param name="keyWidth">key is drawn with this width</param>
/// <param name="keyDrawArea">defines the main key area on the owning form</param>
public void Paint(
Graphics g,
GradientKeyVisualStyle style,
Int32 keyWidth,
Rectangle keyDrawArea,
bool selected)
{
Int32 xLoc = keyDrawArea.Left + (Int32)((Double)keyDrawArea.Width * mPosition);
Int32 keyBtnWidth = keyWidth >> 1;
ButtonState buttonStyle = ButtonState.Normal;
Border3DStyle borderStyle = Border3DStyle.Sunken;
// sort out visual style for the key
switch (style)
{
case GradientKeyVisualStyle.Flat:
{
buttonStyle = ButtonState.Flat;
borderStyle = selected?Border3DStyle.SunkenInner:Border3DStyle.Flat;
}
break;
case GradientKeyVisualStyle.Raised:
{
buttonStyle = ButtonState.Normal;
borderStyle = selected?Border3DStyle.Sunken:Border3DStyle.SunkenOuter;
}
break;
case GradientKeyVisualStyle.Sunken:
{
buttonStyle = ButtonState.Pushed;
borderStyle = selected?Border3DStyle.SunkenInner:Border3DStyle.RaisedInner;
}
break;
}
// regenerate the bounding box if it has been nullified or
// if the parent volume has changed
if (mBounds.IsEmpty || (keyDrawArea.GetHashCode() != mBoundHash))
{
mBounds = new Rectangle(
xLoc - keyBtnWidth,
keyDrawArea.Top - GradientKeyLipHeight,
keyWidth,
keyDrawArea.Height + GradientKeyLipHeight);
// save hash code of parent volume for future comparisons
mBoundHash = keyDrawArea.GetHashCode();
}
// render a button to act as the key container graphic
ControlPaint.DrawButton(
g,
mBounds.Left,
mBounds.Top,
mBounds.Width,
mBounds.Height,
buttonStyle);
// create new color brush if not already generated
if (mDrawColorBrush == null)
mDrawColorBrush = new SolidBrush(mColor);
// draw a color block to show the color set on this key
Rectangle colorBlock = new Rectangle(
mBounds.Left + GradientKeyInteriorRim,
mBounds.Top + GradientKeyLipHeight,
mBounds.Width - (GradientKeyInteriorRim << 1),
mBounds.Height - GradientKeyLipHeight - GradientKeyInteriorRim);
if (style == GradientKeyVisualStyle.Flat)
{
colorBlock.Inflate(-1, -1);
}
g.FillRectangle(mDrawColorBrush, colorBlock);
// sink the color block to give it some depth, and sink it
// fully if this key is being selected and moved about
ControlPaint.DrawBorder3D(
g,
colorBlock,
borderStyle);
}