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

📄 axprogressstatusbarpanel.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 StatusBar panel pre moj <see cref="AxStatusBar"/> - a obsahuje
	/// 'v sebe' progress bar.
	/// </summary>
	public class AxProgressStatusBarPanel : StatusBarPanel
	{
		private int _maximum;
		private int _value;
		private bool _progress_visible = false;

		// -------------------------------------------------------------------------
		/// <summary>
		/// Maximalna hodnota progress baru
		/// </summary>
		public int Maximum 
		{
			get 
			{
				return _maximum;
			}
			set 
			{
				_maximum = value;
				if (this.Parent != null) 
				{
					this.Parent.Invalidate();
				}
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Aktualna hodnota progress baru
		/// </summary>
		public int Value
		{
			get
			{
				return _value;
			}
			set
			{
				_value = value;
				if (this.Parent != null) 
				{
					this.Parent.Invalidate();
				}
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// <c>true</c> = ked ma byt progress bar viditelny; inak <c>false</c>
		/// </summary>
		public bool ProgressVisible 
		{
			get 
			{
				return _progress_visible;
			}
			set
			{
				_progress_visible = value;
				if (this.Parent != null) 
				{
					this.Parent.Invalidate();
				}
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Inicializuje instanciu <see cref="AxProgressStatusBarPanel"/>
		/// </summary>
		public AxProgressStatusBarPanel()
		{
			Style       = StatusBarPanelStyle.OwnerDraw;
			BorderStyle = StatusBarPanelBorderStyle.None;
		}
		
		// -------------------------------------------------------------------------
		/// <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;

			if (ProgressVisible == true) 
			{
				if (this.Maximum <= this.Value) 
				{
					// Ak je hodnota vacsia - alebo je 100% progress
					g.FillRectangle(new SolidBrush(System.Drawing.SystemColors.HotTrack), drawEventArgs.Bounds);
				} 
				else 
				{
					// ak je value nenulove vypocitame sirku progress baru
					if (this.Value > 0) 
					{
						int newwidth = (this.Value * drawEventArgs.Bounds.Width) / this.Maximum;
						g.FillRectangle(new SolidBrush(System.Drawing.SystemColors.HotTrack),
														drawEventArgs.Bounds.X,
                            drawEventArgs.Bounds.Y,
														newwidth,
														drawEventArgs.Bounds.Height);
					}
				}
			}
			DrawBorder(drawEventArgs);
		}

	} // class AxProgressStatusBarPanel
} // namespace XML_editor.MyComponents

⌨️ 快捷键说明

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