⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gpanel.cs

📁 语音视频功能 里面实现了基本的QQ与语音对话
💻 CS
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace gowk.controls
{
	/// <summary>
	/// GPanel 的摘要说明。
	/// </summary>
	public class GPanel : System.Windows.Forms.Panel
	{
		bool isRound=true;
		GColor borderColor;
		GBorderStyle gBorderStyle=GBorderStyle.Solid;
		GColor color;
		public GPanel()
		{
			this.borderColor=new GColor();
this.borderColor.Color=Color.LightBlue;
		/*	this.borderColor.NormalColor=Color.LightBlue;
			this.borderColor.ActiveColor=Color.FromArgb(80,150,240);
			this.borderColor.PressedColor=Color.Blue;*/
			this.SetStyle(ControlStyles.DoubleBuffer|ControlStyles.UserPaint|ControlStyles.AllPaintingInWmPaint,true);
		}
		public GColor GColor
		{
			get
			{
				if(this.color==null)
				{
					this.color=new GColor();
					this.color.Color=this.ForeColor;
				}
				return this.color;
			}
			set{this.color=value;}
		}
		protected override void OnPaint(PaintEventArgs e)
		{
			base.OnPaint (e);
	/*		System.Drawing.Drawing2D.PathGradientBrush b=new PathGradientBrush(this.GetPath(this.ClientRectangle));
			b.SurroundColors=new Color[]{this.BackColor,this.borderColor};
			e.Graphics.FillPath(b,this.GetPath(this.ClientRectangle));*/
			this.DrawBorder(e);
		}

		private GraphicsPath GetPath(Rectangle rect)
		{
			GraphicsPath gp;
			if(this.Width>80 && this.Height>60)
				gp=UT.CreateLargeRoundGraphicsPath(rect);
			else
				gp=UT.CreateSmallRoundGraphicsPath(rect);
			return gp;
		}
		protected internal void DrawBorder(PaintEventArgs e)
		{
			if(this.gBorderStyle==GBorderStyle.Null)return;

			Pen p=null;
			if(this.ClientRectangle.Contains(this.PointToClient(Control.MousePosition)))
			{
				if(this.Capture)
					p=new Pen(this.borderColor.PressedColor,2);
				else
					p=new Pen(this.borderColor.ActiveColor,2);
			}
			else
			{
				p=new Pen(this.borderColor.NormalColor);
			}
		//	System.Diagnostics.Trace.WriteLine(p.Color.ToString());
			switch(this.GBorderStyle)
			{
				case GBorderStyle.Dash:
					p.DashStyle=System.Drawing.Drawing2D.DashStyle.Dash;
					break;
				case GBorderStyle.Dot:
					p.DashStyle=System.Drawing.Drawing2D.DashStyle.Dot;
					break;
				case GBorderStyle.DashDot:
					p.DashStyle=System.Drawing.Drawing2D.DashStyle.DashDot;
					break;
				case GBorderStyle.DashDotDot:
					p.DashStyle=System.Drawing.Drawing2D.DashStyle.DashDotDot;
					break;
				default:
					p.DashStyle=System.Drawing.Drawing2D.DashStyle.Solid;
					break;
			}
				Rectangle rect=this.ClientRectangle;
				rect.Width-=1;
				rect.Height-=1;
			if(this.isRound)
			{
				e.Graphics.DrawPath(p,GetPath(rect));
			}
			else
				e.Graphics.DrawRectangle(p,rect);
		}
		protected override void OnMouseEnter(EventArgs e)
		{
			base.OnMouseEnter(e);
			this.Invalidate();
		}
		protected override void OnMouseLeave(EventArgs e)
		{
			base.OnMouseLeave (e);
			this.Invalidate();
		}
		protected override void OnMouseDown(MouseEventArgs e)
		{
			base.OnMouseDown (e);
			this.Invalidate();
		}
		protected override void OnMouseMove(MouseEventArgs e)
		{
			base.OnMouseMove (e);
			this.Invalidate();
		}




		public GColor BorderColor
		{
			get{return this.borderColor;}
			set{this.borderColor=value;this.Invalidate();}
		}
		public bool IsRound
		{
			get{return this.isRound;}
			set
			{
				if(this.isRound==value)return;
				this.isRound=value;
				this.SetRegion();
			}
		}
		private void SetRegion()
		{
			if(isRound)
			{
				this.Region=new Region(this.GetPath(this.ClientRectangle));
				this.Invalidate();
			}
			else
			{
				this.Region=new Region(this.ClientRectangle);
			}
		}
		protected override void OnSizeChanged(EventArgs e)
		{
			base.OnSizeChanged (e);
			this.SetRegion();
		}

		public GBorderStyle GBorderStyle
		{
			get{return this.gBorderStyle;}
			set{this.gBorderStyle=value;this.Invalidate();}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -