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

📄 settingsdialog.cs

📁 这是一个小型的相片管理器
💻 CS
📖 第 1 页 / 共 2 页
字号:
/*
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>
	/// Zusammenfassung f黵 SettingsDialog.
	/// </summary>
	internal class SettingsDialog : System.Windows.Forms.Form
	{
		// the settings, which we wish to modify
		private string Lang;
		private string DefaultAlbumDir;
		private int SlideShowInterval;
		private int ThumbWidth;
		private int ThumbHeight;
		private bool AssocVPOA;
		private int OldThumbWidth;
		private int OldThumbHeight;
		private bool ShowAlbInfo;
		private bool ShowPhotoInfo;
		private bool ShowImgRes;

		// the instance of the settings class, which we'll use
		Settings Settings = new Settings();

		// the event that indicates if the thumb size was changed
		public delegate void ChangedThumbSize();
		public event ChangedThumbSize ThumbSizeChanged;

		private System.Windows.Forms.Button bOK;
		private System.Windows.Forms.Button bCancel;
		private System.Windows.Forms.Button bBrowse;
		private System.Windows.Forms.Label lbLang;
		private System.Windows.Forms.ComboBox cbLang;
		private System.Windows.Forms.Label lbDADir;
		private System.Windows.Forms.TextBox tbDADir;
		private System.Windows.Forms.Label lbSlideShInt;
		private System.Windows.Forms.NumericUpDown numSlideShInt;
		private System.Windows.Forms.Label lbThumbSize;
		private System.Windows.Forms.NumericUpDown numThWidth;
		private System.Windows.Forms.NumericUpDown numThHeight;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label lbSecs;
		private System.Windows.Forms.CheckBox cbAssoc;
		private System.Windows.Forms.CheckBox cbShowImgRes;
		private System.Windows.Forms.CheckBox cbShowPhotoInfo;
		private System.Windows.Forms.CheckBox cbShowAlbInfo;
		/// <summary>
		/// Erforderliche Designervariable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public SettingsDialog() {
			//
			// Erforderlich f黵 die Windows Form-Designerunterst黷zung
			//
			InitializeComponent();

//			LoadLanguageStrings();
			LoadSettings();
		}

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

		#region LoadLanguageStrings

		private void LoadLanguageStrings() {
			const string MN = "SettingsDialog";
			string lsTitle;
			string lsOK;
			string lsCancel;
			string lsBrowse;
			string lsDADir;
			string lsSlideShInt;
			string lsThumbSize;
			string lsSecs;
			string lsAssoc;
			string lsLang;
			string lsShowAlbInfo;
			string lsShowPhotoInfo;
			string lsShowRes;

			try {
				TXmlReader reader = XmlHandler.OpenLangFile();

				lsTitle = reader.GetString(MN, "Title", "Virtual Photo Organizer Settings");
				lsOK = reader.GetString(MN, "OK", "OK");
				lsCancel = reader.GetString(MN, "Cancel", "Cancel");
				lsBrowse = reader.GetString(MN, "Browse", "Browse...");
				lsDADir = reader.GetString(MN, "DefaultADir", "Default Album Directory:");
				lsSlideShInt = reader.GetString(MN, "SlideShInt", "Slideshow Photo-change Interval:");
				lsThumbSize = reader.GetString(MN, "ThumbSize", "Thumbnail-Size:");
				lsSecs = reader.GetString(MN, "Seconds", "seconds");
				lsLang = reader.GetString(MN, "Lang", "Language:");
				lsAssoc = reader.GetString(MN, "Assoc", "Associate Virtual Photo Organizer with *.vpoa album files");
				lsShowAlbInfo = reader.GetString(MN, "ShowAlbInfo", "Show quick album info");
				lsShowPhotoInfo = reader.GetString(MN, "ShowPhotoInfo", "Show quick photo info");
				lsShowRes = reader.GetString(MN, "ShowImgRes", "Show image resolution in quick photo info (more memory intensive)");

				reader.Close();
			}
			catch {
				lsTitle = "Virtual Photo Organizer Settings";
				lsOK = "OK";
				lsCancel = "Cancel";
				lsBrowse = "Browse...";
				lsDADir = "Default Album Directory:";
				lsSlideShInt = "Slideshow Photo-change Interval:";
				lsThumbSize = "Thumbnail-Size:";
				lsSecs = "seconds";
				lsLang = "Language:";
				lsAssoc = "Associate Virtual Photo Organizer with *.vpoa album files";
				lsShowAlbInfo = "Show quick album info";
				lsShowPhotoInfo = "Show quick photo info";
				lsShowRes = "Show image resolution in quick photo info (more memory intensive)";
			}

			// assign the language strings
			this.Text = lsTitle;
			bOK.Text = lsOK;
			bCancel.Text = lsCancel;
			bBrowse.Text = lsBrowse;
			lbDADir.Text = lsDADir;
			lbSlideShInt.Text = lsSlideShInt;
			lbThumbSize.Text = lsThumbSize;
			lbSecs.Text = lsSecs;
			cbAssoc.Text = lsAssoc;
			lbLang.Text = lsLang;
			cbShowAlbInfo.Text = lsShowAlbInfo;
			cbShowPhotoInfo.Text = lsShowPhotoInfo;
			cbShowImgRes.Text = lsShowRes;
		}

		#endregion

		private void LoadSettings() {
			// read the settings into memory
			Lang = Settings.LangFile;
			DefaultAlbumDir = Settings.DefaultAlbumFolder;
			SlideShowInterval = Settings.SlideShowInterval;
			ThumbWidth = Settings.ThumbWidth;
			ThumbHeight = Settings.ThumbHeight;
			AssocVPOA = Settings.AssocVPOA;
			ShowAlbInfo = Settings.ShowQuickAlbumInfo;
			ShowPhotoInfo = Settings.ShowQuickPhotoInfo;
			ShowImgRes = Settings.ShowImgRes;
			OldThumbWidth = ThumbWidth;
			OldThumbHeight = ThumbHeight;

			// assign the settings to their controls
			cbLang.Text = Lang;
			tbDADir.Text = DefaultAlbumDir;
			numSlideShInt.Value = SlideShowInterval;
			numThWidth.Value = ThumbWidth;
			numThHeight.Value = ThumbHeight;
			cbAssoc.Checked = AssocVPOA;
			cbShowAlbInfo.Checked = ShowAlbInfo;
			cbShowPhotoInfo.Checked = ShowPhotoInfo;
			cbShowImgRes.Checked = ShowImgRes;
			cbShowImgRes.Enabled = ShowPhotoInfo;

			// get the list of available languages
			GetLanguageList();
		}

		private void GetLanguageList() {
			LangFileListRetriever lflr = new LangFileListRetriever();

			// get the list of files and add it to the combobox
			string[] files = lflr.LanguageFiles;
			cbLang.Items.AddRange(files);

			// make sure that the right index of the combobox is selected
			for (int i = 0; i < cbLang.Items.Count; i++) {
				if (files[i] == cbLang.Text) {
					cbLang.SelectedIndex = i;
					break;
				}
			}
		}

		/// <summary>
		/// reads the values from the components into the vars
		/// </summary>
		private void GetSettingsFromComponents() {
			Lang = cbLang.Text;
			DefaultAlbumDir = tbDADir.Text;
			SlideShowInterval = (int) numSlideShInt.Value;
			ThumbWidth = (int) numThWidth.Value;
			ThumbHeight = (int) numThHeight.Value;
			AssocVPOA = cbAssoc.Checked;
			ShowAlbInfo = cbShowAlbInfo.Checked;
			ShowPhotoInfo = cbShowPhotoInfo.Checked;
			ShowImgRes = cbShowImgRes.Checked;
		}

		/// <summary>
		/// saves the settings
		/// </summary>
		private void SaveSettings() {
			Settings.LangFile = Lang;
			Settings.DefaultAlbumFolder = DefaultAlbumDir;
			Settings.SlideShowInterval = SlideShowInterval;
			Settings.ThumbWidth = ThumbWidth;
			Settings.ThumbHeight = ThumbHeight;
			Settings.AssocVPOA = AssocVPOA;
			Settings.ShowQuickAlbumInfo = ShowAlbInfo;
			Settings.ShowQuickPhotoInfo = ShowPhotoInfo;
			Settings.ShowImgRes = ShowImgRes;

			Settings.SaveSettings();

			// check if we are to register vpo to open *.vpoa albums and perform the registration if necessarry
			if (AssocVPOA == true)
				Settings.RegisterVPOA();
		}

		#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(SettingsDialog));
			this.bOK = new System.Windows.Forms.Button();
			this.bCancel = new System.Windows.Forms.Button();

⌨️ 快捷键说明

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