資源簡介
這是本人制作的三角形按鈕,文件中提供了源代碼,謹以拋磚引玉
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Drawing;
using?System.Data;
using?System.Text;
using?System.Windows.Forms;
using?System.Drawing.Drawing2D;
namespace?mybt
{
????public?partial?class?rButton?:?UserControl
????{
????????private?int?orient?=0;?
????????private?Color?color1=?Color.Red;
????????private?Color?color2?=?Color.Blue;
????????private?bool?mouseover?=?false;
????????public?int?Orient
????????{
????????????get?{?return?orient;?}
????????????set
????????????{
????????????????if?(orient!=?value)
????????????????{
????????????????????orient?=?value;
????????????????????Invalidate();
????????????????}
????????????}
????????}
????????public?Color?Color1
????????{
????????????get?{?return?color1;?}
????????????set
????????????{
????????????????if?(color1!=?value)
????????????????{
????????????????????color1?=?value;
????????????????????Invalidate();
????????????????}
????????????}
????????}
????????public?Color?Color2
????????{
????????????get?{?return?color2;?}
????????????set
????????????{
????????????????if?(color2?!=?value)
????????????????{
????????????????????color2?=?value;
????????????????????Invalidate();
????????????????}
????????????}
????????}
??????
????????public?rButton()
????????{
????????????this.Cursor?=?Cursors.Hand;
????????}
????????
????????protected?override?void?OnPaint(System.Windows.Forms.PaintEventArgs?e)
????????{
????????????Graphics?gc?=?e.Graphics;
????????????///?設置繪圖的顏色
????????????Brush?greenBrush?=?new?SolidBrush(Color.Green);
????????????
????????????Brush?b?=?new?System.Drawing.Drawing2D.LinearGradientBrush(ClientRectangle?Color1?Color2?LinearGradientMode.Vertical);
????????????Point[]?points?=?new?Point[3];
????????????switch?(Orient)
????????????{?
????????????????case?0:?points[0].X?=?0;????????????????//0--向上
????????????????????????points[0].Y?=?this.Height;
????????????????????????points[1].X?=?this.Width;
????????????????????????points[1].Y?=?this.Height;
????????????????????????points[2].X?=?this.Width?/?2;
????????????????????????points[2].Y?=?0;
????????????????????????break;
????????????????case?1:?points[0].X?=?0;????????????????//1--向下
????????????????????????points[0].Y?=?0;
????????????????????????points[1].X?=?this.Width;
????????????????????????points[1].Y?=?0;
????????????????????????points[2].X?=?this.Width?/?2;
????????????????????????points[2].Y?=?this.Height;
????????????????????????break;
????????????????case?2:?points[0].X?=?0;????????????????//2--向左
????????????????????????points[0].Y?=?this.Height/2;
????????????????????????points[1].X?=?this.Width;
????????????????????????points[1].Y?=?this.Height;
????????????????????????points[2].X?=?this.Width;
????????????????????????points[2].Y?=?0;
????????????????????????break;
????????????????default:?points[0].X?=?0;????????????????//--向右
????????????????????????points[0
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6656??2012-07-30?23:11??mybt\mybt\bin\Debug\mybt.dll
?????文件??????17920??2012-07-30?23:11??mybt\mybt\bin\Debug\mybt.pdb
?????文件???????2994??2012-07-30?23:11??mybt\mybt\mybt.csproj
?????文件????????601??2012-07-30?23:11??mybt\mybt\obj\Debug\mybt.csproj.FileListAbsolute.txt
?????文件????????776??2012-07-30?23:11??mybt\mybt\obj\Debug\mybt.csproj.GenerateResource.Cache
?????文件???????6656??2012-07-30?23:11??mybt\mybt\obj\Debug\mybt.dll
?????文件??????17920??2012-07-30?23:11??mybt\mybt\obj\Debug\mybt.pdb
?????文件????????180??2012-07-30?23:11??mybt\mybt\obj\Debug\mybt.rButton.resources
?????文件???????1444??2012-07-30?23:11??mybt\mybt\Properties\AssemblyInfo.cs
?????文件???????4075??2012-07-30?23:11??mybt\mybt\rButton.cs
?????文件???????1289??2012-07-30?23:11??mybt\mybt\rButton.Designer.cs
?????文件???????5814??2012-07-30?23:11??mybt\mybt\rButton.resx
?????文件???????1368??2012-07-30?23:11??mybt\mybt.sln
????..A..H.?????28160??2012-07-30?23:11??mybt\mybt.suo
?????文件???????6656??2012-07-30?23:11??mybt\test\bin\Debug\mybt.dll
?????文件??????17920??2012-07-30?23:11??mybt\test\bin\Debug\mybt.pdb
?????文件???????9216??2012-07-30?23:11??mybt\test\bin\Debug\test.exe
?????文件??????22016??2012-07-30?23:11??mybt\test\bin\Debug\test.pdb
?????文件??????14328??2012-07-30?23:11??mybt\test\bin\Debug\test.vshost.exe
?????文件????????490??2012-07-30?23:11??mybt\test\bin\Debug\test.vshost.exe.manifest
?????文件????????809??2012-07-30?23:11??mybt\test\Form1.cs
?????文件???????5175??2012-07-30?23:11??mybt\test\Form1.Designer.cs
?????文件???????6008??2012-07-30?23:11??mybt\test\Form1.resx
?????文件???????7617??2012-07-30?23:11??mybt\test\obj\Debug\ResolveAssemblyReference.cache
?????文件???????2444??2012-07-30?23:11??mybt\test\obj\Debug\test.csproj.FileListAbsolute.txt
?????文件????????847??2012-07-30?23:11??mybt\test\obj\Debug\test.csproj.GenerateResource.Cache
?????文件???????9216??2012-07-30?23:11??mybt\test\obj\Debug\test.exe
?????文件????????180??2012-07-30?23:11??mybt\test\obj\Debug\test.Form1.resources
?????文件??????22016??2012-07-30?23:11??mybt\test\obj\Debug\test.pdb
?????文件????????180??2012-07-30?23:11??mybt\test\obj\Debug\test.Properties.Resources.resources
............此處省略26個文件信息
- 上一篇:基于c#的實驗室設備管理系統621530
- 下一篇:C#版保齡球記分代碼
評論
共有 條評論