mirror of
https://github.com/wmjordan/PDFPatcher.git
synced 2026-10-29 03:46:55 +08:00
!重构代码
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PDFPatcher.Common
|
||||
|
||||
@@ -43,10 +43,8 @@ namespace PDFPatcher.Functions
|
||||
else if (args.ProgressPercentage > 0) {
|
||||
_ProgressBar.SetValue(args.ProgressPercentage);
|
||||
}
|
||||
else {
|
||||
if (args.UserState is PageFont pf) {
|
||||
_FontListBox.AddObject(pf);
|
||||
}
|
||||
else if (args.UserState is PageFont pf) {
|
||||
_FontListBox.AddObject(pf);
|
||||
}
|
||||
};
|
||||
_Worker.RunWorkerCompleted += (s, args) => {
|
||||
@@ -133,8 +131,7 @@ namespace PDFPatcher.Functions
|
||||
}
|
||||
}
|
||||
|
||||
private void SetGoal(int goal) { _ProgressBar.Maximum = goal; }
|
||||
private void _ListFontsButton_Click(object sender, EventArgs e) {
|
||||
void _ListFontsButton_Click(object sender, EventArgs e) {
|
||||
_ProgressBar.Value = 0;
|
||||
_ListFontsButton.Enabled = false;
|
||||
_Worker.RunWorkerAsync();
|
||||
@@ -159,7 +156,7 @@ namespace PDFPatcher.Functions
|
||||
}
|
||||
}
|
||||
|
||||
private void _SelectAllButton_Click(object sender, EventArgs e) {
|
||||
void _SelectAllButton_Click(object sender, EventArgs e) {
|
||||
if (_FontListBox.GetItemCount() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -172,7 +169,7 @@ namespace PDFPatcher.Functions
|
||||
_FontListBox.Focus();
|
||||
}
|
||||
|
||||
private void _AddSelectedFontsButton_Click(object sender, EventArgs e) {
|
||||
void _AddSelectedFontsButton_Click(object sender, EventArgs e) {
|
||||
if (SubstitutionsEditor == null) {
|
||||
return;
|
||||
}
|
||||
@@ -185,7 +182,7 @@ namespace PDFPatcher.Functions
|
||||
Close();
|
||||
}
|
||||
|
||||
private void _AppConfigButton_Click(object sender, EventArgs e) {
|
||||
void _AppConfigButton_Click(object sender, EventArgs e) {
|
||||
this.ShowDialog<AppOptionForm>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,8 +130,7 @@ namespace PDFPatcher.Functions
|
||||
if (o == null) {
|
||||
return;
|
||||
}
|
||||
var f = o.GetFileDropList();
|
||||
foreach (var item in f) {
|
||||
foreach (var item in o.GetFileDropList()) {
|
||||
if (FileHelper.HasExtension(item, Constants.FileExtensions.Xml)
|
||||
|| FileHelper.HasExtension(item, Constants.FileExtensions.Pdf)) {
|
||||
args.Handled = true;
|
||||
@@ -150,7 +149,7 @@ namespace PDFPatcher.Functions
|
||||
e.Effect = DragDropEffects.None;
|
||||
return;
|
||||
}
|
||||
var copy = (Control.ModifierKeys & Keys.Control) != Keys.None || (e.SourceModels[0] as XmlElement).OwnerDocument != ti.OwnerDocument;
|
||||
var copy = (ModifierKeys & Keys.Control) != Keys.None || (e.SourceModels[0] as XmlElement).OwnerDocument != ti.OwnerDocument;
|
||||
if (copy == false) {
|
||||
if (e.DropTargetItem.Selected) {
|
||||
e.Effect = DragDropEffects.None;
|
||||
@@ -195,8 +194,8 @@ namespace PDFPatcher.Functions
|
||||
Freeze();
|
||||
var child = ml.X > d.Position.X + d.GetBounds(ItemBoundsPortion.ItemOnly).Width / 2;
|
||||
var append = ml.Y > d.Position.Y + d.Bounds.Height / 2;
|
||||
var copy = (Control.ModifierKeys & Keys.Control) != Keys.None || (args.SourceModels[0] as BookmarkElement).OwnerDocument != ti.OwnerDocument;
|
||||
var deepCopy = copy && (OperationAffectsDescendants || (Control.ModifierKeys & Keys.Shift) != Keys.None);
|
||||
var copy = (ModifierKeys & Keys.Control) != Keys.None || (args.SourceModels[0] as BookmarkElement).OwnerDocument != ti.OwnerDocument;
|
||||
var deepCopy = copy && (OperationAffectsDescendants || (ModifierKeys & Keys.Shift) != Keys.None);
|
||||
var tii = TopItemIndex;
|
||||
CopyOrMoveElement(se, ti, child, append, copy, deepCopy);
|
||||
//e.RefreshObjects ();
|
||||
@@ -265,12 +264,6 @@ namespace PDFPatcher.Functions
|
||||
pn.Add(e);
|
||||
}
|
||||
}
|
||||
//else {
|
||||
// foreach (var item in source) {
|
||||
// this.Collapse (item);
|
||||
// }
|
||||
// this.RemoveObjects (source);
|
||||
//}
|
||||
if (child) {
|
||||
if (after) {
|
||||
tpr = target.Name == Constants.DocumentBookmark;
|
||||
|
||||
@@ -108,8 +108,7 @@ namespace MuPdfSharp
|
||||
if (grayscale) {
|
||||
bmp.Palette.CreateGrayscalePalette();
|
||||
for (int y = height - 1; y >= 0; y--) {
|
||||
var pDest = bmp.GetScanlinePointer(y);
|
||||
var pl = (byte*)pDest.ToPointer();
|
||||
var pl = (byte*)bmp.GetScanlinePointer(y).ToPointer();
|
||||
var sl = ptrSrc;
|
||||
for (int x = 0; x < width; x++) {
|
||||
*pl = invert ? (byte)(*sl ^ 0xFF) : *sl;
|
||||
@@ -121,8 +120,7 @@ namespace MuPdfSharp
|
||||
}
|
||||
else { // DeviceBGR
|
||||
for (int y = height - 1; y >= 0; y--) {
|
||||
var pDest = bmp.GetScanlinePointer(y);
|
||||
var pl = (byte*)pDest.ToPointer();
|
||||
var pl = (byte*)bmp.GetScanlinePointer(y).ToPointer();
|
||||
var sl = ptrSrc;
|
||||
if (invert) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
|
||||
Reference in New Issue
Block a user