📄 searchdialog.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.Controls;
using VirtualPhotoOrganizer.Photo;
using VirtualPhotoOrganizer.Util;
using TXML;
namespace VirtualPhotoOrganizer.Dialogs
{
/// <summary>
/// Zusammenfassung f黵 SearchDialog.
/// </summary>
internal class SearchDialog : System.Windows.Forms.Form
{
public delegate void EndSearch();
public event EndSearch EndSearchNow;
private Albums Albs;
private bool Searching = false;
private string LsPixels;
private string LsSearch;
private string LsAbort;
private PhotosPane PPane;
private AlbumsPane AlbsPane;
private int CurrItemIndex = -1;
private Point MousePos;
private Label lbPSelect;
private Button bSearch;
private CheckBox cbMatchCase;
private CheckBox cbAllAlbs;
private PictureBox pbAnim;
private Label lbEnterText;
private TextBox tbSearchText;
private PictureBox pbPreview;
private GroupBox gbWhat;
private CheckBox cbTitle;
private CheckBox cbDesc;
private CheckBox cbTimeTaken;
private CheckBox cbPath;
private ListView lvResults;
private ColumnHeader colTitle;
private ColumnHeader colTime;
private ColumnHeader colAlbum;
private TreeView tvAlbums;
private ContextMenu contMenu;
private MenuItem miOpenPhoto;
private MenuItem miPrint;
private MenuItem menuItem3;
private MenuItem miPInfo;
private MenuItem miOpenAlbum;
private ToolTip ttPhotoInfo;
private Timer tToolTip;
private ContextMenu contMenuTv;
private MenuItem miCheckAll;
private MenuItem miUncheckAll;
private IContainer components;
public SearchDialog(AlbumsPane albPane, PhotosPane pPane) {
//
// Erforderlich f黵 die Windows Form-Designerunterst黷zung
//
InitializeComponent();
// LoadLanguageStrings();
AlbsPane = albPane;
PPane = pPane;
Albs = new Albums();
TreeNode node;
foreach (Album a in albPane.RootAlbum.Albums) {
node = new TreeNode(a.AlbumName);
node.Tag = a;
node.Checked = true;
ParseSubAlbums(a, node);
Albs.Add(a);
tvAlbums.Nodes.Add(node);
}
this.EndSearchNow += new EndSearch(SearchDialog_EndSearchNow);
MousePos = new Point();
}
#region LoadLanguageStrings
private void LoadLanguageStrings() {
const string MN = "SearchDialog";
string lsEnterText;
string lsSelect;
string lsWhat;
string lsPTitles;
string lsPDescs;
string lsTimeT;
string lsPPaths;
string lsAllAlbs;
string lsMatchCase;
string lsTitle;
string lsAlbum;
string lsTimeTaken;
string lsOpenPhoto;
string lsOpenAlbum;
string lsPrint;
string lsPhotoInfo;
string lsCheckAll;
string lsUncheckAll;
try {
TXmlReader reader = XmlHandler.OpenLangFile();
LsSearch = reader.GetString(MN, "Search", "Search");
lsEnterText = reader.GetString(MN, "EnterText", "Please enter the search text");
lsSelect = reader.GetString(MN, "Select", "Please select the albums that you want to search");
lsWhat = reader.GetString(MN, "What", "Search in");
lsPTitles = reader.GetString(MN, "PTitles", "Photo titles");
lsPDescs = reader.GetString(MN, "PDescs", "Photo descriptions");
lsTimeT = reader.GetString(MN, "TimeT", "Time taken");
lsPPaths = reader.GetString(MN, "PPaths", "Photo paths");
lsAllAlbs = reader.GetString(MN, "AllAlbs", "All albums");
lsMatchCase = reader.GetString(MN, "MatchCase", "Match case");
LsAbort = reader.GetString(MN, "Abort", "Abort");
lsTitle = reader.GetString(MN, "Title", "Title");
lsAlbum = reader.GetString(MN, "Album", "Album");
LsPixels = reader.GetString("PhotoInfoDialog", "Pixels", "Pixels");
lsTimeTaken = reader.GetString(MN, "TimeTaken", "Time taken");
lsOpenPhoto = reader.GetString(MN, "OpenPhoto", "Open photo...");
lsOpenAlbum = reader.GetString(MN, "OpenAlbum", "Open album");
lsPrint = reader.GetString("PhotosPane", "Print", "Print...");
lsPhotoInfo = reader.GetString("PhotosPane", "PInfo", "Photo-Info");
lsCheckAll = reader.GetString(MN, "CheckAll", "Check all");
lsUncheckAll = reader.GetString(MN, "UncheckAll", "Uncheck all");
reader.Close();
}
catch {
LsSearch = "Search";
lsEnterText = "Please enter the search text";
lsSelect = "Please select the albums that you want to search";
lsWhat = "Search in";
lsPTitles = "Photo titles";
lsPDescs = "Photo descriptions";
lsTimeT = "Time taken";
lsPPaths = "Photo paths";
lsAllAlbs = "All albums";
lsMatchCase = "Match case";
LsAbort = "Abort";
lsTitle = "Title";
lsAlbum = "Album";
LsPixels = "Pixels";
lsTimeTaken = "Time taken";
lsOpenPhoto = "Open photo...";
lsOpenAlbum = "Open album";
lsPrint = "Print...";
lsPhotoInfo = "Photo-Info";
lsCheckAll = "Check all";
lsUncheckAll = "Uncheck all";
}
// assign the strings
this.Text = LsSearch;
lbEnterText.Text = lsEnterText;
lbPSelect.Text = lsSelect;
gbWhat.Text = lsWhat;
cbTitle.Text = lsPTitles;
cbDesc.Text = lsPDescs;
cbTimeTaken.Text = lsTimeT;
cbPath.Text = lsPPaths;
cbAllAlbs.Text = lsAllAlbs;
cbMatchCase.Text = lsMatchCase;
bSearch.Text = LsSearch;
lvResults.Columns[0].Text = lsTitle;
lvResults.Columns[1].Text = lsAlbum;
lvResults.Columns[2].Text = lsTimeTaken;
miOpenAlbum.Text = lsOpenAlbum;
miOpenPhoto.Text = lsOpenPhoto;
miPrint.Text = lsPrint;
miPInfo.Text = lsPhotoInfo;
miCheckAll.Text = lsCheckAll;
miUncheckAll.Text = lsUncheckAll;
}
#endregion
private void ParseSubAlbums(Album album, TreeNode tn) {
TreeNode node;
foreach (Album a in album.SubAlbums) {
node = new TreeNode(a.AlbumName);
node.Tag = a;
node.Checked = true;
tn.Nodes.Add(node);
Albs.Add(a);
ParseSubAlbums(a, node);
}
}
void SearchDialog_EndSearchNow() {
Searching = false;
bSearch.Text = LsSearch;
pbAnim.Visible = false;
}
private void ChangeCheckedState(TreeNode node, bool isChecked) {
node.Checked = isChecked;
foreach (TreeNode n in node.Nodes)
ChangeCheckedState(n, isChecked);
}
/// <summary>
/// Die verwendeten Ressourcen bereinigen.
/// </summary>
protected override void Dispose(bool disposing) {
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
#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() {
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SearchDialog));
this.lbPSelect = new System.Windows.Forms.Label();
this.bSearch = new System.Windows.Forms.Button();
this.cbMatchCase = new System.Windows.Forms.CheckBox();
this.cbAllAlbs = new System.Windows.Forms.CheckBox();
this.pbAnim = new System.Windows.Forms.PictureBox();
this.lbEnterText = new System.Windows.Forms.Label();
this.tbSearchText = new System.Windows.Forms.TextBox();
this.pbPreview = new System.Windows.Forms.PictureBox();
this.gbWhat = new System.Windows.Forms.GroupBox();
this.cbPath = new System.Windows.Forms.CheckBox();
this.cbTimeTaken = new System.Windows.Forms.CheckBox();
this.cbDesc = new System.Windows.Forms.CheckBox();
this.cbTitle = new System.Windows.Forms.CheckBox();
this.lvResults = new System.Windows.Forms.ListView();
this.colTitle = new System.Windows.Forms.ColumnHeader();
this.colAlbum = new System.Windows.Forms.ColumnHeader();
this.colTime = new System.Windows.Forms.ColumnHeader();
this.tvAlbums = new System.Windows.Forms.TreeView();
this.contMenu = new System.Windows.Forms.ContextMenu();
this.miOpenPhoto = new System.Windows.Forms.MenuItem();
this.miOpenAlbum = new System.Windows.Forms.MenuItem();
this.miPrint = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.miPInfo = new System.Windows.Forms.MenuItem();
this.ttPhotoInfo = new System.Windows.Forms.ToolTip(this.components);
this.tToolTip = new System.Windows.Forms.Timer(this.components);
this.contMenuTv = new System.Windows.Forms.ContextMenu();
this.miCheckAll = new System.Windows.Forms.MenuItem();
this.miUncheckAll = new System.Windows.Forms.MenuItem();
this.gbWhat.SuspendLayout();
this.SuspendLayout();
//
// lbPSelect
//
this.lbPSelect.AutoSize = true;
this.lbPSelect.Location = new System.Drawing.Point(12, 58);
this.lbPSelect.Name = "lbPSelect";
this.lbPSelect.Size = new System.Drawing.Size(234, 13);
this.lbPSelect.TabIndex = 1;
this.lbPSelect.Text = "Please select the albums that you want to search";
//
// bSearch
//
this.bSearch.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.bSearch.Location = new System.Drawing.Point(69, 558);
this.bSearch.Name = "bSearch";
this.bSearch.Size = new System.Drawing.Size(75, 23);
this.bSearch.TabIndex = 2;
this.bSearch.Text = "Search";
this.bSearch.Click += new System.EventHandler(this.bSearch_Click);
//
// cbMatchCase
//
this.cbMatchCase.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cbMatchCase.Location = new System.Drawing.Point(13, 535);
this.cbMatchCase.Name = "cbMatchCase";
this.cbMatchCase.Size = new System.Drawing.Size(181, 18);
this.cbMatchCase.TabIndex = 3;
this.cbMatchCase.Text = "Match case";
//
// cbAllAlbs
//
this.cbAllAlbs.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cbAllAlbs.Location = new System.Drawing.Point(13, 512);
this.cbAllAlbs.Name = "cbAllAlbs";
this.cbAllAlbs.Size = new System.Drawing.Size(181, 18);
this.cbAllAlbs.TabIndex = 4;
this.cbAllAlbs.Text = "All Albums";
this.cbAllAlbs.CheckedChanged += new System.EventHandler(this.cbAllAlbs_CheckedChanged);
//
// pbAnim
//
this.pbAnim.Image = ((System.Drawing.Image) (resources.GetObject("pbAnim.Image")));
this.pbAnim.Location = new System.Drawing.Point(229, 84);
this.pbAnim.Name = "pbAnim";
this.pbAnim.Size = new System.Drawing.Size(48, 50);
this.pbAnim.TabIndex = 5;
this.pbAnim.TabStop = false;
this.pbAnim.Visible = false;
//
// lbEnterText
//
this.lbEnterText.AutoSize = true;
this.lbEnterText.Location = new System.Drawing.Point(12, 9);
this.lbEnterText.Name = "lbEnterText";
this.lbEnterText.Size = new System.Drawing.Size(135, 13);
this.lbEnterText.TabIndex = 7;
this.lbEnterText.Text = "Please enter the search text";
//
// tbSearchText
//
this.tbSearchText.Location = new System.Drawing.Point(13, 28);
this.tbSearchText.Name = "tbSearchText";
this.tbSearchText.Size = new System.Drawing.Size(187, 20);
this.tbSearchText.TabIndex = 8;
this.tbSearchText.KeyUp += new System.Windows.Forms.KeyEventHandler(this.tbSearchText_KeyUp);
//
// pbPreview
//
this.pbPreview.Location = new System.Drawing.Point(356, 393);
this.pbPreview.Name = "pbPreview";
this.pbPreview.Size = new System.Drawing.Size(150, 113);
this.pbPreview.TabIndex = 9;
this.pbPreview.TabStop = false;
//
// gbWhat
//
this.gbWhat.Controls.Add(this.cbPath);
this.gbWhat.Controls.Add(this.cbTimeTaken);
this.gbWhat.Controls.Add(this.cbDesc);
this.gbWhat.Controls.Add(this.cbTitle);
this.gbWhat.Location = new System.Drawing.Point(12, 395);
this.gbWhat.Name = "gbWhat";
this.gbWhat.Size = new System.Drawing.Size(188, 111);
this.gbWhat.TabIndex = 10;
this.gbWhat.TabStop = false;
this.gbWhat.Text = "Search what";
//
// cbPath
//
this.cbPath.Checked = true;
this.cbPath.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbPath.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cbPath.Location = new System.Drawing.Point(6, 88);
this.cbPath.Name = "cbPath";
this.cbPath.Size = new System.Drawing.Size(176, 18);
this.cbPath.TabIndex = 3;
this.cbPath.Text = "Photo path";
//
// cbTimeTaken
//
this.cbTimeTaken.Checked = true;
this.cbTimeTaken.CheckState = System.Windows.Forms.CheckState.Checked;
this.cbTimeTaken.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.cbTimeTaken.Location = new System.Drawing.Point(6, 65);
this.cbTimeTaken.Name = "cbTimeTaken";
this.cbTimeTaken.Size = new System.Drawing.Size(176, 18);
this.cbTimeTaken.TabIndex = 2;
this.cbTimeTaken.Text = "Time taken";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -