保存缓存时 自动保存文档

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, "请先保存文档");
}
}
else
{
// 静默时 自动保存文档
Globals.ThisAddIn.ActiveDocument.Save();
}
try
{
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, "提示");
FormMessage.ShowMessage(message, confirmText, confirmAction);
}));
}
public void ShowLogin(string action)
{
TaskPane.Control.BeginInvoke(new Action(() =>
{
FormLogin frm = new FormLogin(action);
frm.ShowDialog();
}));
}
/// <summary>
/// 隐藏面板
/// </summary>
@ -550,7 +560,7 @@ namespace AIProofread.Model
if (item.Tag != "i") index++;
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
{
if (item.Tag == "i")
@ -572,9 +582,10 @@ namespace AIProofread.Model
// //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
@ -703,7 +714,7 @@ namespace AIProofread.Model
{
hasProcessMark = true;
marks[proofreadId].Process(status);
}
}
}
internal bool Saved()
@ -712,15 +723,20 @@ namespace AIProofread.Model
{
return true;
}
if(!hasProofreaded && !CurrentDocument.Saved) // 没有校对前需要提示保存
if (!hasProofreaded && !CurrentDocument.Saved) // 没有校对前需要提示保存
{
return false;
}
if(hasProofreaded && hasProcessMark && !CurrentDocument.Saved)
if (hasProofreaded && hasProcessMark && !CurrentDocument.Saved)
{
return false;
}
return true;
}
internal void Save()
{
CurrentDocument.Save();
}
}
}

View File

@ -357,14 +357,13 @@ namespace AIProofread
/// 显示登录窗口
/// </summary>
/// <param name="action"></param>
public void ShowLoginForm(string action) {
public void ShowLoginForm(string action) {
// 关闭之前的窗口
if(LoginFormList.Count > 0){
LoginFormList.ForEach(f => f.Close());
}
FormLogin frm = new FormLogin(action);
LoginFormList.Add(frm);
frm.Show();
//if(LoginFormList.Count > 0){
// LoginFormList.ForEach(f => f.Close());
//}
//LoginFormList.Add(frm);
ActiveDocument?.ShowLogin(action);
}
/// <summary>