fixed bug
This commit is contained in:
parent
afddb096b7
commit
8ab9a209e5
Binary file not shown.
@ -11,7 +11,7 @@
|
|||||||
<StartProgram>C:\Soft\Kingsoft\WPS Office\12.1.0.18608\office6\wps.exe</StartProgram>
|
<StartProgram>C:\Soft\Kingsoft\WPS Office\12.1.0.18608\office6\wps.exe</StartProgram>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||||
<StartAction>Program</StartAction>
|
<StartAction>Project</StartAction>
|
||||||
<StartProgram>C:\Soft\Kingsoft\WPS Office\12.1.0.18608\office6\wps.exe</StartProgram>
|
<StartProgram>C:\Soft\Kingsoft\WPS Office\12.1.0.18608\office6\wps.exe</StartProgram>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
@ -9,6 +9,7 @@ using Microsoft.Web.WebView2.WinForms;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using NPOI.XSSF.UserModel;
|
using NPOI.XSSF.UserModel;
|
||||||
using NPOI.XWPF.UserModel;
|
using NPOI.XWPF.UserModel;
|
||||||
|
using Org.BouncyCastle.Asn1.Crmf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -51,7 +52,8 @@ namespace AIProofread
|
|||||||
|
|
||||||
public void ShowUpgradeView()
|
public void ShowUpgradeView()
|
||||||
{
|
{
|
||||||
if (CurrentUpgrade == null) {
|
if (CurrentUpgrade == null)
|
||||||
|
{
|
||||||
CheckPluginUpgrade();
|
CheckPluginUpgrade();
|
||||||
if (CurrentUpgrade == null)
|
if (CurrentUpgrade == null)
|
||||||
{
|
{
|
||||||
@ -99,11 +101,19 @@ namespace AIProofread
|
|||||||
CurrentUpgrade = data.Data;
|
CurrentUpgrade = data.Data;
|
||||||
|
|
||||||
// 是否需要强制升级
|
// 是否需要强制升级
|
||||||
//if (ShouldUpgradeForced())
|
if (ShouldUpgradeForced())
|
||||||
//{
|
{
|
||||||
// // 显示升级框
|
var result = MessageBox.Show("插件有新的版本,是否立即更新?", "AI校对王提示", MessageBoxButtons.YesNo);
|
||||||
// ShowUpgradeView();
|
if (result == DialogResult.Yes)
|
||||||
//}
|
{
|
||||||
|
// 显示升级框
|
||||||
|
ShowUpgradeView();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Globals.ThisAddIn.ribbon.SetBtnStatus("disable-by-upgrade", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -120,11 +130,14 @@ namespace AIProofread
|
|||||||
data["environment"] = Config.APP_ENV.ToString();
|
data["environment"] = Config.APP_ENV.ToString();
|
||||||
return JsonConvert.SerializeObject(data);
|
return JsonConvert.SerializeObject(data);
|
||||||
}
|
}
|
||||||
|
public void SetBtnStatus(string key, bool status)
|
||||||
|
|
||||||
public void showDialog(string message,string confirmText="",string confirmAction="")
|
|
||||||
{
|
{
|
||||||
Globals.ThisAddIn.ActiveDocument?.ShowDialog(message,confirmText,confirmAction);
|
Globals.ThisAddIn.ribbon.SetBtnStatus(key, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showDialog(string message, string confirmText = "", string confirmAction = "")
|
||||||
|
{
|
||||||
|
Globals.ThisAddIn.ActiveDocument?.ShowDialog(message, confirmText, confirmAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMinWIdth()
|
public int getMinWIdth()
|
||||||
@ -196,7 +209,7 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StartUpgradeProcess()
|
public static void StartUpgradeProcess(bool showFail = true)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -211,7 +224,10 @@ namespace AIProofread
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Log(e);
|
Logger.Log(e);
|
||||||
MessageBox.Show("启动升级程序失败,请重试");
|
if (showFail)
|
||||||
|
{
|
||||||
|
MessageBox.Show("启动升级程序失败,请重试");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,28 +276,23 @@ namespace AIProofread
|
|||||||
return Tools.GetAllText(Globals.ThisAddIn.Application.ActiveDocument);
|
return Tools.GetAllText(Globals.ThisAddIn.Application.ActiveDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Saved(int documentId)
|
||||||
|
{
|
||||||
|
var document = documentId > 0 ? Globals.ThisAddIn.GetDocumentById(documentId) : Globals.ThisAddIn.ActiveDocument;
|
||||||
|
return document.CurrentDocument.Saved;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取文档数据
|
/// 获取文档数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string getDocumentData()
|
public string getDocumentData(int documentId)
|
||||||
{
|
{
|
||||||
|
|
||||||
Dictionary<string, object> data = new Dictionary<string, object>();
|
Dictionary<string, object> data = new Dictionary<string, object>();
|
||||||
var documentInfo = Globals.ThisAddIn.ActiveDocument;
|
var documentInfo = documentId > 0 ? Globals.ThisAddIn.GetDocumentById(documentId) : Globals.ThisAddIn.ActiveDocument;
|
||||||
|
|
||||||
var doc = documentInfo.CurrentDocument;
|
var doc = documentInfo.CurrentDocument;
|
||||||
//string ext = doc.FullName.ToLower();
|
if (ShouldUpgradeForced())
|
||||||
// 如果是
|
|
||||||
//var shouldCheckSaved = ext.EndsWith(".wps") || doc.Paragraphs.Count < 200 || doc.Tables.Count < 20;
|
|
||||||
// !shouldCheckSaved &&
|
|
||||||
// 必须保存才能继续校对
|
|
||||||
if (!doc.Saved)
|
|
||||||
{
|
|
||||||
data.Add("code", 1);
|
|
||||||
data.Add("message", "请保存文档后再进行校对");
|
|
||||||
}
|
|
||||||
else if (ShouldUpgradeForced())
|
|
||||||
{
|
{
|
||||||
data.Add("code", 2);
|
data.Add("code", 2);
|
||||||
data.Add("message", "请升级插件后再进行校对");
|
data.Add("message", "请升级插件后再进行校对");
|
||||||
@ -350,29 +361,9 @@ namespace AIProofread
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public string getDocumentFileData() => Globals.ThisAddIn.ActiveDocument?.GetOriginFileData() ?? "";
|
public string getDocumentFileData() => Globals.ThisAddIn.ActiveDocument?.GetOriginFileData() ?? "";
|
||||||
|
|
||||||
public void ShowUpgrade(string data)
|
public void ShowUpgrade(string data, bool force = false)
|
||||||
{
|
{
|
||||||
//var upgradeData = JsonConvert.DeserializeObject<UpgradeData>(data);
|
Globals.ThisAddIn.ActiveDocument.ShowUpgrade(data, force);
|
||||||
//var needUpgrade = upgradeData.NeedUpgrade(Config.APP_VERSION);
|
|
||||||
//if (upgradeData.Ext == 1)
|
|
||||||
//{
|
|
||||||
// if (!needUpgrade)
|
|
||||||
// {
|
|
||||||
// showDialog("当前版本为最新版本,无需升级");
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// var ret = MessageBox.Show(upgradeData.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
|
||||||
// if (ret == DialogResult.Yes)
|
|
||||||
// {
|
|
||||||
// OpenUrlWithOsBrowser(upgradeData.DownloadUrl);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// StartUpgradeProcess();
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void noticeOtherWeb(string json, string targetWebName)
|
public void noticeOtherWeb(string json, string targetWebName)
|
||||||
@ -549,7 +540,7 @@ namespace AIProofread
|
|||||||
public void SelectMarkById(int proofreadId, int documentId)
|
public void SelectMarkById(int proofreadId, int documentId)
|
||||||
{
|
{
|
||||||
|
|
||||||
Globals.ThisAddIn.ActiveDocument?.SelectMarkById(proofreadId,false);
|
Globals.ThisAddIn.ActiveDocument?.SelectMarkById(proofreadId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processMark(int proofreadId, int status)
|
public void processMark(int proofreadId, int status)
|
||||||
@ -647,11 +638,12 @@ namespace AIProofread
|
|||||||
Globals.ThisAddIn.ActiveDocument.FocusToPanel();
|
Globals.ThisAddIn.ActiveDocument.FocusToPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SaveCache(string cache, bool silent)
|
public string SaveCache(int documentId, string cache, bool silent)
|
||||||
{
|
{
|
||||||
|
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
if (!Globals.ThisAddIn.Application.ActiveDocument.Saved)
|
if (!document.CurrentDocument.Saved)
|
||||||
{
|
{
|
||||||
MessageBox.Show("请先保存文档");
|
MessageBox.Show("请先保存文档");
|
||||||
return BridgeResult.Error(1, "请先保存文档");
|
return BridgeResult.Error(1, "请先保存文档");
|
||||||
@ -660,11 +652,12 @@ namespace AIProofread
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 静默时 自动保存文档
|
// 静默时 自动保存文档
|
||||||
Globals.ThisAddIn.ActiveDocument.Save();
|
document.Save();
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.WriteAllText(Globals.ThisAddIn.ActiveDocument.ProofreadCachePath, cache);
|
Logger.Log("SaveCache " + document.fileName + " used " + document.ProofreadCachePath);
|
||||||
|
File.WriteAllText(document.ProofreadCachePath, cache);
|
||||||
return BridgeResult.Success("ok");
|
return BridgeResult.Success("ok");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -673,20 +666,23 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CacheExists()
|
public bool CacheExists(int documentId)
|
||||||
{
|
{
|
||||||
return File.Exists(Globals.ThisAddIn.ActiveDocument.ProofreadCachePath);
|
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
||||||
|
return File.Exists(document.ProofreadCachePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LoadCache()
|
public string LoadCache()
|
||||||
{
|
{
|
||||||
if (!File.Exists(Globals.ThisAddIn.ActiveDocument.ProofreadCachePath))
|
var document = Globals.ThisAddIn.ActiveDocument;
|
||||||
|
if (!File.Exists(document.ProofreadCachePath))
|
||||||
{
|
{
|
||||||
return BridgeResult.Error(1, "cache-not-exists");
|
return BridgeResult.Error(1, "cache-not-exists");
|
||||||
}
|
}
|
||||||
|
Logger.Log("Load cache " + document.fileName + " used " + document.ProofreadCachePath);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return BridgeResult.Success(File.ReadAllText(Globals.ThisAddIn.ActiveDocument.ProofreadCachePath));
|
return BridgeResult.Success(File.ReadAllText(document.ProofreadCachePath));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -713,7 +709,7 @@ namespace AIProofread
|
|||||||
public string ShowConfirm(string message, string caption, string yesButtonText, string noButtonText)
|
public string ShowConfirm(string message, string caption, string yesButtonText, string noButtonText)
|
||||||
{
|
{
|
||||||
var result = FormDialog.Show(message, caption, yesButtonText, noButtonText);
|
var result = FormDialog.Show(message, caption, yesButtonText, noButtonText);
|
||||||
|
|
||||||
return BridgeResult.Success(result == DialogResult.Yes ? "yes" : "no");
|
return BridgeResult.Success(result == DialogResult.Yes ? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -730,5 +726,12 @@ namespace AIProofread
|
|||||||
return BridgeResult.Error(ex);
|
return BridgeResult.Error(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetCurrentDocumentProofreadStatus(int documentId,bool status)
|
||||||
|
{
|
||||||
|
|
||||||
|
var document = Globals.ThisAddIn.GetDocumentById(documentId);
|
||||||
|
document.Proofreading = status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace AIProofread
|
|||||||
public static readonly string APP_NAME = "AI校对王";
|
public static readonly string APP_NAME = "AI校对王";
|
||||||
public static readonly string APP_VERSION = "2.0.0";
|
public static readonly string APP_VERSION = "2.0.0";
|
||||||
public static bool IS_WPS = false;
|
public static bool IS_WPS = false;
|
||||||
|
public static bool UpgradeForcedNotice = false;
|
||||||
|
|
||||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
4
AIProofread/Controls/FormMessage.Designer.cs
generated
4
AIProofread/Controls/FormMessage.Designer.cs
generated
@ -42,9 +42,9 @@
|
|||||||
//
|
//
|
||||||
this.LblMeesage.BackColor = System.Drawing.Color.Transparent;
|
this.LblMeesage.BackColor = System.Drawing.Color.Transparent;
|
||||||
this.LblMeesage.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
this.LblMeesage.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||||
this.LblMeesage.Location = new System.Drawing.Point(40, 90);
|
this.LblMeesage.Location = new System.Drawing.Point(30, 60);
|
||||||
this.LblMeesage.Name = "LblMeesage";
|
this.LblMeesage.Name = "LblMeesage";
|
||||||
this.LblMeesage.Size = new System.Drawing.Size(300, 70);
|
this.LblMeesage.Size = new System.Drawing.Size(320, 140);
|
||||||
this.LblMeesage.TabIndex = 4;
|
this.LblMeesage.TabIndex = 4;
|
||||||
this.LblMeesage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
this.LblMeesage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
//
|
//
|
||||||
|
@ -80,6 +80,8 @@ namespace AIProofread.Model
|
|||||||
public CustomTaskPane TaskPane { get; set; }
|
public CustomTaskPane TaskPane { get; set; }
|
||||||
public WdProtectionType ProtectionType { get { return CurrentDocument.ProtectionType; } }
|
public WdProtectionType ProtectionType { get { return CurrentDocument.ProtectionType; } }
|
||||||
|
|
||||||
|
public bool Proofreading { get; set; }
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
public DocumentInfo(Document doc)
|
public DocumentInfo(Document doc)
|
||||||
{
|
{
|
||||||
@ -211,13 +213,22 @@ namespace AIProofread.Model
|
|||||||
TaskPane.VisibleChanged += TaskPane_VisibleChanged;
|
TaskPane.VisibleChanged += TaskPane_VisibleChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void CheckBtnStatus()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (Globals.ThisAddIn.ribbon != null)
|
||||||
|
{
|
||||||
|
Globals.ThisAddIn.ribbon.BtnShowPanel.Enabled = !PaneVisible && marks.Count > 0;
|
||||||
|
Globals.ThisAddIn.ribbon.SetCommonBtnStatus(!Proofreading);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void TaskPane_VisibleChanged(object sender, EventArgs e)
|
private void TaskPane_VisibleChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// 如果已经隐藏 则记录隐藏用于(WPS)多面板的切换的处理
|
// 如果已经隐藏 则记录隐藏用于(WPS)多面板的切换的处理
|
||||||
if (TaskPane.Visible)
|
PaneVisible = TaskPane.Visible;
|
||||||
{
|
CheckBtnStatus();
|
||||||
PaneVisible = TaskPane.Visible;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
@ -516,8 +527,6 @@ namespace AIProofread.Model
|
|||||||
//
|
//
|
||||||
object bookmark = WdGoToItem.wdGoToBookmark;
|
object bookmark = WdGoToItem.wdGoToBookmark;
|
||||||
object bookmarkName = mark.Name;
|
object bookmarkName = mark.Name;
|
||||||
//doc.GoTo(mark);
|
|
||||||
//mark.Range.GoTo();
|
|
||||||
Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref bookmark, ref missing, ref missing, ref bookmarkName);
|
Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref bookmark, ref missing, ref missing, ref bookmarkName);
|
||||||
//
|
//
|
||||||
//mark.DisableCharacterSpaceGrid = false;
|
//mark.DisableCharacterSpaceGrid = false;
|
||||||
@ -767,5 +776,56 @@ namespace AIProofread.Model
|
|||||||
DocumentUtil.ExportProofreadResult();
|
DocumentUtil.ExportProofreadResult();
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void ShowUpgrade(string data, bool force)
|
||||||
|
{
|
||||||
|
TaskPane.Control.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
var upgradeData = JsonConvert.DeserializeObject<UpgradeData>(data);
|
||||||
|
var needUpgrade = upgradeData.NeedUpgrade(Config.APP_VERSION);
|
||||||
|
//force = force && !Config.UpgradeForcedNotice;
|
||||||
|
|
||||||
|
if (force)
|
||||||
|
{
|
||||||
|
if (Config.UpgradeForcedNotice) return;
|
||||||
|
|
||||||
|
var result = MessageBox.Show(upgradeData.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||||
|
if (result == DialogResult.No)
|
||||||
|
{
|
||||||
|
Config.UpgradeForcedNotice = true;
|
||||||
|
Globals.ThisAddIn.ribbon.SetBtnStatus("disable-by-upgrade", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (upgradeData.Ext == 1)
|
||||||
|
{
|
||||||
|
if (!needUpgrade)
|
||||||
|
{
|
||||||
|
ShowDialog("当前版本为最新版本,无需升级","","");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!force)
|
||||||
|
{
|
||||||
|
// 非强制则再问一次
|
||||||
|
var ret = MessageBox.Show(upgradeData.Message, "是否确认更新", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
|
||||||
|
if (ret == DialogResult.No)
|
||||||
|
{
|
||||||
|
Globals.ThisAddIn.ribbon.SetBtnStatus("disable-by-upgrade", false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Bridge.bridge.OpenUrlWithOsBrowser(upgradeData.DownloadUrl);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Bridge.StartUpgradeProcess();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,8 +105,11 @@ namespace UtilLib
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (mark == null) return;
|
if (mark == null) return;
|
||||||
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
|
||||||
mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(content.Color));
|
// 颜色转码
|
||||||
|
var color = (WdColor)ColorTranslator.ToOle(Colors.FromHex(Config.TextBackgroundColor));
|
||||||
|
// 给选区添加背景颜色
|
||||||
|
mark.Shading.BackgroundPatternColor = color;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@ -161,6 +164,7 @@ namespace UtilLib
|
|||||||
}
|
}
|
||||||
else if (status == AcceptStatus.Default)
|
else if (status == AcceptStatus.Default)
|
||||||
{
|
{
|
||||||
|
// 撤销
|
||||||
if (content.Tag == "r" || content.Tag == "d")
|
if (content.Tag == "r" || content.Tag == "d")
|
||||||
{
|
{
|
||||||
mark.Text = content.Origin;
|
mark.Text = content.Origin;
|
||||||
|
26
AIProofread/Ribbon1.Designer.cs
generated
26
AIProofread/Ribbon1.Designer.cs
generated
@ -36,6 +36,9 @@ namespace AIProofread
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
|
Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItemImpl1 = this.Factory.CreateRibbonDropDownItem();
|
||||||
|
Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItemImpl2 = this.Factory.CreateRibbonDropDownItem();
|
||||||
|
Microsoft.Office.Tools.Ribbon.RibbonDropDownItem ribbonDropDownItemImpl3 = this.Factory.CreateRibbonDropDownItem();
|
||||||
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();
|
||||||
@ -62,6 +65,8 @@ namespace AIProofread
|
|||||||
this.BtnOpenLogger = this.Factory.CreateRibbonButton();
|
this.BtnOpenLogger = this.Factory.CreateRibbonButton();
|
||||||
this.BtnTest = this.Factory.CreateRibbonButton();
|
this.BtnTest = this.Factory.CreateRibbonButton();
|
||||||
this.BtnOpenAppDir = this.Factory.CreateRibbonButton();
|
this.BtnOpenAppDir = this.Factory.CreateRibbonButton();
|
||||||
|
this.BtnShowVersion = this.Factory.CreateRibbonButton();
|
||||||
|
this.dropDown1 = this.Factory.CreateRibbonDropDown();
|
||||||
this.tabAIProofread.SuspendLayout();
|
this.tabAIProofread.SuspendLayout();
|
||||||
this.group1.SuspendLayout();
|
this.group1.SuspendLayout();
|
||||||
this.Group.SuspendLayout();
|
this.Group.SuspendLayout();
|
||||||
@ -235,6 +240,8 @@ namespace AIProofread
|
|||||||
this.grpDebug.Items.Add(this.BtnOpenLogger);
|
this.grpDebug.Items.Add(this.BtnOpenLogger);
|
||||||
this.grpDebug.Items.Add(this.BtnTest);
|
this.grpDebug.Items.Add(this.BtnTest);
|
||||||
this.grpDebug.Items.Add(this.BtnOpenAppDir);
|
this.grpDebug.Items.Add(this.BtnOpenAppDir);
|
||||||
|
this.grpDebug.Items.Add(this.BtnShowVersion);
|
||||||
|
this.grpDebug.Items.Add(this.dropDown1);
|
||||||
this.grpDebug.Label = "开发调试";
|
this.grpDebug.Label = "开发调试";
|
||||||
this.grpDebug.Name = "grpDebug";
|
this.grpDebug.Name = "grpDebug";
|
||||||
this.grpDebug.Visible = false;
|
this.grpDebug.Visible = false;
|
||||||
@ -281,6 +288,23 @@ namespace AIProofread
|
|||||||
this.BtnOpenAppDir.Name = "BtnOpenAppDir";
|
this.BtnOpenAppDir.Name = "BtnOpenAppDir";
|
||||||
this.BtnOpenAppDir.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnOpenAppDir_Click);
|
this.BtnOpenAppDir.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnOpenAppDir_Click);
|
||||||
//
|
//
|
||||||
|
// BtnShowVersion
|
||||||
|
//
|
||||||
|
this.BtnShowVersion.Label = "版本查看";
|
||||||
|
this.BtnShowVersion.Name = "BtnShowVersion";
|
||||||
|
this.BtnShowVersion.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnShowVersion_Click);
|
||||||
|
//
|
||||||
|
// dropDown1
|
||||||
|
//
|
||||||
|
ribbonDropDownItemImpl1.Label = "开发";
|
||||||
|
ribbonDropDownItemImpl2.Label = "测试";
|
||||||
|
ribbonDropDownItemImpl3.Label = "生产";
|
||||||
|
this.dropDown1.Items.Add(ribbonDropDownItemImpl1);
|
||||||
|
this.dropDown1.Items.Add(ribbonDropDownItemImpl2);
|
||||||
|
this.dropDown1.Items.Add(ribbonDropDownItemImpl3);
|
||||||
|
this.dropDown1.Label = "环境";
|
||||||
|
this.dropDown1.Name = "dropDown1";
|
||||||
|
//
|
||||||
// Ribbon1
|
// Ribbon1
|
||||||
//
|
//
|
||||||
this.Name = "Ribbon1";
|
this.Name = "Ribbon1";
|
||||||
@ -329,6 +353,8 @@ namespace AIProofread
|
|||||||
internal Microsoft.Office.Tools.Ribbon.RibbonGroup group2;
|
internal Microsoft.Office.Tools.Ribbon.RibbonGroup group2;
|
||||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnShowPanel;
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnShowPanel;
|
||||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnExportProofreadResult;
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnExportProofreadResult;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnShowVersion;
|
||||||
|
internal Microsoft.Office.Tools.Ribbon.RibbonDropDown dropDown1;
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class ThisRibbonCollection
|
partial class ThisRibbonCollection
|
||||||
|
@ -38,6 +38,37 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetCommonBtnStatus(bool status)
|
||||||
|
{
|
||||||
|
BtnProofreadAll.Enabled = status;
|
||||||
|
btnClear.Enabled = status;
|
||||||
|
btnOpenLexicon.Enabled = status;
|
||||||
|
btnSetting.Enabled = status;
|
||||||
|
BtnUpdate.Enabled = status;
|
||||||
|
btnLogin.Enabled = status;
|
||||||
|
btnLogout.Enabled = status;
|
||||||
|
ButtonLoadCache.Enabled = status;
|
||||||
|
ButtonSaveCache.Enabled = status;
|
||||||
|
//BtnShowPanel.Enabled = status;
|
||||||
|
BtnExportProofreadResult.Enabled = status;
|
||||||
|
}
|
||||||
|
public void SetBtnStatus(string key, bool status)
|
||||||
|
{
|
||||||
|
if (key == "proofread-status")
|
||||||
|
{
|
||||||
|
SetCommonBtnStatus(status);
|
||||||
|
}
|
||||||
|
else if (key == "view-panel")
|
||||||
|
{
|
||||||
|
BtnShowPanel.Enabled = status;
|
||||||
|
}
|
||||||
|
else if (key == "disable-by-upgrade")
|
||||||
|
{
|
||||||
|
SetCommonBtnStatus(status);
|
||||||
|
BtnShowPanel.Enabled = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化WPS相关功能(图标)
|
/// 初始化WPS相关功能(图标)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -156,7 +187,7 @@ namespace AIProofread
|
|||||||
{
|
{
|
||||||
//DocumentUtil.ClearProofreadMarks();
|
//DocumentUtil.ClearProofreadMarks();
|
||||||
var result = MessageBox.Show("请确认是否清除此文档的所有校对标注?", "提示", MessageBoxButtons.OKCancel);
|
var result = MessageBox.Show("请确认是否清除此文档的所有校对标注?", "提示", MessageBoxButtons.OKCancel);
|
||||||
if(result == DialogResult.OK)
|
if (result == DialogResult.OK)
|
||||||
{
|
{
|
||||||
//Bridge.bridge.clearAllProofreadMark(null);
|
//Bridge.bridge.clearAllProofreadMark(null);
|
||||||
Globals.ThisAddIn.ClearAllProofreadMark();
|
Globals.ThisAddIn.ClearAllProofreadMark();
|
||||||
@ -442,7 +473,7 @@ namespace AIProofread
|
|||||||
// 获取当前系统时间戳
|
// 获取当前系统时间戳
|
||||||
//int time = (int)(DateTime.Now.Ticks / 10000000);
|
//int time = (int)(DateTime.Now.Ticks / 10000000);
|
||||||
//BtnTest.Label = "测试按钮" + time;
|
//BtnTest.Label = "测试按钮" + time;
|
||||||
var result= MessageBox.Show("Test","xxx");
|
var result = MessageBox.Show("Test", "xxx");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,5 +504,10 @@ namespace AIProofread
|
|||||||
{
|
{
|
||||||
Globals.ThisAddIn.SendMessageToWeb("export-result", "");
|
Globals.ThisAddIn.SendMessageToWeb("export-result", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void BtnShowVersion_Click(object sender, RibbonControlEventArgs e)
|
||||||
|
{
|
||||||
|
Globals.ThisAddIn.SendMessageToWeb("show-version", "");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ using UtilLib;
|
|||||||
using AIProofread.Model;
|
using AIProofread.Model;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading.Tasks;
|
||||||
//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;
|
||||||
@ -87,14 +88,7 @@ namespace AIProofread
|
|||||||
Application.DocumentChange += Application_DocumentChange;
|
Application.DocumentChange += Application_DocumentChange;
|
||||||
// 选区发生变化事件
|
// 选区发生变化事件
|
||||||
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
|
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
|
||||||
//try
|
//CheckPluginUpgradeInfo();
|
||||||
//{
|
|
||||||
// // 检测升级信息
|
|
||||||
// Bridge.bridge.CheckPluginUpgrade();
|
|
||||||
//}catch(Exception ex)
|
|
||||||
//{
|
|
||||||
// Logger.Log("检测升级信息异常: " + ex.ToString());
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex1)
|
catch (Exception ex1)
|
||||||
{
|
{
|
||||||
@ -102,6 +96,22 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async void CheckPluginUpgradeInfo()
|
||||||
|
{
|
||||||
|
await System.Threading.Tasks.Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 检测升级信息
|
||||||
|
Bridge.bridge.CheckPluginUpgrade();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Log("检测升级信息异常: " + ex.ToString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void Application_DocumentBeforeSave(Document originDocument, ref bool SaveAsUI, ref bool Cancel)
|
private void Application_DocumentBeforeSave(Document originDocument, ref bool SaveAsUI, ref bool Cancel)
|
||||||
{
|
{
|
||||||
Logger.Log("DocumentSave", originDocument.Name + "\r\n");
|
Logger.Log("DocumentSave", originDocument.Name + "\r\n");
|
||||||
@ -184,10 +194,10 @@ namespace AIProofread
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var activeDocument = CurrentWordApplication.ActiveDocument;
|
//var document = CurrentWordApplication.ActiveDocument;
|
||||||
|
|
||||||
// 设置当前文档
|
// 设置当前文档
|
||||||
ActiveDocument = documentList.SetActiveDocument(activeDocument);
|
ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument);
|
||||||
|
ActiveDocument.CheckBtnStatus();
|
||||||
Logger.Log("Application_DocumentChange -- " + ActiveDocument.fileName);
|
Logger.Log("Application_DocumentChange -- " + ActiveDocument.fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +369,8 @@ namespace AIProofread
|
|||||||
/// 显示登录窗口
|
/// 显示登录窗口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="action"></param>
|
/// <param name="action"></param>
|
||||||
public void ShowLoginForm(string action) {
|
public void ShowLoginForm(string action)
|
||||||
|
{
|
||||||
// 关闭之前的窗口
|
// 关闭之前的窗口
|
||||||
//if(LoginFormList.Count > 0){
|
//if(LoginFormList.Count > 0){
|
||||||
// LoginFormList.ForEach(f => f.Close());
|
// LoginFormList.ForEach(f => f.Close());
|
||||||
@ -438,12 +449,12 @@ namespace AIProofread
|
|||||||
|
|
||||||
//public string LoadCacheByPath()
|
//public string LoadCacheByPath()
|
||||||
//{
|
//{
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//public void SaveCache(string cache)
|
//public void SaveCache(string cache)
|
||||||
//{
|
//{
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -72,10 +72,25 @@ namespace updater
|
|||||||
string runningApp = CheckHostAppRunning();
|
string runningApp = CheckHostAppRunning();
|
||||||
if (!string.IsNullOrEmpty(runningApp))
|
if (!string.IsNullOrEmpty(runningApp))
|
||||||
{
|
{
|
||||||
MessageBox.Show(string.Format("检测到{0}正在运行中,请关闭{0}后继续执行更新操作",runningApp));
|
var result = MessageBox.Show(string.Format("检测到{0}正在运行中,是否强制关闭并继续执行更新操作",runningApp));
|
||||||
ButtonProcess.Visible = true;
|
if(result != DialogResult.OK)
|
||||||
ButtonProcess.Text = "继续更新";
|
{
|
||||||
return;
|
ButtonProcess.Visible = true;
|
||||||
|
ButtonProcess.Text = "继续更新";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OfficeKiller.KillWPSProcess();
|
||||||
|
OfficeKiller.KillWordProcess();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
MessageBox.Show("强制关闭失败,请手动关闭后重新执行更新操作");
|
||||||
|
ButtonProcess.Visible = true;
|
||||||
|
ButtonProcess.Text = "继续更新";
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ButtonProcess.Visible = false;
|
ButtonProcess.Visible = false;
|
||||||
progressBar1.Visible = true;
|
progressBar1.Visible = true;
|
||||||
|
@ -4,7 +4,7 @@ namespace updater
|
|||||||
{
|
{
|
||||||
public class OfficeKiller
|
public class OfficeKiller
|
||||||
{
|
{
|
||||||
public void KillWordProcess()
|
public static void KillWordProcess()
|
||||||
{
|
{
|
||||||
Process[] processesByName = Process.GetProcessesByName("WINWORD");
|
Process[] processesByName = Process.GetProcessesByName("WINWORD");
|
||||||
foreach (Process obj in processesByName)
|
foreach (Process obj in processesByName)
|
||||||
@ -15,7 +15,7 @@ namespace updater
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KillExcelProcess()
|
public static void KillExcelProcess()
|
||||||
{
|
{
|
||||||
Process[] processesByName = Process.GetProcessesByName("EXCEL");
|
Process[] processesByName = Process.GetProcessesByName("EXCEL");
|
||||||
foreach (Process obj in processesByName)
|
foreach (Process obj in processesByName)
|
||||||
@ -25,7 +25,7 @@ namespace updater
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void KillWPSProcess()
|
public static void KillWPSProcess()
|
||||||
{
|
{
|
||||||
Process[] processesByName = Process.GetProcessesByName("wps");
|
Process[] processesByName = Process.GetProcessesByName("wps");
|
||||||
foreach (Process process in processesByName)
|
foreach (Process process in processesByName)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user