Compare commits
10 Commits
d0126e6986
...
342e32f49f
Author | SHA1 | Date | |
---|---|---|---|
342e32f49f | |||
d16d6d4671 | |||
a296604f2c | |||
5013e10cb1 | |||
31ee6d4894 | |||
03e0ffdce8 | |||
f418ec74e5 | |||
e04d6104b2 | |||
d37882d6dd | |||
b97e7d15ee |
Binary file not shown.
@ -373,6 +373,7 @@
|
|||||||
<Compile Include="core\CorrectionCharacter.cs" />
|
<Compile Include="core\CorrectionCharacter.cs" />
|
||||||
<Compile Include="core\CorrectionFragmentAbstract.cs" />
|
<Compile Include="core\CorrectionFragmentAbstract.cs" />
|
||||||
<Compile Include="core\CorrectionRangeAbstract.cs" />
|
<Compile Include="core\CorrectionRangeAbstract.cs" />
|
||||||
|
<Compile Include="core\DocumentReader.cs" />
|
||||||
<Compile Include="core\DocumentText.cs" />
|
<Compile Include="core\DocumentText.cs" />
|
||||||
<Compile Include="core\DocumentUtil.cs" />
|
<Compile Include="core\DocumentUtil.cs" />
|
||||||
<Compile Include="core\EventForwarder.cs" />
|
<Compile Include="core\EventForwarder.cs" />
|
||||||
@ -389,6 +390,7 @@
|
|||||||
<Compile Include="Model\DocumentList.cs" />
|
<Compile Include="Model\DocumentList.cs" />
|
||||||
<Compile Include="Model\ExportDataItem.cs" />
|
<Compile Include="Model\ExportDataItem.cs" />
|
||||||
<Compile Include="Model\InsertMarkData.cs" />
|
<Compile Include="Model\InsertMarkData.cs" />
|
||||||
|
<Compile Include="Model\ProofreadRangeInfo.cs" />
|
||||||
<Compile Include="ProofreadItem.cs" />
|
<Compile Include="ProofreadItem.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
@ -551,6 +553,15 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Resources\icon-ai-robot-wps.jpg" />
|
<None Include="Resources\icon-ai-robot-wps.jpg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\icon-manual.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="Resources\icon-manual-wps.jpg" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="favicon.ico" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
@ -578,6 +589,9 @@
|
|||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<LangVersion>7.3</LangVersion>
|
<LangVersion>7.3</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<ApplicationIcon>favicon.ico</ApplicationIcon>
|
||||||
|
</PropertyGroup>
|
||||||
<!-- Include the build rules for a C# project. -->
|
<!-- Include the build rules for a C# project. -->
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- Include additional build rules for an Office application add-in. -->
|
<!-- Include additional build rules for an Office application add-in. -->
|
||||||
|
@ -7,6 +7,8 @@ using Microsoft.Office.Tools.Word;
|
|||||||
using Microsoft.Web.WebView2.Core;
|
using Microsoft.Web.WebView2.Core;
|
||||||
using Microsoft.Web.WebView2.WinForms;
|
using Microsoft.Web.WebView2.WinForms;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NPOI;
|
||||||
|
using NPOI.SS.Formula;
|
||||||
using NPOI.XSSF.UserModel;
|
using NPOI.XSSF.UserModel;
|
||||||
using NPOI.XWPF.UserModel;
|
using NPOI.XWPF.UserModel;
|
||||||
using Org.BouncyCastle.Asn1.Crmf;
|
using Org.BouncyCastle.Asn1.Crmf;
|
||||||
@ -45,7 +47,7 @@ namespace AIProofread
|
|||||||
|
|
||||||
public static Dictionary<int, ProofreadItem> marks;
|
public static Dictionary<int, ProofreadItem> marks;
|
||||||
|
|
||||||
private static int selectProofreadId = -1;
|
//private static int selectProofreadId = -1;
|
||||||
|
|
||||||
private static object missing = System.Reflection.Missing.Value;
|
private static object missing = System.Reflection.Missing.Value;
|
||||||
|
|
||||||
@ -245,6 +247,8 @@ namespace AIProofread
|
|||||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(Path.Combine(applicationBase, Path.GetFileName(path)))
|
ProcessStartInfo processStartInfo = new ProcessStartInfo(Path.Combine(applicationBase, Path.GetFileName(path)))
|
||||||
{
|
{
|
||||||
WorkingDirectory = applicationBase,
|
WorkingDirectory = applicationBase,
|
||||||
|
UseShellExecute = true,
|
||||||
|
Verb="runas"
|
||||||
};
|
};
|
||||||
Process.Start(processStartInfo);
|
Process.Start(processStartInfo);
|
||||||
}
|
}
|
||||||
@ -335,12 +339,12 @@ namespace AIProofread
|
|||||||
if (ShouldUpgradeForced())
|
if (ShouldUpgradeForced())
|
||||||
{
|
{
|
||||||
data.Add("code", 2);
|
data.Add("code", 2);
|
||||||
data.Add("message", "请升级插件后再进行校对");
|
data.Add("message", "请先升级插件后再进行校对");
|
||||||
}
|
}
|
||||||
else if (doc.ProtectionType != WdProtectionType.wdNoProtection)
|
else if (doc.ProtectionType != WdProtectionType.wdNoProtection)
|
||||||
{
|
{
|
||||||
data.Add("code", 3);
|
data.Add("code", 3);
|
||||||
data.Add("message", "文档受保护,无法编辑");
|
data.Add("message", "文档受保护,请另存文档后再进行校对");
|
||||||
}
|
}
|
||||||
else if (doc.ReadOnly)
|
else if (doc.ReadOnly)
|
||||||
{
|
{
|
||||||
@ -368,7 +372,22 @@ namespace AIProofread
|
|||||||
data.Add("documentId", GeIdBytDocument(doc));
|
data.Add("documentId", GeIdBytDocument(doc));
|
||||||
data.Add("wordsCount", doc.Words.Count);
|
data.Add("wordsCount", doc.Words.Count);
|
||||||
data.Add("charactersCount", doc.Characters.Count);
|
data.Add("charactersCount", doc.Characters.Count);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
data.Add("content", Tools.GetAllText(doc));
|
data.Add("content", Tools.GetAllText(doc));
|
||||||
|
}
|
||||||
|
catch (POIXMLException ex)
|
||||||
|
{
|
||||||
|
Logger.Log(ex);
|
||||||
|
data["code"] = 5;
|
||||||
|
data["message"] = "文档格式有误,请另存文档后再进行校对";
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Log(ex);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
//if (loadingDialog != null && !loadingDialog.IsDisposed)
|
//if (loadingDialog != null && !loadingDialog.IsDisposed)
|
||||||
//{
|
//{
|
||||||
// loadingDialog.Close();
|
// loadingDialog.Close();
|
||||||
@ -377,6 +396,22 @@ namespace AIProofread
|
|||||||
return Tools.GetJSONString(data);
|
return Tools.GetJSONString(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetDocumentInfo(int documentId)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> data = new Dictionary<string, object>();
|
||||||
|
var documentInfo = documentId > 0 ? Globals.ThisAddIn.GetDocumentById(documentId) : Globals.ThisAddIn.ActiveDocument;
|
||||||
|
var doc = documentInfo.CurrentDocument;
|
||||||
|
data.Add("code", 0);
|
||||||
|
data.Add("message", "success");
|
||||||
|
data.Add("name", doc.Name);
|
||||||
|
//data.Add("documentId", Globals.ThisAddIn.ActiveDocument.Id);
|
||||||
|
data.Add("fullName", doc.FullName);
|
||||||
|
data.Add("documentId", GeIdBytDocument(doc));
|
||||||
|
data.Add("wordsCount", doc.Words.Count);
|
||||||
|
data.Add("charactersCount", doc.Characters.Count);
|
||||||
|
return Tools.GetJSONString(data);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据位置获取文档区域文本
|
/// 根据位置获取文档区域文本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -514,11 +549,21 @@ namespace AIProofread
|
|||||||
public void ClearCurrentDocumentMarks() => Globals.ThisAddIn.ActiveDocument?.ClearAllProofreadMark();
|
public void ClearCurrentDocumentMarks() => Globals.ThisAddIn.ActiveDocument?.ClearAllProofreadMark();
|
||||||
public void removeBookmark(string markId) => DocumentUtil.RemoveBookmark(markId);
|
public void removeBookmark(string markId) => DocumentUtil.RemoveBookmark(markId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取设备ID
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public string GetDeviceId()
|
public string GetDeviceId()
|
||||||
{
|
{
|
||||||
return Config.DeviceId;
|
return Config.DeviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置帮助文档地址
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
public void SetHelpUrl(string url) => Config.USER_MANUAL_URL = url;
|
||||||
|
|
||||||
public string getAllBookmark()
|
public string getAllBookmark()
|
||||||
{
|
{
|
||||||
return ToJSON(DocumentUtil.GetAllBookmark());
|
return ToJSON(DocumentUtil.GetAllBookmark());
|
||||||
@ -715,15 +760,16 @@ namespace AIProofread
|
|||||||
/// 导出勘误表
|
/// 导出勘误表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string ExportProofreadResult()
|
public string ExportProofreadResult(string modelType)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Globals.ThisAddIn.ActiveDocument.ExportResult();
|
Globals.ThisAddIn.ActiveDocument.ExportResult(modelType);
|
||||||
return BridgeResult.Success();
|
return BridgeResult.Success();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Logger.Log("导出勘误表失败:" + ex.Message + "\n" + ex.StackTrace + "\n\n");
|
||||||
return BridgeResult.Error(-1, ex.Message);
|
return BridgeResult.Error(-1, ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -747,6 +793,11 @@ namespace AIProofread
|
|||||||
Globals.ThisAddIn.ActiveDocument.FocusToPanel();
|
Globals.ThisAddIn.ActiveDocument.FocusToPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetProofreadOriginData()
|
||||||
|
{
|
||||||
|
return Tools.GetJSONString(Globals.ThisAddIn.ActiveDocument.GetProofreadOriginData());
|
||||||
|
}
|
||||||
|
|
||||||
public string SaveCache(int documentId, string cache, bool silent)
|
public string SaveCache(int documentId, string cache, bool silent)
|
||||||
{
|
{
|
||||||
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
||||||
@ -833,12 +884,13 @@ namespace AIProofread
|
|||||||
return BridgeResult.Success(result == DialogResult.Yes ? "yes" : "no");
|
return BridgeResult.Success(result == DialogResult.Yes ? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
public string InitProofreadCacheList(string content)
|
public string InitProofreadCacheList(string content,string originData)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<CorrectContext> list = JsonConvert.DeserializeObject<List<CorrectContext>>(content);
|
List<CorrectContext> list = JsonConvert.DeserializeObject<List<CorrectContext>>(content);
|
||||||
Globals.ThisAddIn.InitProofreadCacheList(list);
|
Dictionary<int,ProofreadRangeInfo> dics = string.IsNullOrEmpty(originData) ? null : JsonConvert.DeserializeObject<Dictionary<int, ProofreadRangeInfo>>(originData);
|
||||||
|
Globals.ThisAddIn.InitProofreadCacheList(list, dics);
|
||||||
return BridgeResult.Success();
|
return BridgeResult.Success();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -12,15 +12,16 @@ namespace AIProofread
|
|||||||
public class Config
|
public class Config
|
||||||
{
|
{
|
||||||
public static readonly string APP_NAME = "AI校对王";
|
public static readonly string APP_NAME = "AI校对王";
|
||||||
public static readonly string APP_VERSION = "2.1.1";
|
public static readonly string APP_VERSION = "2.2.2";
|
||||||
public static bool IS_WPS = false;
|
public static bool IS_WPS = false;
|
||||||
public static bool UpgradeForcedNotice = false;
|
public static bool UpgradeForcedNotice = false;
|
||||||
public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory;
|
public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory;
|
||||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||||
|
public static string USER_MANUAL_URL = "https://aiprhelp.guomai.cn/";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文本背景色
|
/// 文本背景色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly string TextBackgroundColor = "#D6AA69";
|
public static readonly string TextBackgroundColor = "#E9DABB"; // e9dabb D6AA69
|
||||||
public static string DeviceId = "";
|
public static string DeviceId = "";
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
4
AIProofread/Controls/FormContact.Designer.cs
generated
4
AIProofread/Controls/FormContact.Designer.cs
generated
@ -40,7 +40,7 @@
|
|||||||
this.WebViewContact.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.WebViewContact.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.WebViewContact.Location = new System.Drawing.Point(0, 0);
|
this.WebViewContact.Location = new System.Drawing.Point(0, 0);
|
||||||
this.WebViewContact.Name = "WebViewContact";
|
this.WebViewContact.Name = "WebViewContact";
|
||||||
this.WebViewContact.Size = new System.Drawing.Size(380, 216);
|
this.WebViewContact.Size = new System.Drawing.Size(620, 450);
|
||||||
this.WebViewContact.TabIndex = 0;
|
this.WebViewContact.TabIndex = 0;
|
||||||
this.WebViewContact.ZoomFactor = 1D;
|
this.WebViewContact.ZoomFactor = 1D;
|
||||||
//
|
//
|
||||||
@ -48,7 +48,7 @@
|
|||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(380, 216);
|
this.ClientSize = new System.Drawing.Size(620, 450);
|
||||||
this.Controls.Add(this.WebViewContact);
|
this.Controls.Add(this.WebViewContact);
|
||||||
this.Name = "FormContact";
|
this.Name = "FormContact";
|
||||||
this.ShowIcon = false;
|
this.ShowIcon = false;
|
||||||
|
@ -4,12 +4,15 @@ using System.ComponentModel;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace AIProofread.Controls
|
namespace AIProofread.Controls
|
||||||
{
|
{
|
||||||
|
[ClassInterface(ClassInterfaceType.AutoDual)]
|
||||||
|
[ComVisible(true)]
|
||||||
public partial class FormContact : BaseWinForm
|
public partial class FormContact : BaseWinForm
|
||||||
{
|
{
|
||||||
public FormContact()
|
public FormContact()
|
||||||
|
@ -5,7 +5,7 @@ namespace AIProofread.Controls
|
|||||||
{
|
{
|
||||||
public partial class FormLogger : Form
|
public partial class FormLogger : Form
|
||||||
{
|
{
|
||||||
private ListView LogListView;
|
private ListView LogListView = new ListView();
|
||||||
|
|
||||||
public FormLogger()
|
public FormLogger()
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,8 @@ namespace AIProofread.Controls
|
|||||||
private void FormLogin_Load(object sender, EventArgs e)
|
private void FormLogin_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
//this.web.Source = new Uri(Config.WebPath("#login"));
|
//this.web.Source = new Uri(Config.WebPath("#login"));
|
||||||
InitWebView(web, Config.WebPath("login?action=" + this.action), "login");
|
var r = new FormLogin();
|
||||||
|
InitWebView(web, Config.WebPath("login?action=" + this.action + "&version=" + Config.APP_VERSION + "&t=" + DateTime.Now.Ticks), "login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ namespace AIProofread
|
|||||||
if (LoggerForm != null && !LoggerForm.IsDisposed && LoggerForm.Visible)
|
if (LoggerForm != null && !LoggerForm.IsDisposed && LoggerForm.Visible)
|
||||||
{
|
{
|
||||||
LoggerForm.Log(time, tag, message);
|
LoggerForm.Log(time, tag, message);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
string path = Config.APP_LOG_PATH + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
string path = Config.APP_LOG_PATH + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||||
if (!Directory.Exists(Config.APP_LOG_PATH))
|
if (!Directory.Exists(Config.APP_LOG_PATH))
|
||||||
@ -41,7 +40,7 @@ namespace AIProofread
|
|||||||
streamWriter.Close();
|
streamWriter.Close();
|
||||||
streamWriter.Dispose();
|
streamWriter.Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception e) { }
|
catch (Exception) { }
|
||||||
}
|
}
|
||||||
public static void Log(string msg)
|
public static void Log(string msg)
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using AIProofread.Controls;
|
using AIProofread.Controls;
|
||||||
@ -158,7 +159,7 @@ namespace AIProofread.Model
|
|||||||
|
|
||||||
private void ShowDocumentStatus(string tag)
|
private void ShowDocumentStatus(string tag)
|
||||||
{
|
{
|
||||||
Logger.Log($"{fileName} {tag} PaneVisible is {PaneVisible} Poofread is {Proofread} Proofreading is {Proofreading}");
|
// Logger.Log($"{fileName} {tag} PaneVisible is {PaneVisible} Poofread is {Proofread} Proofreading is {Proofreading}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -211,6 +212,13 @@ namespace AIProofread.Model
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// 释放com
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Marshal.ReleaseComObject(CurrentDocument);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
if(TaskPane.Control.IsDisposed) return;
|
||||||
ProofreadMainControl control = (ProofreadMainControl)TaskPane.Control;
|
ProofreadMainControl control = (ProofreadMainControl)TaskPane.Control;
|
||||||
control.ResetWeb();
|
control.ResetWeb();
|
||||||
|
|
||||||
@ -604,9 +612,13 @@ namespace AIProofread.Model
|
|||||||
//object goNext = WdGoToDirection.wdGoToNext;
|
//object goNext = WdGoToDirection.wdGoToNext;
|
||||||
//Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref goToLine, ref goNext, ref lineNum);
|
//Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref goToLine, ref goNext, ref lineNum);
|
||||||
//
|
//
|
||||||
object bookmark = WdGoToItem.wdGoToBookmark;
|
//object bookmark = WdGoToItem.wdGoToBookmark;
|
||||||
object bookmarkName = mark.Name;
|
//object bookmarkName = mark.Name;
|
||||||
Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref bookmark, ref missing, ref missing, ref bookmarkName);
|
var targetRange = mark.Range;
|
||||||
|
// 选中
|
||||||
|
targetRange.Select();
|
||||||
|
Globals.ThisAddIn.Application.ActiveWindow.ScrollIntoView(targetRange);//.Selection.GoTo(ref bookmark, ref missing, ref missing, ref bookmarkName);
|
||||||
|
|
||||||
//
|
//
|
||||||
//mark.DisableCharacterSpaceGrid = false;
|
//mark.DisableCharacterSpaceGrid = false;
|
||||||
// 先滚动到可视区域
|
// 先滚动到可视区域
|
||||||
@ -642,7 +654,7 @@ namespace AIProofread.Model
|
|||||||
foreach (var item in correct.CorrectItems)
|
foreach (var item in correct.CorrectItems)
|
||||||
{
|
{
|
||||||
if (marks.ContainsKey(item.Id)) continue;
|
if (marks.ContainsKey(item.Id)) continue;
|
||||||
Logger.Log(string.Format("mark type {0} data {1}->{2}", item.Tag, item.Origin, item.Text));
|
// Logger.Log(string.Format("mark type {0} data {1}->{2}", item.Tag, item.Origin, item.Text));
|
||||||
int _prev = prevOffset;
|
int _prev = prevOffset;
|
||||||
bool isDisabled = false;
|
bool isDisabled = false;
|
||||||
// 判断查找内容是否在原始数据中,否则直跳过
|
// 判断查找内容是否在原始数据中,否则直跳过
|
||||||
@ -745,7 +757,7 @@ namespace AIProofread.Model
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void InitProofreadCache(List<CorrectContext> list)
|
public void InitProofreadCache(List<CorrectContext> list,Dictionary<int, ProofreadRangeInfo> itemInfoDic)
|
||||||
{
|
{
|
||||||
marks.Clear();
|
marks.Clear();
|
||||||
|
|
||||||
@ -757,6 +769,19 @@ namespace AIProofread.Model
|
|||||||
if (mark != null)
|
if (mark != null)
|
||||||
{
|
{
|
||||||
var pi = new ProofreadItem(item, correct.Insert, mark, Id);
|
var pi = new ProofreadItem(item, correct.Insert, mark, Id);
|
||||||
|
// 是否存在样式信息
|
||||||
|
if (itemInfoDic!= null && itemInfoDic.ContainsKey(item.Id))
|
||||||
|
{
|
||||||
|
// 获取样式信息并还原
|
||||||
|
var info = itemInfoDic[item.Id];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
pi.originColor = info.Color;
|
||||||
|
pi.originBackgroundColor = info.Background;
|
||||||
|
pi.originSize = info.Size;
|
||||||
|
}
|
||||||
|
catch (Exception ex) { Logger.Log(ex); }
|
||||||
|
}
|
||||||
marks.Add(item.Id, pi);
|
marks.Add(item.Id, pi);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -870,7 +895,7 @@ namespace AIProofread.Model
|
|||||||
TaskPane.Control.Focus();
|
TaskPane.Control.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -878,7 +903,8 @@ namespace AIProofread.Model
|
|||||||
marks.Clear();
|
marks.Clear();
|
||||||
// 清除区域相关数据
|
// 清除区域相关数据
|
||||||
ranges.Clear();
|
ranges.Clear();
|
||||||
TaskPane.Dispose();
|
// TaskPane.Dispose();
|
||||||
|
this.Dispose();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -886,15 +912,15 @@ namespace AIProofread.Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ExportResult()
|
public void ExportResult(string modelType)
|
||||||
{
|
{
|
||||||
TaskPane.Control.BeginInvoke(new Action(() =>
|
TaskPane.Control.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
DocumentUtil.ExportProofreadResult();
|
DocumentUtil.ExportProofreadResult(modelType);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ShowUpgrade(string data, bool force)
|
public void ShowUpgrade(string data, bool force)
|
||||||
{
|
{
|
||||||
TaskPane.Control.BeginInvoke(new Action(() =>
|
TaskPane.Control.BeginInvoke(new Action(() =>
|
||||||
{
|
{
|
||||||
@ -904,6 +930,7 @@ namespace AIProofread.Model
|
|||||||
|
|
||||||
if (force)
|
if (force)
|
||||||
{
|
{
|
||||||
|
// 已经强制更新但被忽略过则不再提示
|
||||||
if (Config.UpgradeForcedNotice) return;
|
if (Config.UpgradeForcedNotice) return;
|
||||||
|
|
||||||
var result = MessageBox.Show(upgradeData.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
var result = MessageBox.Show(upgradeData.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||||
@ -971,5 +998,31 @@ namespace AIProofread.Model
|
|||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Dictionary<int, ProofreadRangeInfo> GetProofreadOriginData()
|
||||||
|
{
|
||||||
|
Dictionary<int,ProofreadRangeInfo> dic = new Dictionary<int, ProofreadRangeInfo>();
|
||||||
|
// 变量文档所有marks 记录mark对应range的背景、大小、颜色
|
||||||
|
foreach (var item in marks)
|
||||||
|
{
|
||||||
|
if (item.Value.mark != null)
|
||||||
|
{
|
||||||
|
// 添加到数据
|
||||||
|
dic.Add(item.Key, new ProofreadRangeInfo()
|
||||||
|
{
|
||||||
|
Background = item.Value.originBackgroundColor,
|
||||||
|
Color = item.Value.originColor,
|
||||||
|
Size = item.Value.originSize
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dic;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void CheckPanel()
|
||||||
|
{
|
||||||
|
Logger.Log(CurrentDocument.FullName + $" TaskPane visible {PaneVisible} has " + (TaskPane == null ? "null" : "exists"));
|
||||||
|
if (TaskPane == null) CreateTaskPane();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
using Microsoft.Office.Interop.Word;
|
using Microsoft.Office.Interop.Word;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using UtilLib;
|
using UtilLib;
|
||||||
|
|
||||||
@ -30,6 +32,25 @@ namespace AIProofread.Model
|
|||||||
{
|
{
|
||||||
return sentence;
|
return sentence;
|
||||||
}
|
}
|
||||||
|
// 截取中间位置
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var middlePosition = MAX_WORD_LENGTH / 2;
|
||||||
|
var cutStart = item.content.Start - middlePosition;
|
||||||
|
// 越界了
|
||||||
|
if (cutStart < 0)
|
||||||
|
{
|
||||||
|
cutStart = 0;
|
||||||
|
}
|
||||||
|
var originText = sentence.Substring(cutStart, Math.Min(sentence.Length, MAX_WORD_LENGTH));
|
||||||
|
if (!isInsert)
|
||||||
|
{
|
||||||
|
item.content.Start = item.content.Start - cutStart;
|
||||||
|
item.content.End = item.content.End - cutStart;
|
||||||
|
return originText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) { Logger.Log(ex); }
|
||||||
var range = item.mark.Range;
|
var range = item.mark.Range;
|
||||||
|
|
||||||
// 获取range所在句子
|
// 获取range所在句子
|
||||||
@ -50,6 +71,7 @@ namespace AIProofread.Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var first = sentences.First;
|
var first = sentences.First;
|
||||||
|
// 内容位置:用于后续标红
|
||||||
item.content.Start = range.Start - first.Start;
|
item.content.Start = range.Start - first.Start;
|
||||||
item.content.End = range.End - first.Start;
|
item.content.End = range.End - first.Start;
|
||||||
return sb.ToString().Trim();
|
return sb.ToString().Trim();
|
||||||
|
11
AIProofread/Model/ProofreadRangeInfo.cs
Normal file
11
AIProofread/Model/ProofreadRangeInfo.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
using Microsoft.Office.Interop.Word;
|
||||||
|
|
||||||
|
namespace AIProofread.Model
|
||||||
|
{
|
||||||
|
public class ProofreadRangeInfo
|
||||||
|
{
|
||||||
|
public float Size { get; set; }
|
||||||
|
public WdColor Background { get; set; }
|
||||||
|
public WdColor Color { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -14,9 +14,9 @@ namespace UtilLib
|
|||||||
public Bookmark mark;
|
public Bookmark mark;
|
||||||
public string OriginSentence { get; set; }
|
public string OriginSentence { get; set; }
|
||||||
public CorrectItem content;
|
public CorrectItem content;
|
||||||
private float originSize;
|
public float originSize;
|
||||||
private WdColor originColor;
|
public WdColor originColor;
|
||||||
private WdColor originBackgroundColor;
|
public WdColor originBackgroundColor;
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int DocumentId { get; set; }
|
public int DocumentId { get; set; }
|
||||||
|
|
||||||
@ -134,6 +134,33 @@ namespace UtilLib
|
|||||||
Logger.Log(e);
|
Logger.Log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void PrepareCommentProcess(Bookmark mark)
|
||||||
|
{
|
||||||
|
var doc = Globals.ThisAddIn.Application.ActiveDocument;
|
||||||
|
var fullRange = doc.Range();
|
||||||
|
|
||||||
|
var range = mark.Range;
|
||||||
|
var checkRange = doc.Range(
|
||||||
|
Math.Max(range.Start - 2, fullRange.Start),
|
||||||
|
Math.Min(range.End + 2, fullRange.End)
|
||||||
|
);
|
||||||
|
var comments = checkRange.Comments;
|
||||||
|
// 判断当前书签选区内容是否有评论
|
||||||
|
if (comments != null && comments.Count > 0)
|
||||||
|
{
|
||||||
|
Logger.Log("有批注");
|
||||||
|
foreach (Microsoft.Office.Interop.Word.Comment item in comments)
|
||||||
|
{
|
||||||
|
// 判断当前评论和书签选区是否一致
|
||||||
|
if (item.Scope.Start == range.Start && item.Scope.End == range.End)
|
||||||
|
{
|
||||||
|
Logger.Log("删除批注:" + item.Range.Text);
|
||||||
|
// 删除评论
|
||||||
|
item.Delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理校对项
|
/// 处理校对项
|
||||||
@ -148,6 +175,7 @@ namespace UtilLib
|
|||||||
// 采纳
|
// 采纳
|
||||||
if (status == AcceptStatus.Accept)
|
if (status == AcceptStatus.Accept)
|
||||||
{
|
{
|
||||||
|
PrepareCommentProcess(mark);
|
||||||
if (content.Tag == "r" || content.Tag == "i")
|
if (content.Tag == "r" || content.Tag == "i")
|
||||||
{
|
{
|
||||||
mark.Text = content.Text;
|
mark.Text = content.Text;
|
||||||
@ -194,7 +222,10 @@ namespace UtilLib
|
|||||||
|
|
||||||
// 判断书签范围内是否有批注
|
// 判断书签范围内是否有批注
|
||||||
|
|
||||||
if (rng.Text?.IndexOf("%") != -1 && rng.Comments != null && rng.Comments.Count > 0)
|
if (rng.Text?.IndexOf("%") != -1)
|
||||||
|
{
|
||||||
|
Logger.Log($"处理百分号问题:有批注");
|
||||||
|
if (rng.Comments != null && rng.Comments.Count > 0)
|
||||||
{
|
{
|
||||||
for (var i = 1; i < rng.Comments.Count; i++)
|
for (var i = 1; i < rng.Comments.Count; i++)
|
||||||
{
|
{
|
||||||
@ -202,6 +233,11 @@ namespace UtilLib
|
|||||||
comment.Scope.Text = comment.Scope.Text.Replace("%", "");
|
comment.Scope.Text = comment.Scope.Text.Replace("%", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rng.Text = rng.Text.Replace("%", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@ using System.Security;
|
|||||||
// 控制。更改这些特性值可修改
|
// 控制。更改这些特性值可修改
|
||||||
// 与程序集关联的信息。
|
// 与程序集关联的信息。
|
||||||
[assembly: AssemblyTitle("AI校对王")]
|
[assembly: AssemblyTitle("AI校对王")]
|
||||||
[assembly: AssemblyDescription("AI校对王 2.1.0")]
|
[assembly: AssemblyDescription("AI校对王 2.2.1")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("果麦文化")]
|
[assembly: AssemblyCompany("果麦文化传媒股份有限公司")]
|
||||||
[assembly: AssemblyProduct("AI校对王 2.1.0")]
|
[assembly: AssemblyProduct("AI校对王 2.2.1")]
|
||||||
[assembly: AssemblyCopyright("Copyright © GuoMai 2024")]
|
[assembly: AssemblyCopyright("Copyright © 果麦文化传媒股份有限公司 2025")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@ -34,5 +34,5 @@ using System.Security;
|
|||||||
// 方法是按如下所示使用“*”: :
|
// 方法是按如下所示使用“*”: :
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.0")]
|
[assembly: AssemblyVersion("2.0")]
|
||||||
[assembly: AssemblyFileVersion("2.1.0.0")]
|
[assembly: AssemblyFileVersion("2.2.1.0")]
|
||||||
|
|
||||||
|
20
AIProofread/Properties/Resources.Designer.cs
generated
20
AIProofread/Properties/Resources.Designer.cs
generated
@ -230,6 +230,26 @@ namespace AIProofread.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap icon_manual {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("icon-manual", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap icon_manual_wps {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("icon-manual-wps", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -136,6 +136,9 @@
|
|||||||
<data name="icon-history" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-history" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-history.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-history.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="icon-proofread" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\icon-proofread.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="icon-phone" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-phone" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-phone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-phone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@ -178,11 +181,14 @@
|
|||||||
<data name="favicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="favicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\favicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\favicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="icon-ai-robot-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\icon-ai-robot-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="icon-refresh-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-refresh-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-refresh-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-refresh-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="icon-clear" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-export" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-clear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-export.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="button_default" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="button_default" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\button_default.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\button_default.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
@ -196,11 +202,14 @@
|
|||||||
<data name="logo_no_text" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="logo_no_text" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\logo_no_text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\logo_no_text.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="icon-ai-robot" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Resources\icon-ai-robot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="logo_wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="logo_wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\logo_wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\logo_wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="icon-export" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-clear" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-export.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-clear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="icon-phone-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-phone-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-phone-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-phone-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
@ -208,9 +217,6 @@
|
|||||||
<data name="icon-history-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-history-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-history-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-history-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="icon-panel" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\icon-panel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="logo_no_text_wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="logo_no_text_wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\logo_no_text_wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\logo_no_text_wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@ -220,13 +226,13 @@
|
|||||||
<data name="icon_close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon_close" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon_close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon_close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="icon-proofread" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-panel" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-proofread.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-panel.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="icon-ai-robot" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-manual" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-ai-robot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-manual.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="icon-ai-robot-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="icon-manual-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Resources\icon-ai-robot-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Resources\icon-manual-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
BIN
AIProofread/Resources/icon-manual-wps.jpg
Normal file
BIN
AIProofread/Resources/icon-manual-wps.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
AIProofread/Resources/icon-manual.png
Normal file
BIN
AIProofread/Resources/icon-manual.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
45
AIProofread/Ribbon1.Designer.cs
generated
45
AIProofread/Ribbon1.Designer.cs
generated
@ -42,6 +42,9 @@ namespace AIProofread
|
|||||||
this.tabAIProofread = this.Factory.CreateRibbonTab();
|
this.tabAIProofread = this.Factory.CreateRibbonTab();
|
||||||
this.group1 = this.Factory.CreateRibbonGroup();
|
this.group1 = this.Factory.CreateRibbonGroup();
|
||||||
this.BtnProofreadAll = this.Factory.CreateRibbonButton();
|
this.BtnProofreadAll = this.Factory.CreateRibbonButton();
|
||||||
|
this.menuProofreadList = this.Factory.CreateRibbonMenu();
|
||||||
|
this.BtnProofreadExact = this.Factory.CreateRibbonButton();
|
||||||
|
this.BtnProofreadFull = this.Factory.CreateRibbonButton();
|
||||||
this.BtnExportProofreadResult = this.Factory.CreateRibbonButton();
|
this.BtnExportProofreadResult = this.Factory.CreateRibbonButton();
|
||||||
this.btnClear = this.Factory.CreateRibbonButton();
|
this.btnClear = this.Factory.CreateRibbonButton();
|
||||||
this.btnOpenLexicon = this.Factory.CreateRibbonButton();
|
this.btnOpenLexicon = this.Factory.CreateRibbonButton();
|
||||||
@ -62,6 +65,7 @@ namespace AIProofread
|
|||||||
this.LblNickname = this.Factory.CreateRibbonLabel();
|
this.LblNickname = this.Factory.CreateRibbonLabel();
|
||||||
this.group2 = this.Factory.CreateRibbonGroup();
|
this.group2 = this.Factory.CreateRibbonGroup();
|
||||||
this.BtnShowPanel = this.Factory.CreateRibbonButton();
|
this.BtnShowPanel = this.Factory.CreateRibbonButton();
|
||||||
|
this.BtnShowManual = this.Factory.CreateRibbonButton();
|
||||||
this.grpDebug = this.Factory.CreateRibbonGroup();
|
this.grpDebug = this.Factory.CreateRibbonGroup();
|
||||||
this.btnShowPane = this.Factory.CreateRibbonButton();
|
this.btnShowPane = this.Factory.CreateRibbonButton();
|
||||||
this.btnHidePane = this.Factory.CreateRibbonButton();
|
this.btnHidePane = this.Factory.CreateRibbonButton();
|
||||||
@ -94,6 +98,7 @@ namespace AIProofread
|
|||||||
// group1
|
// group1
|
||||||
//
|
//
|
||||||
this.group1.Items.Add(this.BtnProofreadAll);
|
this.group1.Items.Add(this.BtnProofreadAll);
|
||||||
|
this.group1.Items.Add(this.menuProofreadList);
|
||||||
this.group1.Items.Add(this.BtnExportProofreadResult);
|
this.group1.Items.Add(this.BtnExportProofreadResult);
|
||||||
this.group1.Items.Add(this.btnClear);
|
this.group1.Items.Add(this.btnClear);
|
||||||
this.group1.Items.Add(this.btnOpenLexicon);
|
this.group1.Items.Add(this.btnOpenLexicon);
|
||||||
@ -108,8 +113,34 @@ namespace AIProofread
|
|||||||
this.BtnProofreadAll.Label = "全文校对\r\n";
|
this.BtnProofreadAll.Label = "全文校对\r\n";
|
||||||
this.BtnProofreadAll.Name = "BtnProofreadAll";
|
this.BtnProofreadAll.Name = "BtnProofreadAll";
|
||||||
this.BtnProofreadAll.ShowImage = true;
|
this.BtnProofreadAll.ShowImage = true;
|
||||||
|
this.BtnProofreadAll.Visible = false;
|
||||||
this.BtnProofreadAll.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnProofreadAll_Click);
|
this.BtnProofreadAll.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnProofreadAll_Click);
|
||||||
//
|
//
|
||||||
|
// menuProofreadList
|
||||||
|
//
|
||||||
|
this.menuProofreadList.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
|
this.menuProofreadList.Enabled = false;
|
||||||
|
this.menuProofreadList.Image = global::AIProofread.Properties.Resources.icon_proofread;
|
||||||
|
this.menuProofreadList.Items.Add(this.BtnProofreadExact);
|
||||||
|
this.menuProofreadList.Items.Add(this.BtnProofreadFull);
|
||||||
|
this.menuProofreadList.Label = "全文校对\r\n";
|
||||||
|
this.menuProofreadList.Name = "menuProofreadList";
|
||||||
|
this.menuProofreadList.ShowImage = true;
|
||||||
|
//
|
||||||
|
// BtnProofreadExact
|
||||||
|
//
|
||||||
|
this.BtnProofreadExact.Label = "优先查准";
|
||||||
|
this.BtnProofreadExact.Name = "BtnProofreadExact";
|
||||||
|
this.BtnProofreadExact.ShowImage = true;
|
||||||
|
this.BtnProofreadExact.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnProofreadExact_Click);
|
||||||
|
//
|
||||||
|
// BtnProofreadFull
|
||||||
|
//
|
||||||
|
this.BtnProofreadFull.Label = "优先查全";
|
||||||
|
this.BtnProofreadFull.Name = "BtnProofreadFull";
|
||||||
|
this.BtnProofreadFull.ShowImage = true;
|
||||||
|
this.BtnProofreadFull.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnProofreadFull_Click);
|
||||||
|
//
|
||||||
// BtnExportProofreadResult
|
// BtnExportProofreadResult
|
||||||
//
|
//
|
||||||
this.BtnExportProofreadResult.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
this.BtnExportProofreadResult.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
@ -265,6 +296,7 @@ namespace AIProofread
|
|||||||
// group2
|
// group2
|
||||||
//
|
//
|
||||||
this.group2.Items.Add(this.BtnShowPanel);
|
this.group2.Items.Add(this.BtnShowPanel);
|
||||||
|
this.group2.Items.Add(this.BtnShowManual);
|
||||||
this.group2.Name = "group2";
|
this.group2.Name = "group2";
|
||||||
//
|
//
|
||||||
// BtnShowPanel
|
// BtnShowPanel
|
||||||
@ -276,6 +308,15 @@ namespace AIProofread
|
|||||||
this.BtnShowPanel.ShowImage = true;
|
this.BtnShowPanel.ShowImage = true;
|
||||||
this.BtnShowPanel.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnShowPanel_Click);
|
this.BtnShowPanel.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnShowPanel_Click);
|
||||||
//
|
//
|
||||||
|
// BtnShowManual
|
||||||
|
//
|
||||||
|
this.BtnShowManual.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||||
|
this.BtnShowManual.Image = global::AIProofread.Properties.Resources.icon_manual;
|
||||||
|
this.BtnShowManual.Label = "用户手册\r\n";
|
||||||
|
this.BtnShowManual.Name = "BtnShowManual";
|
||||||
|
this.BtnShowManual.ShowImage = true;
|
||||||
|
this.BtnShowManual.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnShowManual_Click);
|
||||||
|
//
|
||||||
// grpDebug
|
// grpDebug
|
||||||
//
|
//
|
||||||
this.grpDebug.Items.Add(this.btnShowPane);
|
this.grpDebug.Items.Add(this.btnShowPane);
|
||||||
@ -407,6 +448,10 @@ namespace AIProofread
|
|||||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionAll;
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionAll;
|
||||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionParagraph;
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionParagraph;
|
||||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionHistory;
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionHistory;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnShowManual;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonMenu menuProofreadList;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnProofreadExact;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnProofreadFull;
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class ThisRibbonCollection
|
partial class ThisRibbonCollection
|
||||||
|
@ -11,13 +11,13 @@ using System.Text;
|
|||||||
using AIProofread.core;
|
using AIProofread.core;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using AIProofread.Properties;
|
using AIProofread.Properties;
|
||||||
|
using System.Security.Policy;
|
||||||
|
|
||||||
namespace AIProofread
|
namespace AIProofread
|
||||||
{
|
{
|
||||||
public partial class Ribbon1
|
public partial class Ribbon1
|
||||||
{
|
{
|
||||||
private bool IS_LOGIN = false;
|
private bool IS_LOGIN = false;
|
||||||
private static bool IS_WPS = false;
|
|
||||||
private Userinfo currentLoginUserinfo;
|
private Userinfo currentLoginUserinfo;
|
||||||
|
|
||||||
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
|
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
|
||||||
@ -42,7 +42,9 @@ namespace AIProofread
|
|||||||
|
|
||||||
public void SetCommonBtnStatus(bool status)
|
public void SetCommonBtnStatus(bool status)
|
||||||
{
|
{
|
||||||
BtnProofreadAll.Enabled = status;
|
// BtnProofreadAll.Enabled = status;
|
||||||
|
menuProofreadList.Enabled = status;
|
||||||
|
|
||||||
btnClear.Enabled = status;
|
btnClear.Enabled = status;
|
||||||
btnOpenLexicon.Enabled = status;
|
btnOpenLexicon.Enabled = status;
|
||||||
btnSetting.Enabled = status;
|
btnSetting.Enabled = status;
|
||||||
@ -68,6 +70,7 @@ namespace AIProofread
|
|||||||
else if (key == "disable-by-upgrade")
|
else if (key == "disable-by-upgrade")
|
||||||
{
|
{
|
||||||
SetCommonBtnStatus(status);
|
SetCommonBtnStatus(status);
|
||||||
|
BtnUpdate.Enabled = true;
|
||||||
BtnShowPanel.Enabled = status;
|
BtnShowPanel.Enabled = status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,9 +80,9 @@ namespace AIProofread
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void InitWPS()
|
public void InitWPS()
|
||||||
{
|
{
|
||||||
IS_WPS = true;
|
|
||||||
|
|
||||||
BtnProofreadAll.Image = AIProofread.Properties.Resources.icon_proofread_wps;
|
BtnProofreadAll.Image = AIProofread.Properties.Resources.icon_proofread_wps;
|
||||||
|
menuProofreadList.Image = AIProofread.Properties.Resources.icon_proofread_wps;
|
||||||
btnClear.Image = AIProofread.Properties.Resources.icon_clear_wps;
|
btnClear.Image = AIProofread.Properties.Resources.icon_clear_wps;
|
||||||
btnOpenLexicon.Image = AIProofread.Properties.Resources.icon_book_wps;
|
btnOpenLexicon.Image = AIProofread.Properties.Resources.icon_book_wps;
|
||||||
btnSetting.Image = AIProofread.Properties.Resources.icon_setting_wps;
|
btnSetting.Image = AIProofread.Properties.Resources.icon_setting_wps;
|
||||||
@ -95,6 +98,7 @@ namespace AIProofread
|
|||||||
BtnShowPanel.Image = AIProofread.Properties.Resources.icon_panel_wps;
|
BtnShowPanel.Image = AIProofread.Properties.Resources.icon_panel_wps;
|
||||||
// 导出校对结果
|
// 导出校对结果
|
||||||
BtnExportProofreadResult.Image = AIProofread.Properties.Resources.icon_export_wps;
|
BtnExportProofreadResult.Image = AIProofread.Properties.Resources.icon_export_wps;
|
||||||
|
BtnShowManual.Image = AIProofread.Properties.Resources.icon_manual_wps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessLoginInfo(Userinfo userinfo)
|
public void ProcessLoginInfo(Userinfo userinfo)
|
||||||
@ -181,7 +185,11 @@ namespace AIProofread
|
|||||||
|
|
||||||
private void BtnGetContact_Click(object sender, RibbonControlEventArgs e)
|
private void BtnGetContact_Click(object sender, RibbonControlEventArgs e)
|
||||||
{
|
{
|
||||||
(new FormContact()).ShowDialog();
|
var frm = new FormContact();
|
||||||
|
Globals.ThisAddIn.ActiveDocument.RunInMainThread(() =>
|
||||||
|
{
|
||||||
|
frm.ShowDialog();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BtnUpdate_Click(object sender, RibbonControlEventArgs e)
|
private void BtnUpdate_Click(object sender, RibbonControlEventArgs e)
|
||||||
@ -608,5 +616,28 @@ namespace AIProofread
|
|||||||
btnDetectionAll.Enabled = allStatus;
|
btnDetectionAll.Enabled = allStatus;
|
||||||
btnDetectionParagraph.Enabled = rangeStatus;
|
btnDetectionParagraph.Enabled = rangeStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BtnShowManual_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Process.Start(Config.USER_MANUAL_URL);
|
||||||
|
}catch (Exception) {
|
||||||
|
Globals.ThisAddIn.ActiveDocument.ShowMessage("打开用户手册失败", 2000, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnProofreadExact_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
Globals.ThisAddIn.ActiveDocument.CheckPanel();
|
||||||
|
Globals.ThisAddIn.SendMessageToWeb("start", "exact");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BtnProofreadFull_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
Globals.ThisAddIn.ActiveDocument.CheckPanel();
|
||||||
|
Globals.ThisAddIn.SendMessageToWeb("start", "full");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,22 +117,118 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="tabAIProofread.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="group1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="BtnProofreadAll.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="BtnProofreadAll.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="menuProofreadList.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnProofreadExact.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnProofreadFull.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnExportProofreadResult.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="btnClear.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="btnClear.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="btnOpenLexicon.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="btnOpenLexicon.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="menuSencenDect.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btnDetectionAll.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btnDetectionParagraph.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btnDetectionHistory.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="btnSetting.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="btnSetting.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="Group.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ButtonSaveCache.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ButtonLoadCache.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="grpOther.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
<metadata name="BtnGetContact.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="BtnGetContact.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="BtnUpdate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="BtnUpdate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="btnLogin.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btnLogout.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="LblDate.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="LblNickname.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="group2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnShowPanel.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnShowManual.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="grpDebug.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btnShowPane.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="btnHidePane.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnOpenLog.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="button1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnOpenLogger.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnTest.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnOpenAppDir.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="BtnShowVersion.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="dropDown1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -10,6 +10,7 @@ using AIProofread.Model;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Text;
|
||||||
//using CustomTaskPane = Microsoft.Office.Core.CustomTaskPane;
|
//using CustomTaskPane = Microsoft.Office.Core.CustomTaskPane;
|
||||||
//using CustomTaskPane = Microsoft.Office.Tools.CustomTaskPane;
|
//using CustomTaskPane = Microsoft.Office.Tools.CustomTaskPane;
|
||||||
//using NPOI.SS.Formula.Functions;
|
//using NPOI.SS.Formula.Functions;
|
||||||
@ -122,7 +123,7 @@ namespace AIProofread
|
|||||||
|
|
||||||
Application.WindowActivate += Application_WindowActivate;
|
Application.WindowActivate += Application_WindowActivate;
|
||||||
//Application.WindowDeactivate += Application_WindowDeactivate;
|
//Application.WindowDeactivate += Application_WindowDeactivate;
|
||||||
Application.DocumentBeforeSave += Application_DocumentBeforeSave; ;
|
Application.DocumentBeforeSave += Application_DocumentBeforeSave;
|
||||||
|
|
||||||
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
|
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
|
||||||
Application.DocumentChange += Application_DocumentChange;
|
Application.DocumentChange += Application_DocumentChange;
|
||||||
@ -139,7 +140,7 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
catch (Exception ex1)
|
catch (Exception ex1)
|
||||||
{
|
{
|
||||||
Logger.Log("Startup", ex1.ToString());
|
Logger.Log("Startup Error" + ex1.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Log("InitDeviceId", ex.ToString());
|
Logger.Log("InitDeviceId Error:" + ex.ToString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -172,25 +173,51 @@ namespace AIProofread
|
|||||||
public void CheckDocumentClosed(object sender, System.Timers.ElapsedEventArgs e)
|
public void CheckDocumentClosed(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
var existsList = new List<string>();
|
var existsList = new List<string>();
|
||||||
//Logger.Log("检测文档是否关闭 ...");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (documentList.Count == 0 || CurrentWordApplication.Documents.Count == documentList.Count) return;
|
var docList = CurrentWordApplication.Documents;
|
||||||
|
if (documentList.Count == 0 || docList.Count == existsList.Count) return;
|
||||||
existsList.Clear();
|
existsList.Clear();
|
||||||
|
foreach (Document item in docList)
|
||||||
foreach (Document item in CurrentWordApplication.Documents)
|
|
||||||
{
|
{
|
||||||
existsList.Add(item.FullName);
|
existsList.Add(item.FullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测文档是否关闭
|
// 检测文档是否关闭
|
||||||
foreach (var item in documentList.documentList)
|
for (int i = documentList.documentList.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (!existsList.Contains(item.fileName))
|
var item = documentList.documentList[i];
|
||||||
|
// 可能出现另存问题 所以需要更新文件名称
|
||||||
|
var oldName = item.fileName;
|
||||||
|
var currentName = item.CurrentDocument.FullName;
|
||||||
|
if(oldName != currentName)
|
||||||
|
{
|
||||||
|
item.fileName = currentName;
|
||||||
|
}
|
||||||
|
if (!existsList.Contains(currentName))
|
||||||
|
{
|
||||||
|
Logger.Log("检测到文档关闭,已移除:" + currentName);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
item.RunInMainThread(() =>
|
||||||
|
{
|
||||||
|
item.Dispose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (Exception ext)
|
||||||
|
{
|
||||||
|
Logger.Log(ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
Logger.Log("检测到文档关闭,已移除:" + item.fileName);
|
|
||||||
documentList.Remove(item);
|
documentList.Remove(item);
|
||||||
}
|
}
|
||||||
|
catch (Exception ext)
|
||||||
|
{
|
||||||
|
Logger.Log(ext);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -320,6 +347,7 @@ namespace AIProofread
|
|||||||
// 设置当前文档
|
// 设置当前文档
|
||||||
ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument);
|
ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument);
|
||||||
ActiveDocument.CheckBtnStatus();
|
ActiveDocument.CheckBtnStatus();
|
||||||
|
CheckDocumentClosed(null, null);
|
||||||
Logger.Log("Application_DocumentChange -- " + ActiveDocument.fileName);
|
Logger.Log("Application_DocumentChange -- " + ActiveDocument.fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,6 +406,11 @@ namespace AIProofread
|
|||||||
/// <param name="Cancel"></param>
|
/// <param name="Cancel"></param>
|
||||||
private void Application_DocumentBeforeClose(Document currentDoc, ref bool Cancel)
|
private void Application_DocumentBeforeClose(Document currentDoc, ref bool Cancel)
|
||||||
{
|
{
|
||||||
|
var doc = documentList.Get(currentDoc);
|
||||||
|
if (doc != null)
|
||||||
|
{
|
||||||
|
doc.HidePane();
|
||||||
|
}
|
||||||
Logger.Log("DocumentBeforeClose", currentDoc.FullName);
|
Logger.Log("DocumentBeforeClose", currentDoc.FullName);
|
||||||
//if (allMarks.ContainsKey(currentDoc))
|
//if (allMarks.ContainsKey(currentDoc))
|
||||||
//{
|
//{
|
||||||
@ -400,12 +433,12 @@ namespace AIProofread
|
|||||||
|
|
||||||
private void Application_NewDocument(Document doc)
|
private void Application_NewDocument(Document doc)
|
||||||
{
|
{
|
||||||
Logger.Log("NewDocument", doc.Name);
|
Logger.Log("NewDocument" + doc.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Application_DocumentOpen(Document doc)
|
private void Application_DocumentOpen(Document doc)
|
||||||
{
|
{
|
||||||
Logger.Log("DocumentOpen", doc.Name);
|
Logger.Log("DocumentOpen " + doc.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -563,7 +596,7 @@ namespace AIProofread
|
|||||||
|
|
||||||
public DocumentInfo GetDocumentById(int id)
|
public DocumentInfo GetDocumentById(int id)
|
||||||
{
|
{
|
||||||
return documentList.GetById(id);
|
return id <= 0 ? ActiveDocument : documentList.GetById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -609,9 +642,9 @@ namespace AIProofread
|
|||||||
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
|
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitProofreadCacheList(System.Collections.Generic.List<CorrectContext> list)
|
public void InitProofreadCacheList(List<CorrectContext> list, Dictionary<int, ProofreadRangeInfo> dics)
|
||||||
{
|
{
|
||||||
ActiveDocument?.InitProofreadCache(list);
|
ActiveDocument?.InitProofreadCache(list, dics);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
76
AIProofread/core/DocumentReader.cs
Normal file
76
AIProofread/core/DocumentReader.cs
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using System;
|
||||||
|
using Word = Microsoft.Office.Interop.Word;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace AIProofread.core
|
||||||
|
{
|
||||||
|
public class ProcessingContext
|
||||||
|
{
|
||||||
|
public Word.Range Range { get; set; }
|
||||||
|
public int GlobalIndex { get; set; }
|
||||||
|
}
|
||||||
|
public class DocumentReader
|
||||||
|
{
|
||||||
|
private static readonly Stack<ProcessingContext> _processingStack = new Stack<ProcessingContext>();
|
||||||
|
public static List<DocumentText> ReadByVSTO(Word.Document _doc, Word.Application _app, List<DocumentText> list)
|
||||||
|
{
|
||||||
|
//List<DocumentText> list = new List<DocumentText>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 关闭屏幕更新
|
||||||
|
_app.ScreenUpdating = false;
|
||||||
|
|
||||||
|
// 初始化堆栈:处理所有顶级 StoryRanges
|
||||||
|
foreach (Word.Range storyRange in _doc.StoryRanges)
|
||||||
|
{
|
||||||
|
_processingStack.Push(new ProcessingContext
|
||||||
|
{
|
||||||
|
Range = storyRange,
|
||||||
|
GlobalIndex = 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 迭代处理堆栈中的每个 Range
|
||||||
|
while (_processingStack.Count > 0)
|
||||||
|
{
|
||||||
|
var context = _processingStack.Pop();
|
||||||
|
ProcessElement(context.Range, context.GlobalIndex, list);
|
||||||
|
Marshal.ReleaseComObject(context.Range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_app.ScreenUpdating = true;
|
||||||
|
Marshal.ReleaseComObject(_doc);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
private static void ProcessElement(Word.Range range, int globalIndex, List<DocumentText> list)
|
||||||
|
{
|
||||||
|
if (range.Text?.Trim() == "\r\a")
|
||||||
|
{
|
||||||
|
globalIndex++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var paragraphs = range.Paragraphs;
|
||||||
|
// Debug.WriteLine($"Processing element: {range.Text}");
|
||||||
|
// 处理段落
|
||||||
|
foreach (Word.Paragraph paragraph in paragraphs)
|
||||||
|
{
|
||||||
|
list.Add(new DocumentText
|
||||||
|
{
|
||||||
|
Text = paragraph.Range.Text,
|
||||||
|
ParagraphNumber = globalIndex + 1
|
||||||
|
});
|
||||||
|
Marshal.ReleaseComObject(paragraph);
|
||||||
|
globalIndex++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -112,6 +112,12 @@ namespace AIProofread
|
|||||||
//mark.Range.Underline = WdUnderline.wdUnderlineNone;
|
//mark.Range.Underline = WdUnderline.wdUnderlineNone;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// feat(20250305): 清除批注的时候,如果监测到书签位置是空格,把空格给删了吧(无缓冲记录时)
|
||||||
|
string text = mark.Range.Text;
|
||||||
|
if (text != null && text.Trim().Length == 0)
|
||||||
|
{
|
||||||
|
mark.Range.Text = "";
|
||||||
|
}
|
||||||
mark.Delete();
|
mark.Delete();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -571,14 +577,15 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void ExportProofreadResult()
|
public static void ExportProofreadResult(string modelType)
|
||||||
{
|
{
|
||||||
string currentName = Globals.ThisAddIn.Application.ActiveDocument.Name;
|
string currentName = Globals.ThisAddIn.Application.ActiveDocument.Name;
|
||||||
// 去掉文件名后缀
|
// 去掉文件名后缀
|
||||||
currentName = currentName.Substring(0, currentName.LastIndexOf("."));
|
currentName = currentName.Substring(0, currentName.LastIndexOf("."));
|
||||||
SaveFileDialog sfd = new SaveFileDialog();
|
SaveFileDialog sfd = new SaveFileDialog();
|
||||||
|
modelType = modelType == "full" ? "查全" : "查准";
|
||||||
// 设置默认文件名
|
// 设置默认文件名
|
||||||
sfd.FileName = currentName + "_勘误表.xlsx";
|
sfd.FileName = currentName + $"_勘误表_优先{modelType}.xlsx";
|
||||||
sfd.Filter = "Excel文件|*.xlsx";
|
sfd.Filter = "Excel文件|*.xlsx";
|
||||||
var result = sfd.ShowDialog();
|
var result = sfd.ShowDialog();
|
||||||
// 如果用户取消选择,则返回
|
// 如果用户取消选择,则返回
|
||||||
@ -593,7 +600,7 @@ namespace AIProofread
|
|||||||
// 判断原始文件是否可以删除
|
// 判断原始文件是否可以删除
|
||||||
if (File.GetAttributes(sfd.FileName).HasFlag(FileAttributes.ReadOnly))
|
if (File.GetAttributes(sfd.FileName).HasFlag(FileAttributes.ReadOnly))
|
||||||
{
|
{
|
||||||
Globals.ThisAddIn.ShowDialog("已经存在名勘误表文件,请更换名称或者手动删除", null, null);
|
Globals.ThisAddIn.ShowDialog("已经存在名勘误表文件,请更换名称或手动删除", null, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 删除文件 重新写入新数据避免出现未知不可控bug
|
// 删除文件 重新写入新数据避免出现未知不可控bug
|
||||||
@ -841,6 +848,10 @@ namespace AIProofread
|
|||||||
{
|
{
|
||||||
tag = "黑名单";
|
tag = "黑名单";
|
||||||
}
|
}
|
||||||
|
else if(it.Type == "fallen_officers")
|
||||||
|
{
|
||||||
|
tag = "落马官员";
|
||||||
|
}
|
||||||
else if (it.Tag == "i")
|
else if (it.Tag == "i")
|
||||||
{
|
{
|
||||||
startIndex = it.Text.Length + 1;
|
startIndex = it.Text.Length + 1;
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
using Microsoft.Office.Interop.Word;
|
using AIProofread.core;
|
||||||
|
using Microsoft.Office.Interop.Word;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using NPOI;
|
||||||
using NPOI.POIFS.FileSystem;
|
using NPOI.POIFS.FileSystem;
|
||||||
using NPOI.XWPF.UserModel;
|
using NPOI.XWPF.UserModel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace AIProofread
|
namespace AIProofread
|
||||||
@ -36,7 +39,36 @@ namespace AIProofread
|
|||||||
// 获取当前文档所有文本
|
// 获取当前文档所有文本
|
||||||
string allText = doc.Range().Text;
|
string allText = doc.Range().Text;
|
||||||
List<DocumentText> list = new List<DocumentText>();
|
List<DocumentText> list = new List<DocumentText>();
|
||||||
|
|
||||||
|
//DocumentReader.ReadByVSTO(doc, Globals.ThisAddIn.Application, list);
|
||||||
using (FileStream stream = new FileStream(docPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
using (FileStream stream = new FileStream(docPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||||
|
{
|
||||||
|
ReadTextByNPOI(stream, list);
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
//catch (POIXMLException npoiError)
|
||||||
|
//{
|
||||||
|
// Logger.Log("GetAllText Error", npoiError);
|
||||||
|
// // Logger.Log("GetAllText", e);
|
||||||
|
// // return GetAllTextByVSTO(doc);
|
||||||
|
// // 读取文档
|
||||||
|
// DocumentReader.ReadByVSTO(doc, Globals.ThisAddIn.Application, list);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
var map = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
{ "list", list },
|
||||||
|
{ "text", allText }
|
||||||
|
};
|
||||||
|
// 删除临时文件
|
||||||
|
File.Delete(docPath);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ReadTextByNPOI(FileStream stream, List<DocumentText> list)
|
||||||
{
|
{
|
||||||
XWPFDocument ndoc = new XWPFDocument(stream);
|
XWPFDocument ndoc = new XWPFDocument(stream);
|
||||||
var paragraphs = ndoc.Paragraphs;
|
var paragraphs = ndoc.Paragraphs;
|
||||||
@ -74,26 +106,16 @@ namespace AIProofread
|
|||||||
|
|
||||||
// 如果需要,可以进一步解析目录项// 例如,按换行符拆分目录内容
|
// 如果需要,可以进一步解析目录项// 例如,按换行符拆分目录内容
|
||||||
var tocEntries = tocText.Split(new string[] { "\n", "\r", "\r\n", "\f" }, StringSplitOptions.None);
|
var tocEntries = tocText.Split(new string[] { "\n", "\r", "\r\n", "\f" }, StringSplitOptions.None);
|
||||||
foreach (string entry in tocEntries)
|
paragraphNumber+= tocEntries.Length;
|
||||||
{
|
// 暂时跳过目录
|
||||||
|
//foreach (string entry in tocEntries)
|
||||||
list.Add(new DocumentText(entry.Replace("\u0002", ""), paragraphNumber));
|
//{
|
||||||
paragraphNumber++;
|
// list.Add(new DocumentText(entry.Replace("\u0002", ""), paragraphNumber));
|
||||||
|
// paragraphNumber++;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Debug.WriteLine("GetAllText End ==>", DateTime.Now.ToLongTimeString());
|
|
||||||
var map = new Dictionary<string, object>
|
|
||||||
{
|
|
||||||
{ "list", list },
|
|
||||||
{ "text", allText }
|
|
||||||
};
|
|
||||||
// 删除临时文件
|
|
||||||
File.Delete(docPath);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetReadDocumentFilePath(Microsoft.Office.Interop.Word.Document doc)
|
public static string GetReadDocumentFilePath(Microsoft.Office.Interop.Word.Document doc)
|
||||||
{
|
{
|
||||||
@ -155,8 +177,7 @@ namespace AIProofread
|
|||||||
// 获取当前文档所有文本
|
// 获取当前文档所有文本
|
||||||
string allText = doc.Range().Text;
|
string allText = doc.Range().Text;
|
||||||
List<DocumentText> list = new List<DocumentText>();
|
List<DocumentText> list = new List<DocumentText>();
|
||||||
// // 开始分割
|
|
||||||
MD5 md5 = new MD5CryptoServiceProvider();
|
|
||||||
|
|
||||||
Paragraphs paragraphs = doc.Paragraphs;
|
Paragraphs paragraphs = doc.Paragraphs;
|
||||||
|
|
||||||
@ -166,18 +187,22 @@ namespace AIProofread
|
|||||||
foreach (Paragraph p in paragraphs)
|
foreach (Paragraph p in paragraphs)
|
||||||
{
|
{
|
||||||
paragraphNumber++;
|
paragraphNumber++;
|
||||||
if (paragraphNumber % 20 == 0)
|
//if (paragraphNumber % 20 == 0)
|
||||||
{
|
//{
|
||||||
Debug.WriteLine("process paragraphNumber{0}", paragraphNumber);
|
// Debug.WriteLine("process paragraphNumber{0}", paragraphNumber);
|
||||||
}
|
//}
|
||||||
Range r = p.Range;
|
Range r = p.Range;
|
||||||
string text = p.Range.Text;
|
string text = p.Range.Text;
|
||||||
|
|
||||||
if (text.Trim().Length == 0 || text.EndsWith("\r\a") || r.Tables.Count > 0)
|
if (text.Trim().Length == 0 || text.EndsWith("\r\a") || r.Tables.Count > 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
list.Add(new DocumentText(text.Replace("\u0002", ""), paragraphNumber));
|
list.Add(new DocumentText(text.Replace("\u0002", ""), paragraphNumber));
|
||||||
|
Marshal.ReleaseComObject(p);
|
||||||
}
|
}
|
||||||
|
Marshal.ReleaseComObject(paragraphs);
|
||||||
|
|
||||||
//for (; paragraphNumber <= total; paragraphNumber++)
|
//for (; paragraphNumber <= total; paragraphNumber++)
|
||||||
//{
|
//{
|
||||||
|
|
||||||
|
BIN
AIProofread/favicon.ico
Normal file
BIN
AIProofread/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.8 KiB |
@ -19,6 +19,7 @@ namespace updater
|
|||||||
{
|
{
|
||||||
private UpgradeInfo localVersion;
|
private UpgradeInfo localVersion;
|
||||||
private UpgradeInfo upgradeInfo;
|
private UpgradeInfo upgradeInfo;
|
||||||
|
private OfficeStarter appStarter = new OfficeStarter();
|
||||||
private static readonly string ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
|
private static readonly string ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
|
||||||
private static readonly string LocalVersionFilePath = ApplicationBase + Path.GetFileName("version.json");
|
private static readonly string LocalVersionFilePath = ApplicationBase + Path.GetFileName("version.json");
|
||||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||||
@ -30,9 +31,9 @@ namespace updater
|
|||||||
* gm-plugin.gachafun.com 正式发布
|
* gm-plugin.gachafun.com 正式发布
|
||||||
*/
|
*/
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
private static string UpgradeInfoURI = "http://pre-gm-plugin.gachafun.com/";
|
private static string UpgradeInfoURI = "https://gm-plugin.gachafun.com/";
|
||||||
#else
|
#else
|
||||||
private static string UpgradeInfoURI = "https://pre-gm-plugin.gachafun.com/";
|
private static string UpgradeInfoURI = "https://gm-plugin.gachafun.com/";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private string updateSource;
|
private string updateSource;
|
||||||
@ -125,17 +126,22 @@ namespace updater
|
|||||||
public string CheckHostAppRunning()
|
public string CheckHostAppRunning()
|
||||||
{
|
{
|
||||||
Process[] array = Process.GetProcesses();
|
Process[] array = Process.GetProcesses();
|
||||||
|
var hasWPS = false;
|
||||||
|
var hasWord = false;
|
||||||
foreach (Process item2 in array)
|
foreach (Process item2 in array)
|
||||||
{
|
{
|
||||||
if (item2.ProcessName.Equals("wps"))
|
if (item2.ProcessName.Equals("WINWORD"))
|
||||||
{
|
{
|
||||||
return "WPS";
|
hasWord = true;
|
||||||
}
|
}
|
||||||
else if (item2.ProcessName.Equals("WINWORD"))
|
else if (item2.ProcessName.Equals("wps"))
|
||||||
{
|
{
|
||||||
return "Word";
|
hasWPS = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (hasWord && hasWPS) return "WPS与Word";
|
||||||
|
if (hasWord) return "Word";
|
||||||
|
if (hasWPS) return "WPS";
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +259,8 @@ namespace updater
|
|||||||
progressBar1.Value = 100;
|
progressBar1.Value = 100;
|
||||||
// 获取升级包路径
|
// 获取升级包路径
|
||||||
string updateFileName = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl);
|
string updateFileName = UpgradeDir + Path.GetFileName(upgradeInfo.DownloadUrl);
|
||||||
|
try
|
||||||
|
{
|
||||||
if (updateFileName.EndsWith(".exe"))
|
if (updateFileName.EndsWith(".exe"))
|
||||||
{
|
{
|
||||||
StartInstallExe(updateFileName);
|
StartInstallExe(updateFileName);
|
||||||
@ -281,9 +289,34 @@ namespace updater
|
|||||||
}
|
}
|
||||||
MessageBox.Show("更新完成, 您可以打开文档继续校对");
|
MessageBox.Show("更新完成, 您可以打开文档继续校对");
|
||||||
// 保存最新版本日志
|
// 保存最新版本日志
|
||||||
|
try
|
||||||
|
{
|
||||||
File.WriteAllText(LocalVersionFilePath, updateSource);
|
File.WriteAllText(LocalVersionFilePath, updateSource);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
appStarter.StartWPS();
|
||||||
|
appStarter.StartMSOffice();
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(updateFileName);
|
||||||
|
}catch { }
|
||||||
|
var ret = MessageBox.Show("升级失败,是否需要手动执行更新?", "更新失败", MessageBoxButtons.YesNo);
|
||||||
|
if (ret == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
Process.Start(upgradeInfo.DownloadUrl);
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ButtonProcess.Visible = true;
|
||||||
|
ButtonProcess.Text = "重新更新";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public static void CopyDirectory(string sourceFolder, string destinationFolder)
|
public static void CopyDirectory(string sourceFolder, string destinationFolder)
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(destinationFolder);
|
Directory.CreateDirectory(destinationFolder);
|
||||||
|
@ -6,6 +6,8 @@ namespace updater
|
|||||||
public class OfficeStarter
|
public class OfficeStarter
|
||||||
{
|
{
|
||||||
public void StartWPS()
|
public void StartWPS()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (UpdateData.GetInstance().ShouldRebootWPS)
|
if (UpdateData.GetInstance().ShouldRebootWPS)
|
||||||
{
|
{
|
||||||
@ -21,8 +23,12 @@ namespace updater
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
public void StartMSOffice()
|
public void StartMSOffice()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (UpdateData.GetInstance().ShouldRebootMSOffice)
|
if (UpdateData.GetInstance().ShouldRebootMSOffice)
|
||||||
{
|
{
|
||||||
@ -53,5 +59,7 @@ namespace updater
|
|||||||
// 没有找到 直接不处理了
|
// 没有找到 直接不处理了
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace UtilLib
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标识类型index(字符型数字)
|
/// 标识类型index(字符型数字)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Index { get; set; }
|
public string Index { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标识类型(校对所属分类)
|
/// 标识类型(校对所属分类)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,7 +39,7 @@ namespace UtilLib
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 校对状态
|
/// 校对状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("is_accept")]
|
[JsonProperty("isAccept")]
|
||||||
public int IsAccept { get; set; }
|
public int IsAccept { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 校对项颜色
|
/// 校对项颜色
|
||||||
|
Loading…
x
Reference in New Issue
Block a user