91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 5KB
    文件類型: .cs
    金幣: 1
    下載: 0 次
    發布日期: 2021-05-13
  • 語言: C#
  • 標簽: TextBox??邊框??圓角??

資源簡介

為Winform中的Textbox添加圓角和邊框,圓角大小和邊框大小可以設置

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Drawing;
using?System.Drawing.Drawing2D;
using?System.Linq;
using?System.Text;
using?System.Windows.Forms;
using?System.ComponentModel;

namespace?WindowsFormsApplicationGDI
{
????[ToolboxItem(true)]
????public?class?MyTextbox:TextBox
????{
????????///?
????????///?圓角值
????????///?

????????[Browsable(true)]
????????public?int?Radius?{?get;?set;?}?=?5;

????????public?int?BorderWidth?{?get;?set;?}?=?2;

????????public?Color?BorderColorForMouseHover?{?get;?set;?}?=?SystemColors.ButtonHighlight;

????????protected?override?void?onresize(EventArgs?e)
????????{
????????????base.onresize(e);
????????????this.Region=?Region?=?new?Region(GetRegionPath());
????????????
????????}
????????///?
????????///?獲取窗體有效區域路徑
????????///?

????????///?
????????private?GraphicsPath?GetRegionPath()
????????{
????????????var?graphicsPath?=?new?GraphicsPath();

????????????graphicsPath.StartFigure();
????????????graphicsPath.AddArc(this.ClientRectangle.Left?this.ClientRectangle.Top?Radius?*?2?Radius?*?2?180?90);
????????????graphicsPath.AddArc(this.ClientRectangle.Right?-?Radius?*?2?this.ClientRectangle.Top?Radius?*?2?Radius?*?2?270?90);
????????????graphicsPath.AddArc(this.ClientRectangle.Right?-?Radius?*?2?this.ClientRectangle.Bottom?-?Radius?*?2?Radius?*?2?Radius?*?2?0?90);
????????????graphicsPath.AddArc(this.ClientRectangle.Left?this.ClientRectangle.Bottom?-?Radius?*?2?Radius?*?2?Radius?*?2?90?90);
????????????graphicsPath.CloseFigure();

????????????return?graphicsPath;
????????}
????????///?
????????///?獲取重繪邊框的路徑
????????///?

????????///?
????????private?GraphicsPath?GetBorderPath()
????????{?????
????????????var?rec?=?new?Rectangle(ClientRectangle.X?+?1?ClientRectangle.Y?+?1?ClientRectangle.Width?-?2?ClientRectangle.Height?-?2);

????????????var?graphicsPath?=?new?GraphicsPath();
????????????graphicsPath.StartFigure();
????????????graphicsPath.AddArc(rec.Left?rec.Top?Radius?*?2?Radius?*?2?180?90);
????????????graphicsPath.AddArc(rec.

評論

共有 條評論