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

📄 basepane.cs

📁 Upload Source code in temp folder
💻 CS
字号:
/* *************************************************
 * Development : Rajesh Lal(connectrajesh@hotmail.com)
 * Date: 04/15/2007
 * Company Info: www.csharptricks.com
 * See EULA.txt and Copyright.txt for additional information
 * **************************************************/
using System.Diagnostics;
using Microsoft.VisualBasic;
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Collections;
using System.ComponentModel;

// Base class for the three panes. Draws caption at top with using
// a different gradient fill if the pane is active or inactive.


namespace PenFlicksDemo
{
	public class BasePane : System.Windows.Forms.UserControl
	{
		
		
		// events
		// raise when the pane becomes active
		public delegate void PaneActiveEventHandler(object sender, EventArgs e);
		private PaneActiveEventHandler PaneActiveEvent;
		
		public event PaneActiveEventHandler PaneActive
		{
			add
			{
				PaneActiveEvent = (PaneActiveEventHandler) System.Delegate.Combine(PaneActiveEvent, value);
			}
			remove
			{
				PaneActiveEvent = (PaneActiveEventHandler) System.Delegate.Remove(PaneActiveEvent, value);
			}
		}
		
		
		// internal members
		// pane caption
		private PaneCaption caption;
		
		// properties
		
		protected PaneCaption CaptionControl
		{
			get
			{
				return caption;
			}
		}
		
		[Description("The pane caption."), Category("Appearance")]public string CaptionText
		{
			get
			{
				return caption.Text;
			}
			
			set
			{
				caption.Text = value;
			}
		}
		
		public bool Active
		{
			get
			{
				return caption.Active;
			}
		}
		
		// ctor
		public BasePane() 
		{
			
			// set double buffer styles
			this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true);
			
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();
		}
		
		#region " Windows Form Designer generated code "
		private System.ComponentModel.Container components =null;
		
		protected override void Dispose (bool disposing)
		{
			if (disposing)
			{
				if (!(components == null))
				{
					components.Dispose();
				}
			}
			
			base.Dispose(disposing);
		}
		
		
		private void InitializeComponent ()
		{
			this.caption = new PenFlicksDemo.PaneCaption();
			this.SuspendLayout();
			//
			//caption
			//
			this.caption.Dock = System.Windows.Forms.DockStyle.Top;
			this.caption.Font = new System.Drawing.Font("Arial", 9.0F, System.Drawing.FontStyle.Bold);
			this.caption.Location = new System.Drawing.Point(1, 1);
			this.caption.Name = "caption";
			this.caption.Size = new System.Drawing.Size(214, 20);
			this.caption.TabIndex = 0;
			//
			//BasePane
			//
			this.Controls.Add(this.caption);
			this.DockPadding.All = 1;
			this.Name = "BasePane";
			this.Size = new System.Drawing.Size(216, 248);
			this.ResumeLayout(false);
			
		}
		
		#endregion
		
		// internal methods
		
		// received focus, make this the active pane
		protected override void OnEnter (System.EventArgs e)
		{
			base.OnEnter(e);
			caption.Active = true;
			if (PaneActiveEvent != null)
				PaneActiveEvent(this, EventArgs.Empty);
		}
		
		// lost focus, not the active pane
		protected override void OnLeave (System.EventArgs e)
		{
			base.OnLeave(e);
			caption.Active = false;
		}
		
		// draw border around the pane
		protected override void OnPaint (PaintEventArgs e)
		{
			Rectangle rc = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
			rc.Inflate(- this.DockPadding.All + 1, - this.DockPadding.All + 1);
			e.Graphics.DrawRectangle(SystemPens.ControlDark, rc);
			base.OnPaint(e);
		}
		
		protected override void OnResize (System.EventArgs e)
		{
			base.OnResize(e);
			
			// manually resize the caption width if in the visual designer
			if (this.DesignMode)
			{
				caption.Width = this.Width;
			}
		}
		
	}
	
}

⌨️ 快捷键说明

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