国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C# > 正文

winform創建不規則窗體的方法

2019-10-29 21:38:50
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了winform創建不規則窗體的方法,涉及C#窗體創建的相關參數設置技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了winform創建不規則窗體的方法。分享給大家供大家參考。具體如下:

 

 
  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.ComponentModel; 
  4. using System.Data; 
  5. using System.Drawing; 
  6. using System.Text; 
  7. using System.Windows.Forms; 
  8. using Microsoft.Win32; 
  9. using System.Drawing.Drawing2D; 
  10. using System.IO; 
  11. namespace WindowsApplication2 
  12. public partial class Form3 : Form 
  13. public Form3() 
  14. InitializeComponent(); 
  15. this.FormBorderStyle = FormBorderStyle.None; 
  16. ColorConverter colorconvert = new ColorConverter(); 
  17. this.BackColor = (Color)colorconvert.ConvertFromString("window"); 
  18. this.TransparencyKey = (Color)colorconvert.ConvertFromString("window"); 
  19. private void button1_Click(object sender, EventArgs e) 
  20. this.Close(); 
  21. protected override void OnPaint(PaintEventArgs e) 
  22. Graphics g = e.Graphics; 
  23. Rectangle mainRect = new Rectangle(0, 0, 695, 278); 
  24. Region mainRegion = new Region(mainRect); 
  25. e.Graphics.SetClip(mainRegion, CombineMode.Replace); 
  26. //設置窗體的外觀形式 
  27. Point point1 = new Point(0, 32); 
  28. Point point2 = new Point(9, 20); 
  29. Point point3 = new Point(21, 13); 
  30. Point point4 = new Point(34, 9); 
  31. // 創建一個以點為元素的數組 
  32. Point[] curvePoints = { point1, point2, point3, point4 }; 
  33. // 創建一個GraphicsPath 對象并添加一條曲線 
  34. GraphicsPath gPath = new GraphicsPath(); 
  35. gPath.AddCurve(curvePoints, 0, 3, 0.8f); 
  36. gPath.AddLine(36, 9, 378, 9); 
  37. point1.X = 378; point1.Y = 9; 
  38. point2.X = 387; point2.Y = 5; 
  39. point3.X = 394; point3.Y = 0; 
  40. Point[] curvePoints2 = { point1, point2, point3 }; 
  41. gPath.AddCurve(curvePoints2, 0, 2, 0.8f); 
  42. gPath.AddLine(394, 0, 0, 0); 
  43. Region rg = new Region(gPath); 
  44. e.Graphics.ExcludeClip(rg); 
  45. //可以為任意圖片 
  46. string str = Directory.GetCurrentDirectory() + "//2.png"
  47. Image img = Image.FromFile(str); 
  48. e.Graphics.DrawImage(img, 0, 0, 695, 278); 
  49. // 重設剪切好的區域 
  50. e.Graphics.ResetClip(); 

希望本文所述對大家的C#程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 汝城县| 志丹县| 磴口县| 泰顺县| 定西市| 图片| 静安区| 南木林县| 许昌县| 叙永县| 琼中| 方山县| 尚志市| 连平县| 威远县| 会东县| 新安县| 丽水市| 长武县| 始兴县| 广昌县| 新宾| 呼图壁县| 乡城县| 泰宁县| 三原县| 德惠市| 铜鼓县| 灵川县| 元朗区| 闵行区| 临安市| 新化县| 于都县| 龙川县| 开鲁县| 凤阳县| 洪雅县| 外汇| 天台县| 贵港市|