1.优化面板尺寸监听;
2.校对标签颜色; 3.添加文档id存储避免网页刷新;
This commit is contained in:
parent
a5ed094f2d
commit
b4c4af198f
Binary file not shown.
@ -8,18 +8,9 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.InteropServices.ComTypes;
|
||||
using System.Runtime.Remoting.Contexts;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using UtilLib;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Header;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.TaskbarClock;
|
||||
using Document = Microsoft.Office.Interop.Word.Document;
|
||||
|
||||
namespace AIProofread
|
||||
@ -84,6 +75,20 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCurrentDocumentId(int id)
|
||||
{
|
||||
var doc = Globals.ThisAddIn.Application.ActiveDocument;
|
||||
Globals.ThisAddIn.documentIdDics[doc] = id;
|
||||
}
|
||||
|
||||
|
||||
public int GetCurrentDocumentId()
|
||||
{
|
||||
var doc = Globals.ThisAddIn.Application.ActiveDocument;
|
||||
var dics = Globals.ThisAddIn.documentIdDics;
|
||||
return dics.ContainsKey(doc) ? dics[doc] : 0;
|
||||
}
|
||||
|
||||
// 打开网页
|
||||
public void OpenUrlWithOsBrowser(string url)
|
||||
{
|
||||
@ -149,8 +154,11 @@ namespace AIProofread
|
||||
{
|
||||
Dictionary<string, object> data = new Dictionary<string, object>();
|
||||
var name = Globals.ThisAddIn.Application.ActiveDocument.Name;
|
||||
var doc = Globals.ThisAddIn.Application.ActiveDocument;
|
||||
data.Add("name", name);
|
||||
data.Add("fullName", Globals.ThisAddIn.Application.ActiveDocument.FullName);
|
||||
data.Add("fullName", doc.FullName);
|
||||
data.Add("wordsCount", doc.Words.Count);
|
||||
data.Add("charactersCount", doc.Characters.Count);
|
||||
data.Add("content", Tools.GetAllText());
|
||||
return Tools.GetJSONString(data);
|
||||
}
|
||||
@ -243,7 +251,8 @@ namespace AIProofread
|
||||
{
|
||||
// 清空marks
|
||||
marks.Clear();
|
||||
}catch (Exception) { }
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
public void removeBookmark(string markId)
|
||||
@ -376,6 +385,7 @@ namespace AIProofread
|
||||
|
||||
public void SelectMarkById(int proofreadId)
|
||||
{
|
||||
|
||||
// 设置当前文档数据
|
||||
Globals.ThisAddIn.ActiveCurrentDocumentMarks();
|
||||
|
||||
@ -434,6 +444,8 @@ namespace AIProofread
|
||||
}
|
||||
|
||||
public void InitContent(string content)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<DocumentCorrectItem> list = JsonConvert.DeserializeObject<List<DocumentCorrectItem>>(content);
|
||||
// 先清除所有数据
|
||||
@ -480,6 +492,10 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception ex)
|
||||
{
|
||||
Logger.Log("Initial Content error:" + ex.Message + "\n" + ex.StackTrace + "\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -520,7 +536,8 @@ namespace AIProofread
|
||||
try
|
||||
{
|
||||
controls.Remove(markName);
|
||||
}catch (Exception) { }
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
Range findRange = null;
|
||||
if (paragraphIndex > document.Paragraphs.Count) return null;
|
||||
|
@ -6,7 +6,7 @@ namespace AIProofread
|
||||
public class Config
|
||||
{
|
||||
public static readonly string APP_NAME = "AI校对王";
|
||||
public static readonly string APP_VERSION = "1.0.4";
|
||||
public static readonly string APP_VERSION = "1.0.7";
|
||||
public static bool IS_WPS = false;
|
||||
|
||||
public static readonly string CONFIG_FILE = AppDomain.CurrentDomain.BaseDirectory + "app.json";
|
||||
|
3
AIProofread/Controls/FormContact.Designer.cs
generated
3
AIProofread/Controls/FormContact.Designer.cs
generated
@ -51,8 +51,9 @@
|
||||
this.ClientSize = new System.Drawing.Size(400, 310);
|
||||
this.Controls.Add(this.WebViewContact);
|
||||
this.Name = "FormContact";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "FormContact";
|
||||
this.Text = "联系客服";
|
||||
this.Load += new System.EventHandler(this.FormContact_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.WebViewContact)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
1
AIProofread/Controls/FormLogin.Designer.cs
generated
1
AIProofread/Controls/FormLogin.Designer.cs
generated
@ -53,6 +53,7 @@
|
||||
this.Controls.Add(this.web);
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Name = "FormLogin";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "登录";
|
||||
this.Load += new System.EventHandler(this.FormLogin_Load);
|
||||
|
2
AIProofread/Controls/FormSetting.Designer.cs
generated
2
AIProofread/Controls/FormSetting.Designer.cs
generated
@ -55,7 +55,7 @@
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormSetting";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "FormSetting";
|
||||
this.Text = "插件设置";
|
||||
this.Load += new System.EventHandler(this.FormSetting_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.WebViewSetting)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
@ -9,12 +9,17 @@ namespace AIProofread.Controls
|
||||
{
|
||||
private Document doc;
|
||||
private int minWidth;
|
||||
|
||||
|
||||
public ProofreadMainControl(Document doc,int minWidth)
|
||||
{
|
||||
InitializeComponent();
|
||||
this.doc = doc;
|
||||
this.minWidth = minWidth;
|
||||
Bridge.InitWebEnvAsync("main", web);
|
||||
|
||||
//this.minWidth = 420 * LabelWidth() / 42;
|
||||
//this.MinimumSize = new System.Drawing.Size(this.minWidth, 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,6 +13,8 @@ namespace UtilLib
|
||||
public Bookmark mark;
|
||||
public CorrectedContent content;
|
||||
private float originSize;
|
||||
private WdColor originColor;
|
||||
private WdColor originBackgroundColor;
|
||||
public string Name { get; set; }
|
||||
public ProofreadItem(CorrectedContent content)
|
||||
{
|
||||
@ -34,6 +36,8 @@ namespace UtilLib
|
||||
this.mark = bookmark;
|
||||
// 记录目前字体
|
||||
originSize = bookmark.Range.Font.Size;
|
||||
originBackgroundColor = bookmark.Shading.BackgroundPatternColor;
|
||||
originColor = bookmark.Shading.ForegroundPatternColor;
|
||||
mark.Selected += OnMarkSelected;
|
||||
}
|
||||
SetMarkName();
|
||||
@ -49,11 +53,8 @@ namespace UtilLib
|
||||
{
|
||||
// 记录目前字体
|
||||
originSize = mark.Range.Font.Size;
|
||||
// 设置下划线
|
||||
mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
||||
// 设置名称
|
||||
mark.Name = Config.BuildBookmarkName(content.id);
|
||||
//mark.SelectionChange += OnMarkSelectionChange;
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +82,7 @@ namespace UtilLib
|
||||
{
|
||||
if (mark == null) return;
|
||||
mark.Range.Font.Size = originSize; // 还原
|
||||
mark.Shading.ForegroundPatternColor = originColor;
|
||||
}
|
||||
|
||||
private void SetMarkStyle()
|
||||
@ -98,7 +100,9 @@ namespace UtilLib
|
||||
{
|
||||
mark.Range.Font.Size = originSize; // 还原
|
||||
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone;
|
||||
mark.Range.Shading.BackgroundPatternColor = Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic;
|
||||
//originBackgroundColor = bookmark.Shading.BackgroundPatternColor;
|
||||
mark.Shading.ForegroundPatternColor = originColor;
|
||||
mark.Range.Shading.BackgroundPatternColor = originColor;// Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic;
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ namespace AIProofread
|
||||
|
||||
public Dictionary<Word.Document, CustomTaskPane> taskPanels = new Dictionary<Word.Document, CustomTaskPane>();
|
||||
public Dictionary<Word.Document, bool> panelsVisibleStatus = new Dictionary<Word.Document, bool>();
|
||||
public Dictionary<Word.Document, int> documentIdDics = new Dictionary<Word.Document, int>();
|
||||
public CustomTaskPane currentDocumentTaskPane;
|
||||
|
||||
private static readonly Dictionary<Word.Document, Dictionary<int, ProofreadItem>> allMarks = new Dictionary<Word.Document, Dictionary<int, ProofreadItem>>();
|
||||
@ -181,21 +182,16 @@ namespace AIProofread
|
||||
this.currentDocumentTaskPane = panel;
|
||||
taskPanels.Add(doc, panel);
|
||||
panel.Visible = false;
|
||||
panel.VisibleChanged += Panel_VisibleChanged;
|
||||
// 设置宽度
|
||||
control.Width = MinWidth;
|
||||
panel.Width = MinWidth;
|
||||
// 监听尺寸变化 防止最小尺寸小于设置值
|
||||
control.SizeChanged += Control_SizeChanged;
|
||||
//new CustomTaskPaneHandler(control, MinWidth);
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void Panel_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (currentDocumentTaskPane == sender)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// word创建面板
|
||||
@ -205,12 +201,20 @@ namespace AIProofread
|
||||
return ShowPanel(doc, !IsWPS);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加变量控制重复调用
|
||||
/// </summary>
|
||||
private bool isResizing = false;
|
||||
private void Control_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (currentDocumentTaskPane != null && currentDocumentTaskPane.Width < MinWidth)
|
||||
if (isResizing) return;
|
||||
if (currentDocumentTaskPane != null && currentDocumentTaskPane.Visible && currentDocumentTaskPane.Width < MinWidth)
|
||||
{
|
||||
isResizing = true;
|
||||
SendKeys.Send("{ESC}");
|
||||
currentDocumentTaskPane.Width = MinWidth;
|
||||
isResizing = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,7 +261,8 @@ namespace AIProofread
|
||||
}
|
||||
}
|
||||
}
|
||||
}catch (Exception) { }
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
private void ThisAddIn_Startup(object sender, System.EventArgs e)
|
||||
|
Binary file not shown.
@ -1 +1 @@
|
||||
c42860264b8acb7028e263a703e52b2dc93d902c0171fb7e18b49cb7e7de737a
|
||||
45c1006d89b86a8263132b8f944b694a4253831b72578a761854fd2065ca7135
|
||||
|
@ -49,6 +49,6 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Ribbon1.resources
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.GenerateResource.cache
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.CoreCompileInputs.cache
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.CopyComplete
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.dll
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.pdb
|
||||
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofr.8811D769.Up2Date
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user