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

📄 axstatusbarpanel.cs

📁 C#实现DHTML编辑器功能!
💻 CS
字号:
// DINAMIC XML Editor
//
// Copyright (c) 2002-2003 Dusan Hlavaty
// mailto: duddo@atlas.cz
//
// This software is licensed under the terms of
// GNU General Public license
//
using System;
using System.Collections;
using System.Drawing;
using System.Windows.Forms;

namespace XML_editor.MyComponents
{
	/// <summary>
	/// Reprezentuje StatusPanel - pouziva sa v <see cref="AxStatusBar"/> namiesto
	/// povodneho <see cref="StatusBarPanel"/>
	/// </summary>
	public class AxStatusBarPanel : StatusBarPanel
	{
		private StringFormat sFormat = new StringFormat();
		
		// -------------------------------------------------------------------------
		/// <summary>
		/// Inicializuje instanciu <see cref="AxStatusBarPanel"/>
		/// </summary>
		public AxStatusBarPanel()
		{
			Style       = StatusBarPanelStyle.OwnerDraw;
			BorderStyle = StatusBarPanelBorderStyle.None;
			
			sFormat.LineAlignment = StringAlignment.Center;
		}
		
		// -------------------------------------------------------------------------
		/// <summary>
		/// Vykresli okraj okolo tohoto <c>StatusBarPanela</c>
		/// </summary>
		/// <param name="drawEventArgs"></param>
		protected virtual void DrawBorder(StatusBarDrawItemEventArgs drawEventArgs)
		{
			drawEventArgs.Graphics.DrawRectangle(SystemPens.ControlDark, 
			                                     new Rectangle(drawEventArgs.Bounds.X,
			                                                   drawEventArgs.Bounds.Y,
			                                                   drawEventArgs.Bounds.Width - 1,
			                                                   drawEventArgs.Bounds.Height - 1));
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Vykresli samotny <c>StatusBarPanel</c>
		/// </summary>
		/// <param name="drawEventArgs"></param>
		public virtual void DrawPanel(StatusBarDrawItemEventArgs drawEventArgs)
		{
			Graphics g = drawEventArgs.Graphics;
			switch (Alignment) 
			{
				case HorizontalAlignment.Left:
					sFormat.Alignment = StringAlignment.Near;
					break;
				case HorizontalAlignment.Center:
					sFormat.Alignment = StringAlignment.Center;
					break;
				case HorizontalAlignment.Right:
					sFormat.Alignment = StringAlignment.Far;
					break;
			}
			g.DrawString(Text,
			             drawEventArgs.Font,
			             SystemBrushes.ControlText, 
			             drawEventArgs.Bounds,
			             sFormat);
			DrawBorder(drawEventArgs);
		}
		
		// -------------------------------------------------------------------------
		/// <summary>
		/// Vola sa pri odstranovani panela z pamate
		/// </summary>
		/// <param name="disposing"></param>
		protected override void Dispose(bool disposing)
		{
			if (disposing) 
			{
				sFormat.Dispose();
			}
		}

	} // class AxStatusBarPanel
} // namespace XML_editor.MyComponents

⌨️ 快捷键说明

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