diff --git a/.vs/AIProofread/v17/.suo b/.vs/AIProofread/v17/.suo index b482155..1c166b3 100644 Binary files a/.vs/AIProofread/v17/.suo and b/.vs/AIProofread/v17/.suo differ diff --git a/AIProofread/AIProofread.csproj b/AIProofread/AIProofread.csproj index e22f0c3..f989125 100644 --- a/AIProofread/AIProofread.csproj +++ b/AIProofread/AIProofread.csproj @@ -326,7 +326,7 @@ - + diff --git a/AIProofread/AIProofread.csproj.user b/AIProofread/AIProofread.csproj.user index eaac49e..5a3723a 100644 --- a/AIProofread/AIProofread.csproj.user +++ b/AIProofread/AIProofread.csproj.user @@ -6,4 +6,8 @@ + + Program + C:\Soft\Kingsoft\WPS Office\12.1.0.16412\office6\wps.exe + \ No newline at end of file diff --git a/AIProofread/Bridge.cs b/AIProofread/Bridge.cs index c3babbf..dde95d1 100644 --- a/AIProofread/Bridge.cs +++ b/AIProofread/Bridge.cs @@ -12,8 +12,10 @@ using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; +using System.Runtime.Remoting.Contexts; using System.Text; using System.Text.RegularExpressions; +using System.Windows.Forms; using System.Xml.Linq; using UtilLib; using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header; @@ -95,12 +97,21 @@ namespace AIProofread Globals.ThisAddIn.SendMessageToWeb("start", "login"); } + public void ShowCurrentPane() + { + Globals.ThisAddIn.currentDocumentTaskPane.Visible = true; + } + public void HideCurrentPane() + { + Globals.ThisAddIn.currentDocumentTaskPane.Visible = false; + } + public void Logout(string action) { if (action == "async-info") { // web同步注销到ribbon - Globals.ThisAddIn.ribbon.ProcessLogout(); + Globals.ThisAddIn.SyncLogout(); } else { @@ -199,9 +210,22 @@ namespace AIProofread // 清除所有标记 public void clearAllProofreadMark() { - selectProofreadId = -1; - marks.Clear(); - DocumentUtil.ClearProofreadMarks(); + try + { + selectProofreadId = -1; + foreach (var item in marks.Values) + { + if (item.mark != null && item.content.tag == "i" && item.content.isAccept == AcceptStatus.Default) + { + item.mark.Text = ""; + } + } + marks.Clear(); + DocumentUtil.ClearProofreadMarks(); + }catch (Exception ex) + { + Logger.Log("ClearAllProofreadMark",ex); + } } public void removeBookmark(string markId) @@ -320,6 +344,11 @@ namespace AIProofread { Globals.ThisAddIn.ShowLoginForm(action); } + public void ShowSettingForm() + { + FormSetting frm = new FormSetting(); + frm.Show(); + } public void MoveCursor(int pos) { @@ -355,18 +384,22 @@ namespace AIProofread marks.Remove(selectProofreadId); return; } - Globals.ThisAddIn.SendMessageToWeb("select", proofreadId); + //object lineNum = (int)mark.Range.Information[WdInformation.wdFirstCharacterLineNumber] - 1; + //object goToLine = WdGoToItem.wdGoToLine; + //object goNext = WdGoToDirection.wdGoToNext; + //Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref goToLine, ref goNext, ref lineNum); // - object bookmark = (int)Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark; + object bookmark = WdGoToItem.wdGoToBookmark; object bookmarkName = mark.Name; //doc.GoTo(mark); //mark.Range.GoTo(); Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref bookmark, ref missing, ref missing, ref bookmarkName); - // - //mark.DisableCharacterSpaceGrid = false; - // 先滚动到可视区域 - //doc.ActiveWindow.ScrollIntoView(mark.Range); - // marks[proofreadId].Select(); + // + //mark.DisableCharacterSpaceGrid = false; + // 先滚动到可视区域 + //doc.ActiveWindow.ScrollIntoView(mark.Range); + marks[proofreadId].Select(); + Globals.ThisAddIn.SendMessageToWeb("select", proofreadId); } Globals.ThisAddIn.SendMessageToWeb("select_proofread", proofreadId); } @@ -382,7 +415,8 @@ namespace AIProofread public void InitContent(string content) { List list = JsonConvert.DeserializeObject>(content); - + // 先清除所有数据 + clearAllProofreadMark(); //var app = Globals.ThisAddIn.Application; //var cur = app.Selection; // @@ -402,12 +436,29 @@ namespace AIProofread { var mark = AddBookmark(item, index, correct.Offset, correct.Insert_len); if (item.tag != "i") index++; - marks.Add(item.id, new ProofreadItem(item, mark)); + if (mark != null) { + marks.Add(item.id, new ProofreadItem(item, mark)); + } + } + } + } + foreach (var item in marks) + { + if(item.Value.mark != null) + { + if (item.Value.content.tag == "i") + { + item.Value.mark.Text = ToolUtil.GetBlankText(item.Value.content.text.Length); + } + if (item.Value.content.color != null) + { + // 给选区添加背景颜色 + item.Value.mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.Value.content.color)); } } } } - + public Microsoft.Office.Tools.Word.Bookmark AddBookmark(CorrectedContent item, int findIndex, int offset, int length) { @@ -437,11 +488,7 @@ namespace AIProofread { bookmark = controls.AddBookmark(r, markName); bookmark.Tag = "ai_proofread"; - if (item.color != null) - { - // 给选区添加背景颜色 - r.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.color)); - } + } else { @@ -453,11 +500,6 @@ namespace AIProofread r = document.Range(offset + index, offset + index + item.origin.Length); bookmark = controls.AddBookmark(r, markName); bookmark.Tag = "ai_proofread"; - if (item.color != null) - { - // 给选区添加背景颜色 - r.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.color)); - } break; } startPos = index; diff --git a/AIProofread/Config.cs b/AIProofread/Config.cs index 3b4762a..de1a8a6 100644 --- a/AIProofread/Config.cs +++ b/AIProofread/Config.cs @@ -7,15 +7,20 @@ namespace AIProofread { public static readonly string APP_NAME = "AI校对王"; public static readonly string APP_VERSION = "1.0.0"; + public static bool IS_WPS = false; #if DEBUG /// /// 网页访问地址 /// public static readonly string WEB_PATH = "http://192.168.10.100:5173/"; + public static readonly bool RUN_IN_DEBUG = true; #else public static readonly string WEB_PATH = "https://gm-plugin.gachafun.com/"; + public static readonly bool RUN_IN_DEBUG = false; #endif - public static readonly string WEB_DATA_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ai_proofread\\userdata"; + public static readonly string APP_DATA_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ai_proofread"; + public static readonly string APP_LOG_PATH = APP_DATA_PATH + "\\logs\\"; + public static readonly string WEB_DATA_PATH = APP_DATA_PATH + "\\userdata"; /// /// 书签前缀 diff --git a/AIProofread/Controls/FormSetting.Designer.cs b/AIProofread/Controls/FormSetting.Designer.cs index 179a53d..4b1a9d3 100644 --- a/AIProofread/Controls/FormSetting.Designer.cs +++ b/AIProofread/Controls/FormSetting.Designer.cs @@ -51,11 +51,10 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(621, 450); this.Controls.Add(this.WebViewSetting); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "FormSetting"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "FormSetting"; this.Load += new System.EventHandler(this.FormSetting_Load); ((System.ComponentModel.ISupportInitialize)(this.WebViewSetting)).EndInit(); diff --git a/AIProofread/Logger.cs b/AIProofread/Logger.cs index 729eb3b..996bd87 100644 --- a/AIProofread/Logger.cs +++ b/AIProofread/Logger.cs @@ -9,26 +9,31 @@ namespace AIProofread { public class Logger { + private static readonly string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); /// /// /// /// public static void Log(string msg) { - string text = string.Concat(AppDomain.CurrentDomain.BaseDirectory + "\\logs", "\\"); - string path = text + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; - if (!Directory.Exists(text)) + string path = Config.APP_LOG_PATH + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"; + if (!Directory.Exists(Config.APP_LOG_PATH)) { - Directory.CreateDirectory(text); + Directory.CreateDirectory(Config.APP_LOG_PATH); } StreamWriter streamWriter = File.AppendText(path); streamWriter.WriteLine("消息:" + msg); - streamWriter.WriteLine("时间:" + DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss: fff:ffffff")); - streamWriter.WriteLine("**************************************************"); + streamWriter.WriteLine("时间:" + DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss")); + streamWriter.WriteLine("***************************[" + (Config.IS_WPS?"WPS":"WORD")+ "]***************************"); streamWriter.WriteLine(); streamWriter.Flush(); streamWriter.Close(); streamWriter.Dispose(); } + + public static void Log(string tag, Exception e) + { + Log(tag + "\n" + e.StackTrace); + } } } diff --git a/AIProofread/ProofreadItem.cs b/AIProofread/ProofreadItem.cs index 48a8d18..23d7800 100644 --- a/AIProofread/ProofreadItem.cs +++ b/AIProofread/ProofreadItem.cs @@ -11,7 +11,7 @@ namespace UtilLib public class ProofreadItem { public Bookmark mark; - private CorrectedContent content; + public CorrectedContent content; private float originSize; public string Name { get; set; } public ProofreadItem(CorrectedContent content) @@ -34,6 +34,7 @@ namespace UtilLib this.mark = bookmark; // 记录目前字体 originSize = bookmark.Range.Font.Size; + mark.Selected += OnMarkSelected; } SetMarkName(); //InitBookMark(bookmark); @@ -52,7 +53,6 @@ namespace UtilLib mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick; // 设置名称 mark.Name = Config.BuildBookmarkName(content.id); - //mark.Selected += OnMarkSelected; //mark.SelectionChange += OnMarkSelectionChange; } } @@ -61,25 +61,18 @@ namespace UtilLib { //throw new System.NotImplementedException(); //mark.Range.Font.Size = originSize; - Console.WriteLine("xxx"); + //Console.WriteLine("xxx"); } private void OnMarkSelected(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e) { //throw new System.NotImplementedException(); - mark.Range.Font.Size = originSize + 2; // 将选中标签文本放大字体 + Bridge.bridge.SelectMarkById(content.id); } public void Select() { if (mark == null) return; - if (content.tag == "i") - { - var endPos = mark.Range.End; - var rng = Globals.ThisAddIn.Application.ActiveDocument.Range(endPos, endPos); - rng.Select(); - return; - } mark.Range.Font.Size = originSize + 2; // 将选中标签文本放大字体 mark.Select(); @@ -93,14 +86,14 @@ namespace UtilLib private void SetMarkStyle() { if (mark == null) return; - mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick; + //mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick; mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(content.color)); } private void ResetMarkStyle() { if (mark == null) return; - mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone; + //mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone; mark.Range.Shading.BackgroundPatternColor = Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic; } @@ -125,6 +118,11 @@ namespace UtilLib else if (status == AcceptStatus.Review || status == AcceptStatus.Ignore) { ResetMarkStyle(); + // 新增添加了空格 所以当忽略时还原 + if (content.tag == "i") + { + mark.Text = ""; + } } else if (status == AcceptStatus.Default) { @@ -134,7 +132,7 @@ namespace UtilLib } else if (content.tag == "i") { - mark.Text = ""; + mark.Text = ToolUtil.GetBlankText(content.text.Length); } SetMarkStyle(); } diff --git a/AIProofread/Properties/AssemblyInfo.cs b/AIProofread/Properties/AssemblyInfo.cs index a176bdd..895e054 100644 --- a/AIProofread/Properties/AssemblyInfo.cs +++ b/AIProofread/Properties/AssemblyInfo.cs @@ -6,7 +6,7 @@ using System.Security; // 有关程序集的一般信息由以下 // 控制。更改这些特性值可修改 // 与程序集关联的信息。 -[assembly: AssemblyTitle("AIProofread")] +[assembly: AssemblyTitle("AI校对王")] [assembly: AssemblyDescription("AI校对王")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("果麦文化")] @@ -33,6 +33,6 @@ using System.Security; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: : // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.1")] +[assembly: AssemblyFileVersion("1.0.0.1")] diff --git a/AIProofread/Ribbon1.Designer.cs b/AIProofread/Ribbon1.Designer.cs index b2536eb..aa5f183 100644 --- a/AIProofread/Ribbon1.Designer.cs +++ b/AIProofread/Ribbon1.Designer.cs @@ -48,13 +48,18 @@ namespace AIProofread this.btnLogout = this.Factory.CreateRibbonButton(); this.LblNickname = this.Factory.CreateRibbonLabel(); this.LblDate = this.Factory.CreateRibbonLabel(); + this.grpDebug = this.Factory.CreateRibbonGroup(); + this.btnShowPane = this.Factory.CreateRibbonButton(); + this.btnHidePane = this.Factory.CreateRibbonButton(); this.tabAIProofread.SuspendLayout(); this.group1.SuspendLayout(); + this.grpDebug.SuspendLayout(); this.SuspendLayout(); // // tabAIProofread // this.tabAIProofread.Groups.Add(this.group1); + this.tabAIProofread.Groups.Add(this.grpDebug); this.tabAIProofread.Label = "AI校对王"; this.tabAIProofread.Name = "tabAIProofread"; this.tabAIProofread.Position = this.Factory.RibbonPosition.AfterOfficeId("TabHelp"); @@ -158,6 +163,26 @@ namespace AIProofread this.LblDate.Name = "LblDate"; this.LblDate.Visible = false; // + // grpDebug + // + this.grpDebug.Items.Add(this.btnShowPane); + this.grpDebug.Items.Add(this.btnHidePane); + this.grpDebug.Label = "开发调试"; + this.grpDebug.Name = "grpDebug"; + this.grpDebug.Visible = false; + // + // btnShowPane + // + this.btnShowPane.Label = "显示面板"; + this.btnShowPane.Name = "btnShowPane"; + this.btnShowPane.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnShowPane_Click); + // + // btnHidePane + // + this.btnHidePane.Label = "隐藏面板"; + this.btnHidePane.Name = "btnHidePane"; + this.btnHidePane.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnHidePane_Click); + // // Ribbon1 // this.Name = "Ribbon1"; @@ -168,6 +193,8 @@ namespace AIProofread this.tabAIProofread.PerformLayout(); this.group1.ResumeLayout(false); this.group1.PerformLayout(); + this.grpDebug.ResumeLayout(false); + this.grpDebug.PerformLayout(); this.ResumeLayout(false); } @@ -186,6 +213,9 @@ namespace AIProofread internal Microsoft.Office.Tools.Ribbon.RibbonButton btnSetting; internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnGetContact; internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnUpdate; + internal Microsoft.Office.Tools.Ribbon.RibbonGroup grpDebug; + internal Microsoft.Office.Tools.Ribbon.RibbonButton btnShowPane; + internal Microsoft.Office.Tools.Ribbon.RibbonButton btnHidePane; } partial class ThisRibbonCollection diff --git a/AIProofread/Ribbon1.cs b/AIProofread/Ribbon1.cs index 51686e9..65972bc 100644 --- a/AIProofread/Ribbon1.cs +++ b/AIProofread/Ribbon1.cs @@ -17,6 +17,10 @@ namespace AIProofread //btnLogout.Label = "退出\n登录"; Globals.ThisAddIn.ribbon = this; + if(Config.RUN_IN_DEBUG) + { + grpDebug.Visible = true; + } } public void InitWPS() @@ -64,8 +68,8 @@ namespace AIProofread btnLogin.Visible = !IS_LOGIN; btnLogout.Visible = IS_LOGIN; - LblNickname.Visible = IS_LOGIN; - LblDate.Visible = IS_LOGIN; + //LblNickname.Visible = IS_LOGIN; + //LblDate.Visible = IS_LOGIN; } // 弹出登录窗口 @@ -89,8 +93,7 @@ namespace AIProofread private void btnSetting_Click(object sender, RibbonControlEventArgs e) { - FormSetting frm = new FormSetting(); - frm.ShowDialog(); + Globals.ThisAddIn.SendMessageToWeb("show-setting", null); } private void BtnGetContact_Click(object sender, RibbonControlEventArgs e) @@ -115,5 +118,15 @@ namespace AIProofread DocumentUtil.ClearProofreadMarks(); Globals.ThisAddIn.SendMessageToWeb("clear-tips", null); } + + private void btnShowPane_Click(object sender, RibbonControlEventArgs e) + { + Globals.ThisAddIn.ShowPanel(); + } + + private void btnHidePane_Click(object sender, RibbonControlEventArgs e) + { + Globals.ThisAddIn.HidePanel(); + } } } diff --git a/AIProofread/ThisAddIn.cs b/AIProofread/ThisAddIn.cs index 2bdcefa..cc6e486 100644 --- a/AIProofread/ThisAddIn.cs +++ b/AIProofread/ThisAddIn.cs @@ -43,13 +43,28 @@ namespace AIProofread public List LoginFormList = new List(); public Dictionary taskPanels = new Dictionary(); - private CustomTaskPane customTaskPane; + public Dictionary panelsVisible = new Dictionary(); + public CustomTaskPane currentDocumentTaskPane; - private void Application_WindowDeactivate(Word.Document Doc, Window Wn) + private void Application_WindowDeactivate(Word.Document doc, Window Wn) { - Logger.Log("Application_WindowDeactivate -- " + Doc.FullName); + Logger.Log("Application_WindowDeactivate -- " + doc.FullName); //HidePanel(Doc); + if (taskPanels.ContainsKey(doc)) + { + var visible = taskPanels[doc].Visible; + // 记录当前文档的显示状态 + if (!panelsVisible.ContainsKey(doc)) + { + panelsVisible.Add(doc, visible); + } + else + { + panelsVisible[doc] = visible; + } + } + } private void Application_WindowActivate(Word.Document Doc, Window Wn) @@ -59,9 +74,17 @@ namespace AIProofread if (!taskPanels.ContainsKey(Doc)) { - ShowPanel(Doc); + ShowPanel(Doc,false); + } + this.currentDocumentTaskPane = taskPanels[Doc]; + if (IsWPS) + { + HideOtherPanel(Doc); + } + if (panelsVisible.ContainsKey(Doc) && panelsVisible[Doc]) + { + taskPanels[Doc].Visible = true; } - HideOtherPanel(Doc); } private void Application_DocumentBeforeClose(Word.Document Doc, ref bool Cancel) @@ -99,7 +122,7 @@ namespace AIProofread } foreach (var key in taskPanels.Keys) { - taskPanels[key].Visible = doc == key; + taskPanels[key].Visible = false; } } @@ -119,23 +142,32 @@ namespace AIProofread if (taskPanels.ContainsKey(doc)) { - taskPanels[doc].Visible = true; - this.customTaskPane = taskPanels[doc]; return taskPanels[doc]; } //proofreadPanel = new ProofreadMainControl(); var control = new ProofreadMainControl(doc, MinWidth); var panel = Globals.ThisAddIn.CustomTaskPanes.Add(control, AddinName); - this.customTaskPane = panel; + this.currentDocumentTaskPane = panel; taskPanels.Add(doc, panel); control.Width = MinWidth; panel.Width = MinWidth; - panel.Visible = show; + panel.Visible = false; + panel.VisibleChanged += Panel_VisibleChanged; + // 监听尺寸变化 防止最小尺寸小于设置值 control.SizeChanged += Control_SizeChanged; return panel; } + + private void Panel_VisibleChanged(object sender, EventArgs e) + { + if(currentDocumentTaskPane == sender) + { + + } + } + /// /// word创建面板 /// @@ -146,10 +178,10 @@ namespace AIProofread private void Control_SizeChanged(object sender, EventArgs e) { - if (customTaskPane != null && customTaskPane.Width < MinWidth) + if (currentDocumentTaskPane != null && currentDocumentTaskPane.Width < MinWidth) { SendKeys.Send("{ESC}"); - customTaskPane.Width = MinWidth; + currentDocumentTaskPane.Width = MinWidth; } } @@ -178,6 +210,7 @@ namespace AIProofread if (applicationStartupPath.Contains("WPS")) { IsWPS = true; + Config.IS_WPS = true; try { Globals.Ribbons.Ribbon1.InitWPS(); @@ -194,12 +227,18 @@ namespace AIProofread Application.WindowDeactivate += Application_WindowDeactivate; (Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument; // 选区发生变化事件 - this.Application.WindowSelectionChange += Application_WindowSelectionChange; + //this.Application.WindowSelectionChange += Application_WindowSelectionChange; - if (Application.ActiveDocument != null) + try { - // 默认直接打开文档 就直接创建panel - ShowPanel(Application.ActiveDocument, false); + if (Application.ActiveDocument != null) + { + // 默认直接打开文档 就直接创建panel + ShowPanel(Application.ActiveDocument, false); + } + }catch (Exception ex2) + { + Logger.Log("加载默认文档失败: " + ex2.ToString()); } } catch (Exception ex1) @@ -241,8 +280,13 @@ namespace AIProofread { // 先显示panel var panel = this.ShowPanel(Application.ActiveDocument, true); + SendMessageToWeb(panel.Control, msg, data); + } + + public void SendMessageToWeb(UserControl panelControl, string msg, object data) + { var json = JsonConvert.SerializeObject(new WebMessage(msg, data)); - var control = (ProofreadMainControl)panel.Control; + var control = (ProofreadMainControl)panelControl; try { if (control.web.CoreWebView2 == null) @@ -260,13 +304,13 @@ namespace AIProofread // 显示面板 public void ShowPanel() { - this.customTaskPane.Visible = true; + this.currentDocumentTaskPane.Visible = true; } // 隐藏面板 public void HidePanel() { - this.customTaskPane.Visible = false; + this.currentDocumentTaskPane.Visible = false; } @@ -314,6 +358,22 @@ namespace AIProofread this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown); } + public void SyncLogout() + { + ribbon.ProcessLogout(); + taskPanels.Values.ToList().ForEach(p => + { + try + { + // 同步登录失败信息 + SendMessageToWeb(p.Control, "async-logout", null); + }catch (Exception ex) { + Logger.Log("async-logout:",ex); + } + }); + + } + #endregion diff --git a/AIProofread/core/DocumentUtil.cs b/AIProofread/core/DocumentUtil.cs index bcca15c..6546b92 100644 --- a/AIProofread/core/DocumentUtil.cs +++ b/AIProofread/core/DocumentUtil.cs @@ -6,6 +6,8 @@ using UtilLib; using Microsoft.Office.Interop.Word; using Bookmark = Microsoft.Office.Tools.Word.Bookmark; using System.Collections.Generic; +using Microsoft.Office.Tools.Word; +using System; namespace AIProofread { @@ -84,6 +86,7 @@ namespace AIProofread public static void ClearProofreadMarks() { var bookmarks = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks; + ControlCollection controls = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument).Controls; foreach (Microsoft.Office.Interop.Word.Bookmark mark in bookmarks) { if (Config.IsProofreadMark(mark.Name)) @@ -92,7 +95,17 @@ namespace AIProofread mark.Range.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic; // 去除下划线 mark.Range.Underline = WdUnderline.wdUnderlineNone; - mark.Delete(); + //mark.Delete(); + } + try + { + if (controls.Contains(mark)) + { + controls.Remove(mark); + } + }catch(Exception e) + { + Logger.Log("remove mark",e); } } diff --git a/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache b/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache index d79df3e..411971b 100644 Binary files a/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache and b/AIProofread/obj/Debug/AIProofread.csproj.AssemblyReference.cache differ diff --git a/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache b/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache index a236767..b226628 100644 Binary files a/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache and b/AIProofread/obj/Debug/AIProofread.csproj.GenerateResource.cache differ diff --git a/AIProofread/obj/Debug/AIProofread.dll b/AIProofread/obj/Debug/AIProofread.dll index 4f03a3d..3b97bb1 100644 Binary files a/AIProofread/obj/Debug/AIProofread.dll and b/AIProofread/obj/Debug/AIProofread.dll differ diff --git a/AIProofread/obj/Debug/AIProofread.pdb b/AIProofread/obj/Debug/AIProofread.pdb index ce9a92b..1fdea6b 100644 Binary files a/AIProofread/obj/Debug/AIProofread.pdb and b/AIProofread/obj/Debug/AIProofread.pdb differ diff --git a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache index ea5f57f..863b494 100644 Binary files a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index 90f79c7..df29434 100644 Binary files a/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/AIProofread/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/util-lib/Colors.cs b/util-lib/Colors.cs index 46aefb2..6fe884d 100644 --- a/util-lib/Colors.cs +++ b/util-lib/Colors.cs @@ -7,16 +7,12 @@ namespace UtilLib { public static Color FromHex(string hex) { - hex = hex.TrimStart('#'); - int hexValue = Convert.ToInt32(hex, 16); - byte red = (byte)((hexValue >> 16) & 0xFF); - byte green = (byte)((hexValue >> 8) & 0xFF); - byte blue = (byte)(hexValue & 0xFF); - return FromRGB(red, green, blue); + if(!hex.StartsWith("#")) hex = "#" + hex; + return ColorTranslator.FromHtml(hex); } - public static Color FromRGB(byte red, byte green, byte blue) + public static Color FromRGB(byte red, byte green, byte blue, int opacity) { - return Color.FromArgb(red, green, blue); + return Color.FromArgb(opacity,red, green, blue); } } } diff --git a/util-lib/Properties/AssemblyInfo.cs b/util-lib/Properties/AssemblyInfo.cs index d5c9d6c..2a7ef55 100644 --- a/util-lib/Properties/AssemblyInfo.cs +++ b/util-lib/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ using System.Runtime.InteropServices; // 有关程序集的一般信息由以下 // 控制。更改这些特性值可修改 // 与程序集关联的信息。 -[assembly: AssemblyTitle("util-lib")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyTitle("AI校对王")] +[assembly: AssemblyDescription("AI校对王")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("util-lib")] -[assembly: AssemblyCopyright("Copyright © 2024")] +[assembly: AssemblyCompany("果麦文化")] +[assembly: AssemblyProduct("AI校对王")] +[assembly: AssemblyCopyright("Copyright © GuoMai 2024")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.1")] +[assembly: AssemblyFileVersion("1.0.0.1")] diff --git a/util-lib/ToolUtil.cs b/util-lib/ToolUtil.cs new file mode 100644 index 0000000..98a4888 --- /dev/null +++ b/util-lib/ToolUtil.cs @@ -0,0 +1,17 @@ +using System.Text; + +namespace UtilLib +{ + public class ToolUtil + { + public static string GetBlankText(int len) + { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < len; i++) + { + sb.Append(' '); + } + return sb.ToString(); + } + } +} diff --git a/util-lib/UtilLib.cs b/util-lib/UtilLib.cs deleted file mode 100644 index d40212a..0000000 --- a/util-lib/UtilLib.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UtilLib -{ - public class UtilLib - { - } -} diff --git a/util-lib/util-lib.csproj b/util-lib/util-lib.csproj index d14cdc6..99dc0c5 100644 --- a/util-lib/util-lib.csproj +++ b/util-lib/util-lib.csproj @@ -49,7 +49,7 @@ - +