mirror of
https://github.com/wmjordan/PDFPatcher.git
synced 2026-10-18 21:52:34 +08:00
a25ebdfd4d
一般是在 if 控制范围很大的情况下进行调整,如果控制范围小则不调整。 从第三方代码的 Demo 中复制的代码块不修改。
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using System.Windows.Forms;
|
|
|
|
namespace PDFPatcher.Functions
|
|
{
|
|
internal sealed class MacroMenu : ContextMenuStrip
|
|
{
|
|
readonly TextBox __editOperationWrapper = new TextBox();
|
|
|
|
internal const string InsertText = "插入";
|
|
//internal const string Copy = "复制";
|
|
//internal const string Paste = "粘贴";
|
|
//internal const string Cut = "剪切";
|
|
//internal const string Delete = "删除";
|
|
|
|
//internal void LoadCopyEditMacros () {
|
|
// this.Items.AddRange (new ToolStripItem[] {
|
|
// new ToolStripMenuItem (Cut),
|
|
// new ToolStripMenuItem (Copy),
|
|
// new ToolStripMenuItem (Paste),
|
|
// new ToolStripMenuItem (Delete)
|
|
// });
|
|
//}
|
|
public MacroMenu() : base() { }
|
|
public MacroMenu(System.ComponentModel.IContainer container) : base(container) { }
|
|
|
|
internal void AddInsertMacroMenuItem(string text) {
|
|
Items.Add(InsertText + text);
|
|
}
|
|
|
|
internal void LoadStandardSourceFileMacros() {
|
|
Items.AddRange(new ToolStripItem[] {
|
|
new ToolStripMenuItem (InsertText + Constants.FileNameMacros.PathName),
|
|
new ToolStripMenuItem (InsertText + Constants.FileNameMacros.FileName),
|
|
new ToolStripMenuItem (InsertText + Constants.FileNameMacros.FolderName)
|
|
});
|
|
}
|
|
|
|
internal void LoadStandardInfoMacros() {
|
|
Items.AddRange(new ToolStripItem[] {
|
|
new ToolStripMenuItem (InsertText + Constants.FileNameMacros.TitleProperty),
|
|
new ToolStripMenuItem (InsertText + Constants.FileNameMacros.AuthorProperty),
|
|
new ToolStripMenuItem (InsertText + Constants.FileNameMacros.SubjectProperty),
|
|
new ToolStripMenuItem (InsertText + Constants.FileNameMacros.KeywordsProperty)
|
|
});
|
|
}
|
|
|
|
internal void ProcessInsertMacroCommand(object sender, ToolStripItemClickedEventArgs e) {
|
|
var t = e.ClickedItem.Text;
|
|
if (!t.StartsWith(InsertText)) {
|
|
return;
|
|
}
|
|
|
|
t = t.Substring(InsertText.Length);
|
|
var c = SourceControl as TextBoxBase;
|
|
if (c != null) {
|
|
c.SelectedText = t;
|
|
return;
|
|
}
|
|
var cb = SourceControl as ComboBox;
|
|
if (cb != null) {
|
|
cb.SelectedText = t;
|
|
}
|
|
}
|
|
}
|
|
}
|