fix: 修正扩展初始化时面板没有初始化的问题
This commit is contained in:
parent
fa62b66a02
commit
d061406026
Binary file not shown.
@ -110,14 +110,8 @@ namespace AIProofread.Model
|
|||||||
public DocumentInfo SetActiveDocument(Document originDocument)
|
public DocumentInfo SetActiveDocument(Document originDocument)
|
||||||
{
|
{
|
||||||
if (originDocument == null) return null;
|
if (originDocument == null) return null;
|
||||||
var document = Get(originDocument);
|
var document = InitDocument(originDocument);
|
||||||
|
|
||||||
// 如果不存在,则添加
|
|
||||||
if (document == null)
|
|
||||||
{
|
|
||||||
document = new DocumentInfo(originDocument);
|
|
||||||
Add(document);
|
|
||||||
}
|
|
||||||
if (ActiveDocument == document) return document;
|
if (ActiveDocument == document) return document;
|
||||||
else if (Globals.ThisAddIn.IsWPS)
|
else if (Globals.ThisAddIn.IsWPS)
|
||||||
{
|
{
|
||||||
@ -135,5 +129,18 @@ namespace AIProofread.Model
|
|||||||
{
|
{
|
||||||
documentList.ForEach(d => d.HidePane());
|
documentList.ForEach(d => d.HidePane());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DocumentInfo InitDocument(Document originDocument)
|
||||||
|
{
|
||||||
|
var document = Get(originDocument);
|
||||||
|
|
||||||
|
// 如果不存在,则添加
|
||||||
|
if (document == null)
|
||||||
|
{
|
||||||
|
document = new DocumentInfo(originDocument);
|
||||||
|
Add(document);
|
||||||
|
}
|
||||||
|
return document;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ namespace AIProofread
|
|||||||
//formCommonsenseDetection.ShowInTaskbar = false;
|
//formCommonsenseDetection.ShowInTaskbar = false;
|
||||||
//formCommonsenseDetection.Show();
|
//formCommonsenseDetection.Show();
|
||||||
|
|
||||||
Logger.Debug("ThisAddIn_Startup Platform --> " + (IsWPS?"WPS":"WORD"));
|
Logger.Debug("ThisAddIn_Startup Platform --> " + (IsWPS ? "WPS" : "WORD"));
|
||||||
// 捕获全局异常
|
// 捕获全局异常
|
||||||
AppDomain.CurrentDomain.UnhandledException += ProcessApplicationException;
|
AppDomain.CurrentDomain.UnhandledException += ProcessApplicationException;
|
||||||
System.Windows.Forms.Application.ThreadException += ProcessApplicationFormException;
|
System.Windows.Forms.Application.ThreadException += ProcessApplicationFormException;
|
||||||
@ -121,7 +121,7 @@ namespace AIProofread
|
|||||||
Application.WindowActivate += Application_WindowActivate;
|
Application.WindowActivate += Application_WindowActivate;
|
||||||
//Application.WindowDeactivate += Application_WindowDeactivate;
|
//Application.WindowDeactivate += Application_WindowDeactivate;
|
||||||
Application.DocumentBeforeSave += Application_DocumentBeforeSave;
|
Application.DocumentBeforeSave += Application_DocumentBeforeSave;
|
||||||
|
|
||||||
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
|
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
|
||||||
Application.DocumentChange += Application_DocumentChange;
|
Application.DocumentChange += Application_DocumentChange;
|
||||||
// 选区发生变化事件
|
// 选区发生变化事件
|
||||||
@ -137,7 +137,7 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
catch (Exception ex1)
|
catch (Exception ex1)
|
||||||
{
|
{
|
||||||
Logger.Error("Startup Error",ex1);
|
Logger.Error("Startup Error", ex1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error("InitDeviceId Error:",ex);
|
Logger.Error("InitDeviceId Error:", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ namespace AIProofread
|
|||||||
// 可能出现另存问题 所以需要更新文件名称
|
// 可能出现另存问题 所以需要更新文件名称
|
||||||
var oldName = item.fileName;
|
var oldName = item.fileName;
|
||||||
var currentName = item.CurrentDocument.FullName;
|
var currentName = item.CurrentDocument.FullName;
|
||||||
if(oldName != currentName)
|
if (oldName != currentName)
|
||||||
{
|
{
|
||||||
item.fileName = currentName;
|
item.fileName = currentName;
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Debug(ex.Message,ex);
|
Logger.Debug(ex.Message, ex);
|
||||||
}
|
}
|
||||||
//await System.Threading.Tasks.Task.Run(() =>
|
//await System.Threading.Tasks.Task.Run(() =>
|
||||||
// {
|
// {
|
||||||
@ -244,7 +244,7 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error("检测升级信息异常: ",ex);
|
Logger.Error("检测升级信息异常: ", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -286,9 +286,25 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error("Init WPS Error ",ex);
|
Logger.Error("Init WPS Error ", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 默认已经打开了文档 直接初始化
|
||||||
|
if(CurrentWordApplication.Documents.Count > 0){
|
||||||
|
foreach (Document item in CurrentWordApplication.Documents)
|
||||||
|
{
|
||||||
|
var info = documentList.InitDocument(item);
|
||||||
|
// 直接初始化面板
|
||||||
|
info.CheckPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error("Initialize documentlist Error ", ex);
|
||||||
|
}
|
||||||
string verTextFile = Config.APP_BASE_DIR + Path.GetFileName("app_version.txt");
|
string verTextFile = Config.APP_BASE_DIR + Path.GetFileName("app_version.txt");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -345,7 +361,8 @@ namespace AIProofread
|
|||||||
ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument);
|
ActiveDocument = documentList.SetActiveDocument(CurrentWordApplication.ActiveDocument);
|
||||||
ActiveDocument.CheckBtnStatus();
|
ActiveDocument.CheckBtnStatus();
|
||||||
CheckDocumentClosed(null, null);
|
CheckDocumentClosed(null, null);
|
||||||
if (formCommonsenseDetection != null) {
|
if (formCommonsenseDetection != null)
|
||||||
|
{
|
||||||
formCommonsenseDetection.SendMessageToWeb("document-change", null);
|
formCommonsenseDetection.SendMessageToWeb("document-change", null);
|
||||||
}
|
}
|
||||||
//LogHelper.Log("Application_DocumentChange -- " + ActiveDocument.fileName + " track is " + ActiveDocument.CurrentDocument.TrackRevisions);
|
//LogHelper.Log("Application_DocumentChange -- " + ActiveDocument.fileName + " track is " + ActiveDocument.CurrentDocument.TrackRevisions);
|
||||||
@ -373,7 +390,7 @@ namespace AIProofread
|
|||||||
/// <param name="Wn"></param>
|
/// <param name="Wn"></param>
|
||||||
private void Application_WindowActivate(Document activeDoc, Window Wn)
|
private void Application_WindowActivate(Document activeDoc, Window Wn)
|
||||||
{
|
{
|
||||||
if(activeDoc != null && (ActiveDocument == null || activeDoc != ActiveDocument.CurrentDocument))
|
if (activeDoc != null && (ActiveDocument == null || activeDoc != ActiveDocument.CurrentDocument))
|
||||||
{
|
{
|
||||||
ActiveDocument = documentList.SetActiveDocument(activeDoc);
|
ActiveDocument = documentList.SetActiveDocument(activeDoc);
|
||||||
Logger.Info("Application_WindowActivate -- " + ActiveDocument.fileName);
|
Logger.Info("Application_WindowActivate -- " + ActiveDocument.fileName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user