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

📄 progressdialog.cs

📁 这是一个小型的相片管理器
💻 CS
字号:
/*
Copyright (C) 2005  tommazzo

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Virtual Photo Organzier (VPO) version 1.*, Copyright (C) 2005 by tommazzo
Virtual Photo Organzier (VPO) comes with ABSOLUTELY NO WARRANTY. 
This is free software, and you are welcome to redistribute it under certain conditions.
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using VirtualPhotoOrganizer.Util;
using TXML;

namespace VirtualPhotoOrganizer.Dialogs
{
	/// <summary>
	/// a multi purpose progress dialog ProgressDialog.
	/// </summary>
	internal class ProgressDialog : System.Windows.Forms.Form
	{
		// the album creator needed for the "addPhotos" events
		AlbumCreator AlbC;

		// the HTMLExporter needed for the export events
		HTMLExporter HTMLExp;

		// the cancel event
		public delegate void Cancel();
		public event Cancel CancelProcess;

		private System.Windows.Forms.Button bCancel;
		private System.Windows.Forms.ProgressBar pBar;
		private System.Windows.Forms.Label lbAction;
		/// <summary>
		/// Erforderliche Designervariable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// constructor to be used when adding photos to an album
		/// </summary>
		public ProgressDialog(AlbumCreator ac) {
			//
			// Erforderlich f黵 die Windows Form-Designerunterst黷zung
			//
			InitializeComponent();

			LoadStrings();
			AlbC = ac;

			// hook into events
			ac.UpdateMax += new VirtualPhotoOrganizer.Util.AlbumCreator.MaxUpdate(ac_UpdateMax);
			ac.ProgressUpdate += new VirtualPhotoOrganizer.Util.AlbumCreator.UpdateProgress(ac_ProgressUpdate);
			ac.ProcessDone += new VirtualPhotoOrganizer.Util.AlbumCreator.Finish(ac_ProcessDone);
		}

		/// <summary>
		/// constructor to be used photos to an HTML album
		/// </summary>
		public ProgressDialog(HTMLExporter htex) {
			InitializeComponent();

			LoadStrings();
			HTMLExp = htex;

			// hook into events
			htex.MaxUpdate += new VirtualPhotoOrganizer.Util.HTMLExporter.UpdateMax(htex_MaxUpdate);
			htex.ProgressUpdate += new VirtualPhotoOrganizer.Util.HTMLExporter.UpdateProgress(htex_ProgressUpdate);
			htex.ProcessDone += new VirtualPhotoOrganizer.Util.HTMLExporter.Finish(htex_ProcessDone);
		}

		/// <summary>
		/// Die verwendeten Ressourcen bereinigen.
		/// </summary>
		protected override void Dispose(bool disposing) {
			if (disposing) {
				if (components != null) {
					components.Dispose();
				}
			}
			base.Dispose(disposing);
		}

		/// <summary>
		/// loads the language strings
		/// </summary>
		private void LoadStrings() {
			try {
				// load strings from file
				TXmlReader reader = XmlHandler.OpenLangFile();

				this.Text = reader.GetString("Progress", "Title", "Progress");
				bCancel.Text = reader.GetString("Progress", "Cancel", "Cancel");

				reader.Close();
			}
			catch {
				// use defaults
				this.Text = "Progress";
				bCancel.Text = "Cancel";
			}
		}


		#region Vom Windows Form-Designer generierter Code
		/// <summary>
		/// Erforderliche Methode f黵 die Designerunterst黷zung. 
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor ge鋘dert werden.
		/// </summary>
		private void InitializeComponent() {
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProgressDialog));
			this.bCancel = new System.Windows.Forms.Button();
			this.pBar = new System.Windows.Forms.ProgressBar();
			this.lbAction = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// bCancel
			// 
			this.bCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.bCancel.Location = new System.Drawing.Point(360, 96);
			this.bCancel.Name = "bCancel";
			this.bCancel.Size = new System.Drawing.Size(75, 23);
			this.bCancel.TabIndex = 0;
			this.bCancel.Text = "Cancel";
			this.bCancel.Click += new System.EventHandler(this.bCancel_Click);
			// 
			// pBar
			// 
			this.pBar.Location = new System.Drawing.Point(16, 32);
			this.pBar.Name = "pBar";
			this.pBar.Size = new System.Drawing.Size(424, 24);
			this.pBar.Step = 5;
			this.pBar.TabIndex = 1;
			// 
			// lbAction
			// 
			this.lbAction.Location = new System.Drawing.Point(16, 64);
			this.lbAction.Name = "lbAction";
			this.lbAction.Size = new System.Drawing.Size(424, 23);
			this.lbAction.TabIndex = 2;
			// 
			// ProgressDialog
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(456, 134);
			this.ControlBox = false;
			this.Controls.Add(this.lbAction);
			this.Controls.Add(this.pBar);
			this.Controls.Add(this.bCancel);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(464, 168);
			this.MinimizeBox = false;
			this.Name = "ProgressDialog";
			this.ShowInTaskbar = false;
			this.Text = "ProgressDialog";
			this.TopMost = true;
			this.ResumeLayout(false);

		}
		#endregion

		private void bCancel_Click(object sender, System.EventArgs e) {
			// let's cancel the current action
			CancelProcess();
			Application.DoEvents();
		}

		private void ac_UpdateMax(int newMax) {
			this.pBar.Maximum = newMax;
			Application.DoEvents();
		}

		private void ac_ProgressUpdate(int progress, string message) {
			lbAction.Text = message;
			pBar.Value = progress;
			Application.DoEvents();
		}

		private void ac_ProcessDone() {
			this.Close();
		}

		private void htex_MaxUpdate(int newMax, string message) {
			pBar.Maximum = newMax;
			lbAction.Text = message;
			Application.DoEvents();
		}

		private void htex_ProgressUpdate(int progress) {
			pBar.Value = progress;
			Application.DoEvents();
		}

		private void htex_ProcessDone() {
			this.Close();
		}
	}
}

⌨️ 快捷键说明

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