📄 frmfolder.cs
字号:
// lnkFontSizeDown
//
this.lnkFontSizeDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkFontSizeDown.AutoSize = true;
this.lnkFontSizeDown.BackColor = System.Drawing.Color.Transparent;
this.lnkFontSizeDown.Location = new System.Drawing.Point(448, 16);
this.lnkFontSizeDown.Name = "lnkFontSizeDown";
this.lnkFontSizeDown.Size = new System.Drawing.Size(54, 17);
this.lnkFontSizeDown.TabIndex = 13;
this.lnkFontSizeDown.TabStop = true;
this.lnkFontSizeDown.Text = "减小字体";
this.lnkFontSizeDown.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkFontSizeDown_LinkClicked);
//
// lnkSelectFont
//
this.lnkSelectFont.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkSelectFont.AutoSize = true;
this.lnkSelectFont.BackColor = System.Drawing.Color.Transparent;
this.lnkSelectFont.Location = new System.Drawing.Point(512, 16);
this.lnkSelectFont.Name = "lnkSelectFont";
this.lnkSelectFont.Size = new System.Drawing.Size(54, 17);
this.lnkSelectFont.TabIndex = 12;
this.lnkSelectFont.TabStop = true;
this.lnkSelectFont.Text = "设置字体";
this.lnkSelectFont.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkSelectFont_LinkClicked);
//
// lnkCut
//
this.lnkCut.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkCut.AutoSize = true;
this.lnkCut.BackColor = System.Drawing.Color.Transparent;
this.lnkCut.Location = new System.Drawing.Point(352, 40);
this.lnkCut.Name = "lnkCut";
this.lnkCut.Size = new System.Drawing.Size(29, 17);
this.lnkCut.TabIndex = 5;
this.lnkCut.TabStop = true;
this.lnkCut.Text = "剪切";
this.lnkCut.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkCut_LinkClicked);
//
// lnkCopy
//
this.lnkCopy.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkCopy.AutoSize = true;
this.lnkCopy.BackColor = System.Drawing.Color.Transparent;
this.lnkCopy.Location = new System.Drawing.Point(392, 40);
this.lnkCopy.Name = "lnkCopy";
this.lnkCopy.Size = new System.Drawing.Size(29, 17);
this.lnkCopy.TabIndex = 4;
this.lnkCopy.TabStop = true;
this.lnkCopy.Text = "复制";
this.lnkCopy.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkCopy_LinkClicked);
//
// lnkPaste
//
this.lnkPaste.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkPaste.AutoSize = true;
this.lnkPaste.BackColor = System.Drawing.Color.Transparent;
this.lnkPaste.Location = new System.Drawing.Point(432, 40);
this.lnkPaste.Name = "lnkPaste";
this.lnkPaste.Size = new System.Drawing.Size(29, 17);
this.lnkPaste.TabIndex = 6;
this.lnkPaste.TabStop = true;
this.lnkPaste.Text = "粘贴";
this.lnkPaste.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkPaste_LinkClicked);
//
// lnkSelectAll
//
this.lnkSelectAll.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkSelectAll.AutoSize = true;
this.lnkSelectAll.BackColor = System.Drawing.Color.Transparent;
this.lnkSelectAll.Location = new System.Drawing.Point(472, 40);
this.lnkSelectAll.Name = "lnkSelectAll";
this.lnkSelectAll.Size = new System.Drawing.Size(29, 17);
this.lnkSelectAll.TabIndex = 8;
this.lnkSelectAll.TabStop = true;
this.lnkSelectAll.Text = "全选";
this.lnkSelectAll.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkSelectAll_LinkClicked);
//
// lnkFind
//
this.lnkFind.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lnkFind.AutoSize = true;
this.lnkFind.BackColor = System.Drawing.Color.Transparent;
this.lnkFind.Location = new System.Drawing.Point(512, 40);
this.lnkFind.Name = "lnkFind";
this.lnkFind.Size = new System.Drawing.Size(54, 17);
this.lnkFind.TabIndex = 7;
this.lnkFind.TabStop = true;
this.lnkFind.Text = "查找替换";
this.lnkFind.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkFind_LinkClicked);
//
// btnAddFile
//
this.btnAddFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnAddFile.BackColor = System.Drawing.Color.Transparent;
this.btnAddFile.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnAddFile.Location = new System.Drawing.Point(496, 208);
this.btnAddFile.Name = "btnAddFile";
this.btnAddFile.Size = new System.Drawing.Size(80, 24);
this.btnAddFile.TabIndex = 3;
this.btnAddFile.Text = "添加文件";
this.btnAddFile.Click += new System.EventHandler(this.btnAddFile_Click);
//
// lstFiles
//
this.lstFiles.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lstFiles.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lstFiles.ItemHeight = 12;
this.lstFiles.Location = new System.Drawing.Point(24, 208);
this.lstFiles.Name = "lstFiles";
this.lstFiles.Size = new System.Drawing.Size(448, 110);
this.lstFiles.TabIndex = 2;
this.lstFiles.SelectedIndexChanged += new System.EventHandler(this.lstFiles_SelectedIndexChanged);
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(24, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(42, 17);
this.label1.TabIndex = 1;
this.label1.Text = "说明:";
//
// btnDeleteFile
//
this.btnDeleteFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnDeleteFile.BackColor = System.Drawing.Color.Transparent;
this.btnDeleteFile.Enabled = false;
this.btnDeleteFile.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnDeleteFile.Location = new System.Drawing.Point(496, 252);
this.btnDeleteFile.Name = "btnDeleteFile";
this.btnDeleteFile.Size = new System.Drawing.Size(80, 24);
this.btnDeleteFile.TabIndex = 3;
this.btnDeleteFile.Text = "删除文件";
this.btnDeleteFile.Click += new System.EventHandler(this.btnDeleteFile_Click);
//
// btnExportFile
//
this.btnExportFile.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnExportFile.BackColor = System.Drawing.Color.Transparent;
this.btnExportFile.Enabled = false;
this.btnExportFile.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnExportFile.Location = new System.Drawing.Point(496, 296);
this.btnExportFile.Name = "btnExportFile";
this.btnExportFile.Size = new System.Drawing.Size(80, 24);
this.btnExportFile.TabIndex = 3;
this.btnExportFile.Text = "导出文件";
this.btnExportFile.Click += new System.EventHandler(this.btnExportFile_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(24, 184);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(66, 17);
this.label2.TabIndex = 1;
this.label2.Text = "文件清单:";
//
// openFileDialog1
//
this.openFileDialog1.Filter = "*.*|*.*";
this.openFileDialog1.Multiselect = true;
this.openFileDialog1.RestoreDirectory = true;
//
// saveFileDialog1
//
this.saveFileDialog1.Filter = "*.*|*.*";
this.saveFileDialog1.RestoreDirectory = true;
//
// frmFolder
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(632, 358);
this.Controls.Add(this.pnlFolder);
this.Name = "frmFolder";
this.Text = "frmFolder";
this.pnlFolder.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
#region 变量区
private AttachFileAccessObj FileSaver;
private FolderAccessObj FolderSaver = null;
public frmFolder(FolderAccessObj foldersaver)
{
this.InitializeComponent();
this.FolderSaver = foldersaver;
this.FileSaver = new AttachFileAccessObj(this.FolderSaver.dbObj);
}
private Folder _Folder = null;
public Folder FolderObject
{
get
{
return this._Folder;
}
set
{
if(this._Folder != null)
{
this.UpdateDB();
}
this._Folder = value;
this.ShowObjInForm();
}
}
#endregion
#region 系统功能区
/// <summary>
/// 清除所有输出框
/// </summary>
public void ClearInput()
{
this.txtComment.Text = "";
this.lstFiles.Items.Clear();
this.btnAddFile.Enabled = true;
this.btnDeleteFile.Enabled = false;
this.btnExportFile.Enabled = false;
}
/// <summary>
/// 更新对象信息
/// </summary>
private void UpdateObj()
{
this._Folder.Text = this.txtComment.Text;
this._Folder.RTFText = this.txtComment.Rtf;
}
/// <summary>
/// 更新文件加对象到数据库
/// </summary>
public void UpdateDB()
{
if(this._Folder == null)
return;
//存入数据库中
if(this._Folder.HasChanged)
{
this.FolderSaver.UpdateDBRow(this._Folder,true);
this._Folder.HasChanged = false;
}
}
/// <summary>
/// 将文件名显示在ListBox中,同时装入FileID
/// </summary>
private void ShowObjInForm()
{
if(this._Folder.RTFText.Trim() == string.Empty)
{
this.txtComment.Text = this._Folder.Text;
}
else
{
this.txtComment.Rtf = this._Folder.RTFText;
}
//必须调用自定义的Clear过程,以同步清除所有的Tag对象
this.lstFiles.Clear();
Attachment file;
for(int i=0; i<this._Folder.AttachFiles.Count; i++)
{
file = this._Folder.AttachFiles[i] as Attachment;
this.lstFiles.Add(file.FileName, file.FileID);
}
}
/// <summary>
/// 增加文件,同时保存到数据库中
/// </summary>
private void AddFile()
{
string FileName;
Attachment fileObj;
if(this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
FileName = this.openFileDialog1.FileName;
if(FileName.Trim() == string.Empty)
return;
try
{
this.Cursor = Cursors.WaitCursor;
foreach(string filename in this.openFileDialog1.FileNames)
{
fileObj = this.FolderSaver.AddFile(this._Folder, filename);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -