Compare commits
4 Commits
c036b904fa
...
697756127c
Author | SHA1 | Date | |
---|---|---|---|
697756127c | |||
e363d6df8b | |||
f7f9fdf5d3 | |||
b3b931e89f |
Binary file not shown.
@ -284,6 +284,12 @@
|
||||
<Compile Include="Controls\BaseWinForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\FormCommonsenseDetection.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\FormCommonsenseDetection.Designer.cs">
|
||||
<DependentUpon>FormCommonsenseDetection.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\FormContact.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -357,18 +363,21 @@
|
||||
<DependentUpon>ProofreadMainControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="core\BridgeResult.cs" />
|
||||
<Compile Include="core\CommonSenseDetection.cs" />
|
||||
<Compile Include="core\CorrectionCharacter.cs" />
|
||||
<Compile Include="core\CorrectionFragmentAbstract.cs" />
|
||||
<Compile Include="core\CorrectionRangeAbstract.cs" />
|
||||
<Compile Include="core\DocumentText.cs" />
|
||||
<Compile Include="core\DocumentUtil.cs" />
|
||||
<Compile Include="core\EventForwarder.cs" />
|
||||
<Compile Include="core\JSONObject.cs" />
|
||||
<Compile Include="core\StringUtil.cs" />
|
||||
<Compile Include="core\Tools.cs" />
|
||||
<Compile Include="core\MainPanelWebMessage.cs" />
|
||||
<Compile Include="core\ExportConfig.cs" />
|
||||
<Compile Include="Logger.cs" />
|
||||
<Compile Include="Model\BridgeResult.cs" />
|
||||
<Compile Include="Model\CommonsenseDetectionItem.cs" />
|
||||
<Compile Include="Model\DocumentContent.cs" />
|
||||
<Compile Include="Model\DocumentInfo.cs" />
|
||||
<Compile Include="Model\DocumentList.cs" />
|
||||
@ -382,6 +391,9 @@
|
||||
<Compile Include="Util\HostHelper.cs" />
|
||||
<Compile Include="Util\HttpUtil.cs" />
|
||||
<Compile Include="Util\User32Util.cs" />
|
||||
<EmbeddedResource Include="Controls\FormCommonsenseDetection.resx">
|
||||
<DependentUpon>FormCommonsenseDetection.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Controls\FormContact.resx">
|
||||
<DependentUpon>FormContact.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
@ -524,6 +536,12 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\logo_no_text_wps.jpg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\icon-ai-robot.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\icon-ai-robot-wps.jpg" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
|
@ -17,6 +17,7 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using UtilLib;
|
||||
using Document = Microsoft.Office.Interop.Word.Document;
|
||||
@ -87,6 +88,30 @@ namespace AIProofread
|
||||
return CurrentUpgrade != null && CurrentUpgrade.NeedUpgrade(Config.APP_VERSION) && CurrentUpgrade.UpgradeType == 1;
|
||||
}
|
||||
|
||||
public void SendNoticeToCheckAll()
|
||||
{
|
||||
Globals.ThisAddIn.ShowDetection();
|
||||
Globals.ThisAddIn.formCommonsenseDetection.SendMessageToWeb("detect-all", null);
|
||||
}
|
||||
public void SendNoticeToCheckRange(int start, int end)
|
||||
{
|
||||
Globals.ThisAddIn.ShowDetection();
|
||||
// 获取当前选中的选区的首尾段落起始与结束位置
|
||||
if (start != -1 && end != -1)
|
||||
{
|
||||
var currectSelectRange = Globals.ThisAddIn.ribbon.currectSelectRange;
|
||||
start = currectSelectRange.Paragraphs.First.Range.Start;
|
||||
end = currectSelectRange.Paragraphs.Last.Range.End;
|
||||
}
|
||||
var data = JSONObject.Create().AddField("start", start).AddField("end", end).ToString();
|
||||
Globals.ThisAddIn.formCommonsenseDetection.SendMessageToWeb("detect-range", data);
|
||||
}
|
||||
public void SendNoticeToShowCheckHistory()
|
||||
{
|
||||
Globals.ThisAddIn.ShowDetection();
|
||||
Globals.ThisAddIn.formCommonsenseDetection.SendMessageToWeb("show-history", null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查插件更新信息
|
||||
/// </summary>
|
||||
@ -260,7 +285,7 @@ namespace AIProofread
|
||||
// web同步注销到ribbon
|
||||
Globals.ThisAddIn.SyncLogout();
|
||||
|
||||
if(string.IsNullOrEmpty(action) || action != "disabled-send")
|
||||
if (string.IsNullOrEmpty(action) || action != "disabled-send")
|
||||
{
|
||||
// ribbon 发送注销动作到 web
|
||||
Globals.ThisAddIn.SendMessageToWeb("logout", null);
|
||||
@ -313,6 +338,16 @@ namespace AIProofread
|
||||
}
|
||||
else
|
||||
{
|
||||
Thread.Sleep(3000);
|
||||
//FormMessage loadingDialog = null;
|
||||
//// 大于15W字符无法校对
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
// if (doc.Characters.Count > 15 * 10000)
|
||||
// {
|
||||
// loadingDialog = Globals.ThisAddIn.ActiveDocument.ShowMessage("文档内容解析中,请稍候...", 0, false);
|
||||
// }
|
||||
//});
|
||||
documentInfo.hasProcessMark = false;
|
||||
data.Add("code", 0);
|
||||
data.Add("message", "success");
|
||||
@ -323,6 +358,10 @@ namespace AIProofread
|
||||
data.Add("wordsCount", doc.Words.Count);
|
||||
data.Add("charactersCount", doc.Characters.Count);
|
||||
data.Add("content", Tools.GetAllText(doc));
|
||||
//if (loadingDialog != null && !loadingDialog.IsDisposed)
|
||||
//{
|
||||
// loadingDialog.Close();
|
||||
//}
|
||||
}
|
||||
return Tools.GetJSONString(data);
|
||||
}
|
||||
@ -330,14 +369,23 @@ namespace AIProofread
|
||||
/// <summary>
|
||||
/// 根据位置获取文档区域文本
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <param name="start">开始段落数</param>
|
||||
/// <param name="end">数据段落书</param>
|
||||
/// <returns></returns>
|
||||
public string getParagraphTextByRange(int start, int end)
|
||||
{
|
||||
var list = Tools.GetTextListByParagraphRange(start, end);
|
||||
return Tools.GetJSONString(list);
|
||||
}
|
||||
|
||||
public string GetDocumentAllText()
|
||||
{
|
||||
return Globals.ThisAddIn.ActiveDocument.GetAllText();
|
||||
}
|
||||
public string GetTextByRange(int start, int end)
|
||||
{
|
||||
return Globals.ThisAddIn.ActiveDocument.GetRangeText(start, end);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取文档所有段落文本
|
||||
/// </summary>
|
||||
@ -569,7 +617,7 @@ namespace AIProofread
|
||||
try
|
||||
{
|
||||
// 根据文档编号 获取当前文档避免数据混乱
|
||||
var document = documentId < 1 ? Globals.ThisAddIn.ActiveDocument :(Globals.ThisAddIn.GetDocumentById(documentId) ?? throw new Exception("没有找到校对文档对象"));
|
||||
var document = documentId < 1 ? Globals.ThisAddIn.ActiveDocument : (Globals.ThisAddIn.GetDocumentById(documentId) ?? throw new Exception("没有找到校对文档对象"));
|
||||
|
||||
// 先清除所有数据
|
||||
if (clearOriginMark) document.ClearAllProofreadMark();
|
||||
@ -595,18 +643,18 @@ namespace AIProofread
|
||||
return InitContent(content, documentId, false);
|
||||
}
|
||||
|
||||
public void ShowMessage(string message,int closeDelay=1000, bool showCloseBtn = true)
|
||||
public void ShowMessage(string message, int closeDelay = 1000, bool showCloseBtn = true)
|
||||
{
|
||||
//FormMessage.ShowMessage(message, closeDelay);
|
||||
Globals.ThisAddIn.ActiveDocument?.ShowMessage(message, closeDelay, showCloseBtn);
|
||||
}
|
||||
public void ShowConfirmMessage(string message, string confirmText, string confirmAction)
|
||||
{
|
||||
Globals.ThisAddIn.ActiveDocument.ShowDialog(message,confirmText,confirmAction);
|
||||
Globals.ThisAddIn.ActiveDocument.ShowDialog(message, confirmText, confirmAction);
|
||||
}
|
||||
public string ShowDialogMessage(string message)
|
||||
{
|
||||
var result = FormMessage.ShowMessage(message, "确认",null);
|
||||
var result = FormMessage.ShowMessage(message, "确认", null);
|
||||
if (result == DialogResult.Retry)
|
||||
{
|
||||
return "retry";
|
||||
|
@ -12,7 +12,7 @@ namespace AIProofread
|
||||
public class Config
|
||||
{
|
||||
public static readonly string APP_NAME = "AI校对王";
|
||||
public static readonly string APP_VERSION = "2.0.4";
|
||||
public static readonly string APP_VERSION = "2.1.0";
|
||||
public static bool IS_WPS = false;
|
||||
public static bool UpgradeForcedNotice = false;
|
||||
public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory;
|
||||
@ -25,7 +25,7 @@ namespace AIProofread
|
||||
/// <summary>
|
||||
/// 网页访问地址
|
||||
/// </summary>
|
||||
public static string WEB_PATH = "http://localhost:5173/"; //pre-gm-plugin.gachafun.com 192.168.0.231:5137 192.168.10.100:5173 gm2-plugin.zverse.group
|
||||
public static string WEB_PATH = "http://gm2-plugin.zverse.group/"; //pre-gm-plugin.gachafun.com 192.168.0.231:5137 192.168.10.100:5173 gm2-plugin.zverse.group
|
||||
public static bool RUN_IN_DEBUG = true;
|
||||
public static AppEnvironment APP_ENV = AppEnvironment.Dev;
|
||||
#else
|
||||
|
@ -110,7 +110,7 @@ namespace AIProofread.Controls
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
}
|
||||
|
||||
protected async void InitWebView(WebView2 webView,String url,string name)
|
||||
protected async void InitWebView(WebView2 webView,String url,string name,Action callaback = null)
|
||||
{
|
||||
//Bridge.InitWebEnvAsync(name, webView);
|
||||
try
|
||||
@ -124,6 +124,10 @@ namespace AIProofread.Controls
|
||||
var eventForwarder = new EventForwarder(this);
|
||||
webView.CoreWebView2.AddHostObjectToScript("event", eventForwarder);
|
||||
webView.CoreWebView2.AddHostObjectToScript("bridge", Bridge.bridge);
|
||||
if(callaback != null)
|
||||
{
|
||||
callaback();
|
||||
}
|
||||
|
||||
webView.Source = new Uri(url);
|
||||
}catch (Exception ex)
|
||||
|
66
AIProofread/Controls/FormCommonsenseDetection.Designer.cs
generated
Normal file
66
AIProofread/Controls/FormCommonsenseDetection.Designer.cs
generated
Normal file
@ -0,0 +1,66 @@
|
||||
namespace AIProofread.Controls
|
||||
{
|
||||
partial class FormCommonsenseDetection
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.MainWebView = new Microsoft.Web.WebView2.WinForms.WebView2();
|
||||
((System.ComponentModel.ISupportInitialize)(this.MainWebView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// MainWebView
|
||||
//
|
||||
this.MainWebView.AllowExternalDrop = false;
|
||||
this.MainWebView.BackColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.MainWebView.CreationProperties = null;
|
||||
this.MainWebView.DefaultBackgroundColor = System.Drawing.Color.White;
|
||||
this.MainWebView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.MainWebView.Location = new System.Drawing.Point(0, 0);
|
||||
this.MainWebView.Name = "MainWebView";
|
||||
this.MainWebView.Size = new System.Drawing.Size(700, 600);
|
||||
this.MainWebView.TabIndex = 0;
|
||||
this.MainWebView.ZoomFactor = 1D;
|
||||
//
|
||||
// FormCommonsenseDetection
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 600);
|
||||
this.Controls.Add(this.MainWebView);
|
||||
this.Name = "FormCommonsenseDetection";
|
||||
this.Text = "FormCommonsenseDetection";
|
||||
this.Load += new System.EventHandler(this.FormCommonsenseDetection_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.MainWebView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Microsoft.Web.WebView2.WinForms.WebView2 MainWebView;
|
||||
}
|
||||
}
|
63
AIProofread/Controls/FormCommonsenseDetection.cs
Normal file
63
AIProofread/Controls/FormCommonsenseDetection.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using AIProofread.core;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using UtilLib;
|
||||
|
||||
namespace AIProofread.Controls
|
||||
{
|
||||
[ClassInterface(ClassInterfaceType.AutoDual)]
|
||||
[ComVisible(true)]
|
||||
public partial class FormCommonsenseDetection : BaseWinForm
|
||||
{
|
||||
private bool initialized = false;
|
||||
|
||||
private string action;
|
||||
private object data;
|
||||
|
||||
public FormCommonsenseDetection()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void FormCommonsenseDetection_Load(object sender, EventArgs e)
|
||||
{
|
||||
// 初始化
|
||||
InitWebView(MainWebView, Config.WebPath("commonsense-detection"), "commonsense-detection", () =>
|
||||
{
|
||||
MainWebView.CoreWebView2.AddHostObjectToScript("detection", CommonSenseDetection.Instance(this));
|
||||
});
|
||||
}
|
||||
|
||||
private void SendToWeb(string action, object data)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(new WebMessage(action, data));
|
||||
MainWebView.CoreWebView2.PostWebMessageAsJson(json);
|
||||
}
|
||||
|
||||
public void SendMessageToWeb(string action, object data)
|
||||
{
|
||||
// 判断是否已经初始化完成
|
||||
if (this.initialized)
|
||||
{
|
||||
SendToWeb(action, data);
|
||||
return;
|
||||
}
|
||||
// 添加到队列
|
||||
this.action = action;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void InitializationCompleted()
|
||||
{
|
||||
if (!this.initialized && !string.IsNullOrEmpty(this.action))
|
||||
{
|
||||
SendToWeb(this.action, this.data);
|
||||
this.action = null;
|
||||
this.data = null;
|
||||
}
|
||||
this.initialized = true;
|
||||
}
|
||||
}
|
||||
}
|
120
AIProofread/Controls/FormCommonsenseDetection.resx
Normal file
120
AIProofread/Controls/FormCommonsenseDetection.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
27
AIProofread/Model/CommonsenseDetectionItem.cs
Normal file
27
AIProofread/Model/CommonsenseDetectionItem.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AIProofread.Model
|
||||
{
|
||||
public enum CommonsenseDetectionType
|
||||
{
|
||||
All = 1,
|
||||
Paragraph = 2
|
||||
}
|
||||
|
||||
public class CommonsenseDetectionItem
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public int Id { get; set; }
|
||||
[JsonProperty("type")]
|
||||
public CommonsenseDetectionType Type { get; set; }
|
||||
[JsonProperty("summary")]
|
||||
public string Summary { get; set; }
|
||||
[JsonProperty("result_content")]
|
||||
public string ResultContent { get; set; }
|
||||
}
|
||||
}
|
@ -115,10 +115,11 @@ namespace AIProofread.Model
|
||||
FormMessage.ShowMessage(message, confirmText, confirmAction);
|
||||
}));
|
||||
}
|
||||
public void ShowMessage(string message, int closeDelay,bool showCloseBtn = true)
|
||||
public FormMessage ShowMessage(string message, int closeDelay, bool showCloseBtn = true)
|
||||
{
|
||||
var msgForm = FormMessage.ShowMessage(message, closeDelay);
|
||||
if(closeDelay > 0){
|
||||
if (closeDelay > 0)
|
||||
{
|
||||
|
||||
if (!showCloseBtn)
|
||||
{
|
||||
@ -134,6 +135,7 @@ namespace AIProofread.Model
|
||||
}));
|
||||
});
|
||||
}
|
||||
return msgForm;
|
||||
}
|
||||
|
||||
public void ShowLogin(string action)
|
||||
@ -316,7 +318,7 @@ namespace AIProofread.Model
|
||||
}
|
||||
|
||||
// 获取当前文档文本
|
||||
public string GetText()
|
||||
public string GetAllText()
|
||||
{
|
||||
return CurrentDocument.Range().Text;
|
||||
}
|
||||
@ -327,7 +329,9 @@ namespace AIProofread.Model
|
||||
/// <returns></returns>
|
||||
public string GetSelectedText()
|
||||
{
|
||||
return CurrentDocument.Range().Text;
|
||||
// 获取当前文档的选区
|
||||
var selection = Globals.ThisAddIn.Application.Selection;
|
||||
return selection.Text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -340,6 +344,17 @@ namespace AIProofread.Model
|
||||
string text = range?.Text;
|
||||
return string.IsNullOrEmpty(text) ? "" : text;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取指定选区的文本
|
||||
/// </summary>
|
||||
/// <param name="start"></param>
|
||||
/// <param name="end"></param>
|
||||
/// <returns></returns>
|
||||
public string GetRangeText(int start, int end)
|
||||
{
|
||||
if (start >= end) return null;
|
||||
return GetRangeText(CurrentDocument.Range(start, end));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存校对缓存结果
|
||||
|
@ -7,10 +7,10 @@ using System.Security;
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("AI校对王")]
|
||||
[assembly: AssemblyDescription("AI校对王 2.0.3")]
|
||||
[assembly: AssemblyDescription("AI校对王 2.1.0")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("果麦文化")]
|
||||
[assembly: AssemblyProduct("AI校对王 2.0.3")]
|
||||
[assembly: AssemblyProduct("AI校对王 2.1.0")]
|
||||
[assembly: AssemblyCopyright("Copyright © GuoMai 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
@ -34,5 +34,5 @@ using System.Security;
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.0")]
|
||||
[assembly: AssemblyFileVersion("2.0.3.0")]
|
||||
[assembly: AssemblyFileVersion("2.1.0.0")]
|
||||
|
||||
|
20
AIProofread/Properties/Resources.Designer.cs
generated
20
AIProofread/Properties/Resources.Designer.cs
generated
@ -100,6 +100,26 @@ namespace AIProofread.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icon_ai_robot {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon-ai-robot", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap icon_ai_robot_wps {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("icon-ai-robot-wps", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
|
@ -118,6 +118,9 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="button" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-setting-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-setting-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
@ -130,11 +133,8 @@
|
||||
<data name="icon-proofread-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-proofread-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="button" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</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 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>
|
||||
</data>
|
||||
<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>
|
||||
@ -181,11 +181,8 @@
|
||||
<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>
|
||||
</data>
|
||||
<data name="icon-export" 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>
|
||||
</data>
|
||||
<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>
|
||||
<data name="icon-clear" 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>
|
||||
</data>
|
||||
<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>
|
||||
@ -196,11 +193,14 @@
|
||||
<data name="icon-refresh" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<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>
|
||||
</data>
|
||||
<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>
|
||||
</data>
|
||||
<data name="icon-clear" 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>
|
||||
<data name="icon-export" 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>
|
||||
</data>
|
||||
<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>
|
||||
@ -208,19 +208,25 @@
|
||||
<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>
|
||||
</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">
|
||||
<value>..\Resources\logo_no_text_wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="icon-logout" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\icon-logout.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<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>
|
||||
</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 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="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>
|
||||
<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_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>
|
||||
<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>
|
||||
</root>
|
BIN
AIProofread/Resources/icon-ai-robot-wps.jpg
Normal file
BIN
AIProofread/Resources/icon-ai-robot-wps.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
BIN
AIProofread/Resources/icon-ai-robot.png
Normal file
BIN
AIProofread/Resources/icon-ai-robot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
42
AIProofread/Ribbon1.Designer.cs
generated
42
AIProofread/Ribbon1.Designer.cs
generated
@ -45,6 +45,10 @@ namespace AIProofread
|
||||
this.BtnExportProofreadResult = this.Factory.CreateRibbonButton();
|
||||
this.btnClear = this.Factory.CreateRibbonButton();
|
||||
this.btnOpenLexicon = this.Factory.CreateRibbonButton();
|
||||
this.menuSencenDect = this.Factory.CreateRibbonMenu();
|
||||
this.btnDetectionAll = this.Factory.CreateRibbonButton();
|
||||
this.btnDetectionParagraph = this.Factory.CreateRibbonButton();
|
||||
this.btnDetectionHistory = this.Factory.CreateRibbonButton();
|
||||
this.btnSetting = this.Factory.CreateRibbonButton();
|
||||
this.Group = this.Factory.CreateRibbonGroup();
|
||||
this.ButtonSaveCache = this.Factory.CreateRibbonButton();
|
||||
@ -93,6 +97,7 @@ namespace AIProofread
|
||||
this.group1.Items.Add(this.BtnExportProofreadResult);
|
||||
this.group1.Items.Add(this.btnClear);
|
||||
this.group1.Items.Add(this.btnOpenLexicon);
|
||||
this.group1.Items.Add(this.menuSencenDect);
|
||||
this.group1.Items.Add(this.btnSetting);
|
||||
this.group1.Name = "group1";
|
||||
//
|
||||
@ -132,6 +137,39 @@ namespace AIProofread
|
||||
this.btnOpenLexicon.ShowImage = true;
|
||||
this.btnOpenLexicon.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnOpenLexicon_Click);
|
||||
//
|
||||
// menuSencenDect
|
||||
//
|
||||
this.menuSencenDect.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||
this.menuSencenDect.Image = global::AIProofread.Properties.Resources.icon_ai_robot;
|
||||
this.menuSencenDect.Items.Add(this.btnDetectionAll);
|
||||
this.menuSencenDect.Items.Add(this.btnDetectionParagraph);
|
||||
this.menuSencenDect.Items.Add(this.btnDetectionHistory);
|
||||
this.menuSencenDect.Label = "校对助手\r\n";
|
||||
this.menuSencenDect.Name = "menuSencenDect";
|
||||
this.menuSencenDect.ShowImage = true;
|
||||
//
|
||||
// btnDetectionAll
|
||||
//
|
||||
this.btnDetectionAll.Label = "全文常识检测\r\n";
|
||||
this.btnDetectionAll.Name = "btnDetectionAll";
|
||||
this.btnDetectionAll.ShowImage = true;
|
||||
this.btnDetectionAll.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnDetectionAll_Click);
|
||||
//
|
||||
// btnDetectionParagraph
|
||||
//
|
||||
this.btnDetectionParagraph.Enabled = false;
|
||||
this.btnDetectionParagraph.Label = "段落常识检测\r\n";
|
||||
this.btnDetectionParagraph.Name = "btnDetectionParagraph";
|
||||
this.btnDetectionParagraph.ShowImage = true;
|
||||
this.btnDetectionParagraph.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnDetectionParagraph_Click);
|
||||
//
|
||||
// btnDetectionHistory
|
||||
//
|
||||
this.btnDetectionHistory.Label = "历史检测记录\r\n";
|
||||
this.btnDetectionHistory.Name = "btnDetectionHistory";
|
||||
this.btnDetectionHistory.ShowImage = true;
|
||||
this.btnDetectionHistory.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnDetectionHistory_Click);
|
||||
//
|
||||
// btnSetting
|
||||
//
|
||||
this.btnSetting.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
|
||||
@ -365,6 +403,10 @@ namespace AIProofread
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnShowVersion;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonDropDown dropDown1;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonGroup grpOther;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonMenu menuSencenDect;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionAll;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionParagraph;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnDetectionHistory;
|
||||
}
|
||||
|
||||
partial class ThisRibbonCollection
|
||||
|
@ -51,6 +51,7 @@ namespace AIProofread
|
||||
btnLogout.Enabled = status;
|
||||
ButtonLoadCache.Enabled = status;
|
||||
ButtonSaveCache.Enabled = status;
|
||||
menuSencenDect.Enabled = status;
|
||||
//BtnShowPanel.Enabled = status;
|
||||
BtnExportProofreadResult.Enabled = status;
|
||||
}
|
||||
@ -85,6 +86,7 @@ namespace AIProofread
|
||||
BtnGetContact.Image = AIProofread.Properties.Resources.icon_phone_wps;
|
||||
BtnUpdate.Image = AIProofread.Properties.Resources.icon_update_wps;
|
||||
btnLogin.Image = AIProofread.Properties.Resources.icon_user_wps;
|
||||
menuSencenDect.Image = AIProofread.Properties.Resources.icon_ai_robot_wps;
|
||||
btnLogout.Image = AIProofread.Properties.Resources.icon_logout_wps;
|
||||
// 缓存相关
|
||||
ButtonLoadCache.Image = AIProofread.Properties.Resources.icon_refresh_wps;
|
||||
@ -480,21 +482,9 @@ namespace AIProofread
|
||||
Logger.LoggerForm.Show();
|
||||
}
|
||||
|
||||
private void BtnTest_Click(object sender, RibbonControlEventArgs e)
|
||||
private int GetRangeParagraphNumber(Range range)
|
||||
{
|
||||
// 获取当前系统时间戳
|
||||
//int time = (int)(DateTime.Now.Ticks / 10000000);
|
||||
//BtnTest.Label = "测试按钮" + time;
|
||||
//var result = MessageBox.Show("Test", "xxx");
|
||||
//Globals.ThisAddIn.Application.
|
||||
var app = Globals.ThisAddIn.Application;
|
||||
var selection = app.Selection;
|
||||
var range = selection.Range;
|
||||
// 获取所在页
|
||||
var pageNumber = GetIndexPageNumber(range);
|
||||
// 获取所在行
|
||||
var rowNumber = range.get_Information(WdInformation.wdFirstCharacterLineNumber);
|
||||
|
||||
int paragraphNumber = 0;
|
||||
if (range.Paragraphs.Count > 0)
|
||||
{
|
||||
@ -517,6 +507,26 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
}
|
||||
return paragraphNumber;
|
||||
}
|
||||
|
||||
private void BtnTest_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
// 获取当前系统时间戳
|
||||
//int time = (int)(DateTime.Now.Ticks / 10000000);
|
||||
//BtnTest.Label = "测试按钮" + time;
|
||||
//var result = MessageBox.Show("Test", "xxx");
|
||||
//Globals.ThisAddIn.Application.
|
||||
var app = Globals.ThisAddIn.Application;
|
||||
var selection = app.Selection;
|
||||
var range = selection.Range;
|
||||
// 获取所在页
|
||||
var pageNumber = GetIndexPageNumber(range);
|
||||
// 获取所在行
|
||||
var rowNumber = range.get_Information(WdInformation.wdFirstCharacterLineNumber);
|
||||
int paragraphNumber = GetRangeParagraphNumber(range);
|
||||
|
||||
|
||||
MessageBox.Show($"当前页:{pageNumber}, 行:{rowNumber}, 段落:{paragraphNumber}");
|
||||
}
|
||||
|
||||
@ -552,5 +562,44 @@ namespace AIProofread
|
||||
{
|
||||
Globals.ThisAddIn.SendMessageToWeb("show-version", "");
|
||||
}
|
||||
|
||||
public Range currectSelectRange;
|
||||
|
||||
private void btnDetectionAll_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
Globals.ThisAddIn.SendMessageToWeb("show-check-all", "");
|
||||
}
|
||||
|
||||
private void btnDetectionParagraph_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
// 获取当前选中的选区的首尾段落起始与结束位置
|
||||
var start = currectSelectRange.Paragraphs.First.Range.Start;
|
||||
var end = currectSelectRange.Paragraphs.Last.Range.End;
|
||||
var data = JSONObject.Create().AddField("start", start).AddField("end", end).ToString();
|
||||
|
||||
Globals.ThisAddIn.SendMessageToWeb("show-check-range", data);
|
||||
}
|
||||
|
||||
private void btnDetectionHistory_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
Globals.ThisAddIn.SendMessageToWeb("show-check-history", "");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储当前选区
|
||||
/// </summary>
|
||||
/// <param name="s"></param>
|
||||
public void ParseSelectionChange(Selection s)
|
||||
{
|
||||
var r = s.Range;
|
||||
btnDetectionParagraph.Enabled = r.Start != r.End;
|
||||
this.currectSelectRange = r;
|
||||
}
|
||||
|
||||
public void SetDetectionBtnStatus(bool status)
|
||||
{
|
||||
btnDetectionAll.Enabled = status;
|
||||
btnDetectionParagraph.Enabled = status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,10 @@ namespace AIProofread
|
||||
/// 当前文档信息
|
||||
/// </summary>
|
||||
public DocumentInfo ActiveDocument { get; set; }
|
||||
/// <summary>
|
||||
/// 智能常识检测对话框 = new FormCommonsenseDetection()
|
||||
/// </summary>
|
||||
public FormCommonsenseDetection formCommonsenseDetection;
|
||||
public bool IsWPS { get; set; }
|
||||
|
||||
public List<FormLogin> LoginFormList = new List<FormLogin>();
|
||||
@ -71,6 +75,23 @@ namespace AIProofread
|
||||
// CurrentWordApplication.DocumentChange += CurrentWordApplication_DocumentChange;
|
||||
//}
|
||||
|
||||
public void ShowDetection()
|
||||
{
|
||||
if (formCommonsenseDetection == null)
|
||||
{
|
||||
formCommonsenseDetection = new FormCommonsenseDetection();
|
||||
}
|
||||
|
||||
|
||||
//formCommonsenseDetection.ShowInTaskbar = true;
|
||||
formCommonsenseDetection.Show();
|
||||
}
|
||||
public void HideDetection()
|
||||
{
|
||||
formCommonsenseDetection.Close();
|
||||
formCommonsenseDetection = null;
|
||||
}
|
||||
|
||||
private void ProcessApplicationException(object sender,UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Logger.Log("UnhandledException",e.ExceptionObject as Exception);
|
||||
@ -86,6 +107,9 @@ namespace AIProofread
|
||||
try
|
||||
{
|
||||
AppInitialize();
|
||||
//formCommonsenseDetection.ShowInTaskbar = false;
|
||||
//formCommonsenseDetection.Show();
|
||||
|
||||
Logger.Log("ThisAddIn_Startup IS_WPS --> " + IsWPS);
|
||||
// 捕获全局异常
|
||||
AppDomain.CurrentDomain.UnhandledException += ProcessApplicationException;
|
||||
@ -381,6 +405,8 @@ namespace AIProofread
|
||||
|
||||
private void Application_WindowSelectionChange(Selection s)
|
||||
{
|
||||
ribbon.ParseSelectionChange(s);
|
||||
|
||||
if (s.Bookmarks != null)
|
||||
{
|
||||
if (s.Range.Start == s.Range.End) // 说明是点击呀
|
||||
|
100
AIProofread/core/CommonSenseDetection.cs
Normal file
100
AIProofread/core/CommonSenseDetection.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using AIProofread.Controls;
|
||||
using AIProofread.Model;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace AIProofread.core
|
||||
{
|
||||
/// <summary>
|
||||
/// 常识性检测数据
|
||||
/// </summary>
|
||||
[ClassInterface(ClassInterfaceType.AutoDual)]
|
||||
[ComVisible(true)]
|
||||
public class CommonSenseDetection
|
||||
{
|
||||
/// <summary>
|
||||
/// 检测历史
|
||||
/// </summary>
|
||||
//public static readonly Dictionary<int, List<CommonsenseDetectionItem>> histories = new Dictionary<int, List<CommonsenseDetectionItem>>();
|
||||
// 暂时改成全局
|
||||
private List<CommonsenseDetectionItem> history = new List<CommonsenseDetectionItem>();
|
||||
|
||||
// 生成单例
|
||||
private static readonly CommonSenseDetection instance = new CommonSenseDetection();
|
||||
private FormCommonsenseDetection formCommonsenseDetection;
|
||||
private CommonSenseDetection() { }
|
||||
|
||||
public static CommonSenseDetection Instance(FormCommonsenseDetection handler)
|
||||
{
|
||||
instance.formCommonsenseDetection = handler;
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void WebInitializationCompleted()
|
||||
{
|
||||
if (formCommonsenseDetection != null && !formCommonsenseDetection.IsDisposed)
|
||||
{
|
||||
formCommonsenseDetection.InitializationCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 检测状态
|
||||
public bool isChecking = false;
|
||||
public string checkingSummary;
|
||||
public string checkingKey;
|
||||
|
||||
public string GetCheckStatus()
|
||||
{
|
||||
return JSONObject.Create()
|
||||
.AddField("isChecking", isChecking)
|
||||
.AddField("checkingKey", checkingKey)
|
||||
.AddField("checkingSummary", checkingSummary)
|
||||
.ToString();
|
||||
}
|
||||
|
||||
public void SetCheckingData(bool isChecking, string checkingKey, string checkingSummary)
|
||||
{
|
||||
if (isChecking)
|
||||
{
|
||||
this.isChecking = isChecking;
|
||||
this.checkingKey = checkingKey;
|
||||
this.checkingSummary = checkingSummary;
|
||||
Globals.ThisAddIn.ribbon.SetDetectionBtnStatus(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.isChecking = false;
|
||||
this.checkingKey = null;
|
||||
this.checkingSummary = null;
|
||||
Globals.ThisAddIn.ribbon.SetDetectionBtnStatus(true);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetHistory()
|
||||
{
|
||||
//int id = Globals.ThisAddIn.ActiveDocument.Id;
|
||||
return JsonConvert.SerializeObject(history);// histories.ContainsKey(id) ? JsonConvert.SerializeObject(histories[id]) : "[]";
|
||||
}
|
||||
public void SetHistory(string json)
|
||||
{
|
||||
var item = JsonConvert.DeserializeObject<CommonsenseDetectionItem>(json);
|
||||
history.Add(item);
|
||||
//int id = Globals.ThisAddIn.ActiveDocument.Id;
|
||||
//if (histories.ContainsKey(id))
|
||||
//{
|
||||
// histories.Add(id, new List<CommonsenseDetectionItem>() { item });
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// histories[id].Add(item);
|
||||
//}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Globals.ThisAddIn.HideDetection();
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ using MathNet.Numerics.LinearAlgebra.Factorization;
|
||||
using System.Linq;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using AIProofread.Model;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
@ -397,12 +398,36 @@ namespace AIProofread
|
||||
{
|
||||
return document.Range(offset + item.Start, offset + item.Start);
|
||||
}
|
||||
// 比对原始内容与校对原文是否一致
|
||||
var range = document.Range(offset + item.Start, offset + item.End + 1);
|
||||
//
|
||||
if (range.Text == item.Origin)
|
||||
int count = 0;
|
||||
while (true && count++ < 10)
|
||||
{
|
||||
return range;
|
||||
var range = document.Range(offset + item.Start, offset + item.End + 1);
|
||||
//
|
||||
try
|
||||
{
|
||||
if (range.Text == null && range.Comments.Count > 0)
|
||||
{
|
||||
// 删除批注
|
||||
foreach (Comment comment in range.Comments)
|
||||
{
|
||||
comment.Delete();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception dce)
|
||||
{
|
||||
Logger.Log(dce);
|
||||
}
|
||||
// 比对原始内容与校对原文是否一致
|
||||
if (range.Text == item.Origin)
|
||||
{
|
||||
return range;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 直接找
|
||||
@ -677,7 +702,7 @@ namespace AIProofread
|
||||
{
|
||||
//row.CreateCell(5).SetCellValue(suggest);
|
||||
}
|
||||
else if ( !string.IsNullOrEmpty(it.Type) && ExportConfig.ErrorTypeMap.ContainsKey(it.Type.ToLower()))
|
||||
else if (!string.IsNullOrEmpty(it.Type) && ExportConfig.ErrorTypeMap.ContainsKey(it.Type.ToLower()))
|
||||
{
|
||||
|
||||
tag = $"【提示】{ExportConfig.ErrorTypeMap[it.Type.ToLower()]}";
|
||||
|
40
AIProofread/core/JSONObject.cs
Normal file
40
AIProofread/core/JSONObject.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
|
||||
namespace AIProofread.core
|
||||
{
|
||||
[Serializable]
|
||||
public class JSONObject
|
||||
{
|
||||
private Dictionary<string, object> m_Dict = new Dictionary<string, object>();
|
||||
private JSONObject()
|
||||
{
|
||||
}
|
||||
public static JSONObject Create()
|
||||
{
|
||||
JSONObject obj = new JSONObject();
|
||||
return obj;
|
||||
}
|
||||
|
||||
public JSONObject AddField(string key, object value)
|
||||
{
|
||||
m_Dict.Add(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ToJSONString();
|
||||
}
|
||||
|
||||
public string ToJSONString()
|
||||
{
|
||||
return Tools.GetJSONString(m_Dict);
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
0ffc09f3eb798c1989429f7c2b6c0220e93f9976a035c03b8478b5bf94f1b55c
|
||||
80a1b62e50022f6927ea33d64c401a80d068064724a07da1ca8562102f036978
|
||||
|
@ -215,3 +215,4 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AIProofread.dll.config
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AntdUI.dll
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\AntdUI.xml
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormCommonsenseDetection.resources
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
21
updater/Form1.Designer.cs
generated
21
updater/Form1.Designer.cs
generated
@ -35,18 +35,16 @@
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.IconClose = new System.Windows.Forms.PictureBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.IconClose)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// LabelLog
|
||||
//
|
||||
this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.LabelLog.Location = new System.Drawing.Point(75, 57);
|
||||
this.LabelLog.Location = new System.Drawing.Point(40, 57);
|
||||
this.LabelLog.Name = "LabelLog";
|
||||
this.LabelLog.Size = new System.Drawing.Size(254, 71);
|
||||
this.LabelLog.Size = new System.Drawing.Size(300, 71);
|
||||
this.LabelLog.TabIndex = 0;
|
||||
this.LabelLog.Text = "正在检测。。。";
|
||||
this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@ -54,7 +52,7 @@
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
this.progressBar1.Location = new System.Drawing.Point(29, 136);
|
||||
this.progressBar1.Location = new System.Drawing.Point(40, 136);
|
||||
this.progressBar1.Name = "progressBar1";
|
||||
this.progressBar1.Size = new System.Drawing.Size(300, 14);
|
||||
this.progressBar1.TabIndex = 3;
|
||||
@ -109,16 +107,6 @@
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "温馨提示";
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Image = global::updater.Properties.Resources.upgrade;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(29, 72);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(40, 40);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||
this.pictureBox1.TabIndex = 5;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
@ -127,7 +115,6 @@
|
||||
this.ClientSize = new System.Drawing.Size(380, 216);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.ButtonProcess);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Controls.Add(this.progressBar1);
|
||||
this.Controls.Add(this.LabelLog);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
@ -142,7 +129,6 @@
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.IconClose)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -151,7 +137,6 @@
|
||||
|
||||
private System.Windows.Forms.Label LabelLog;
|
||||
private System.Windows.Forms.ProgressBar progressBar1;
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private AntdUI.Button ButtonProcess;
|
||||
private System.Windows.Forms.PictureBox IconClose;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
|
@ -189,7 +189,7 @@ namespace updater
|
||||
}
|
||||
else
|
||||
{
|
||||
LabelLog.Text = "当前是最新版本";
|
||||
LabelLog.Text = "当前已是最新版本 V" + localVersion.Version;
|
||||
ButtonProcess.Text = "关闭";
|
||||
ButtonProcess.Visible = true;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user