mirror of
https://github.com/wmjordan/PDFPatcher.git
synced 2026-10-16 20:31:48 +08:00
Convert .cs and .txt file encoding to UTF-8 with BOM
Convert the file encoding format to prevent VS from issuing warnings and displaying garbled characters.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Devcorp.Controls.Design
|
namespace Devcorp.Controls.Design
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Devcorp.Controls.Design
|
namespace Devcorp.Controls.Design
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Devcorp.Controls.Design
|
namespace Devcorp.Controls.Design
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@@ -774,26 +774,26 @@ namespace Devcorp.Controls.Design
|
|||||||
|
|
||||||
#region CMYK convert
|
#region CMYK convert
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将四色分量(必须为 0~1)转换为 RGB 颜色。
|
/// 将四色分量(必须为 0~1)转换为 RGB 颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="c">青</param>
|
/// <param name="c">青</param>
|
||||||
/// <param name="m">紫</param>
|
/// <param name="m">紫</param>
|
||||||
/// <param name="y">黄</param>
|
/// <param name="y">黄</param>
|
||||||
/// <param name="k">黑</param>
|
/// <param name="k">黑</param>
|
||||||
/// <returns>颜色。</returns>
|
/// <returns>颜色。</returns>
|
||||||
public static Color CMYKtoColor (float c, float m, float y, float k)
|
public static Color CMYKtoColor (float c, float m, float y, float k)
|
||||||
{
|
{
|
||||||
return CMYKtoColor((double)c, (double)m, (double)y, (double)k);
|
return CMYKtoColor((double)c, (double)m, (double)y, (double)k);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将四色分量(必须为 0~1)转换为 RGB 颜色。
|
/// 将四色分量(必须为 0~1)转换为 RGB 颜色。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="c">青</param>
|
/// <param name="c">青</param>
|
||||||
/// <param name="m">紫</param>
|
/// <param name="m">紫</param>
|
||||||
/// <param name="y">黄</param>
|
/// <param name="y">黄</param>
|
||||||
/// <param name="k">黑</param>
|
/// <param name="k">黑</param>
|
||||||
/// <returns>颜色。</returns>
|
/// <returns>颜色。</returns>
|
||||||
public static Color CMYKtoColor (double c, double m, double y, double k)
|
public static Color CMYKtoColor (double c, double m, double y, double k)
|
||||||
{
|
{
|
||||||
return CMYKtoColor(new CMYK(c,m,y,k));
|
return CMYKtoColor(new CMYK(c,m,y,k));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Devcorp.Controls.Design
|
namespace Devcorp.Controls.Design
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Devcorp.Controls.Design
|
namespace Devcorp.Controls.Design
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Devcorp.Controls.Design
|
namespace Devcorp.Controls.Design
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Devcorp.Controls.Design
|
namespace Devcorp.Controls.Design
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Having received many constructive comments and bug reports about my previous
|
Having received many constructive comments and bug reports about my previous
|
||||||
C implementation of my color quantizer (Graphics Gems vol. II, p. 126-133),
|
C implementation of my color quantizer (Graphics Gems vol. II, p. 126-133),
|
||||||
I am posting the following second version of my program (hopefully 100%
|
I am posting the following second version of my program (hopefully 100%
|
||||||
healthy) as a reply to all those who are interested in the problem.
|
healthy) as a reply to all those who are interested in the problem.
|
||||||
|
|||||||
@@ -1,32 +1,32 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
|
||||||
namespace MuPdfSharp
|
namespace MuPdfSharp
|
||||||
{
|
{
|
||||||
public sealed class MuPage : IDisposable
|
public sealed class MuPage : IDisposable
|
||||||
{
|
{
|
||||||
#region 非托管资源成员
|
#region 非托管资源成员
|
||||||
private ContextHandle _context;
|
private ContextHandle _context;
|
||||||
private DocumentHandle _document;
|
private DocumentHandle _document;
|
||||||
private PageHandle _page;
|
private PageHandle _page;
|
||||||
private DisplayListHandle _displayList;
|
private DisplayListHandle _displayList;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 托管资源成员
|
#region 托管资源成员
|
||||||
static readonly ImageRendererOptions __defaultOptions = new ImageRendererOptions ();
|
static readonly ImageRendererOptions __defaultOptions = new ImageRendererOptions ();
|
||||||
MuCookie _cookie;
|
MuCookie _cookie;
|
||||||
MuTextPage _TextPage;
|
MuTextPage _TextPage;
|
||||||
bool _flattened;
|
bool _flattened;
|
||||||
|
|
||||||
/// <summary>获取当前页面的页码。</summary>
|
/// <summary>获取当前页面的页码。</summary>
|
||||||
public int PageNumber { get; private set; }
|
public int PageNumber { get; private set; }
|
||||||
/// <summary>获取当前页面的尺寸(左下角坐标置为“0,0”)。如需获取页面字典中的原始可视区域,请使用 <see cref="VisualBound"/> 属性。</summary>
|
/// <summary>获取当前页面的尺寸(左下角坐标置为“0,0”)。如需获取页面字典中的原始可视区域,请使用 <see cref="VisualBound"/> 属性。</summary>
|
||||||
public Rectangle Bound {
|
public Rectangle Bound {
|
||||||
get {
|
get {
|
||||||
return NativeMethods.BoundPage (_context, _page);
|
return NativeMethods.BoundPage (_context, _page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>获取当前页面可视区域的坐标及尺寸。</summary>
|
/// <summary>获取当前页面可视区域的坐标及尺寸。</summary>
|
||||||
public Rectangle VisualBound => Matrix.Identity.RotateTo(Rotation).Transform(VisualBox);
|
public Rectangle VisualBound => Matrix.Identity.RotateTo(Rotation).Transform(VisualBox);
|
||||||
|
|
||||||
public Rectangle ArtBox => LookupPageBox("ArtBox");
|
public Rectangle ArtBox => LookupPageBox("ArtBox");
|
||||||
@@ -70,46 +70,46 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
catch (AccessViolationException) {
|
catch (AccessViolationException) {
|
||||||
_page.DisposeHandle ();
|
_page.DisposeHandle ();
|
||||||
throw new MuPdfException ("无法加载第 " + pageNumber + " 页。");
|
throw new MuPdfException ("无法加载第 " + pageNumber + " 页。");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 获取指定区域的文本。
|
///// 获取指定区域的文本。
|
||||||
///// </summary>
|
///// </summary>
|
||||||
///// <param name="selection">区域。</param>
|
///// <param name="selection">区域。</param>
|
||||||
///// <returns>区域内的文本。</returns>
|
///// <returns>区域内的文本。</returns>
|
||||||
//public string GetSelection (Rectangle selection) {
|
//public string GetSelection (Rectangle selection) {
|
||||||
// return Interop.DecodeUtf8String (NativeMethods.CopySelection (_context, GetTextPage (), selection));
|
// return Interop.DecodeUtf8String (NativeMethods.CopySelection (_context, GetTextPage (), selection));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 获取指定区域的文本。
|
///// 获取指定区域的文本。
|
||||||
///// </summary>
|
///// </summary>
|
||||||
///// <param name="selection">区域。</param>
|
///// <param name="selection">区域。</param>
|
||||||
///// <returns>区域内的文本。</returns>
|
///// <returns>区域内的文本。</returns>
|
||||||
//public List<Rectangle> HighlightSelection (Rectangle selection) {
|
//public List<Rectangle> HighlightSelection (Rectangle selection) {
|
||||||
// var l =
|
// var l =
|
||||||
// return Interop.DecodeUtf8String (NativeMethods.HighlightSelection (_context, _page, selection));
|
// return Interop.DecodeUtf8String (NativeMethods.HighlightSelection (_context, _page, selection));
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 使用默认的配置渲染页面。
|
/// 使用默认的配置渲染页面。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="width">页面的宽度。</param>
|
/// <param name="width">页面的宽度。</param>
|
||||||
/// <param name="height">页面的高度。</param>
|
/// <param name="height">页面的高度。</param>
|
||||||
/// <returns>渲染后生成的 <see cref="Bitmap"/>。</returns>
|
/// <returns>渲染后生成的 <see cref="Bitmap"/>。</returns>
|
||||||
public FreeImageAPI.FreeImageBitmap RenderPage (int width, int height) {
|
public FreeImageAPI.FreeImageBitmap RenderPage (int width, int height) {
|
||||||
return RenderPage (width, height, __defaultOptions);
|
return RenderPage (width, height, __defaultOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 使用指定的配置渲染页面。
|
/// 使用指定的配置渲染页面。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="width">页面的宽度。</param>
|
/// <param name="width">页面的宽度。</param>
|
||||||
/// <param name="height">页面的高度。</param>
|
/// <param name="height">页面的高度。</param>
|
||||||
/// <param name="options">渲染选项。</param>
|
/// <param name="options">渲染选项。</param>
|
||||||
/// <returns>渲染后生成的 <see cref="FreeImageAPI.FreeImageBitmap"/>。</returns>
|
/// <returns>渲染后生成的 <see cref="FreeImageAPI.FreeImageBitmap"/>。</returns>
|
||||||
public FreeImageAPI.FreeImageBitmap RenderPage (int width, int height, ImageRendererOptions options) {
|
public FreeImageAPI.FreeImageBitmap RenderPage (int width, int height, ImageRendererOptions options) {
|
||||||
using (var pix = InternalRenderPage (width, height, options)) {
|
using (var pix = InternalRenderPage (width, height, options)) {
|
||||||
if (pix != null) {
|
if (pix != null) {
|
||||||
@@ -120,12 +120,12 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 使用指定的配置渲染页面。
|
/// 使用指定的配置渲染页面。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="width">页面的宽度。</param>
|
/// <param name="width">页面的宽度。</param>
|
||||||
/// <param name="height">页面的高度。</param>
|
/// <param name="height">页面的高度。</param>
|
||||||
/// <param name="options">渲染选项。</param>
|
/// <param name="options">渲染选项。</param>
|
||||||
/// <returns>渲染后生成的 <see cref="Bitmap"/>。</returns>
|
/// <returns>渲染后生成的 <see cref="Bitmap"/>。</returns>
|
||||||
public Bitmap RenderBitmapPage (int width, int height, ImageRendererOptions options) {
|
public Bitmap RenderBitmapPage (int width, int height, ImageRendererOptions options) {
|
||||||
using (var pix = InternalRenderPage (width, height, options)) {
|
using (var pix = InternalRenderPage (width, height, options)) {
|
||||||
if (pix != null) {
|
if (pix != null) {
|
||||||
@@ -156,7 +156,7 @@ namespace MuPdfSharp
|
|||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
if (_cookie.ErrorCount > 0) {
|
if (_cookie.ErrorCount > 0) {
|
||||||
System.Diagnostics.Debug.WriteLine("在第 " + PageNumber + " 页有 " + _cookie.ErrorCount + " 个错误。");
|
System.Diagnostics.Debug.WriteLine("在第 " + PageNumber + " 页有 " + _cookie.ErrorCount + " 个错误。");
|
||||||
}
|
}
|
||||||
return _displayList;
|
return _displayList;
|
||||||
}
|
}
|
||||||
@@ -225,7 +225,7 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
catch (AccessViolationException) {
|
catch (AccessViolationException) {
|
||||||
pix.DisposeHandle ();
|
pix.DisposeHandle ();
|
||||||
throw new MuPdfException ("无法渲染页面:" + PageNumber);
|
throw new MuPdfException ("无法渲染页面:" + PageNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,9 +276,9 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取页面内容的实际覆盖范围。
|
/// 获取页面内容的实际覆盖范围。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>包含页面内容的最小 <see cref="BBox"/>。</returns>
|
/// <returns>包含页面内容的最小 <see cref="BBox"/>。</returns>
|
||||||
public Rectangle GetContentBoundary () {
|
public Rectangle GetContentBoundary () {
|
||||||
var b = Bound;
|
var b = Bound;
|
||||||
var o = b;
|
var o = b;
|
||||||
@@ -292,25 +292,25 @@ namespace MuPdfSharp
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
catch (AccessViolationException) {
|
catch (AccessViolationException) {
|
||||||
throw new MuPdfException ("无法获取页面内容边框:" + PageNumber);
|
throw new MuPdfException ("无法获取页面内容边框:" + PageNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 实现 IDisposable 接口的属性和方法
|
#region 实现 IDisposable 接口的属性和方法
|
||||||
private bool disposed;
|
private bool disposed;
|
||||||
public void Dispose () {
|
public void Dispose () {
|
||||||
Dispose (true);
|
Dispose (true);
|
||||||
GC.SuppressFinalize (this); // 抑制析构函数
|
GC.SuppressFinalize (this); // 抑制析构函数
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>释放由 MuPdfPage 占用的资源。</summary>
|
/// <summary>释放由 MuPdfPage 占用的资源。</summary>
|
||||||
/// <param name="disposing">是否手动释放托管资源。</param>
|
/// <param name="disposing">是否手动释放托管资源。</param>
|
||||||
[System.Diagnostics.CodeAnalysis.SuppressMessage ("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_page")]
|
[System.Diagnostics.CodeAnalysis.SuppressMessage ("Microsoft.Usage", "CA2213:DisposableFieldsShouldBeDisposed", MessageId = "_page")]
|
||||||
void Dispose (bool disposing) {
|
void Dispose (bool disposing) {
|
||||||
if (!disposed) {
|
if (!disposed) {
|
||||||
if (disposing) {
|
if (disposing) {
|
||||||
#region 释放托管资源
|
#region 释放托管资源
|
||||||
if (_TextPage != null) {
|
if (_TextPage != null) {
|
||||||
_TextPage.Dispose();
|
_TextPage.Dispose();
|
||||||
}
|
}
|
||||||
@@ -318,8 +318,8 @@ namespace MuPdfSharp
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 释放非托管资源
|
#region 释放非托管资源
|
||||||
// 注意这里不是线程安全的
|
// 注意这里不是线程安全的
|
||||||
//int retry = 0;
|
//int retry = 0;
|
||||||
//_cookie.CancelAsync ();
|
//_cookie.CancelAsync ();
|
||||||
//while (_cookie.IsRunning && ++retry < 10) {
|
//while (_cookie.IsRunning && ++retry < 10) {
|
||||||
@@ -333,8 +333,8 @@ namespace MuPdfSharp
|
|||||||
disposed = true;
|
disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 析构函数只在未调用 Dispose 方法时调用
|
// 析构函数只在未调用 Dispose 方法时调用
|
||||||
// 派生类中不必再提供析构函数
|
// 派生类中不必再提供析构函数
|
||||||
~MuPage () {
|
~MuPage () {
|
||||||
Dispose (false);
|
Dispose (false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
@@ -32,9 +32,9 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加页码标签。如集合中存在相同页码的页码标签,则先将旧的标签删除,再添加新的页码标签。
|
/// 添加页码标签。如集合中存在相同页码的页码标签,则先将旧的标签删除,再添加新的页码标签。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="label">需要添加的页码标签。</param>
|
/// <param name="label">需要添加的页码标签。</param>
|
||||||
public void Add (PageLabel label) {
|
public void Add (PageLabel label) {
|
||||||
Remove (label);
|
Remove (label);
|
||||||
_labels.Add (label);
|
_labels.Add (label);
|
||||||
@@ -42,10 +42,10 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据传入的页码,返回当前页码标签集合格式化后生成的页码。
|
/// 根据传入的页码,返回当前页码标签集合格式化后生成的页码。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="pageNumber">绝对页码。</param>
|
/// <param name="pageNumber">绝对页码。</param>
|
||||||
/// <returns>格式化后的页码文本。</returns>
|
/// <returns>格式化后的页码文本。</returns>
|
||||||
public string Format (int pageNumber) {
|
public string Format (int pageNumber) {
|
||||||
var l = _labels.Count;
|
var l = _labels.Count;
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
@@ -75,10 +75,10 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 返回集合中是否包含具有与 <paramref name="item"/> 相同起始页码的页码标签。
|
/// 返回集合中是否包含具有与 <paramref name="item"/> 相同起始页码的页码标签。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">需要检查起始页码的页码标签。</param>
|
/// <param name="item">需要检查起始页码的页码标签。</param>
|
||||||
/// <returns>如包含相同页码的页码标签,返回 true,否则返回 false。</returns>
|
/// <returns>如包含相同页码的页码标签,返回 true,否则返回 false。</returns>
|
||||||
public bool Contains (PageLabel item) {
|
public bool Contains (PageLabel item) {
|
||||||
for (int i = _labels.Count - 1; i >= 0; i--) {
|
for (int i = _labels.Count - 1; i >= 0; i--) {
|
||||||
if (_labels[i].FromPageNumber == item.FromPageNumber) {
|
if (_labels[i].FromPageNumber == item.FromPageNumber) {
|
||||||
@@ -101,10 +101,10 @@ namespace MuPdfSharp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除集合中具有与 <paramref name="item"/> 相同起始页码的页码标签。
|
/// 删除集合中具有与 <paramref name="item"/> 相同起始页码的页码标签。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">需要删除的页码标签。</param>
|
/// <param name="item">需要删除的页码标签。</param>
|
||||||
/// <returns>如包含相同页码的页码标签,返回 true,否则返回 false。</returns>
|
/// <returns>如包含相同页码的页码标签,返回 true,否则返回 false。</returns>
|
||||||
public bool Remove (PageLabel item) {
|
public bool Remove (PageLabel item) {
|
||||||
for (int i = _labels.Count - 1; i >= 0; i--) {
|
for (int i = _labels.Count - 1; i >= 0; i--) {
|
||||||
if (_labels[i].FromPageNumber == item.FromPageNumber) {
|
if (_labels[i].FromPageNumber == item.FromPageNumber) {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
《PDF 补丁丁(PDFPatcher)》软件最终用户授权协议
|
《PDF 补丁丁(PDFPatcher)》软件最终用户授权协议
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user