Compare commits
2 Commits
200f415ac6
...
cf148e9000
Author | SHA1 | Date | |
---|---|---|---|
cf148e9000 | |||
e52fd188b6 |
Binary file not shown.
@ -329,7 +329,7 @@ namespace AIProofread
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="documentId"></param>
|
/// <param name="documentId"></param>
|
||||||
/// <param name="callback"></param>
|
/// <param name="callback"></param>
|
||||||
public void CheckInTrackRevisions(string message,int documentId, string callbackId)
|
public void CheckInTrackRevisions(string message, int documentId, string callbackId)
|
||||||
{
|
{
|
||||||
var doc = documentId > 0 ? Globals.ThisAddIn.GetDocumentById(documentId) : Globals.ThisAddIn.ActiveDocument;
|
var doc = documentId > 0 ? Globals.ThisAddIn.GetDocumentById(documentId) : Globals.ThisAddIn.ActiveDocument;
|
||||||
|
|
||||||
@ -789,17 +789,45 @@ namespace AIProofread
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 保存文件
|
// 保存文件
|
||||||
public string WriteText(string content, string path)
|
public void WriteText(string content, string filename, string callbackId)
|
||||||
{
|
{
|
||||||
|
Globals.ThisAddIn.ActiveDocument.RunInMainThread(() =>
|
||||||
|
{
|
||||||
|
var json = JSONObject.Create();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File.WriteAllText(path, content);
|
string currentName = Globals.ThisAddIn.Application.ActiveDocument.Name;
|
||||||
return BridgeResult.Success("ok");
|
// 去掉文件名后缀
|
||||||
|
currentName = currentName.Substring(0, currentName.LastIndexOf("."));
|
||||||
|
SaveFileDialog sfd = new SaveFileDialog
|
||||||
|
{
|
||||||
|
// 设置默认文件名
|
||||||
|
FileName = filename,
|
||||||
|
Filter = "文本文件|*.txt"
|
||||||
|
};
|
||||||
|
|
||||||
|
var result = sfd.ShowDialog();
|
||||||
|
// 如果用户取消选择,则返回
|
||||||
|
if (result != DialogResult.Cancel)
|
||||||
|
{
|
||||||
|
if (File.Exists(sfd.FileName))
|
||||||
|
{
|
||||||
|
File.Delete(sfd.FileName);
|
||||||
|
}
|
||||||
|
File.WriteAllText(sfd.FileName, content);
|
||||||
|
json.Put("status", "success");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
return BridgeResult.Error(-1, ex.Message);
|
json.Put("status", "error").Put("message", ex.Message);
|
||||||
}
|
}
|
||||||
|
Globals.ThisAddIn.GlobalCallback(
|
||||||
|
callbackId,
|
||||||
|
json.ToString()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
4
AIProofread/Controls/FormLogin.Designer.cs
generated
4
AIProofread/Controls/FormLogin.Designer.cs
generated
@ -41,7 +41,7 @@
|
|||||||
this.web.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.web.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.web.Location = new System.Drawing.Point(0, 0);
|
this.web.Location = new System.Drawing.Point(0, 0);
|
||||||
this.web.Name = "web";
|
this.web.Name = "web";
|
||||||
this.web.Size = new System.Drawing.Size(650, 400);
|
this.web.Size = new System.Drawing.Size(650, 500);
|
||||||
this.web.TabIndex = 0;
|
this.web.TabIndex = 0;
|
||||||
this.web.ZoomFactor = 1D;
|
this.web.ZoomFactor = 1D;
|
||||||
//
|
//
|
||||||
@ -49,7 +49,7 @@
|
|||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(650, 400);
|
this.ClientSize = new System.Drawing.Size(650, 500);
|
||||||
this.Controls.Add(this.web);
|
this.Controls.Add(this.web);
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
this.Name = "FormLogin";
|
this.Name = "FormLogin";
|
||||||
|
@ -14,6 +14,19 @@ namespace AIProofread.Controls
|
|||||||
public FormLogin()
|
public FormLogin()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.FormClosed += (s, e) =>
|
||||||
|
{
|
||||||
|
// 关闭时释放资源
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (web != null)
|
||||||
|
{
|
||||||
|
web.Dispose();
|
||||||
|
web = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { };
|
||||||
|
};
|
||||||
//Bridge.InitWebEnvAsync("login", web);
|
//Bridge.InitWebEnvAsync("login", web);
|
||||||
//Bridge.AddEventHandler(BridgeEvent.LoginSuccess, OnLoginSuccess);
|
//Bridge.AddEventHandler(BridgeEvent.LoginSuccess, OnLoginSuccess);
|
||||||
}
|
}
|
||||||
@ -21,6 +34,19 @@ namespace AIProofread.Controls
|
|||||||
{
|
{
|
||||||
this.action = action;
|
this.action = action;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.FormClosed += (s, e) =>
|
||||||
|
{
|
||||||
|
// 关闭时释放资源
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (web != null)
|
||||||
|
{
|
||||||
|
web.Dispose();
|
||||||
|
web = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnLoginSuccess(object sender, EventArgs e)
|
private void OnLoginSuccess(object sender, EventArgs e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user