<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      先上效果圖

       

      參考

      1. 代碼分享:給窗體添加水印 - 陳恩點 - 博客園 (cnblogs.com)
      2. WinForm添加水印 - 白衣如花 - 博客園

      思路

      使用透明無框窗體覆蓋需要添加水印的窗體,并設置owner為主窗體。然后在透明窗體繪制水印文本即可。

      代碼

        1 public class Watermark
        2 {
        3     private string text;
        4     private int gap;
        5     private Font font = new Font("微軟雅黑", 16, FontStyle.Regular);
        6     private Color color = Color.FromArgb(255, 0, 0, 0);
        7 
        8     private Form form = new Form();
        9 
       10     public Watermark(Form ownerForm, string text = "Watermark", int gap = 75, double opacity = 0.1, Font font = null, Color? color = null)
       11     {
       12         this.text = text;
       13         this.gap = gap;
       14         if (font != null)
       15         {
       16             this.font = font;
       17         }
       18         if (color.HasValue)
       19         {
       20             this.color = color.Value;
       21         }
       22         form.Size = ownerForm.Size;
       23         ownerForm.SizeChanged += OwnerForm_SizeChanged;
       24         ownerForm.Move += OwnerForm_Move;
       25 
       26         form.Owner = ownerForm;
       27         form.FormBorderStyle = FormBorderStyle.None;
       28         form.Opacity = opacity;
       29         form.ShowInTaskbar = false;
       30         form.TransparencyKey = Color.White;
       31         form.BackColor = Color.White;
       32 
       33         form.Paint += Form_Paint;
       34         form.Show();
       35 
       36 
       37         GetWindowLong(form.Handle, GWL_EXSTYLE);
       38         SetWindowLong(form.Handle, GWL_EXSTYLE, WS_EX_TRANSPARENT | WS_EX_LAYERED);
       39     }
       40 
       41     private void OwnerForm_Move(object sender, EventArgs e)
       42     {
       43         form.Location = ((Form)sender).Location;
       44     }
       45 
       46     private void OwnerForm_SizeChanged(object sender, EventArgs e)
       47     {
       48         form.Size = ((Form)sender).Size;
       49     }
       50     private void Form_Paint(object sender, PaintEventArgs e)
       51     {
       52         const float cos30 = 0.866f;
       53         const float sin30 = 0.5f;
       54         var g = e.Graphics;
       55         g.SmoothingMode = SmoothingMode.AntiAlias;
       56         g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
       57         //平移畫布到需要畫印章的位置
       58         g.TranslateTransform(0, gap);
       59         //逆時針旋轉30度
       60         g.RotateTransform(-30);
       61         // 繪制畫布區域
       62         //g.FillRectangle(new SolidBrush(Color.FromArgb(50, 100, 100, 100)), 0, 0, frm.Width, frm.Height);
       63         for (int x = 5; x < e.ClipRectangle.Right + gap; x += gap * 2)
       64         {
       65             for (int y = 5; y < e.ClipRectangle.Bottom + gap; y += gap * 2)
       66             {
       67                 // 計算文字起點位置
       68                 float x1 = cos30 * x - sin30 * y;
       69                 float y1 = sin30 * x + cos30 * y;
       70                 //畫上文字
       71                 g.DrawString(text, font, new SolidBrush(color), x1, y1);
       72             }
       73         }
       74     }
       75 
       76     #region 在窗口結構中為指定的窗口設置信息
       77     /// <summary>
       78     /// 在窗口結構中為指定的窗口設置信息
       79     /// </summary>
       80     /// <param name="hwnd">欲為其取得信息的窗口的句柄</param>
       81     /// <param name="nIndex">欲取回的信息</param>
       82     /// <param name="dwNewLong">由nIndex指定的窗口信息的新值</param>
       83     /// <returns></returns>
       84     [DllImport("user32", EntryPoint = "SetWindowLong")]
       85     private static extern uint SetWindowLong(IntPtr hwnd, int nIndex, uint dwNewLong);
       86     #endregion
       87 
       88     #region 從指定窗口的結構中取得信息
       89     /// <summary>
       90     /// 從指定窗口的結構中取得信息
       91     /// </summary>
       92     /// <param name="hwnd">欲為其獲取信息的窗口的句柄</param>
       93     /// <param name="nIndex">欲取回的信息</param>
       94     /// <returns></returns>
       95     [DllImport("user32", EntryPoint = "GetWindowLong")]
       96     private static extern uint GetWindowLong(IntPtr hwnd, int nIndex);
       97     #endregion
       98 
       99     private const uint WS_EX_LAYERED = 0x80000;
      100     private const int WS_EX_TRANSPARENT = 0x20;
      101     private const int GWL_EXSTYLE = (-20);
      102 }

       

      使用

      1 public Form1()
      2 {
      3     InitializeComponent();
      4     new Watermark(this);
      5 }

       

      posted on 2024-06-14 09:40  什么鬼-  閱讀(553)  評論(0)    收藏  舉報

      主站蜘蛛池模板: 午夜精品福利亚洲国产| 人妻蜜臀久久av不卡| 久久婷婷综合色一区二区| 久久99国产精品尤物| 亚洲女同在线播放一区二区| 国产亚洲精品中文字幕| 亚洲肥老太bbw中国熟女| 久久精品亚洲精品国产区| 亚洲第一综合天堂另类专| 她也色tayese在线视频| 国产亚洲精品成人av久| 亚洲一区二区三区自拍天堂| 中国农村真卖bbwbbw| 亚洲人成小说网站色在线 | 久久亚洲欧美日本精品| 国产精品一在线观看| 精品无码国产污污污免费| 国产精品va在线观看无码不卡| 中文字幕亚洲人妻一区| 宜君县| 狠狠噜天天噜日日噜无码| 在线观看成人年视频免费| 国产午夜精品理论大片| 男人的天堂av一二三区| 性欧美vr高清极品| 亚洲精品无码久久一线| 极品无码国模国产在线观看| 人妻少妇精品性色av蜜桃| 日韩精品国产中文字幕| 国产精品九九九一区二区| 国产欧美在线观看一区| 亚洲欧美高清在线精品一区二区| 99久久国产综合精品色| 精品国产中文字幕av| 人人爽人人爽人人片av东京热 | 深夜视频国产在线观看| 人妻熟女av一区二区三区| 精品国产精品午夜福利| 亚洲最大成人av免费看| a片在线免费观看| 久久精品国产亚洲成人av|