设为首页 加入收藏

TOP

(七十五)c#Winform自定义控件-控件水印组件(二)
2019-09-30 16:48:48 】 浏览:146
Tags:七十五 c#Winform 定义 控件 水印 组件
.ClientSize.Height) / 2); 93 } 94 95 // Translate the location so that we can use form-relative coordinates to draw on the control. 96 if (control != owner) 97 e.Graphics.TranslateTransform(-location.X, -location.Y); 98 99 // Fire a paint event. 100 OnPaint(sender, e); 101 } 102 103 private void OnPaint(object sender, PaintEventArgs e) 104 { 105 // Fire a paint event. 106 // The paint event will be handled in Form1.graphicalOverlay1_Paint(). 107 108 if (Paint != null) 109 Paint(sender, e); 110 } 111 } 112 } 113 114 namespace System.Windows.Forms 115 { 116 using System.Drawing; 117 118 public static class Extensions 119 { 120 public static Rectangle Coordinates(this Control control) 121 { 122 // Extend System.Windows.Forms.Control to have a Coordinates property. 123 // The Coordinates property contains the control's form-relative location. 124 Rectangle coordinates; 125 Form form = (Form)control.TopLevelControl; 126 127 if (control == form) 128 coordinates = form.ClientRectangle; 129 else 130 coordinates = form.RectangleToClient(control.Parent.RectangleToScreen(control.Bounds)); 131 132 return coordinates; 133 } 134 } 135 }

 

最后的话

如果你喜欢的话,请到 https://gitee.com/kwwwvagaa/net_winform_custom_control 点个星星吧

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇快速整理代码(c#) 下一篇微信小程序支付

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目