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

📄 photospane.cs

📁 这是一个小型的相片管理器
💻 CS
📖 第 1 页 / 共 4 页
字号:
		}

		/// <summary>
		/// loads the required settings (thWidth & thHeight) from the settings file
		/// </summary>
		public void LoadSettings() {
			Settings settings = new Settings();

			// read the thumb settings from disk
			ThumbWidth = settings.ThumbWidth;
			ThumbHeight = settings.ThumbHeight;

			// read the quick photo info settings
			timerToolTip.Enabled = settings.ShowQuickPhotoInfo;
			ttPhotoInfo.Active = settings.ShowQuickPhotoInfo;
			ShowImgRes = settings.ShowImgRes;

			// apply the thumb settings to the il
			ilThumbs.ImageSize = new System.Drawing.Size(ThumbWidth, ThumbHeight);
		}

		public void LoadLanugageStrings() {
			// language strings
			string lsOpen;
			string lsSlSh;
			string lsSelAll;
			string lsRL;
			string lsRR;
			string lsRen;
			string lsPInfo;
			string lsHTMLExp;
			string lsPrint;
			string lsRenTime;
			string lsArrAZ;
			string lsArrZA;
			string lsArrChro;
			string lsRenReo;
			string lsCopy;
			string lsCut;
			string lsPaste;

			const string MN = "PhotosPane";
			try {
				TXmlReader reader = XmlHandler.OpenLangFile();

				LsNoPhoto = reader.GetString(MN, "NoPhoto", "The indicated photo was not found in the album's path - thus it'll be removed from the album");
				LsLThumb = reader.GetString(MN, "LThumb", "Loading Thumbnails...");
				lsOpen = reader.GetString(MN, "Open", "Open...");
				lsSlSh = reader.GetString(MN, "Slidesh", "Start Slideshow...");
				lsSelAll = reader.GetString(MN, "SelAll", "Select All");
				lsRL = reader.GetString(MN, "RL", "Rotate Left");
				lsRR = reader.GetString(MN, "RR", "Rotate Right");
				LsDel = reader.GetString(MN, "Del", "Delete");
				lsRen = reader.GetString(MN, "Ren", "Rename");
				lsHTMLExp = reader.GetString(MN, "HTMLExport", "Export to HTML Album...");
				lsPInfo = reader.GetString(MN, "PInfo", "Photo-Info");
				LsDeleteQ = reader.GetString(MN, "DeleteQ", "Are you sure that you want to delete the selected photo(s)?");
				LsRot = reader.GetString(MN, "Rotating", "Rotating Images...");
				LsNoAlbumSave = reader.GetString(MN, "NoAlbumSave", "The file could not be saved. Please make sure that the disk is neither full, nor write-protected!");
				LsPixels = reader.GetString("PhotoInfoDialog", "Pixels", "Pixels");
				lsPrint = reader.GetString(MN, "Print", "Print...");
				lsRenTime = reader.GetString(MN, "RenTime", "Rename Photos based on Time");
				lsArrAZ = reader.GetString(MN, "ArrangeAZ", "Arrange Photos alphabetically (A->Z)");
				lsArrZA = reader.GetString(MN, "ArrangeZA", "Arrange Photos alphabetically (Z->A)");
				lsArrChro = reader.GetString(MN, "ArrangeChro", "Arrange Photos chronologically");
				LsArrChroErr = reader.GetString(MN, "ArrangeChroError", "The time taken value of the above photo does not conform to the DateTime syntax, thus the operation will be aborted");
				lsRenReo = reader.GetString(MN, "RenReo", "Rename/Arrange");
				lsCopy = reader.GetString(MN, "Copy", "Copy");
				lsCut = reader.GetString(MN, "Cut", "Cut");
				lsPaste = reader.GetString(MN, "Paste", "Paste");

				reader.Close();
			}
			catch {
				LsNoPhoto = "The indicated photo was not found in the album's path - thus it'll be removed from the album";
				LsLThumb = "Loading Thumbnails...";
				lsOpen = "Open...";
				lsSlSh = "Start Slideshow...";
				lsSelAll = "Select All";
				lsRL = "Rotate Left";
				lsRR = "Rotate Right";
				LsDel = "Delete";
				lsRen = "Rename";
				lsPInfo = "Photo-Info";
				LsDeleteQ = "Are you sure that you want to delete the selected photo(s)?";
				LsRot = "Rotating Images...";
				lsHTMLExp = "Export to HTML Album...";
				LsNoAlbumSave = "The file could not be saved. Please make sure that the disk is neither full, nor write-protected!";
				LsPixels = "Pixels";
				lsPrint = "Print...";
				lsRenTime = "Rename Photos based on Time";
				lsArrAZ = "Arrange Photos alphabetically (A->Z)";
				lsArrZA = "Arrange Photos alphabetically (Z->A)";
				lsArrChro = "Arrange Photos chronologically";
				LsArrChroErr = "The time taken value of the above photo does not conform to the DateTime syntax, thus the operation will be aborted";
				lsRenReo = "Rename/Arrange";
				lsCopy = "Copy";
				lsCut = "Cut";
				lsPaste = "Paste";
			}

			// assign the language strings
			miOpen.Text = lsOpen;
			miSlideSh.Text = lsSlSh;
			miSelAll.Text = lsSelAll;
			miRLeft.Text = lsRL;
			miRRight.Text = lsRR;
			miDel.Text = LsDel;
			miRen.Text = lsRen;
			miPInfo.Text = lsPInfo;
			miHTMLExp.Text = lsHTMLExp;
			miPrint.Text = lsPrint;
			miRenTime.Text = lsRenTime;
			miReoAZ.Text = lsArrAZ;
			miReoZA.Text = lsArrZA;
			miReoChro.Text = lsArrChro;
			miRenReo.Text = lsRenReo;
			miCopy.Text = lsCopy;
			miCut.Text = lsCut;
			miPaste.Text = lsPaste;
		}

		#endregion

		#region HTML Export

		/// <summary>
		/// initiates the procedure of exporting the selected photos to an HTML album
		/// </summary>
		public void DoHTMLExport() {
			Dialogs.HTMLExportDialog hed;
			if (this.SelPhotos.Count > 1)
				hed = new VirtualPhotoOrganizer.Dialogs.HTMLExportDialog(SelPhotos);
			else
				hed = new VirtualPhotoOrganizer.Dialogs.HTMLExportDialog(Album.Photos);

			hed.ShowDialog();
		}

		#endregion

		#region Drag&Drop

		/// <summary>
		/// rearranges the album's photos after a drag&drop event has occured
		/// </summary>
		/// <returns>true if the save was successful and false if it wasn't</returns>
		private bool DoAlbumDragDrop(int[] selIndices, int destIndex) {
			// add the selected photos to a photos list
			Photos selPhotos = new Photos();
			foreach (int i in selIndices)
				selPhotos.Add(Album.Photos[i]);

			// delete the old photos
			for (int i = 0; i < selIndices.Length; i++) {
				if (selIndices[i] < destIndex)
					destIndex--;

				Album.Photos.RemoveAt(selIndices[i] - i);
			}

			// reinsert the dragged photos
			for (int i = selPhotos.Count - 1; i >= 0; i--)
				Album.Photos.Insert(destIndex, selPhotos[i]);

			// save the album
			bool save = AttemptSave();
			if (save == false) {	// if the save was not successful reload the album
				string path = Album.AlbumPath;
				Album = new Album(path);
			}
			return save;
		}

		/// <summary>
		/// returns the destIndex for a drag&drop operation
		/// </summary>
		private int GetDestIndex() {
			ListViewItem item = lvPhotos.GetItemAt(MousePos.X, MousePos.Y);	// try getting the item at the current mouse pos
			if (item == null)
				item = lvPhotos.GetItemAt(MousePos.X - ItemOffset, MousePos.Y);
			if (item == null)
				item = lvPhotos.GetItemAt(MousePos.X + ItemOffset, MousePos.Y);
			if (item == null)
				item = lvPhotos.GetItemAt(MousePos.X - ItemOffset, MousePos.Y - ItemOffset);
			if (item == null)
				item = lvPhotos.GetItemAt(MousePos.X + ItemOffset, MousePos.Y + ItemOffset);
			if (item == null)
				item = lvPhotos.GetItemAt(MousePos.X, MousePos.Y - ItemOffset);
			if (item == null)
				item = lvPhotos.GetItemAt(MousePos.X, MousePos.Y + ItemOffset);

			if (item != null)
				return item.Index;
			else
				return lvPhotos.Items.Count;
		}

		/// <summary>
		/// previews the drag&drop operation
		/// </summary>
		private void PreviewDragDrop() {
			ListViewItem item;
			int index = GetDestIndex();
			if (index != CurrItemIndex) {
				lvPhotos.Refresh();
				if (index < lvPhotos.Items.Count) {
					item = lvPhotos.Items[index];
					GlvPhotos.DrawLine(PPrev, item.Bounds.Left - ItemOffset / 2 + 1, item.Bounds.Top, item.Bounds.Left - ItemOffset / 2 + 1, item.Bounds.Bottom);
				} else {
					item = lvPhotos.Items[lvPhotos.Items.Count - 1];
					GlvPhotos.DrawLine(PPrev, item.Bounds.Right + ItemOffset / 2 - 1, item.Bounds.Top, item.Bounds.Right + ItemOffset / 2 - 1, item.Bounds.Bottom);
				}
				CurrItemIndex = index;
			}
		}

		#endregion

		#region Print

		/// <summary>
		/// prints the currently selected photos
		/// </summary>
		public void PrintSelectedPhotos() {
			if (SelPhotos.Count > 0) {
				Printer p = new Printer(SelPhotos);
				System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(p.Print));
				t.Start();
			}
		}

		#endregion

		#region Vom Komponenten-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() {
			this.components = new System.ComponentModel.Container();
			this.lvPhotos = new System.Windows.Forms.ListView();
			this.contMenu = new System.Windows.Forms.ContextMenu();
			this.miOpen = new System.Windows.Forms.MenuItem();
			this.miSlideSh = new System.Windows.Forms.MenuItem();
			this.miHTMLExp = new System.Windows.Forms.MenuItem();
			this.miPrint = new System.Windows.Forms.MenuItem();
			this.miSelAll = new System.Windows.Forms.MenuItem();
			this.menuItem2 = new System.Windows.Forms.MenuItem();
			this.miCut = new System.Windows.Forms.MenuItem();
			this.miCopy = new System.Windows.Forms.MenuItem();
			this.miPaste = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.miRenReo = new System.Windows.Forms.MenuItem();
			this.miRenTime = new System.Windows.Forms.MenuItem();
			this.miReoAZ = new System.Windows.Forms.MenuItem();
			this.miReoZA = new System.Windows.Forms.MenuItem();
			this.miReoChro = new System.Windows.Forms.MenuItem();
			this.menuItem3 = new System.Windows.Forms.MenuItem();
			this.miRLeft = new System.Windows.Forms.MenuItem();
			this.miRRight = new System.Windows.Forms.MenuItem();
			this.menuItem6 = new System.Windows.Forms.MenuItem();
			this.miDel = new System.Windows.Forms.MenuItem();
			this.miRen = new System.Windows.Forms.MenuItem();
			this.menuItem9 = new System.Windows.Forms.MenuItem();
			this.miPInfo = new System.Windows.Forms.MenuItem();
			this.ilThumbs = new System.Windows.Forms.ImageList(this.components);
			this.paneTitle = new VirtualPhotoOrganizer.Controls.PaneTitle();
			this.ttPhotoInfo = new System.Windows.Forms.ToolTip(this.components);
			this.timerToolTip = new System.Windows.Forms.Timer(this.components);
			this.SuspendLayout();
			// 
			// lvPhotos
			// 
			this.lvPhotos.AllowDrop = true;
			this.lvPhotos.ContextMenu = this.contMenu;
			this.lvPhotos.FullRowSelect = true;
			this.lvPhotos.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
			this.lvPhotos.HideSelection = false;
			this.lvPhotos.LabelEdit = true;
			this.lvPhotos.LargeImageList = this.ilThumbs;
			this.lvPhotos.Location = new System.Drawing.Point(0, 20);
			this.lvPhotos.Name = "lvPhotos";
			this.lvPhotos.Size = new System.Drawing.Size(264, 324);
			this.lvPhotos.TabIndex = 1;
			this.lvPhotos.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvPhotos_KeyDown);
			this.lvPhotos.DoubleClick += new System.EventHandler(this.lvPhotos_DoubleClick);
			this.lvPhotos.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lvPhotos_MouseUp);
			this.lvPhotos.DragOver += new System.Windows.Forms.DragEventHandler(this.lvPhotos_DragOver);
			this.lvPhotos.DragDrop += new System.Windows.Forms.DragEventHandler(this.lvPhotos_DragDrop);
			this.lvPhotos.AfterLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.lvPhotos_AfterLabelEdit);
			this.lvPhotos.DragEnter += new System.Windows.Forms.DragEventHandler(this.lvPhotos_DragEnter);
			this.lvPhotos.MouseMove += new System.Windows.Forms.MouseEventHandler(this.lvPhotos_MouseMove);
			this.lvPhotos.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.lvPhotos_ItemDrag);
			this.lvPhotos.BeforeLabelEdit += new System.Windows.Forms.LabelEditEventHandler(this.lvPhotos_BeforeLabelEdit);
			this.lvPhotos.DragLeave += new System.EventHandler(this.lvPhotos_DragLeave);
			this.lvPhotos.SelectedIndexChanged += new System.EventHandler(this.lvPhotos_SelectedIndexChanged);
			// 
			// contMenu
			// 
			this.contMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.miOpen,
																					 this.miSlideSh,
																					 this.miHTMLExp,
																					 this.miPrint,
																					 this.miSelAll,
																					 this.menuItem2,
																					 this.miCut,
																					 this.miCopy,
																					 this.miPaste,
																					 this.menuItem1,
																					 this.miRenReo,
																					 this.menuItem3,
																					 this.miRLeft,
																					 this.miRRight,
																					 this.menuItem6,
																					 this.miDel,
																					 this.miRen,
																					 this.menuItem9,
																					 this.miPInfo});
			this.contMenu.Popup += new System.EventHandler(this.contMenu_Popup);
			// 
			// miOpen
			// 
			this.miOpen.Index = 0;
			this.miOpen.Text = "打开";
			this.miOpen.Click += new System.EventHandler(this.miOpen_Click);
			// 
			// miSlideSh
			// 
			this.miSlideSh.Index = 1;
			this.miSlideSh.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
			this.miSlideSh.Text = "开始幻灯放映";
			this.miSlideSh.Click += new System.EventHandler(this.miSlideSh_Click);
			// 
			// miHTMLExp
			// 
			this.miHTMLExp.Index = 2;
			this.miHTMLExp.Shortcut = System.Windows.Forms.Shortcut.CtrlE;
			this.miHTMLExp.Text = "导出成HTML";
			this.miHTMLExp.Click += new System.EventHandler(this.miHTMLExp_Click);
			// 
			// miPrint
			// 
			this.miPrint.Index = 3;
			this.miPrint.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
			this.miPrint.Text = "打印";
			this.miPrint.Click += new System.EventHandler(this.miPrint_Click);
			// 
			// miSelAll
			// 
			this.miSelAll.Index = 4;
			this.miSelAll.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
			this.miSelAll.Text = "全选";
			this.miSelAll.Click += new System.EventHandler(this.miSelAll_Click);
			// 
			// menuItem2
			// 
			this.menuItem2.Index = 5;
			this.menuItem2.Text = "-";
			// 
			// miCut
			// 
			this.miCut.Index = 6;
			this.miCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
			this.miCut.Text = "剪切";
			this.miCut.Click += new System.EventHandler(this.miCut_Click);
			// 
			// miCopy
			// 
			this.miCopy.Index = 7;
			this.miCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
			this.miCopy.Text = "拷贝";
			this.miCopy.Click += new System.EventHandler(this.miCopy_Click);
			// 
			// miPaste
			// 
			this.miPaste.Enabled = false;
			this.miPaste.Index = 8;
			this.miPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlV;
			this.miPaste.Text = "粘贴";
			this.miPaste.Click += new System.EventHandler(this.miPaste_Click);
			// 
			// menuItem1
			// 
			this.menuItem1.Index = 9;
			this.menuItem1.Text = "-";
			// 
			// miRenReo
			// 
			this.miRenReo.Index = 10;
			this.miRenReo.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.miRenTime,
																					 this.miReoAZ,
																					 this.miReoZA,
																					 this.miReoChro});
			this.miRenReo.Text = "重命名/排列";
			// 
			// miRenTime
			// 
			this.miRenTime.Index = 0;
			this.miRenTime.Text = "按照时间重命名";
			this.miRenTime.Click += new System.EventHandler(this.miRenTime_Click);
			// 
			// miReoAZ
			// 
			this.miReoAZ.Index = 1;
			this.miReoAZ.Text = "按字母排序";
			this.miReoAZ.Click += new System.EventHandler(this.miReoAZ_Click);
			// 
			// miReoZA
			// 
			this.miReoZA.Index = 2;
			this.miReoZA.Text = "按字母倒序";
			this.miReoZA.Click += new System.EventHandler(this.miReoZA_Click);
			// 
			// miReoChro
			// 
			this.miReoChro.Index = 3;
			this.miReoChro.Text = "按图片创建日期";
			this.miReoChro.Click += new System.EventHandler(this.miReoChro_Click);
			// 
			// menuItem3
			// 
			this.menuItem3.Index = 11;
			this.menuItem3.Text = "-";
			// 
			// miRLeft
			// 
			this.miRLeft.Index = 12;
			this.miRLeft.Shortcut = System.Windows.Forms.Shortcut.CtrlL;
			this.miRLeft.Text = "逆时针旋转";
			this.miRLeft.Click += new System.EventHandler(this.miRLeft_Click);
			// 
			// miRRight
			// 
			this.miRRight.Index = 13;
			this.miRRight.Shortcut = System.Windows.Forms.Shortcut.CtrlR;
			this.miRRight.Text = "顺时针旋转";
			this.miRRight.Click += new System.EventHandler(this.miRRight_Click);
			// 
			// menuItem6
			// 
			this.menuItem6.Index = 14;
			this.menuItem6.Text = "-";
			// 

⌨️ 快捷键说明

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