fixed 优化多文档窗口显示;优化工具栏显示
This commit is contained in:
parent
cce4e0fb1d
commit
98885c3aef
Binary file not shown.
@ -326,7 +326,7 @@
|
||||
<FlavorProperties GUID="{BAA0C2D2-18E2-41B9-852F-F413020CAA33}">
|
||||
<ProjectProperties HostName="Word" HostPackage="{29A7B9D7-A7F1-4328-8EF0-6B2D1A56B2C1}" OfficeVersion="15.0" VstxVersion="4.0" ApplicationType="Word" Language="cs" TemplatesPath="" DebugInfoExeName="#Software\Microsoft\Office\16.0\Word\InstallRoot\Path#WINWORD.EXE" DebugInfoCommandLine="/x" AddItemTemplatesGuid="{51063C3A-E220-4D12-8922-BDA915ACD783}" />
|
||||
<Host Name="Word" GeneratedCodeNamespace="AIProofread" PublishedHash="69C324AB27932AA2FBF2B7EA72250886FF164DE6" IconIndex="0">
|
||||
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" PublishedHash="357D2DF929A084E03FE7F47F128956530D7A31AC" />
|
||||
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" PublishedHash="357D2DF929A084E03FE7F47F128956530D7A31AC" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
|
||||
</Host>
|
||||
</FlavorProperties>
|
||||
</VisualStudio>
|
||||
|
@ -6,4 +6,8 @@
|
||||
<InstallUrlHistory />
|
||||
<SupportUrlHistory />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<StartAction>Program</StartAction>
|
||||
<StartProgram>C:\Soft\Kingsoft\WPS Office\12.1.0.16412\office6\wps.exe</StartProgram>
|
||||
</PropertyGroup>
|
||||
</Project>
|
@ -12,8 +12,10 @@ 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;
|
||||
@ -95,12 +97,21 @@ namespace AIProofread
|
||||
Globals.ThisAddIn.SendMessageToWeb("start", "login");
|
||||
}
|
||||
|
||||
public void ShowCurrentPane()
|
||||
{
|
||||
Globals.ThisAddIn.currentDocumentTaskPane.Visible = true;
|
||||
}
|
||||
public void HideCurrentPane()
|
||||
{
|
||||
Globals.ThisAddIn.currentDocumentTaskPane.Visible = false;
|
||||
}
|
||||
|
||||
public void Logout(string action)
|
||||
{
|
||||
if (action == "async-info")
|
||||
{
|
||||
// web同步注销到ribbon
|
||||
Globals.ThisAddIn.ribbon.ProcessLogout();
|
||||
Globals.ThisAddIn.SyncLogout();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -198,10 +209,23 @@ namespace AIProofread
|
||||
|
||||
// 清除所有标记
|
||||
public void clearAllProofreadMark()
|
||||
{
|
||||
try
|
||||
{
|
||||
selectProofreadId = -1;
|
||||
foreach (var item in marks.Values)
|
||||
{
|
||||
if (item.mark != null && item.content.tag == "i" && item.content.isAccept == AcceptStatus.Default)
|
||||
{
|
||||
item.mark.Text = "";
|
||||
}
|
||||
}
|
||||
marks.Clear();
|
||||
DocumentUtil.ClearProofreadMarks();
|
||||
}catch (Exception ex)
|
||||
{
|
||||
Logger.Log("ClearAllProofreadMark",ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeBookmark(string markId)
|
||||
@ -320,6 +344,11 @@ namespace AIProofread
|
||||
{
|
||||
Globals.ThisAddIn.ShowLoginForm(action);
|
||||
}
|
||||
public void ShowSettingForm()
|
||||
{
|
||||
FormSetting frm = new FormSetting();
|
||||
frm.Show();
|
||||
}
|
||||
|
||||
public void MoveCursor(int pos)
|
||||
{
|
||||
@ -355,9 +384,12 @@ namespace AIProofread
|
||||
marks.Remove(selectProofreadId);
|
||||
return;
|
||||
}
|
||||
Globals.ThisAddIn.SendMessageToWeb("select", proofreadId);
|
||||
//object lineNum = (int)mark.Range.Information[WdInformation.wdFirstCharacterLineNumber] - 1;
|
||||
//object goToLine = WdGoToItem.wdGoToLine;
|
||||
//object goNext = WdGoToDirection.wdGoToNext;
|
||||
//Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref goToLine, ref goNext, ref lineNum);
|
||||
//
|
||||
object bookmark = (int)Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
|
||||
object bookmark = WdGoToItem.wdGoToBookmark;
|
||||
object bookmarkName = mark.Name;
|
||||
//doc.GoTo(mark);
|
||||
//mark.Range.GoTo();
|
||||
@ -366,7 +398,8 @@ namespace AIProofread
|
||||
//mark.DisableCharacterSpaceGrid = false;
|
||||
// 先滚动到可视区域
|
||||
//doc.ActiveWindow.ScrollIntoView(mark.Range);
|
||||
// marks[proofreadId].Select();
|
||||
marks[proofreadId].Select();
|
||||
Globals.ThisAddIn.SendMessageToWeb("select", proofreadId);
|
||||
}
|
||||
Globals.ThisAddIn.SendMessageToWeb("select_proofread", proofreadId);
|
||||
}
|
||||
@ -382,7 +415,8 @@ namespace AIProofread
|
||||
public void InitContent(string content)
|
||||
{
|
||||
List<DocumentCorrectItem> list = JsonConvert.DeserializeObject<List<DocumentCorrectItem>>(content);
|
||||
|
||||
// 先清除所有数据
|
||||
clearAllProofreadMark();
|
||||
//var app = Globals.ThisAddIn.Application;
|
||||
//var cur = app.Selection;
|
||||
//
|
||||
@ -402,11 +436,28 @@ namespace AIProofread
|
||||
{
|
||||
var mark = AddBookmark(item, index, correct.Offset, correct.Insert_len);
|
||||
if (item.tag != "i") index++;
|
||||
if (mark != null) {
|
||||
marks.Add(item.id, new ProofreadItem(item, mark));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var item in marks)
|
||||
{
|
||||
if(item.Value.mark != null)
|
||||
{
|
||||
if (item.Value.content.tag == "i")
|
||||
{
|
||||
item.Value.mark.Text = ToolUtil.GetBlankText(item.Value.content.text.Length);
|
||||
}
|
||||
if (item.Value.content.color != null)
|
||||
{
|
||||
// 给选区添加背景颜色
|
||||
item.Value.mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.Value.content.color));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Microsoft.Office.Tools.Word.Bookmark AddBookmark(CorrectedContent item, int findIndex, int offset, int length)
|
||||
@ -437,11 +488,7 @@ namespace AIProofread
|
||||
{
|
||||
bookmark = controls.AddBookmark(r, markName);
|
||||
bookmark.Tag = "ai_proofread";
|
||||
if (item.color != null)
|
||||
{
|
||||
// 给选区添加背景颜色
|
||||
r.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.color));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -453,11 +500,6 @@ namespace AIProofread
|
||||
r = document.Range(offset + index, offset + index + item.origin.Length);
|
||||
bookmark = controls.AddBookmark(r, markName);
|
||||
bookmark.Tag = "ai_proofread";
|
||||
if (item.color != null)
|
||||
{
|
||||
// 给选区添加背景颜色
|
||||
r.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(item.color));
|
||||
}
|
||||
break;
|
||||
}
|
||||
startPos = index;
|
||||
|
@ -7,15 +7,20 @@ namespace AIProofread
|
||||
{
|
||||
public static readonly string APP_NAME = "AI校对王";
|
||||
public static readonly string APP_VERSION = "1.0.0";
|
||||
public static bool IS_WPS = false;
|
||||
#if DEBUG
|
||||
/// <summary>
|
||||
/// 网页访问地址
|
||||
/// </summary>
|
||||
public static readonly string WEB_PATH = "http://192.168.10.100:5173/";
|
||||
public static readonly bool RUN_IN_DEBUG = true;
|
||||
#else
|
||||
public static readonly string WEB_PATH = "https://gm-plugin.gachafun.com/";
|
||||
public static readonly bool RUN_IN_DEBUG = false;
|
||||
#endif
|
||||
public static readonly string WEB_DATA_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ai_proofread\\userdata";
|
||||
public static readonly string APP_DATA_PATH = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\ai_proofread";
|
||||
public static readonly string APP_LOG_PATH = APP_DATA_PATH + "\\logs\\";
|
||||
public static readonly string WEB_DATA_PATH = APP_DATA_PATH + "\\userdata";
|
||||
|
||||
/// <summary>
|
||||
/// 书签前缀
|
||||
|
3
AIProofread/Controls/FormSetting.Designer.cs
generated
3
AIProofread/Controls/FormSetting.Designer.cs
generated
@ -51,11 +51,10 @@
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(621, 450);
|
||||
this.Controls.Add(this.WebViewSetting);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormSetting";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "FormSetting";
|
||||
this.Load += new System.EventHandler(this.FormSetting_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.WebViewSetting)).EndInit();
|
||||
|
@ -9,26 +9,31 @@ namespace AIProofread
|
||||
{
|
||||
public class Logger
|
||||
{
|
||||
private static readonly string AppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
public static void Log(string msg)
|
||||
{
|
||||
string text = string.Concat(AppDomain.CurrentDomain.BaseDirectory + "\\logs", "\\");
|
||||
string path = text + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
if (!Directory.Exists(text))
|
||||
string path = Config.APP_LOG_PATH + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
if (!Directory.Exists(Config.APP_LOG_PATH))
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
Directory.CreateDirectory(Config.APP_LOG_PATH);
|
||||
}
|
||||
StreamWriter streamWriter = File.AppendText(path);
|
||||
streamWriter.WriteLine("消息:" + msg);
|
||||
streamWriter.WriteLine("时间:" + DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss: fff:ffffff"));
|
||||
streamWriter.WriteLine("**************************************************");
|
||||
streamWriter.WriteLine("时间:" + DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss"));
|
||||
streamWriter.WriteLine("***************************[" + (Config.IS_WPS?"WPS":"WORD")+ "]***************************");
|
||||
streamWriter.WriteLine();
|
||||
streamWriter.Flush();
|
||||
streamWriter.Close();
|
||||
streamWriter.Dispose();
|
||||
}
|
||||
|
||||
public static void Log(string tag, Exception e)
|
||||
{
|
||||
Log(tag + "\n" + e.StackTrace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace UtilLib
|
||||
public class ProofreadItem
|
||||
{
|
||||
public Bookmark mark;
|
||||
private CorrectedContent content;
|
||||
public CorrectedContent content;
|
||||
private float originSize;
|
||||
public string Name { get; set; }
|
||||
public ProofreadItem(CorrectedContent content)
|
||||
@ -34,6 +34,7 @@ namespace UtilLib
|
||||
this.mark = bookmark;
|
||||
// 记录目前字体
|
||||
originSize = bookmark.Range.Font.Size;
|
||||
mark.Selected += OnMarkSelected;
|
||||
}
|
||||
SetMarkName();
|
||||
//InitBookMark(bookmark);
|
||||
@ -52,7 +53,6 @@ namespace UtilLib
|
||||
mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
||||
// 设置名称
|
||||
mark.Name = Config.BuildBookmarkName(content.id);
|
||||
//mark.Selected += OnMarkSelected;
|
||||
//mark.SelectionChange += OnMarkSelectionChange;
|
||||
}
|
||||
}
|
||||
@ -61,25 +61,18 @@ namespace UtilLib
|
||||
{
|
||||
//throw new System.NotImplementedException();
|
||||
//mark.Range.Font.Size = originSize;
|
||||
Console.WriteLine("xxx");
|
||||
//Console.WriteLine("xxx");
|
||||
}
|
||||
|
||||
private void OnMarkSelected(object sender, Microsoft.Office.Tools.Word.SelectionEventArgs e)
|
||||
{
|
||||
//throw new System.NotImplementedException();
|
||||
mark.Range.Font.Size = originSize + 2; // 将选中标签文本放大字体
|
||||
Bridge.bridge.SelectMarkById(content.id);
|
||||
}
|
||||
|
||||
public void Select()
|
||||
{
|
||||
if (mark == null) return;
|
||||
if (content.tag == "i")
|
||||
{
|
||||
var endPos = mark.Range.End;
|
||||
var rng = Globals.ThisAddIn.Application.ActiveDocument.Range(endPos, endPos);
|
||||
rng.Select();
|
||||
return;
|
||||
}
|
||||
mark.Range.Font.Size = originSize + 2; // 将选中标签文本放大字体
|
||||
mark.Select();
|
||||
|
||||
@ -93,14 +86,14 @@ namespace UtilLib
|
||||
private void SetMarkStyle()
|
||||
{
|
||||
if (mark == null) return;
|
||||
mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
||||
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineThick;
|
||||
mark.Shading.BackgroundPatternColor = (WdColor)ColorTranslator.ToOle(Colors.FromHex(content.color));
|
||||
}
|
||||
|
||||
private void ResetMarkStyle()
|
||||
{
|
||||
if (mark == null) return;
|
||||
mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone;
|
||||
//mark.Range.Underline = Microsoft.Office.Interop.Word.WdUnderline.wdUnderlineNone;
|
||||
mark.Range.Shading.BackgroundPatternColor = Microsoft.Office.Interop.Word.WdColor.wdColorAutomatic;
|
||||
}
|
||||
|
||||
@ -125,6 +118,11 @@ namespace UtilLib
|
||||
else if (status == AcceptStatus.Review || status == AcceptStatus.Ignore)
|
||||
{
|
||||
ResetMarkStyle();
|
||||
// 新增添加了空格 所以当忽略时还原
|
||||
if (content.tag == "i")
|
||||
{
|
||||
mark.Text = "";
|
||||
}
|
||||
}
|
||||
else if (status == AcceptStatus.Default)
|
||||
{
|
||||
@ -134,7 +132,7 @@ namespace UtilLib
|
||||
}
|
||||
else if (content.tag == "i")
|
||||
{
|
||||
mark.Text = "";
|
||||
mark.Text = ToolUtil.GetBlankText(content.text.Length);
|
||||
}
|
||||
SetMarkStyle();
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Security;
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("AIProofread")]
|
||||
[assembly: AssemblyTitle("AI校对王")]
|
||||
[assembly: AssemblyDescription("AI校对王")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("果麦文化")]
|
||||
@ -33,6 +33,6 @@ using System.Security;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
||||
// 方法是按如下所示使用“*”: :
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
||||
|
||||
|
30
AIProofread/Ribbon1.Designer.cs
generated
30
AIProofread/Ribbon1.Designer.cs
generated
@ -48,13 +48,18 @@ namespace AIProofread
|
||||
this.btnLogout = this.Factory.CreateRibbonButton();
|
||||
this.LblNickname = this.Factory.CreateRibbonLabel();
|
||||
this.LblDate = this.Factory.CreateRibbonLabel();
|
||||
this.grpDebug = this.Factory.CreateRibbonGroup();
|
||||
this.btnShowPane = this.Factory.CreateRibbonButton();
|
||||
this.btnHidePane = this.Factory.CreateRibbonButton();
|
||||
this.tabAIProofread.SuspendLayout();
|
||||
this.group1.SuspendLayout();
|
||||
this.grpDebug.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tabAIProofread
|
||||
//
|
||||
this.tabAIProofread.Groups.Add(this.group1);
|
||||
this.tabAIProofread.Groups.Add(this.grpDebug);
|
||||
this.tabAIProofread.Label = "AI校对王";
|
||||
this.tabAIProofread.Name = "tabAIProofread";
|
||||
this.tabAIProofread.Position = this.Factory.RibbonPosition.AfterOfficeId("TabHelp");
|
||||
@ -158,6 +163,26 @@ namespace AIProofread
|
||||
this.LblDate.Name = "LblDate";
|
||||
this.LblDate.Visible = false;
|
||||
//
|
||||
// grpDebug
|
||||
//
|
||||
this.grpDebug.Items.Add(this.btnShowPane);
|
||||
this.grpDebug.Items.Add(this.btnHidePane);
|
||||
this.grpDebug.Label = "开发调试";
|
||||
this.grpDebug.Name = "grpDebug";
|
||||
this.grpDebug.Visible = false;
|
||||
//
|
||||
// btnShowPane
|
||||
//
|
||||
this.btnShowPane.Label = "显示面板";
|
||||
this.btnShowPane.Name = "btnShowPane";
|
||||
this.btnShowPane.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnShowPane_Click);
|
||||
//
|
||||
// btnHidePane
|
||||
//
|
||||
this.btnHidePane.Label = "隐藏面板";
|
||||
this.btnHidePane.Name = "btnHidePane";
|
||||
this.btnHidePane.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnHidePane_Click);
|
||||
//
|
||||
// Ribbon1
|
||||
//
|
||||
this.Name = "Ribbon1";
|
||||
@ -168,6 +193,8 @@ namespace AIProofread
|
||||
this.tabAIProofread.PerformLayout();
|
||||
this.group1.ResumeLayout(false);
|
||||
this.group1.PerformLayout();
|
||||
this.grpDebug.ResumeLayout(false);
|
||||
this.grpDebug.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -186,6 +213,9 @@ namespace AIProofread
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnSetting;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnGetContact;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnUpdate;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonGroup grpDebug;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnShowPane;
|
||||
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnHidePane;
|
||||
}
|
||||
|
||||
partial class ThisRibbonCollection
|
||||
|
@ -17,6 +17,10 @@ namespace AIProofread
|
||||
//btnLogout.Label = "退出\n登录";
|
||||
|
||||
Globals.ThisAddIn.ribbon = this;
|
||||
if(Config.RUN_IN_DEBUG)
|
||||
{
|
||||
grpDebug.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitWPS()
|
||||
@ -64,8 +68,8 @@ namespace AIProofread
|
||||
btnLogin.Visible = !IS_LOGIN;
|
||||
|
||||
btnLogout.Visible = IS_LOGIN;
|
||||
LblNickname.Visible = IS_LOGIN;
|
||||
LblDate.Visible = IS_LOGIN;
|
||||
//LblNickname.Visible = IS_LOGIN;
|
||||
//LblDate.Visible = IS_LOGIN;
|
||||
}
|
||||
|
||||
// 弹出登录窗口
|
||||
@ -89,8 +93,7 @@ namespace AIProofread
|
||||
|
||||
private void btnSetting_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
FormSetting frm = new FormSetting();
|
||||
frm.ShowDialog();
|
||||
Globals.ThisAddIn.SendMessageToWeb("show-setting", null);
|
||||
}
|
||||
|
||||
private void BtnGetContact_Click(object sender, RibbonControlEventArgs e)
|
||||
@ -115,5 +118,15 @@ namespace AIProofread
|
||||
DocumentUtil.ClearProofreadMarks();
|
||||
Globals.ThisAddIn.SendMessageToWeb("clear-tips", null);
|
||||
}
|
||||
|
||||
private void btnShowPane_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
Globals.ThisAddIn.ShowPanel();
|
||||
}
|
||||
|
||||
private void btnHidePane_Click(object sender, RibbonControlEventArgs e)
|
||||
{
|
||||
Globals.ThisAddIn.HidePanel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,13 +43,28 @@ namespace AIProofread
|
||||
public List<FormLogin> LoginFormList = new List<FormLogin>();
|
||||
|
||||
public Dictionary<Word.Document, CustomTaskPane> taskPanels = new Dictionary<Word.Document, CustomTaskPane>();
|
||||
private CustomTaskPane customTaskPane;
|
||||
public Dictionary<Word.Document,bool> panelsVisible = new Dictionary<Word.Document, bool>();
|
||||
public CustomTaskPane currentDocumentTaskPane;
|
||||
|
||||
|
||||
private void Application_WindowDeactivate(Word.Document Doc, Window Wn)
|
||||
private void Application_WindowDeactivate(Word.Document doc, Window Wn)
|
||||
{
|
||||
Logger.Log("Application_WindowDeactivate -- " + Doc.FullName);
|
||||
Logger.Log("Application_WindowDeactivate -- " + doc.FullName);
|
||||
//HidePanel(Doc);
|
||||
if (taskPanels.ContainsKey(doc))
|
||||
{
|
||||
var visible = taskPanels[doc].Visible;
|
||||
// 记录当前文档的显示状态
|
||||
if (!panelsVisible.ContainsKey(doc))
|
||||
{
|
||||
panelsVisible.Add(doc, visible);
|
||||
}
|
||||
else
|
||||
{
|
||||
panelsVisible[doc] = visible;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Application_WindowActivate(Word.Document Doc, Window Wn)
|
||||
@ -59,10 +74,18 @@ namespace AIProofread
|
||||
|
||||
if (!taskPanels.ContainsKey(Doc))
|
||||
{
|
||||
ShowPanel(Doc);
|
||||
ShowPanel(Doc,false);
|
||||
}
|
||||
this.currentDocumentTaskPane = taskPanels[Doc];
|
||||
if (IsWPS)
|
||||
{
|
||||
HideOtherPanel(Doc);
|
||||
}
|
||||
if (panelsVisible.ContainsKey(Doc) && panelsVisible[Doc])
|
||||
{
|
||||
taskPanels[Doc].Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Application_DocumentBeforeClose(Word.Document Doc, ref bool Cancel)
|
||||
{
|
||||
@ -99,7 +122,7 @@ namespace AIProofread
|
||||
}
|
||||
foreach (var key in taskPanels.Keys)
|
||||
{
|
||||
taskPanels[key].Visible = doc == key;
|
||||
taskPanels[key].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,23 +142,32 @@ namespace AIProofread
|
||||
|
||||
if (taskPanels.ContainsKey(doc))
|
||||
{
|
||||
taskPanels[doc].Visible = true;
|
||||
this.customTaskPane = taskPanels[doc];
|
||||
return taskPanels[doc];
|
||||
}
|
||||
|
||||
//proofreadPanel = new ProofreadMainControl();
|
||||
var control = new ProofreadMainControl(doc, MinWidth);
|
||||
var panel = Globals.ThisAddIn.CustomTaskPanes.Add(control, AddinName);
|
||||
this.customTaskPane = panel;
|
||||
this.currentDocumentTaskPane = panel;
|
||||
taskPanels.Add(doc, panel);
|
||||
control.Width = MinWidth;
|
||||
panel.Width = MinWidth;
|
||||
panel.Visible = show;
|
||||
panel.Visible = false;
|
||||
panel.VisibleChanged += Panel_VisibleChanged;
|
||||
|
||||
// 监听尺寸变化 防止最小尺寸小于设置值
|
||||
control.SizeChanged += Control_SizeChanged;
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void Panel_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if(currentDocumentTaskPane == sender)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// word创建面板
|
||||
/// </summary>
|
||||
@ -146,10 +178,10 @@ namespace AIProofread
|
||||
|
||||
private void Control_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (customTaskPane != null && customTaskPane.Width < MinWidth)
|
||||
if (currentDocumentTaskPane != null && currentDocumentTaskPane.Width < MinWidth)
|
||||
{
|
||||
SendKeys.Send("{ESC}");
|
||||
customTaskPane.Width = MinWidth;
|
||||
currentDocumentTaskPane.Width = MinWidth;
|
||||
}
|
||||
}
|
||||
|
||||
@ -178,6 +210,7 @@ namespace AIProofread
|
||||
if (applicationStartupPath.Contains("WPS"))
|
||||
{
|
||||
IsWPS = true;
|
||||
Config.IS_WPS = true;
|
||||
try
|
||||
{
|
||||
Globals.Ribbons.Ribbon1.InitWPS();
|
||||
@ -194,13 +227,19 @@ namespace AIProofread
|
||||
Application.WindowDeactivate += Application_WindowDeactivate;
|
||||
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
|
||||
// 选区发生变化事件
|
||||
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
|
||||
//this.Application.WindowSelectionChange += Application_WindowSelectionChange;
|
||||
|
||||
try
|
||||
{
|
||||
if (Application.ActiveDocument != null)
|
||||
{
|
||||
// 默认直接打开文档 就直接创建panel
|
||||
ShowPanel(Application.ActiveDocument, false);
|
||||
}
|
||||
}catch (Exception ex2)
|
||||
{
|
||||
Logger.Log("加载默认文档失败: " + ex2.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception ex1)
|
||||
{
|
||||
@ -241,8 +280,13 @@ namespace AIProofread
|
||||
{
|
||||
// 先显示panel
|
||||
var panel = this.ShowPanel(Application.ActiveDocument, true);
|
||||
SendMessageToWeb(panel.Control, msg, data);
|
||||
}
|
||||
|
||||
public void SendMessageToWeb(UserControl panelControl, string msg, object data)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(new WebMessage(msg, data));
|
||||
var control = (ProofreadMainControl)panel.Control;
|
||||
var control = (ProofreadMainControl)panelControl;
|
||||
try
|
||||
{
|
||||
if (control.web.CoreWebView2 == null)
|
||||
@ -260,13 +304,13 @@ namespace AIProofread
|
||||
// 显示面板
|
||||
public void ShowPanel()
|
||||
{
|
||||
this.customTaskPane.Visible = true;
|
||||
this.currentDocumentTaskPane.Visible = true;
|
||||
}
|
||||
|
||||
// 隐藏面板
|
||||
public void HidePanel()
|
||||
{
|
||||
this.customTaskPane.Visible = false;
|
||||
this.currentDocumentTaskPane.Visible = false;
|
||||
}
|
||||
|
||||
|
||||
@ -314,6 +358,22 @@ namespace AIProofread
|
||||
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
|
||||
}
|
||||
|
||||
public void SyncLogout()
|
||||
{
|
||||
ribbon.ProcessLogout();
|
||||
taskPanels.Values.ToList().ForEach(p =>
|
||||
{
|
||||
try
|
||||
{
|
||||
// 同步登录失败信息
|
||||
SendMessageToWeb(p.Control, "async-logout", null);
|
||||
}catch (Exception ex) {
|
||||
Logger.Log("async-logout:",ex);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -6,6 +6,8 @@ using UtilLib;
|
||||
using Microsoft.Office.Interop.Word;
|
||||
using Bookmark = Microsoft.Office.Tools.Word.Bookmark;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Office.Tools.Word;
|
||||
using System;
|
||||
|
||||
namespace AIProofread
|
||||
{
|
||||
@ -84,6 +86,7 @@ namespace AIProofread
|
||||
public static void ClearProofreadMarks()
|
||||
{
|
||||
var bookmarks = Globals.ThisAddIn.Application.ActiveDocument.Bookmarks;
|
||||
ControlCollection controls = Globals.Factory.GetVstoObject(Globals.ThisAddIn.Application.ActiveDocument).Controls;
|
||||
foreach (Microsoft.Office.Interop.Word.Bookmark mark in bookmarks)
|
||||
{
|
||||
if (Config.IsProofreadMark(mark.Name))
|
||||
@ -92,7 +95,17 @@ namespace AIProofread
|
||||
mark.Range.Shading.BackgroundPatternColor = WdColor.wdColorAutomatic;
|
||||
// 去除下划线
|
||||
mark.Range.Underline = WdUnderline.wdUnderlineNone;
|
||||
mark.Delete();
|
||||
//mark.Delete();
|
||||
}
|
||||
try
|
||||
{
|
||||
if (controls.Contains(mark))
|
||||
{
|
||||
controls.Remove(mark);
|
||||
}
|
||||
}catch(Exception e)
|
||||
{
|
||||
Logger.Log("remove mark",e);
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,16 +7,12 @@ namespace UtilLib
|
||||
{
|
||||
public static Color FromHex(string hex)
|
||||
{
|
||||
hex = hex.TrimStart('#');
|
||||
int hexValue = Convert.ToInt32(hex, 16);
|
||||
byte red = (byte)((hexValue >> 16) & 0xFF);
|
||||
byte green = (byte)((hexValue >> 8) & 0xFF);
|
||||
byte blue = (byte)(hexValue & 0xFF);
|
||||
return FromRGB(red, green, blue);
|
||||
if(!hex.StartsWith("#")) hex = "#" + hex;
|
||||
return ColorTranslator.FromHtml(hex);
|
||||
}
|
||||
public static Color FromRGB(byte red, byte green, byte blue)
|
||||
public static Color FromRGB(byte red, byte green, byte blue, int opacity)
|
||||
{
|
||||
return Color.FromArgb(red, green, blue);
|
||||
return Color.FromArgb(opacity,red, green, blue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("util-lib")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyTitle("AI校对王")]
|
||||
[assembly: AssemblyDescription("AI校对王")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("util-lib")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2024")]
|
||||
[assembly: AssemblyCompany("果麦文化")]
|
||||
[assembly: AssemblyProduct("AI校对王")]
|
||||
[assembly: AssemblyCopyright("Copyright © GuoMai 2024")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyVersion("1.0.0.1")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
||||
|
17
util-lib/ToolUtil.cs
Normal file
17
util-lib/ToolUtil.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System.Text;
|
||||
|
||||
namespace UtilLib
|
||||
{
|
||||
public class ToolUtil
|
||||
{
|
||||
public static string GetBlankText(int len)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
sb.Append(' ');
|
||||
}
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace UtilLib
|
||||
{
|
||||
public class UtilLib
|
||||
{
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@
|
||||
<Compile Include="ProofreadType.cs" />
|
||||
<Compile Include="UpgradeData.cs" />
|
||||
<Compile Include="Userinfo.cs" />
|
||||
<Compile Include="UtilLib.cs" />
|
||||
<Compile Include="ToolUtil.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="WebMessage.cs" />
|
||||
</ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user