Compare commits

...

4 Commits

Author SHA1 Message Date
3ab356ff26 fixed: 修正扩展初始化时面板没有初始化的问题 2025-04-18 21:26:40 +08:00
7e7718b9e0 feat: 更新到最新升级程序 2025-04-15 22:22:17 +08:00
7cfab47216 添加窗体居中显示功能并优化资源释放 2025-04-14 22:32:54 +08:00
7e26695000 更新 APP_VERSION 和 Ribbon1 组件属性
更新了 `Config.cs` 文件中的 `APP_VERSION` 常量值,从 "2.0.0" 改为 "2.2.2"。
在 `Ribbon1.Designer.cs` 文件中,删除了 `menuProofreadList` 的 `Enabled` 属性设置,使其默认启用。
新增了 `BtnShowPanel` 的 `Enabled` 属性设置,并将其设为 `false`,使其默认禁用。
2025-04-14 19:16:56 +08:00
14 changed files with 99 additions and 58 deletions

Binary file not shown.

View File

@ -20,12 +20,12 @@ Global
Test|Any CPU = Test|Any CPU Test|Any CPU = Test|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Debug|Any CPU.ActiveCfg = Release_Anno|Any CPU
{6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Debug|Any CPU.Build.0 = Debug|Any CPU {6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Debug|Any CPU.Build.0 = Release_Anno|Any CPU
{6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Release|Any CPU.ActiveCfg = Release|Any CPU {6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Release|Any CPU.Build.0 = Release|Any CPU {6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Release|Any CPU.Build.0 = Release|Any CPU
{6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Test|Any CPU.ActiveCfg = Test|Any CPU {6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Test|Any CPU.ActiveCfg = Release_Anno|Any CPU
{6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Test|Any CPU.Build.0 = Test|Any CPU {6CE536CB-6154-4FDF-9FFE-23A73B4E84AB}.Test|Any CPU.Build.0 = Release_Anno|Any CPU
{455E23BE-F34F-4F6F-A9EA-381D66170B1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {455E23BE-F34F-4F6F-A9EA-381D66170B1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{455E23BE-F34F-4F6F-A9EA-381D66170B1B}.Debug|Any CPU.Build.0 = Debug|Any CPU {455E23BE-F34F-4F6F-A9EA-381D66170B1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{455E23BE-F34F-4F6F-A9EA-381D66170B1B}.Release|Any CPU.ActiveCfg = Release|Any CPU {455E23BE-F34F-4F6F-A9EA-381D66170B1B}.Release|Any CPU.ActiveCfg = Release|Any CPU

View File

@ -577,7 +577,7 @@
<PropertyGroup> <PropertyGroup>
<ManifestCertificateThumbprint>62DF6B414BD2608A130540A801F32D12E0199A99</ManifestCertificateThumbprint> <ManifestCertificateThumbprint>62DF6B414BD2608A130540A801F32D12E0199A99</ManifestCertificateThumbprint>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|AnyCPU'"> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Anno|AnyCPU' ">
<OutputPath>bin\Test\</OutputPath> <OutputPath>bin\Test\</OutputPath>
<DefineConstants>VSTO40;TRACE</DefineConstants> <DefineConstants>VSTO40;TRACE</DefineConstants>
<Optimize>true</Optimize> <Optimize>true</Optimize>
@ -585,7 +585,7 @@
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>7.3</LangVersion> <LangVersion>7.3</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Test|Win32'"> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release_Anno|Win32' ">
<OutputPath>bin\Win32\Test\</OutputPath> <OutputPath>bin\Win32\Test\</OutputPath>
<DefineConstants>VSTO40</DefineConstants> <DefineConstants>VSTO40</DefineConstants>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>

View File

@ -36,7 +36,7 @@ namespace AIProofread
public class Config public class Config
{ {
public static readonly string APP_NAME = "AI校对王(公告版)"; public static readonly string APP_NAME = "AI校对王(公告版)";
public static readonly string APP_VERSION = "2.0.0"; public static readonly string APP_VERSION = "2.2.2";
public static bool IS_WPS = false; public static bool IS_WPS = false;
public static bool UpgradeForcedNotice = false; public static bool UpgradeForcedNotice = false;
public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory; public static readonly string APP_BASE_DIR = AppDomain.CurrentDomain.BaseDirectory;

View File

@ -112,6 +112,12 @@ namespace AIProofread.Controls
this.FormBorderStyle = FormBorderStyle.None; this.FormBorderStyle = FormBorderStyle.None;
} }
public void SetHeight(int height)
{
this.Height = height;
CenterToScreen();
}
protected async void InitWebView(WebView2 webView,String url,string name,Action callaback = null) protected async void InitWebView(WebView2 webView,String url,string name,Action callaback = null)
{ {
//Bridge.InitWebEnvAsync(name, webView); //Bridge.InitWebEnvAsync(name, webView);

View File

@ -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)

View File

@ -39,6 +39,7 @@ namespace AIProofread.Controls
{ {
this.Width = (int)(width * dpiScaleFactor); this.Width = (int)(width * dpiScaleFactor);
this.Height = (int)(height * dpiScaleFactor); this.Height = (int)(height * dpiScaleFactor);
CenterToScreen();
} }
private void FormWebView_Load(object sender, EventArgs e) private void FormWebView_Load(object sender, EventArgs e)

View File

@ -32,10 +32,7 @@ namespace AIProofread
try try
{ {
StreamWriter streamWriter = File.AppendText(path); StreamWriter streamWriter = File.AppendText(path);
streamWriter.WriteLine("***************************[" + tag + "]***************************"); streamWriter.WriteLine($"{time} [{tag}]" + message);
streamWriter.WriteLine("消息:" + message);
streamWriter.WriteLine("时间:" + time);
streamWriter.WriteLine();
streamWriter.Flush(); streamWriter.Flush();
streamWriter.Close(); streamWriter.Close();
streamWriter.Dispose(); streamWriter.Dispose();

View File

@ -102,6 +102,7 @@ namespace AIProofread.Model
/// </summary> /// </summary>
public void ShowPane() public void ShowPane()
{ {
CheckPanel();
if (null != TaskPane) if (null != TaskPane)
{ {
TaskPane.Visible = PaneVisible = true; TaskPane.Visible = PaneVisible = true;
@ -110,6 +111,7 @@ namespace AIProofread.Model
public void RunInMainThread(Action action) public void RunInMainThread(Action action)
{ {
CheckPanel();
if (null != TaskPane) if (null != TaskPane)
{ {
TaskPane.Control.BeginInvoke(action); TaskPane.Control.BeginInvoke(action);
@ -914,6 +916,7 @@ namespace AIProofread.Model
public void ExportResult(string modelType) public void ExportResult(string modelType)
{ {
CheckPanel();
TaskPane.Control.BeginInvoke(new Action(() => TaskPane.Control.BeginInvoke(new Action(() =>
{ {
DocumentUtil.ExportProofreadResult(modelType); DocumentUtil.ExportProofreadResult(modelType);
@ -922,6 +925,7 @@ namespace AIProofread.Model
public void ShowUpgrade(string data, bool force) public void ShowUpgrade(string data, bool force)
{ {
CheckPanel();
TaskPane.Control.BeginInvoke(new Action(() => TaskPane.Control.BeginInvoke(new Action(() =>
{ {
var upgradeData = JsonConvert.DeserializeObject<UpgradeData>(data); var upgradeData = JsonConvert.DeserializeObject<UpgradeData>(data);
@ -974,7 +978,7 @@ namespace AIProofread.Model
public void ShowSetting() public void ShowSetting()
{ {
CheckPanel();
TaskPane.Control.BeginInvoke(new Action(() => TaskPane.Control.BeginInvoke(new Action(() =>
{ {
FormSetting frm = new FormSetting(); FormSetting frm = new FormSetting();
@ -983,6 +987,7 @@ namespace AIProofread.Model
} }
public void ShowWebView(string url, int width, int height, bool dialog) public void ShowWebView(string url, int width, int height, bool dialog)
{ {
CheckPanel();
TaskPane.Control.BeginInvoke(new Action(() => TaskPane.Control.BeginInvoke(new Action(() =>
{ {
FormWebView view = new FormWebView(url, width, height); FormWebView view = new FormWebView(url, width, height);
@ -1019,7 +1024,7 @@ namespace AIProofread.Model
return dic; return dic;
} }
internal void CheckPanel() public void CheckPanel()
{ {
Logger.Log(CurrentDocument.FullName + $" TaskPane visible {PaneVisible} has " + (TaskPane == null ? "null" : "exists")); Logger.Log(CurrentDocument.FullName + $" TaskPane visible {PaneVisible} has " + (TaskPane == null ? "null" : "exists"));
if (TaskPane == null) CreateTaskPane(); if (TaskPane == null) CreateTaskPane();

View File

@ -103,6 +103,19 @@ namespace AIProofread.Model
return documentList.IndexOf(item); return documentList.IndexOf(item);
} }
public DocumentInfo InitDocument(Document originDocument)
{
var document = Get(originDocument);
// 如果不存在,则添加
if (document == null)
{
document = new DocumentInfo(originDocument);
Add(document);
}
return document;
}
/// <summary> /// <summary>
/// 设置当前激活的文档 /// 设置当前激活的文档
/// </summary> /// </summary>
@ -110,14 +123,8 @@ namespace AIProofread.Model
public DocumentInfo SetActiveDocument(Document originDocument) public DocumentInfo SetActiveDocument(Document originDocument)
{ {
if (originDocument == null) return null; if (originDocument == null) return null;
var document = Get(originDocument); var document = InitDocument(originDocument);
// 如果不存在,则添加
if (document == null)
{
document = new DocumentInfo(originDocument);
Add(document);
}
if (ActiveDocument == document) return document; if (ActiveDocument == document) return document;
else if (Globals.ThisAddIn.IsWPS) else if (Globals.ThisAddIn.IsWPS)
{ {

View File

@ -121,7 +121,6 @@ namespace AIProofread
// menuProofreadList // menuProofreadList
// //
this.menuProofreadList.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge; this.menuProofreadList.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.menuProofreadList.Enabled = false;
this.menuProofreadList.Image = global::AIProofread.Properties.Resources.icon_proofread; this.menuProofreadList.Image = global::AIProofread.Properties.Resources.icon_proofread;
this.menuProofreadList.Items.Add(this.BtnProofreadExact); this.menuProofreadList.Items.Add(this.BtnProofreadExact);
this.menuProofreadList.Items.Add(this.BtnProofreadFull); this.menuProofreadList.Items.Add(this.BtnProofreadFull);
@ -314,6 +313,7 @@ namespace AIProofread
// BtnShowPanel // BtnShowPanel
// //
this.BtnShowPanel.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge; this.BtnShowPanel.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.BtnShowPanel.Enabled = false;
this.BtnShowPanel.Image = global::AIProofread.Properties.Resources.icon_panel; this.BtnShowPanel.Image = global::AIProofread.Properties.Resources.icon_panel;
this.BtnShowPanel.Label = "显示面板\r\n"; this.BtnShowPanel.Label = "显示面板\r\n";
this.BtnShowPanel.Name = "BtnShowPanel"; this.BtnShowPanel.Name = "BtnShowPanel";

View File

@ -285,6 +285,7 @@ namespace AIProofread
private void AppInitialize() private void AppInitialize()
{ {
Logger.Log("AppInitialize start... ");
CurrentWordApplication = Application; CurrentWordApplication = Application;
// 初始化配置 // 初始化配置
InitAppByConfig(); InitAppByConfig();
@ -308,6 +309,25 @@ namespace AIProofread
Logger.Log("Init WPS Error " + ex.Message); Logger.Log("Init WPS Error " + ex.Message);
} }
} }
// 如果启用直接有文档打开
// 初始化面板
try
{
var docList = CurrentWordApplication.Documents;
if(docList.Count > 0)
{
foreach (Document item in docList)
{
Logger.Log("Init Documentinfo ==> " + item.Name);
var info = documentList.InitDocument(item);
info.CheckPanel();
}
}
}
catch (Exception ex)
{
Logger.Log("Init Documentinfo Error " + ex.Message);
}
string verTextFile = Config.APP_BASE_DIR + Path.GetFileName("app_version.txt"); string verTextFile = Config.APP_BASE_DIR + Path.GetFileName("app_version.txt");
try try
{ {
@ -317,6 +337,7 @@ namespace AIProofread
{ {
Logger.Log("Write App Version Error " + ex.Message); Logger.Log("Write App Version Error " + ex.Message);
} }
} }
private void InitAppByConfig() private void InitAppByConfig()

View File

@ -35,8 +35,7 @@
this.panel1 = new System.Windows.Forms.Panel(); this.panel1 = new System.Windows.Forms.Panel();
this.IconClose = new System.Windows.Forms.PictureBox(); this.IconClose = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.panelLog = new System.Windows.Forms.Panel(); this.panelLog = new AntdUI.Panel();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.IconClose)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.IconClose)).BeginInit();
this.panelLog.SuspendLayout(); this.panelLog.SuspendLayout();
@ -44,12 +43,13 @@
// //
// LabelLog // LabelLog
// //
this.LabelLog.AutoEllipsis = true;
this.LabelLog.BackColor = System.Drawing.Color.Transparent;
this.LabelLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 10F); this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 10F);
this.LabelLog.Location = new System.Drawing.Point(2, 2); this.LabelLog.Location = new System.Drawing.Point(5, 5);
this.LabelLog.MaximumSize = new System.Drawing.Size(296, 0);
this.LabelLog.MinimumSize = new System.Drawing.Size(296, 0);
this.LabelLog.Name = "LabelLog"; this.LabelLog.Name = "LabelLog";
this.LabelLog.Size = new System.Drawing.Size(296, 21); this.LabelLog.Size = new System.Drawing.Size(290, 100);
this.LabelLog.TabIndex = 0; this.LabelLog.TabIndex = 0;
this.LabelLog.Text = "版本检测中 ..."; this.LabelLog.Text = "版本检测中 ...";
this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -114,31 +114,21 @@
// //
// panelLog // panelLog
// //
this.panelLog.AutoScroll = true; this.panelLog.Back = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(248)))), ((int)(((byte)(249)))));
this.panelLog.Controls.Add(this.LabelLog); this.panelLog.Controls.Add(this.LabelLog);
this.panelLog.Location = new System.Drawing.Point(40, 58); this.panelLog.Location = new System.Drawing.Point(40, 60);
this.panelLog.Name = "panelLog"; this.panelLog.Name = "panelLog";
this.panelLog.Size = new System.Drawing.Size(300, 114); this.panelLog.Padding = new System.Windows.Forms.Padding(5);
this.panelLog.Radius = 4;
this.panelLog.Size = new System.Drawing.Size(300, 110);
this.panelLog.TabIndex = 8; this.panelLog.TabIndex = 8;
// //
// richTextBox1
//
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.richTextBox1.Location = new System.Drawing.Point(237, 149);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.richTextBox1.Size = new System.Drawing.Size(100, 96);
this.richTextBox1.TabIndex = 9;
this.richTextBox1.Text = "";
//
// Form1 // Form1
// //
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.BackColor = System.Drawing.Color.White; this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(380, 260); this.ClientSize = new System.Drawing.Size(380, 260);
this.Controls.Add(this.richTextBox1);
this.Controls.Add(this.panelLog); this.Controls.Add(this.panelLog);
this.Controls.Add(this.panel1); this.Controls.Add(this.panel1);
this.Controls.Add(this.ButtonProcess); this.Controls.Add(this.ButtonProcess);
@ -168,8 +158,7 @@
private System.Windows.Forms.PictureBox IconClose; private System.Windows.Forms.PictureBox IconClose;
private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panelLog; private AntdUI.Panel panelLog;
private System.Windows.Forms.RichTextBox richTextBox1;
} }
} }

View File

@ -30,11 +30,7 @@ namespace updater
* pre-gm-plugin.gachafun.com * pre-gm-plugin.gachafun.com
* gm-plugin.gachafun.com * gm-plugin.gachafun.com
*/ */
#if DEBUG private static string UpgradeInfoURI = "https://gm-plugin-fn.gachafun.com/";
private static string UpgradeInfoURI = "https://gm-plugin.gachafun.com/";
#else
private static string UpgradeInfoURI = "https://gm-plugin.gachafun.com/";
#endif
private string updateSource; private string updateSource;
@ -187,15 +183,8 @@ namespace updater
private void ProcessUpdate(UpgradeModel update) private void ProcessUpdate(UpgradeModel update)
{ {
this.upgradeInfo = update.Info; this.upgradeInfo = update.Info;
//richTextBox1.Text
richTextBox1.Text = update.Info.Message LabelLog.Text = update.Info.Message;
+ @"Com加载项勾选
office或wps的版本
Com加载项勾选
windowS10或11wps在安装插件";
if (localVersion == null || update.Info.NeedUpgrade(localVersion.Version)) if (localVersion == null || update.Info.NeedUpgrade(localVersion.Version))
{ {