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

首頁(yè) > 編程 > C# > 正文

winform創(chuàng)建不規(guī)則窗體的方法

2020-01-24 01:28:47
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

本文實(shí)例講述了winform創(chuàng)建不規(guī)則窗體的方法。分享給大家供大家參考。具體如下:

using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;using Microsoft.Win32;using System.Drawing.Drawing2D;using System.IO;namespace WindowsApplication2{ public partial class Form3 : Form {  public Form3()  {   InitializeComponent();   this.FormBorderStyle = FormBorderStyle.None;   ColorConverter colorconvert = new ColorConverter();   this.BackColor = (Color)colorconvert.ConvertFromString("window");   this.TransparencyKey = (Color)colorconvert.ConvertFromString("window");  }  private void button1_Click(object sender, EventArgs e)  {   this.Close();  }  protected override void OnPaint(PaintEventArgs e)  {   Graphics g = e.Graphics;   Rectangle mainRect = new Rectangle(0, 0, 695, 278);   Region mainRegion = new Region(mainRect);   e.Graphics.SetClip(mainRegion, CombineMode.Replace);   //設(shè)置窗體的外觀形式   Point point1 = new Point(0, 32);   Point point2 = new Point(9, 20);   Point point3 = new Point(21, 13);   Point point4 = new Point(34, 9);   // 創(chuàng)建一個(gè)以點(diǎn)為元素的數(shù)組   Point[] curvePoints = { point1, point2, point3, point4 };   // 創(chuàng)建一個(gè)GraphicsPath 對(duì)象并添加一條曲線   GraphicsPath gPath = new GraphicsPath();   gPath.AddCurve(curvePoints, 0, 3, 0.8f);   gPath.AddLine(36, 9, 378, 9);   point1.X = 378; point1.Y = 9;   point2.X = 387; point2.Y = 5;   point3.X = 394; point3.Y = 0;   Point[] curvePoints2 = { point1, point2, point3 };   gPath.AddCurve(curvePoints2, 0, 2, 0.8f);   gPath.AddLine(394, 0, 0, 0);   Region rg = new Region(gPath);   e.Graphics.ExcludeClip(rg);  //可以為任意圖片   string str = Directory.GetCurrentDirectory() + "http://2.png";   Image img = Image.FromFile(str);   e.Graphics.DrawImage(img, 0, 0, 695, 278);   // 重設(shè)剪切好的區(qū)域   e.Graphics.ResetClip();  } }}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 恭城| 雅江县| 南京市| 灵山县| 南陵县| 营口市| 东港市| 曲周县| 海南省| 阜城县| 淮滨县| 龙陵县| 新干县| 蒲城县| 石棉县| 迭部县| 涿鹿县| 关岭| 蓬安县| 滁州市| 宁城县| 独山县| 宝坻区| 正阳县| 永年县| 苏尼特左旗| 朝阳区| 旺苍县| 迭部县| 宣恩县| 长乐市| 获嘉县| 崇左市| 大田县| 西宁市| 朝阳市| 靖安县| 司法| 江源县| 民权县| 武隆县|