当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.GetHashCode方法代码示例

本文整理汇总了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);
        }
开发者ID:ishani,项目名称:Oddity,代码行数:92,代码来源:GradientKey.cs


注:本文中的System.Drawing.Rectangle.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。