你的位置:软件开发定制多少钱 > 软件开发价格 > 软件定制开发 Winform圆角按钮(无锯齿)

软件定制开发 Winform圆角按钮(无锯齿)

发布日期:2024-08-09 08:56    点击次数:164

引子:不知谈从什么时候运行,群众心爱上了这种平滑式的筹算,对于原本简大致单、方耿介正的筹算运行置之不睬了(我到当今还独爱Windows 8的筹算);在Winform上作念出来这种平滑的后果相对来说依然相比虚浮的,不像CSS一滑代码就可惩处。

对于圆角的代码念念必许多东谈主皆用GDI+齐全过,然而径直的后果可能不太理念念,大部分情况下皆有锯齿;其实对于纯色配景的情况下,这种锯齿依然不错消震恐的。

图片软件定制开发

底下是一段绘图圆角的代码,然而这么径直绘图出来的话,就会产生锯齿

 private void DrawRoundRegion()        {            Rectangle rect = new Rectangle(-1, -1, base.Width + 1, base.Height);            Rectangle rect2 = new Rectangle(rect.Location, new Size(_roundRadius, _roundRadius));            GraphicsPath graphicsPath = new GraphicsPath();            graphicsPath.AddArc(rect2, 180f, 90f);//左上角            rect2.X = rect.Right - _roundRadius;            graphicsPath.AddArc(rect2, 270f, 90f);//右上角            rect2.Y = rect.Bottom - _roundRadius;            rect2.Width += 1;            rect2.Height += 1;            graphicsPath.AddArc(rect2, 360f, 90f);//右下角               rect2.X = rect.Left;            graphicsPath.AddArc(rect2, 90f, 90f);//左下角            graphicsPath.CloseFigure();            base.Region = new Region(graphicsPath);        }

废除锯齿,对圆角区域进行填充

福彩双色球上周星期四(第2024076期)开出奖号:03 22 24 27 29 32 + 15,其中红球大小比为5:1,奇偶比为3:3,软件定制开发012路比为3:1:2,无连码,出现1个重复号码。

纵观大乐透上市至今累计2594期开奖,开出前区跨度10的次数不多,算上本次共计开出22次,该形态占比只有0.84%。

private void FillRoundRegion(Graphics graphics)        {            Rectangle rect = ClientRectangle;            Rectangle rect2 = new Rectangle(rect.Location, new Size(_roundRadius, _roundRadius));            GraphicsPath graphicsPath = new GraphicsPath();            graphicsPath.AddArc(rect2, 180f, 90f);//左上角            rect2.X = rect.Right - _roundRadius - 1;            graphicsPath.AddArc(rect2, 270f, 90f);//右上角            rect2.Y = rect.Bottom - _roundRadius - 1;            graphicsPath.AddArc(rect2, 0f, 90f);//右下角               rect2.X = rect.Left;            graphicsPath.AddArc(rect2, 90f, 90f);//左下角            graphicsPath.CloseFigure();            graphics.FillPath(new SolidBrush(HoverBackColor == Color.Empty ? _BackColor : HoverBackColor), graphicsPath);        }

在Paint事件中进行调用

软件开发
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;            if (RoundRadius > 0)            {                DrawRoundRegion();                FillRoundRegion(e.Graphics);            }

底下不错看下加第二段代码与不加的分手

图片

图片

不错发现后果依然很较着的,临了咱们为了浅易使用加入一个Type类型,来齐全大致的换色后果

图片

按钮自界说控件已封装:

☛☛☛点击取得☚☚☚

图片

本站仅提供存储作事,系数执行均由用户发布,如发现存害或侵权执行,请点击举报。