保存缓存时 自动保存文档

This commit is contained in:
LittleBoy 2024-11-11 17:45:40 +08:00
parent 8ceaf028d8
commit 70c0654a41
9 changed files with 35 additions and 15 deletions

Binary file not shown.

View File

@ -650,6 +650,11 @@ namespace AIProofread
return BridgeResult.Error(1, "请先保存文档"); return BridgeResult.Error(1, "请先保存文档");
} }
} }
else
{
// 静默时 自动保存文档
Globals.ThisAddIn.ActiveDocument.Save();
}
try try
{ {
File.WriteAllText(Globals.ThisAddIn.ActiveDocument.ProofreadCachePath, cache); File.WriteAllText(Globals.ThisAddIn.ActiveDocument.ProofreadCachePath, cache);

View File

@ -98,14 +98,24 @@ namespace AIProofread.Model
} }
} }
public void ShowDialog(string message,string confirmText, string confirmAction) public void ShowDialog(string message, string confirmText, string confirmAction)
{
TaskPane.Control.BeginInvoke(new Action(() =>
{ {
TaskPane.Control.BeginInvoke(new Action(() => {
//MessageBox.Show(message, "提示"); //MessageBox.Show(message, "提示");
FormMessage.ShowMessage(message, confirmText, confirmAction); FormMessage.ShowMessage(message, confirmText, confirmAction);
})); }));
} }
public void ShowLogin(string action)
{
TaskPane.Control.BeginInvoke(new Action(() =>
{
FormLogin frm = new FormLogin(action);
frm.ShowDialog();
}));
}
/// <summary> /// <summary>
/// 隐藏面板 /// 隐藏面板
/// </summary> /// </summary>
@ -550,7 +560,7 @@ namespace AIProofread.Model
if (item.Tag != "i") index++; if (item.Tag != "i") index++;
if (mark != null) if (mark != null)
{ {
marks.Add(item.Id, new ProofreadItem(item,correct.Insert, mark, Id)); marks.Add(item.Id, new ProofreadItem(item, correct.Insert, mark, Id));
try try
{ {
if (item.Tag == "i") if (item.Tag == "i")
@ -572,9 +582,10 @@ namespace AIProofread.Model
// //item.Value.mark.Shading.BackgroundPatternColor = WdColor.wdColorLightOrange; // //item.Value.mark.Shading.BackgroundPatternColor = WdColor.wdColorLightOrange;
//} //}
} }
}catch(Exception e) }
catch (Exception e)
{ {
Logger.Log(string.Format("mark color error {0}",e.Message)); Logger.Log(string.Format("mark color error {0}", e.Message));
} }
} }
else else
@ -712,15 +723,20 @@ namespace AIProofread.Model
{ {
return true; return true;
} }
if(!hasProofreaded && !CurrentDocument.Saved) // 没有校对前需要提示保存 if (!hasProofreaded && !CurrentDocument.Saved) // 没有校对前需要提示保存
{ {
return false; return false;
} }
if(hasProofreaded && hasProcessMark && !CurrentDocument.Saved) if (hasProofreaded && hasProcessMark && !CurrentDocument.Saved)
{ {
return false; return false;
} }
return true; return true;
} }
internal void Save()
{
CurrentDocument.Save();
}
} }
} }

View File

@ -359,12 +359,11 @@ namespace AIProofread
/// <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());
} //}
FormLogin frm = new FormLogin(action); //LoginFormList.Add(frm);
LoginFormList.Add(frm); ActiveDocument?.ShowLogin(action);
frm.Show();
} }
/// <summary> /// <summary>