优化找不到标记异常;优化对象查找
This commit is contained in:
parent
0c1fd59146
commit
a5ed094f2d
Binary file not shown.
@ -233,13 +233,17 @@ namespace AIProofread
|
||||
item.ResetMarkStyle();
|
||||
}
|
||||
}
|
||||
marks.Clear();
|
||||
DocumentUtil.ClearProofreadMarks();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log("ClearAllProofreadMark", ex);
|
||||
}
|
||||
try
|
||||
{
|
||||
// 清空marks
|
||||
marks.Clear();
|
||||
}catch (Exception) { }
|
||||
}
|
||||
|
||||
public void removeBookmark(string markId)
|
||||
@ -416,7 +420,7 @@ namespace AIProofread
|
||||
// 先滚动到可视区域
|
||||
//doc.ActiveWindow.ScrollIntoView(mark.Range);
|
||||
marks[proofreadId].Select();
|
||||
Globals.ThisAddIn.SendMessageToWeb("select", proofreadId);
|
||||
//Globals.ThisAddIn.SendMessageToWeb("select", proofreadId);
|
||||
}
|
||||
Globals.ThisAddIn.SendMessageToWeb("select_proofread", proofreadId);
|
||||
}
|
||||
@ -438,7 +442,6 @@ namespace AIProofread
|
||||
//var app = Globals.ThisAddIn.Application;
|
||||
//var cur = app.Selection;
|
||||
//
|
||||
int aIndex = 0;
|
||||
foreach (var correct in list)
|
||||
{
|
||||
//cur.TypeText(correct.Insert);
|
||||
@ -451,16 +454,8 @@ namespace AIProofread
|
||||
// return it.start + correct.Insert_len;
|
||||
//}).ToList();
|
||||
int index = 0;
|
||||
if (aIndex++ > 20)
|
||||
{
|
||||
Console.WriteLine(aIndex);
|
||||
}
|
||||
foreach (var item in correct.Diffs)
|
||||
{
|
||||
if(item.id == 109288)
|
||||
{
|
||||
Console.WriteLine("xxx");
|
||||
}
|
||||
var mark = AddBookmark(item, index, correct.Sentence_offset, correct.Insert_len, correct.Paragraph_offset);
|
||||
if (item.tag != "i") index++;
|
||||
if (mark != null)
|
||||
@ -522,7 +517,10 @@ namespace AIProofread
|
||||
// 判断是否已经存在
|
||||
if (controls.Contains(markName))
|
||||
{
|
||||
controls.Remove(markName);
|
||||
try
|
||||
{
|
||||
controls.Remove(markName);
|
||||
}catch (Exception) { }
|
||||
}
|
||||
Range findRange = null;
|
||||
if (paragraphIndex > document.Paragraphs.Count) return null;
|
||||
|
@ -8,15 +8,17 @@ namespace AIProofread
|
||||
public static readonly string APP_NAME = "AI校对王";
|
||||
public static readonly string APP_VERSION = "1.0.4";
|
||||
public static bool IS_WPS = false;
|
||||
|
||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// 网页访问地址
|
||||
/// </summary>
|
||||
public static readonly string WEB_PATH = "http://192.168.10.100:5173/";
|
||||
public static readonly bool RUN_IN_DEBUG = true;
|
||||
public static string WEB_PATH = "http://192.168.10.100:5173/";
|
||||
public static 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;
|
||||
public static string WEB_PATH = "https://gm-plugin.gachafun.com/";
|
||||
public static bool RUN_IN_DEBUG = false;
|
||||
#endif
|
||||
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\\";
|
||||
|
@ -36,5 +36,13 @@ namespace AIProofread.Controls
|
||||
{
|
||||
return label1.Width;
|
||||
}
|
||||
public void ResetWeb()
|
||||
{
|
||||
if (!this.web.IsDisposed)
|
||||
{
|
||||
this.web.Stop();
|
||||
this.web.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,14 @@ namespace UtilLib
|
||||
public void ResetMarkStyle()
|
||||
{
|
||||
if (mark == null) return;
|
||||
mark.Range.Font.Size = originSize; // 还原
|
||||
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone;
|
||||
mark.Range.Shading.BackgroundPatternColor = Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic;
|
||||
if (mark.Range == null) return;
|
||||
try
|
||||
{
|
||||
mark.Range.Font.Size = originSize; // 还原
|
||||
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone;
|
||||
mark.Range.Shading.BackgroundPatternColor = Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic;
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
public void Process(int status)
|
||||
|
@ -19,6 +19,11 @@ namespace AIProofread
|
||||
//btnLogout.Label = "退出\n登录";
|
||||
|
||||
Globals.ThisAddIn.ribbon = this;
|
||||
ShowDebug();
|
||||
}
|
||||
|
||||
public void ShowDebug()
|
||||
{
|
||||
if (Config.RUN_IN_DEBUG)
|
||||
{
|
||||
grpDebug.Visible = true;
|
||||
@ -118,7 +123,8 @@ namespace AIProofread
|
||||
|
||||
private void btnClear_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
DocumentUtil.ClearProofreadMarks();
|
||||
//DocumentUtil.ClearProofreadMarks();
|
||||
Bridge.bridge.clearAllProofreadMark();
|
||||
Globals.ThisAddIn.SendMessageToWeb("clear-tips", null);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ using System.Threading;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
@ -50,8 +51,12 @@ namespace AIProofread
|
||||
|
||||
private void Application_WindowDeactivate(Word.Document doc, Window Wn)
|
||||
{
|
||||
Logger.Log("Application_WindowDeactivate -- " + doc.FullName + " visible:" + currentDocumentTaskPane.Visible);
|
||||
Logger.Log("Application_WindowDeactivate -- " + doc.FullName + " visible:");
|
||||
//HidePanel(Doc);
|
||||
// 处理wps直接资源管理器新开文档面板闪烁问题
|
||||
//if (IsWPS) {
|
||||
// this.currentDocumentTaskPane.Visible = false;
|
||||
//}
|
||||
}
|
||||
|
||||
private void Application_WindowActivate(Word.Document activeDoc, Window Wn)
|
||||
@ -122,6 +127,8 @@ namespace AIProofread
|
||||
}
|
||||
if (taskPanels.ContainsKey(doc))
|
||||
{
|
||||
var control = (ProofreadMainControl)taskPanels[doc].Control;
|
||||
control.ResetWeb();
|
||||
taskPanels[doc].Visible = false;
|
||||
taskPanels[doc].Dispose();
|
||||
taskPanels.Remove(doc);
|
||||
@ -227,10 +234,37 @@ namespace AIProofread
|
||||
// }
|
||||
//}
|
||||
|
||||
private void InitAppByConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(Config.CONFIG_FILE))
|
||||
{
|
||||
string content = File.ReadAllText(Config.CONFIG_FILE);
|
||||
Logger.Log("Found app.json " + content);
|
||||
if (content == null || content.Length == 0) return;
|
||||
AppConfig config = JsonConvert.DeserializeObject<AppConfig>(content);
|
||||
if (config.AppUrl?.Length > 0)
|
||||
{
|
||||
Config.WEB_PATH = config.AppUrl;
|
||||
}
|
||||
if (config.AppRunInDebug)
|
||||
{
|
||||
Config.RUN_IN_DEBUG = config.AppRunInDebug;
|
||||
if(this.ribbon != null)
|
||||
{
|
||||
this.ribbon.ShowDebug();
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception) { }
|
||||
}
|
||||
|
||||
private void ThisAddIn_Startup(object sender, System.EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitAppByConfig();
|
||||
FmainThreadContext = SynchronizationContext.Current;
|
||||
// 启动地址
|
||||
applicationStartupPath = System.Windows.Forms.Application.StartupPath;
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
9
util-lib/AppConfig.cs
Normal file
9
util-lib/AppConfig.cs
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
namespace UtilLib
|
||||
{
|
||||
public class AppConfig
|
||||
{
|
||||
public string AppUrl { get; set; }
|
||||
public bool AppRunInDebug { get; set; }
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AcceptEnum.cs" />
|
||||
<Compile Include="AppConfig.cs" />
|
||||
<Compile Include="Colors.cs" />
|
||||
<Compile Include="CorrectedContent.cs" />
|
||||
<Compile Include="DocumentCorrectItem.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user