!重构代码

This commit is contained in:
WMJ
2022-07-19 10:08:25 +08:00
parent 2e8594fd86
commit b8217429cc
3 changed files with 58 additions and 61 deletions
+34 -34
View File
@@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
@@ -13,13 +13,13 @@ namespace PDFPatcher {
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Configuration {
@@ -33,7 +33,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
@@ -47,8 +47,8 @@ namespace PDFPatcher {
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性
/// 重写当前线程的 CurrentUICulture 属性。
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@@ -61,7 +61,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 书签文本 的本地化字符串。
/// Looks up a localized string similar to 书签文本.
/// </summary>
internal static string BookmarkText {
get {
@@ -70,7 +70,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 自定义工具栏按钮 的本地化字符串。
/// Looks up a localized string similar to 自定义工具栏按钮.
/// </summary>
internal static string CustomToolbarButtons {
get {
@@ -79,7 +79,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 文档属性 的本地化字符串。
/// Looks up a localized string similar to 文档属性.
/// </summary>
internal static string DocInfo {
get {
@@ -88,7 +88,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 正文文本 的本地化字符串。
/// Looks up a localized string similar to 正文文本.
/// </summary>
internal static string DocText {
get {
@@ -97,7 +97,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 编码方式 的本地化字符串。
/// Looks up a localized string similar to 编码方式.
/// </summary>
internal static string Encodings {
get {
@@ -106,7 +106,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 导出图片目录 的本地化字符串。
/// Looks up a localized string similar to 导出图片目录.
/// </summary>
internal static string Folders {
get {
@@ -115,7 +115,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 信息文件 的本地化字符串。
/// Looks up a localized string similar to 信息文件.
/// </summary>
internal static string InfoFiles {
get {
@@ -124,7 +124,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 减少占用内存 的本地化字符串。
/// Looks up a localized string similar to 减少占用内存.
/// </summary>
internal static string OptimalMemoryUsage {
get {
@@ -133,7 +133,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 优化处理效率 的本地化字符串。
/// Looks up a localized string similar to 优化处理效率.
/// </summary>
internal static string OptimalSpeed {
get {
@@ -142,7 +142,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 处理选项 的本地化字符串。
/// Looks up a localized string similar to 处理选项.
/// </summary>
internal static string Options {
get {
@@ -151,7 +151,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 路径 的本地化字符串。
/// Looks up a localized string similar to 路径.
/// </summary>
internal static string Path {
get {
@@ -160,7 +160,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 PDF读取方式 的本地化字符串。
/// Looks up a localized string similar to PDF读取方式.
/// </summary>
internal static string PdfLoadMode {
get {
@@ -169,7 +169,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 PDF阅读器路径 的本地化字符串。
/// Looks up a localized string similar to PDF阅读器路径.
/// </summary>
internal static string PdfReaderPath {
get {
@@ -178,7 +178,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 历史文件 的本地化字符串。
/// Looks up a localized string similar to 历史文件.
/// </summary>
internal static string RecentFiles {
get {
@@ -187,7 +187,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 替换文本 的本地化字符串。
/// Looks up a localized string similar to 替换文本.
/// </summary>
internal static string ReplaceItems {
get {
@@ -196,7 +196,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 配置文件 的本地化字符串。
/// Looks up a localized string similar to 配置文件.
/// </summary>
internal static string Root {
get {
@@ -205,7 +205,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 保存程序配置 的本地化字符串。
/// Looks up a localized string similar to 保存程序配置.
/// </summary>
internal static string SaveAppSettings {
get {
@@ -214,7 +214,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 查找文本 的本地化字符串。
/// Looks up a localized string similar to 查找文本.
/// </summary>
internal static string SearchItems {
get {
@@ -223,7 +223,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 输入文件 的本地化字符串。
/// Looks up a localized string similar to 输入文件.
/// </summary>
internal static string SourceFiles {
get {
@@ -232,7 +232,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 目标文件 的本地化字符串。
/// Looks up a localized string similar to 目标文件.
/// </summary>
internal static string TargetFiles {
get {
@@ -241,7 +241,7 @@ namespace PDFPatcher {
}
/// <summary>
/// 查找类似 版本 的本地化字符串。
/// Looks up a localized string similar to 版本.
/// </summary>
internal static string Version {
get {
+21 -27
View File
@@ -18,7 +18,7 @@ namespace PDFPatcher.Functions
static readonly CommandRegistry<Editor.Controller> __Commands = InitCommands();
private static CommandRegistry<Editor.Controller> InitCommands() {
static CommandRegistry<Editor.Controller> InitCommands() {
var d = new CommandRegistry<Editor.Controller>();
d.Register(new Editor.LoadDocumentCommand(true, false), Commands.Open);
d.Register(new Editor.LoadDocumentCommand(true, true), Commands.ImportBookmark);
@@ -114,7 +114,7 @@ namespace PDFPatcher.Functions
di.Insert(0, new ToolStripMenuItem { Name = Constants.Coordinates.Unchanged, Text = Constants.Coordinates.Unchanged });
_ChangeZoomRate.DropDownItemClicked += _MainToolbar_ItemClicked;
_ChangeCase.DropDownItemClicked += (object s, ToolStripItemClickedEventArgs args) => {
FormHelper.HidePopupMenu(args.ClickedItem);
args.ClickedItem.HidePopupMenu();
_EditMenu.Hide();
var i = Array.IndexOf(SetCaseProcessor.CaseNames, args.ClickedItem.Text);
if (i != -1) {
@@ -127,7 +127,7 @@ namespace PDFPatcher.Functions
_SetOpenStatus.DropDownItemClicked += _MainToolbar_ItemClicked;
AppContext.MainForm.SetTooltip(_IncludeDecendantBox, "选中此选项后,加粗、斜体等其它修改书签的操作将应用到选中书签的子书签");
_IncludeDecendantBox.CheckedChanged += (s, args) => { _BookmarkBox.OperationAffectsDescendants = _IncludeDecendantBox.Checked; };
_IncludeDecendantBox.CheckedChanged += (s, args) => _BookmarkBox.OperationAffectsDescendants = _IncludeDecendantBox.Checked;
_UndoButton.DropDownOpening += (object s, EventArgs args) => {
var i = _UndoMenu.Items;
@@ -191,7 +191,7 @@ namespace PDFPatcher.Functions
break;
case Keys.Home:
_ViewerBox.CurrentPageNumber = 1;
return;
return;
case Keys.End:
_ViewerBox.CurrentPageNumber = -1;
return;
@@ -202,12 +202,8 @@ namespace PDFPatcher.Functions
_ViewerBox.CurrentPageNumber = p + d;
}
};
_ViewerButton.DropDownOpening += (s, args) => {
SetupMenu(_ViewerButton.DropDownItems);
};
_OcrMenu.DropDownItemClicked += (s, args) => {
_ViewerBox.OcrLanguage = (int)(args.ClickedItem.Tag ?? 0);
};
_ViewerButton.DropDownOpening += (s, args) => SetupMenu(_ViewerButton.DropDownItems);
_OcrMenu.DropDownItemClicked += (s, args) => _ViewerBox.OcrLanguage = (int)(args.ClickedItem.Tag ?? 0);
_OcrMenu.DropDownOpening += (s, args) => {
var m = _OcrMenu.DropDownItems;
if (m.Count == 1) {
@@ -223,9 +219,7 @@ namespace PDFPatcher.Functions
}
};
_ZoomBox.Text = Constants.DestinationAttributes.ViewType.FitH;
_ZoomBox.TextChanged += (s, args) => {
_ViewerBox.LiteralZoom = _ZoomBox.Text;
};
_ZoomBox.TextChanged += (s, args) => _ViewerBox.LiteralZoom = _ZoomBox.Text;
_ViewerBox.Enabled = false;
_ViewerBox.DocumentLoaded += (s, args) => _CurrentPageBox.ToolTipText = "文档共" + _ViewerBox.Document.PageCount + "页\nHome:转到第一页\nEnd:转到最后一页";
_ViewerBox.ZoomChanged += (s, args) => _ZoomBox.ToolTipText = "当前显示比例:" + (_ViewerBox.ZoomFactor * 100).ToInt32() + "%";
@@ -255,10 +249,10 @@ namespace PDFPatcher.Functions
_ViewerBox.MouseClick += _ViewBox_MouseClick;
_ViewerToolbar.Enabled = false;
Disposed += (s, args) => { _controller.Destroy(); };
Disposed += (s, args) => _controller.Destroy();
}
private void ScrollToSelectedBookmarkLocation() {
void ScrollToSelectedBookmarkLocation() {
BookmarkElement el;
var i = _BookmarkBox.GetFirstSelectedIndex();
//_MainToolbar.ToggleEnabled (i != -1, _editButtonNames);
@@ -290,7 +284,7 @@ namespace PDFPatcher.Functions
_searchForm?.Close();
}
private void _ViewBox_MouseClick(object sender, MouseEventArgs args) {
void _ViewBox_MouseClick(object sender, MouseEventArgs args) {
if (_ViewerBox.FirstPage == 0) {
return;
}
@@ -311,12 +305,12 @@ namespace PDFPatcher.Functions
//_controller.ShowInsertBookmarkDialog (l, p, t);
}
private void _MainToolbar_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {
FormHelper.HidePopupMenu(e.ClickedItem);
void _MainToolbar_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {
e.ClickedItem.HidePopupMenu();
ExecuteCommand(e.ClickedItem.Name);
}
private void ButtonClicked(object sender, EventArgs e) {
void ButtonClicked(object sender, EventArgs e) {
if (sender == _UndoButton) {
_controller.Undo(1);
}
@@ -468,12 +462,12 @@ namespace PDFPatcher.Functions
_ViewerBox.Reopen();
}
private void _BookmarkColorButton_SelectedColorChanged(object sender, EventArgs e) {
void _BookmarkColorButton_SelectedColorChanged(object sender, EventArgs e) {
var c = _BookmarkColorButton.Color;
_controller.ProcessBookmarks(new SetTextColorProcessor(c));
}
private void _OpenButton_DropDownOpening(object sender, EventArgs e) {
void _OpenButton_DropDownOpening(object sender, EventArgs e) {
var m = (sender as ToolStripDropDownItem);
var l = m.DropDown.Items;
l.ClearDropDownItems();
@@ -484,8 +478,8 @@ namespace PDFPatcher.Functions
l.AddInfoFiles();
}
private void _OpenButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) {
FormHelper.HidePopupMenu(e.ClickedItem);
void _OpenButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) {
e.ClickedItem.HidePopupMenu();
ExecuteCommand(Commands.OpenFile, e.ClickedItem.ToolTipText);
}
@@ -553,12 +547,12 @@ namespace PDFPatcher.Functions
return base.ProcessCmdKey(ref msg, keyData);
}
private void _BookmarkBox_DragEnter(object sender, DragEventArgs e) {
FormHelper.FeedbackDragFileOver(e, Constants.FileExtensions.PdfAndAllBookmarkExtension);
void _BookmarkBox_DragEnter(object sender, DragEventArgs e) {
e.FeedbackDragFileOver(Constants.FileExtensions.PdfAndAllBookmarkExtension);
}
private void _BookmarkBox_DragDrop(object sender, DragEventArgs e) {
if (FormHelper.DropFileOver(this, e, Constants.FileExtensions.PdfAndAllBookmarkExtension)) {
void _BookmarkBox_DragDrop(object sender, DragEventArgs e) {
if (this.DropFileOver(e, Constants.FileExtensions.PdfAndAllBookmarkExtension)) {
_controller.LoadDocument(Text, false);
}
}
+3
View File
@@ -20,6 +20,7 @@
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
@@ -31,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<UseVSHostingProcess>false</UseVSHostingProcess>
<LangVersion>latest</LangVersion>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>..\bin\Release\</OutputPath>
@@ -42,6 +44,7 @@
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
<LangVersion>latest</LangVersion>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Common\app.manifest</ApplicationManifest>