更新图标,优化多文档操作

This commit is contained in:
LittleBoy 2024-04-16 22:04:29 +08:00
parent 6241b74048
commit ab0bf64ff9
47 changed files with 302 additions and 221 deletions

Binary file not shown.

View File

@ -32,10 +32,10 @@
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<BootstrapperEnabled>true</BootstrapperEnabled>
<PublishUrl>publish\</PublishUrl>
<PublishUrl>C:\Users\yaclt\Desktop\jiaodui\</PublishUrl>
<InstallUrl />
<TargetCulture>zh-chs</TargetCulture>
<ApplicationVersion>1.0.0.0</ApplicationVersion>
<ApplicationVersion>1.0.0.1</ApplicationVersion>
<AutoIncrementApplicationRevision>true</AutoIncrementApplicationRevision>
<UpdateEnabled>true</UpdateEnabled>
<UpdateInterval>7</UpdateInterval>
@ -255,14 +255,9 @@
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<EmbeddedResource Include="Ribbon1.resx">
<DependentUpon>Ribbon1.cs</DependentUpon>
</EmbeddedResource>
@ -271,6 +266,11 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
@ -294,25 +294,6 @@
<AppDesigner Include="Properties\" />
<None Include="AIProofread_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\search-proofread.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\logout.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\user.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\selection.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\clear.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\setting.png" />
<None Include="Resources\lexicon.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\util-lib\util-lib.csproj">
<Project>{ff204e99-82f8-405e-847b-88fc6df07715}</Project>
@ -320,28 +301,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-book.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-clear.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-logout.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-phone.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-proofread.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-setting.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-update.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\icon-user.png" />
<Folder Include="Resources\" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
@ -365,8 +325,8 @@
<VisualStudio>
<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" IconIndex="0">
<HostItem Name="ThisAddIn" Code="ThisAddIn.cs" CanonicalName="AddIn" CanActivate="false" IconIndex="1" Blueprint="ThisAddIn.Designer.xml" GeneratedCode="ThisAddIn.Designer.cs" />
<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" />
</Host>
</FlavorProperties>
</VisualStudio>

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<PublishUrlHistory>
</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
</PropertyGroup>

View File

@ -9,6 +9,7 @@ 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.Text;
@ -43,6 +44,8 @@ namespace AIProofread
private static int selectProofreadId = -1;
private static object missing = System.Reflection.Missing.Value;
public string GetAppVersion()
{
return Config.APP_VERSION;
@ -137,8 +140,8 @@ namespace AIProofread
public void ShowUpgrade(string data)
{
var upgradeData = JsonConvert.DeserializeObject<UpgradeData>(data);
var ret = System.Windows.Forms.MessageBox.Show(upgradeData.Message,"更新提示",System.Windows.Forms.MessageBoxButtons.YesNo,System.Windows.Forms.MessageBoxIcon.Question);
if(ret == System.Windows.Forms.DialogResult.Yes)
var ret = System.Windows.Forms.MessageBox.Show(upgradeData.Message, "更新提示", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question);
if (ret == System.Windows.Forms.DialogResult.Yes)
{
OpenUrlWithOsBrowser(upgradeData.DownloadUrl);
}
@ -318,7 +321,8 @@ namespace AIProofread
Globals.ThisAddIn.ShowLoginForm(action);
}
public void MoveCursor(int pos) {
public void MoveCursor(int pos)
{
var rng = Globals.ThisAddIn.Application.ActiveDocument.Range(pos, pos);
rng.Select();
}
@ -326,17 +330,43 @@ namespace AIProofread
public void SelectMarkById(int proofreadId)
{
if (proofreadId == selectProofreadId) return;
var doc = Globals.ThisAddIn.Application.ActiveDocument;
// 取消上一个标签移除
if (selectProofreadId > 0 && marks.ContainsKey(selectProofreadId))
{
marks[selectProofreadId].UnSelect();
var m = marks[selectProofreadId];
if (doc.Bookmarks.Exists(m.Name))
{
marks[selectProofreadId].UnSelect();
}
else
{
marks.Remove(selectProofreadId);
}
}
selectProofreadId = proofreadId;
if (proofreadId > 0 && marks.ContainsKey(proofreadId))
{
var mark = marks[proofreadId].mark;
// 已经不存在该标签了
if (!doc.Bookmarks.Exists(mark.Name))
{
marks.Remove(selectProofreadId);
return;
}
Globals.ThisAddIn.SendMessageToWeb("select", proofreadId);
marks[proofreadId].Select();
var doc = Globals.ThisAddIn.Application.ActiveDocument;
//
object bookmark = (int)Microsoft.Office.Interop.Word.WdGoToItem.wdGoToBookmark;
object bookmarkName = mark.Name;
//doc.GoTo(mark);
//mark.Range.GoTo();
Globals.ThisAddIn.Application.ActiveWindow.Selection.GoTo(ref bookmark, ref missing, ref missing, ref bookmarkName);
//
//mark.DisableCharacterSpaceGrid = false;
// 先滚动到可视区域
//doc.ActiveWindow.ScrollIntoView(mark.Range);
// marks[proofreadId].Select();
}
Globals.ThisAddIn.SendMessageToWeb("select_proofread", proofreadId);
}
@ -352,8 +382,6 @@ 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;

View File

@ -1,21 +1,19 @@
using Microsoft.Web.WebView2.Core;
using Microsoft.Office.Interop.Word;
using Microsoft.Web.WebView2.Core;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AIProofread.Controls
{
public partial class ProofreadMainControl : UserControl
{
public ProofreadMainControl()
private Document doc;
private int minWidth;
public ProofreadMainControl(Document doc,int minWidth)
{
InitializeComponent();
this.doc = doc;
this.minWidth = minWidth;
Bridge.InitWebEnvAsync("main", web);
}
@ -23,7 +21,16 @@ namespace AIProofread.Controls
private void ProofreadMainControl_Load(object sender, EventArgs e)
{
this.web.Source = new Uri(Config.WebPath("#home?version=" + Config.APP_VERSION));
//this.SizeChanged += ProofreadMainControl_SizeChanged;
}
private void ProofreadMainControl_SizeChanged(object sender, EventArgs e)
{
if(this.minWidth > 0 && this.Width < this.minWidth)
{
SendKeys.Send("{ESC}");
this.Width = this.minWidth;
}
}
}
}

View File

@ -13,11 +13,17 @@ namespace UtilLib
public Bookmark mark;
private CorrectedContent content;
private float originSize;
public string Name { get; set; }
public ProofreadItem(CorrectedContent content)
{
this.content = content;
InitBookMark(null);
SetMarkName();
}
private void SetMarkName()
{
this.Name = this.mark != null ? mark.Name : Config.BuildBookmarkName(content.id);
}
public ProofreadItem(CorrectedContent content, Bookmark bookmark)
@ -29,6 +35,7 @@ namespace UtilLib
// 记录目前字体
originSize = bookmark.Range.Font.Size;
}
SetMarkName();
//InitBookMark(bookmark);
}
@ -66,7 +73,7 @@ namespace UtilLib
public void Select()
{
if (mark == null) return;
if(content.tag == "i")
if (content.tag == "i")
{
var endPos = mark.Range.End;
var rng = Globals.ThisAddIn.Application.ActiveDocument.Range(endPos, endPos);
@ -75,7 +82,7 @@ namespace UtilLib
}
mark.Range.Font.Size = originSize + 2; // 将选中标签文本放大字体
mark.Select();
}
public void UnSelect()
{

View File

@ -63,9 +63,9 @@ namespace AIProofread.Properties {
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap clear {
internal static System.Drawing.Bitmap favicon {
get {
object obj = ResourceManager.GetObject("clear", resourceCulture);
object obj = ResourceManager.GetObject("favicon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@ -80,6 +80,16 @@ namespace AIProofread.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_book_wps {
get {
object obj = ResourceManager.GetObject("icon-book-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -90,6 +100,16 @@ namespace AIProofread.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_clear_wps {
get {
object obj = ResourceManager.GetObject("icon-clear-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -100,6 +120,16 @@ namespace AIProofread.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_logout_wps {
get {
object obj = ResourceManager.GetObject("icon-logout-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -110,6 +140,16 @@ namespace AIProofread.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_phone_wps {
get {
object obj = ResourceManager.GetObject("icon-phone-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -120,6 +160,16 @@ namespace AIProofread.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_proofread_wps {
get {
object obj = ResourceManager.GetObject("icon-proofread-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -130,6 +180,16 @@ namespace AIProofread.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_setting_wps {
get {
object obj = ResourceManager.GetObject("icon-setting-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -140,6 +200,16 @@ namespace AIProofread.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_update_wps {
get {
object obj = ResourceManager.GetObject("icon-update-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -153,59 +223,9 @@ namespace AIProofread.Properties {
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap lexicon {
internal static System.Drawing.Bitmap icon_user_wps {
get {
object obj = ResourceManager.GetObject("lexicon", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap logout {
get {
object obj = ResourceManager.GetObject("logout", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap search_proofread {
get {
object obj = ResourceManager.GetObject("search-proofread", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap selection {
get {
object obj = ResourceManager.GetObject("selection", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap setting {
get {
object obj = ResourceManager.GetObject("setting", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap user {
get {
object obj = ResourceManager.GetObject("user", resourceCulture);
object obj = ResourceManager.GetObject("icon-user-wps", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}

View File

@ -118,20 +118,12 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="logout" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\logout.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="clear" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\clear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="setting" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\setting.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-logout" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-logout.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="lexicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\lexicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
<data name="favicon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\favicon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-setting" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-setting.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
@ -139,21 +131,12 @@
<data name="icon-phone" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-phone.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="selection" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\selection.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="user" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-book" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-book.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="search-proofread" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\search-proofread.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-clear" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-clear.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -163,4 +146,28 @@
<data name="icon-user" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-user.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-book-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-book-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-clear-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-clear-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-logout-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-logout-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-phone-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-phone-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-proofread-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-proofread-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-setting-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-setting-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-update-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-update-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-user-wps" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-user-wps.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 948 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 942 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

View File

@ -1,4 +1,6 @@
namespace AIProofread
using System;
namespace AIProofread
{
partial class Ribbon1 : Microsoft.Office.Tools.Ribbon.RibbonBase
{
@ -37,8 +39,7 @@
this.tabAIProofread = this.Factory.CreateRibbonTab();
this.group1 = this.Factory.CreateRibbonGroup();
this.LblNickname = this.Factory.CreateRibbonLabel();
this.LblPhone = this.Factory.CreateRibbonLabel();
this.LblVersion = this.Factory.CreateRibbonLabel();
this.LblDate = this.Factory.CreateRibbonLabel();
this.BtnProofreadAll = this.Factory.CreateRibbonButton();
this.btnClear = this.Factory.CreateRibbonButton();
this.btnOpenLexicon = this.Factory.CreateRibbonButton();
@ -69,30 +70,24 @@
this.group1.Items.Add(this.btnLogin);
this.group1.Items.Add(this.btnLogout);
this.group1.Items.Add(this.LblNickname);
this.group1.Items.Add(this.LblPhone);
this.group1.Items.Add(this.LblVersion);
this.group1.Items.Add(this.LblDate);
this.group1.Name = "group1";
//
// LblNickname
//
this.LblNickname.Label = "张三 已登录";
this.LblNickname.Label = "xxx 已登录";
this.LblNickname.Name = "LblNickname";
//
// LblPhone
// LblDate
//
this.LblPhone.Label = "188****8888";
this.LblPhone.Name = "LblPhone";
//
// LblVersion
//
this.LblVersion.Label = "企业内测版";
this.LblVersion.Name = "LblVersion";
this.LblDate.Label = "过期时间:";
this.LblDate.Name = "LblDate";
//
// BtnProofreadAll
//
this.BtnProofreadAll.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.BtnProofreadAll.Image = global::AIProofread.Properties.Resources.icon_proofread;
this.BtnProofreadAll.Label = "全文校对";
this.BtnProofreadAll.Label = "全文校对\n";
this.BtnProofreadAll.Name = "BtnProofreadAll";
this.BtnProofreadAll.ShowImage = true;
this.BtnProofreadAll.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnProofreadAll_Click);
@ -101,7 +96,7 @@
//
this.btnClear.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.btnClear.Image = global::AIProofread.Properties.Resources.icon_clear;
this.btnClear.Label = "清除标注";
this.btnClear.Label = "清除标注\n";
this.btnClear.Name = "btnClear";
this.btnClear.ShowImage = true;
this.btnClear.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnClear_Click);
@ -110,7 +105,7 @@
//
this.btnOpenLexicon.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.btnOpenLexicon.Image = global::AIProofread.Properties.Resources.icon_book;
this.btnOpenLexicon.Label = "词库管理";
this.btnOpenLexicon.Label = "词库管理\n";
this.btnOpenLexicon.Name = "btnOpenLexicon";
this.btnOpenLexicon.ShowImage = true;
this.btnOpenLexicon.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnOpenLexicon_Click);
@ -119,7 +114,7 @@
//
this.btnSetting.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.btnSetting.Image = global::AIProofread.Properties.Resources.icon_setting;
this.btnSetting.Label = "插件设置";
this.btnSetting.Label = "插件设置\n";
this.btnSetting.Name = "btnSetting";
this.btnSetting.ShowImage = true;
this.btnSetting.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnSetting_Click);
@ -128,7 +123,7 @@
//
this.BtnGetContact.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.BtnGetContact.Image = global::AIProofread.Properties.Resources.icon_phone;
this.BtnGetContact.Label = "联系客服";
this.BtnGetContact.Label = "联系客服\n";
this.BtnGetContact.Name = "BtnGetContact";
this.BtnGetContact.ShowImage = true;
this.BtnGetContact.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnGetContact_Click);
@ -137,7 +132,7 @@
//
this.BtnUpdate.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.BtnUpdate.Image = global::AIProofread.Properties.Resources.icon_update;
this.BtnUpdate.Label = "版本更新";
this.BtnUpdate.Label = "版本更新\n";
this.BtnUpdate.Name = "BtnUpdate";
this.BtnUpdate.ShowImage = true;
this.BtnUpdate.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.BtnUpdate_Click);
@ -146,7 +141,7 @@
//
this.btnLogin.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.btnLogin.Image = global::AIProofread.Properties.Resources.icon_user;
this.btnLogin.Label = "用户登录";
this.btnLogin.Label = "用户登录\n";
this.btnLogin.Name = "btnLogin";
this.btnLogin.ShowImage = true;
this.btnLogin.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnLogin_Click);
@ -155,7 +150,7 @@
//
this.btnLogout.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.btnLogout.Image = global::AIProofread.Properties.Resources.icon_logout;
this.btnLogout.Label = "退出登录";
this.btnLogout.Label = "退出登录\n";
this.btnLogout.Name = "btnLogout";
this.btnLogout.ShowImage = true;
this.btnLogout.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.btnLogout_Click);
@ -180,8 +175,7 @@
internal Microsoft.Office.Tools.Ribbon.RibbonGroup group1;
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnLogout;
internal Microsoft.Office.Tools.Ribbon.RibbonLabel LblNickname;
internal Microsoft.Office.Tools.Ribbon.RibbonLabel LblPhone;
internal Microsoft.Office.Tools.Ribbon.RibbonLabel LblVersion;
internal Microsoft.Office.Tools.Ribbon.RibbonLabel LblDate;
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnLogin;
internal Microsoft.Office.Tools.Ribbon.RibbonButton BtnProofreadAll;
internal Microsoft.Office.Tools.Ribbon.RibbonButton btnClear;

View File

@ -3,6 +3,7 @@ using System;
using System.Diagnostics;
using AIProofread.Controls;
using UtilLib;
using System.Drawing;
namespace AIProofread
{
@ -18,14 +19,27 @@ namespace AIProofread
Globals.ThisAddIn.ribbon = this;
}
public void InitWPS()
{
BtnProofreadAll.Image = AIProofread.Properties.Resources.icon_proofread_wps;
btnClear.Image = AIProofread.Properties.Resources.icon_clear_wps;
btnOpenLexicon.Image = AIProofread.Properties.Resources.icon_book_wps;
btnSetting.Image = AIProofread.Properties.Resources.icon_setting_wps;
BtnGetContact.Image = AIProofread.Properties.Resources.icon_phone_wps;
BtnUpdate.Image = AIProofread.Properties.Resources.icon_update_wps;
btnLogin.Image = AIProofread.Properties.Resources.icon_user_wps;
btnLogout.Image = AIProofread.Properties.Resources.icon_logout_wps;
}
public void ProcessLoginInfo(Userinfo userinfo)
{
if (userinfo == null) return;
IS_LOGIN = true;
ToggleLogin();
LblNickname.Label = userinfo.nickname + " 已登录";
LblPhone.Label = userinfo.phone;
LblNickname.Label = userinfo.nickname;
LblDate.Label = userinfo.expiration;
// 关闭所有登录窗口
foreach (var item in Globals.ThisAddIn.LoginFormList)
@ -51,8 +65,7 @@ namespace AIProofread
btnLogout.Visible = IS_LOGIN;
LblNickname.Visible = IS_LOGIN;
LblPhone.Visible = IS_LOGIN;
LblVersion.Visible = IS_LOGIN;
LblDate.Visible = IS_LOGIN;
}
// 弹出登录窗口
@ -88,7 +101,7 @@ namespace AIProofread
private void BtnUpdate_Click(object sender, RibbonControlEventArgs e)
{
//System.Windows.Forms.MessageBox.Show("当前插件是最新版本");
Globals.ThisAddIn.SendMessageToWeb("upgrade",Config.APP_VERSION);
Globals.ThisAddIn.SendMessageToWeb("upgrade", Config.APP_VERSION);
}
private void BtnProofreadAll_Click(object sender, RibbonControlEventArgs e)
@ -100,7 +113,7 @@ namespace AIProofread
private void btnClear_Click(object sender, RibbonControlEventArgs e)
{
DocumentUtil.ClearProofreadMarks();
Globals.ThisAddIn.SendMessageToWeb("clear-tips",null);
Globals.ThisAddIn.SendMessageToWeb("clear-tips", null);
}
}
}

View File

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="BtnProofreadAll.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -9,6 +9,7 @@ using UtilLib;
using System.Threading;
using Microsoft.Office.Interop.Word;
using System.Linq;
using System.Windows.Forms;
namespace AIProofread
{
@ -18,11 +19,11 @@ namespace AIProofread
public static SynchronizationContext FmainThreadContext;
public string AddinName = Config.APP_NAME;
public string AddinName = " ";
/// <summary>
/// 最小宽度
/// </summary>
private const int MinWidth = 400;
private const int MinWidth = 420;
/// <summary>
/// 启动路径
/// </summary>
@ -47,11 +48,13 @@ namespace AIProofread
private void Application_WindowDeactivate(Word.Document Doc, Window Wn)
{
Logger.Log("Application_WindowDeactivate -- " + Doc.FullName);
//HidePanel(Doc);
}
private void Application_WindowActivate(Word.Document Doc, Window Wn)
{
Logger.Log("Application_WindowActivate -- " + Doc.FullName);
//ShowPanel(Doc);
if (!taskPanels.ContainsKey(Doc))
@ -63,16 +66,19 @@ namespace AIProofread
private void Application_DocumentBeforeClose(Word.Document Doc, ref bool Cancel)
{
Logger.Log("Application_DocumentBeforeClose -- " + Doc.FullName);
DisposePanel(Doc);
}
private void Application_NewDocument(Word.Document Doc)
{
Logger.Log("Application_NewDocument -- " + Doc.FullName);
ShowPanel(Doc);
}
private void Application_DocumentOpen(Word.Document Doc)
{
Logger.Log("Application_DocumentOpen -- " + Doc.FullName);
ShowPanel(Doc);
}
void DisposePanel(Word.Document doc)
@ -104,33 +110,48 @@ namespace AIProofread
taskPanels[doc].Visible = false;
}
}
/// <summary>
/// word创建面板
/// </summary>
private CustomTaskPane ShowPanel(Word.Document doc)
private CustomTaskPane ShowPanel(Word.Document doc, bool show)
{
//if (!IsWPS)
//{
// if (Application.ActiveDocument == null) return;
// if (doc == null) doc = Application.ActiveDocument;
//}
if (Application.ActiveDocument == null) return null;
if (doc == null) doc = Application.ActiveDocument;
if (taskPanels.ContainsKey(doc))
{
taskPanels[doc].Visible = true;
this.customTaskPane = taskPanels[doc];
return taskPanels[doc];
}
//proofreadPanel = new ProofreadMainControl();
var panel = Globals.ThisAddIn.CustomTaskPanes.Add(new ProofreadMainControl(), AddinName);
var control = new ProofreadMainControl(doc, MinWidth);
var panel = Globals.ThisAddIn.CustomTaskPanes.Add(control, AddinName);
this.customTaskPane = panel;
taskPanels.Add(doc, panel);
control.Width = MinWidth;
panel.Width = MinWidth;
panel.Visible = !IsWPS;
panel.Visible = show;
// 监听尺寸变化 防止最小尺寸小于设置值
control.SizeChanged += Control_SizeChanged;
return panel;
}
/// <summary>
/// word创建面板
/// </summary>
private CustomTaskPane ShowPanel(Word.Document doc)
{
return ShowPanel(doc, !IsWPS);
}
private void Control_SizeChanged(object sender, EventArgs e)
{
if (customTaskPane != null && customTaskPane.Width < MinWidth)
{
SendKeys.Send("{ESC}");
customTaskPane.Width = MinWidth;
}
}
public void Send(SendOrPostCallback d)
{
@ -149,21 +170,42 @@ namespace AIProofread
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
FmainThreadContext = SynchronizationContext.Current;
// 启动地址
applicationStartupPath = System.Windows.Forms.Application.StartupPath;
if (applicationStartupPath.Contains("WPS"))
try
{
IsWPS = true;
FmainThreadContext = SynchronizationContext.Current;
// 启动地址
applicationStartupPath = System.Windows.Forms.Application.StartupPath;
if (applicationStartupPath.Contains("WPS"))
{
IsWPS = true;
try
{
Globals.Ribbons.Ribbon1.InitWPS();
}
catch (Exception ex)
{
Logger.Log("Init WPS Error " + ex.Message);
}
}
// 处理文档事件
Application.DocumentOpen += Application_DocumentOpen;
Application.DocumentBeforeClose += Application_DocumentBeforeClose;
Application.WindowActivate += Application_WindowActivate;
Application.WindowDeactivate += Application_WindowDeactivate;
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
// 选区发生变化事件
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
if (Application.ActiveDocument != null)
{
// 默认直接打开文档 就直接创建panel
ShowPanel(Application.ActiveDocument, false);
}
}
catch (Exception ex1)
{
Logger.Log("Init Error " + ex1.ToString());
}
// 处理文档事件
Application.DocumentOpen += Application_DocumentOpen;
Application.DocumentBeforeClose += Application_DocumentBeforeClose;
Application.WindowActivate += Application_WindowActivate;
Application.WindowDeactivate += Application_WindowDeactivate;
(Application as ApplicationEvents4_Event).NewDocument += Application_NewDocument;
// 选区发生变化事件
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
}
@ -197,10 +239,22 @@ namespace AIProofread
public void SendMessageToWeb(string msg, object data)
{
var panel = this.ShowPanel(Application.ActiveDocument);
// 先显示panel
var panel = this.ShowPanel(Application.ActiveDocument, true);
var json = JsonConvert.SerializeObject(new WebMessage(msg, data));
var control = (ProofreadMainControl)panel.Control;
control.web.CoreWebView2.PostWebMessageAsJson(json);
try
{
if (control.web.CoreWebView2 == null)
{
Thread.Sleep(500);
}
control.web.CoreWebView2.PostWebMessageAsJson(json);
}
catch (Exception ex)
{
Logger.Log("send message to web error \n" + ex.Message + "\n" + msg + data.ToString());
}
}
// 显示面板
@ -216,7 +270,6 @@ namespace AIProofread
}
public void ShowLoginForm(string action)
{
FormLogin frm = new FormLogin(action);

View File

@ -17,7 +17,7 @@ namespace AIProofread
{
if (ctp == null)
{
uc = new ProofreadMainControl();
uc = new ProofreadMainControl(null,450);
ctp = Globals.ThisAddIn.CustomTaskPanes.Add(control: uc, title: "AI校对王");
ctp.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
}

View File

@ -40,7 +40,9 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.We
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.WinForms.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\bin\Debug\Microsoft.Web.WebView2.Wpf.xml
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.csproj.AssemblyReference.cache
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormContact.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormLogin.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormMain.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormSetting.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.ProofreadMainControl.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Properties.Resources.resources
@ -50,5 +52,3 @@ C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.
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\AIProofread.Controls.FormContact.resources
C:\Users\yaclt\source\repos\repos\AIProofread\AIProofread\obj\Debug\AIProofread.Controls.FormMain.resources

View File

@ -2,23 +2,11 @@
{
public class Userinfo
{
/*
{
"avatar": "",
"createdAt": 1697466498,
"is_bind_wechat": true,
"nickname": "189****8214",
"phone": "18982208214",
"registerIp": "118.113.176.206",
"status": 1,
"uid": 23
}
*/
public string avatar { get; set; }
public int createdAt { get; set; }
public bool is_bind_wechat { get; set; }
public string nickname { get; set; }
public string phone { get; set; }
public string expiration { get; set; }
}
}