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

📄 mainform.cs

📁 这是一个小型的相片管理器
💻 CS
📖 第 1 页 / 共 3 页
字号:
			// pPane
			// 
			this.pPane.Album = null;
			this.pPane.Dock = System.Windows.Forms.DockStyle.Fill;
			this.pPane.Location = new System.Drawing.Point(250, 39);
			this.pPane.Name = "pPane";
			this.pPane.PhotoSaverQuality = 100;
			this.pPane.Size = new System.Drawing.Size(652, 559);
			this.pPane.TabIndex = 6;
			// 
			// albPane
			// 
			this.albPane.Dock = System.Windows.Forms.DockStyle.Left;
			this.albPane.Location = new System.Drawing.Point(0, 39);
			this.albPane.Name = "albPane";
			this.albPane.Size = new System.Drawing.Size(250, 559);
			this.albPane.TabIndex = 3;
			// 
			// MainForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(902, 621);
			this.Controls.Add(this.albPhotoSplitter);
			this.Controls.Add(this.pbLoading);
			this.Controls.Add(this.pPane);
			this.Controls.Add(this.albPane);
			this.Controls.Add(this.tBar);
			this.Controls.Add(this.stBar);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.mm;
			this.Name = "MainForm";
			this.Text = "相册管理器";
			this.Resize += new System.EventHandler(this.MainForm_Resize);
			this.Load += new System.EventHandler(this.MainForm_Load);
			this.Closed += new System.EventHandler(this.MainForm_Closed);
			((System.ComponentModel.ISupportInitialize)(this.stpProg)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stpCurrP)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.stpPhotos)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Application's main entry point
		/// </summary>
		[STAThread]
		static void Main(string[] args) {
#if !DEBUG
			// add a general exception handler for unhandled exceptions
			Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
#endif

			Application.Run(new MainForm(args));
		}

		private void albPane_OpenAlbum(Album a) {
			this.pPane.Album = a;
		}

		private void pPane_OnProgressUpdate(int progress, int max, string desc) {
			pbLoading.Maximum = max;
			pbLoading.Value = progress;
			stpProg.Text = desc;
		}

		private void MainForm_Resize(object sender, System.EventArgs e) {
			OnResize();
		}

		private void MainForm_Load(object sender, System.EventArgs e) {
			// load size-related settings
			Settings settings = new Settings();
			this.Width = settings.MainWidth;
			this.Height = settings.MainHeight;
			if (settings.MainMaximized == true)
				this.WindowState = FormWindowState.Maximized;
			albPane.Width = settings.APSplitPos;

			// update the activeness state of quick album info
			albPane.UpdateToolTipState(settings.ShowQuickAlbumInfo);

			// if specified register vpo to open *.vpoa albums
			if (settings.AssocVPOA == true)
				settings.RegisterVPOA();

			OnResize();

			// see if this is the program's first start and show the choose language dialog if it is
			if (settings.FirstStart == true) {
//				ChooseLanguageDialog cld = new ChooseLanguageDialog(settings);
//				cld.ShowDialog();
//				LoadLanguageStrings();
//				albPane.LoadStrings();
//				pPane.LoadLanugageStrings();
			} else {
//				albPane.LoadStrings();
//				pPane.LoadLanugageStrings();
			}

			// check for start params
			if (Args.Length > 0)
				albPane.OpenAlbumFromFile(new Album(Args[0]));

			// init the toolBarTags
			int i = 0;
			foreach (ToolBarButton b in tBar.Buttons) {
				if (b.Style != ToolBarButtonStyle.Separator)
					b.Tag = i++;
			}
		}

		private void pPane_SelectedPhotosChanged(Photos selPhotos) {
			stpCurrP.Text = LsSel + ' ' + selPhotos.Count.ToString();
			bool active;
			if (selPhotos.Count > 0)
				active = true;
			else
				active = false;
			miCopy.Enabled = active;
			miCut.Enabled = active;
		}

		private void pPane_AlbumLoaded(int photos) {
			stpPhotos.Text = LsTotal + ' ' + photos.ToString();
			stpCurrP.Text = LsSel + " 0";
		}

		private void albPane_AddedPhotos(Album a) {
			if (pPane.Album != null) {
				// if the album, to which the photos have been added is currently open, add the new photos to the listview
				if (a.AlbumName == pPane.Album.AlbumName && a.AlbumPath == pPane.Album.AlbumPath)
					pPane.Album = a;
				//pPane.AddPhotos();
			}
		}

		private void pPane_PhotosDeleted(int photosCount) {
			// update the albPane and the status bar
			albPane.ReloadRootAlbum();
			stpPhotos.Text = LsTotal + ' ' + photosCount.ToString();
		}

		private void miNAlbum_Click(object sender, System.EventArgs e) {
			albPane.AddAlbum();
		}

		private void miOpenAlbum_Click(object sender, System.EventArgs e) {
			// show an ofd and call OpenAlbum()
			OpenFileDialog ofd = new OpenFileDialog();
			ofd.Filter = LsAlbums + " (*.vpoa)|*.vpoa";
			if (ofd.ShowDialog() == DialogResult.OK)
				albPane.OpenAlbumFromFile(new Album(ofd.FileName));
		}

		private void miFromFile_Click(object sender, System.EventArgs e) {
			if (albPane.SelectedAlbum != null)
				albPane.AddPhotosFromFiles();
		}

		private void miFolder_Click(object sender, System.EventArgs e) {
			if (albPane.SelectedAlbum != null)
				albPane.AddPhotosFromFolder();
		}

		private void miRenAlbum_Click(object sender, System.EventArgs e) {
			if (albPane.SelectedAlbum != null)
				albPane.RenameAlbum();
		}

		private void miDelAlbum_Click(object sender, System.EventArgs e) {
			albPane.DeleteAlbum();
		}

		private void miExit_Click(object sender, System.EventArgs e) {
			Application.Exit();
		}

		private void miOpenPhoto_Click(object sender, System.EventArgs e) {
			if (pPane.SelectedPhotos.Count != 0)
				pPane.OpenPhotoEditor();
		}

		private void miSlideSh_Click(object sender, System.EventArgs e) {
			if (pPane.Album != null)
				pPane.StartSlideShow();
		}

		private void miRotLeft_Click(object sender, System.EventArgs e) {
			if (pPane.SelectedPhotos.Count != 0)
				pPane.RotateLeft();
		}

		private void miRotRight_Click(object sender, System.EventArgs e) {
			if (pPane.SelectedPhotos.Count != 0)
				pPane.RotateRight();
		}

		private void miRenPhoto_Click(object sender, System.EventArgs e) {
			if (pPane.SelectedPhotos.Count != 0)
				pPane.RenamePhoto();
		}

		private void miDelPhoto_Click(object sender, System.EventArgs e) {
			if (pPane.SelectedPhotos.Count != 0)
				pPane.DeletePhoto();
		}

		private void miSettings_Click(object sender, System.EventArgs e) {
			SettingsDialog sd = new SettingsDialog();
			sd.ThumbSizeChanged += new VirtualPhotoOrganizer.Dialogs.SettingsDialog.ChangedThumbSize(sd_ThumbSizeChanged);
			if (sd.ShowDialog() == DialogResult.OK) {
				Settings settings = new Settings();
				pPane.LoadSettings();
//				LoadLanguageStrings();
//				albPane.LoadStrings();
//				pPane.LoadLanugageStrings();
//				VPOClipboard.LoadStrings();
				albPane.UpdateToolTipState(settings.ShowQuickAlbumInfo);
				if (ThumbSizeChanged == true)
					pPane.RefreshPhotoView();
				ThumbSizeChanged = false;
			}
			sd.ThumbSizeChanged -= new VirtualPhotoOrganizer.Dialogs.SettingsDialog.ChangedThumbSize(sd_ThumbSizeChanged);

		}

		private void miHTMLExp_Click(object sender, System.EventArgs e) {
			if (pPane.Album != null)
				pPane.DoHTMLExport();
		}

		private void miAbout_Click(object sender, System.EventArgs e) {
//			AboutDialog ad = new AboutDialog();
//			ad.ShowDialog();
		}

		private void tBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e) {
			// determine which button was pressed and take the appropriate action
			switch ((ToolBarB) e.Button.Tag) {
				case ToolBarB.AddAlbum: albPane.AddAlbum();
					break;
				case ToolBarB.ImportPhotos:
					if (albPane.SelectedAlbum != null)
						albPane.AddPhotosFromFiles();
					break;
				case ToolBarB.OpenPhoto:
					if (pPane.SelectedPhotos.Count > 0)
						pPane.OpenPhotoEditor();
					break;
				case ToolBarB.StartSlideShow:
					if (pPane.Album != null)
						pPane.StartSlideShow();
					break;
				case ToolBarB.RLeft:
					if (pPane.SelectedPhotos.Count > 0)
						pPane.RotateLeft();
					break;
				case ToolBarB.RRight:
					if (pPane.SelectedPhotos.Count > 0)
						pPane.RotateRight();
					break;
				case ToolBarB.Delete:
					if (pPane.SelectedPhotos.Count > 0)
						pPane.DeletePhoto();
					break;
				case ToolBarB.Print:
					if (pPane.SelectedPhotos.Count > 0)
						pPane.PrintSelectedPhotos();
					break;
				case ToolBarB.ExpToHTML:
					if (pPane.Album != null)
						pPane.DoHTMLExport();
					break;
				default:
					break;
			}
		}

		private void MainForm_Closed(object sender, System.EventArgs e) {
			// save size-related settings
			Settings settings = new Settings();

			if (this.WindowState == FormWindowState.Maximized)
				settings.MainMaximized = true;
			else {
				settings.MainMaximized = false;
				settings.MainWidth = this.Width;
				settings.MainHeight = this.Height;
			}

			settings.APSplitPos = albPane.Width;

			settings.SaveSettings();
		}

		private void albPane_AlbumNameChanged(Album a) {
			if (this.pPane.Album == a)
				this.pPane.ReloadAlbumName();
		}

		private void sd_ThumbSizeChanged() {
			ThumbSizeChanged = true;
		}

		private void albPane_AlbumDeleted(Album a) {
			if (pPane.Album == a)
				pPane.AlbumDeleted();
		}

#if !DEBUG
		private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e) {
			MessageBox.Show("Please make a screenshot of this window by pressing Ctrl + Alt + Print scr and send it to support@tommazzo.com along with a short description of what you did!" + "\n\n" + e.Exception.Message + '\n' + e.Exception.StackTrace, e.Exception.GetType().ToString());
		}
#endif

		private void VPOClipboard_ProgressUpdate(string action, int pos, int max) {
			this.pbLoading.Maximum = max;
			this.pbLoading.Value = pos;
			this.stpProg.Text = action;
		}

		private void VPOClipboard_ClipboardChanged(int count) {
			if (count > 0)
				miPaste.Enabled = true;
			else
				miPaste.Enabled = false;
		}

		private void miCut_Click(object sender, System.EventArgs e) {
			pPane.CutToClipboard();
		}

		private void miCopy_Click(object sender, System.EventArgs e) {
			pPane.CopyToClipboard();
		}

		private void miPaste_Click(object sender, System.EventArgs e) {
			pPane.PasteFromClipboard();
		}

		private void albPane_PhotosEnter() {
			pPane.CopyToClipboard();
		}

		private void albPane_PhotosDropped(Album a) {
			if (pPane.Album == a)
				pPane.Album = a;
		}

		private void miSearch_Click(object sender, EventArgs e) {
			SearchDialog sd = new SearchDialog(albPane, pPane);
			sd.Show();
		}

		private void pPane_Load(object sender, System.EventArgs e) {
		
		}
	}
}

⌨️ 快捷键说明

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