统一弹出框样式

This commit is contained in:
LittleBoy 2024-12-25 19:29:29 +08:00
parent 95de468a04
commit c036b904fa
20 changed files with 288 additions and 52 deletions

Binary file not shown.

View File

@ -259,8 +259,12 @@ namespace AIProofread
{
// web同步注销到ribbon
Globals.ThisAddIn.SyncLogout();
// ribbon 发送注销动作到 web
Globals.ThisAddIn.SendMessageToWeb("logout", null);
if(string.IsNullOrEmpty(action) || action != "disabled-send")
{
// ribbon 发送注销动作到 web
Globals.ThisAddIn.SendMessageToWeb("logout", null);
}
}
/// <summary>
@ -596,6 +600,10 @@ namespace AIProofread
//FormMessage.ShowMessage(message, closeDelay);
Globals.ThisAddIn.ActiveDocument?.ShowMessage(message, closeDelay, showCloseBtn);
}
public void ShowConfirmMessage(string message, string confirmText, string confirmAction)
{
Globals.ThisAddIn.ActiveDocument.ShowDialog(message,confirmText,confirmAction);
}
public string ShowDialogMessage(string message)
{
var result = FormMessage.ShowMessage(message, "确认",null);

View File

@ -25,7 +25,7 @@ namespace AIProofread
/// <summary>
/// 网页访问地址
/// </summary>
public static string WEB_PATH = "https://pre-gm-plugin.gachafun.com/"; //pre-gm-plugin.gachafun.com 192.168.0.231:5137 192.168.10.100:5173 gm2-plugin.zverse.group
public static string WEB_PATH = "http://localhost:5173/"; //pre-gm-plugin.gachafun.com 192.168.0.231:5137 192.168.10.100:5173 gm2-plugin.zverse.group
public static bool RUN_IN_DEBUG = true;
public static AppEnvironment APP_ENV = AppEnvironment.Dev;
#else

View File

@ -29,13 +29,13 @@
private void InitializeComponent()
{
this.LblMeesage = new System.Windows.Forms.Label();
this.IconClose = new System.Windows.Forms.PictureBox();
this.panel1 = new System.Windows.Forms.Panel();
this.IconClose = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.BtnClose = new System.Windows.Forms.Button();
this.BtnConfirm = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.IconClose)).BeginInit();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.IconClose)).BeginInit();
this.SuspendLayout();
//
// LblMeesage
@ -48,18 +48,6 @@
this.LblMeesage.TabIndex = 4;
this.LblMeesage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// IconClose
//
this.IconClose.BackColor = System.Drawing.Color.Transparent;
this.IconClose.Cursor = System.Windows.Forms.Cursors.Hand;
this.IconClose.Image = global::AIProofread.Properties.Resources.icon_close;
this.IconClose.Location = new System.Drawing.Point(350, 15);
this.IconClose.Name = "IconClose";
this.IconClose.Size = new System.Drawing.Size(16, 16);
this.IconClose.TabIndex = 1;
this.IconClose.TabStop = false;
this.IconClose.Click += new System.EventHandler(this.IconClose_Click);
//
// panel1
//
this.panel1.BackgroundImage = global::AIProofread.Properties.Resources.form_bg;
@ -72,6 +60,18 @@
this.panel1.TabIndex = 3;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
//
// IconClose
//
this.IconClose.BackColor = System.Drawing.Color.Transparent;
this.IconClose.Cursor = System.Windows.Forms.Cursors.Hand;
this.IconClose.Image = global::AIProofread.Properties.Resources.icon_close;
this.IconClose.Location = new System.Drawing.Point(350, 15);
this.IconClose.Name = "IconClose";
this.IconClose.Size = new System.Drawing.Size(16, 16);
this.IconClose.TabIndex = 1;
this.IconClose.TabStop = false;
this.IconClose.Click += new System.EventHandler(this.IconClose_Click);
//
// label1
//
this.label1.AutoSize = true;
@ -137,11 +137,12 @@
this.Controls.Add(this.BtnClose);
this.Controls.Add(this.BtnConfirm);
this.Name = "FormMessage";
this.ShowIcon = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "FormMessage";
((System.ComponentModel.ISupportInitialize)(this.IconClose)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.IconClose)).EndInit();
this.ResumeLayout(false);
}

View File

@ -72,6 +72,7 @@ namespace AIProofread.Controls
public void HideCloseBtn()
{
BtnClose.Visible = false;
LblMeesage.Location = new System.Drawing.Point(LblMeesage.Location.X, LblMeesage.Location.Y + ScaleSize(30));
}
public static FormMessage ShowMessage(string message, int closeDelay = 3000)

View File

@ -118,19 +118,22 @@ namespace AIProofread.Model
public void ShowMessage(string message, int closeDelay,bool showCloseBtn = true)
{
var msgForm = FormMessage.ShowMessage(message, closeDelay);
if (!showCloseBtn)
{
msgForm.HideCloseBtn();
}
// n毫秒后自动关闭
System.Threading.Tasks.Task.Delay(closeDelay).ContinueWith(t =>
{
if(msgForm.IsDisposed) return;
TaskPane.Control.BeginInvoke(new Action(() =>
if(closeDelay > 0){
if (!showCloseBtn)
{
msgForm.Close();
}));
});
msgForm.HideCloseBtn();
}
// n毫秒后自动关闭
System.Threading.Tasks.Task.Delay(closeDelay).ContinueWith(t =>
{
if (msgForm.IsDisposed) return;
TaskPane.Control.BeginInvoke(new Action(() =>
{
msgForm.Close();
}));
});
}
}
public void ShowLogin(string action)

View File

@ -18,6 +18,7 @@ namespace AIProofread
{
private bool IS_LOGIN = false;
private static bool IS_WPS = false;
private Userinfo currentLoginUserinfo;
private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
@ -97,6 +98,7 @@ namespace AIProofread
public void ProcessLoginInfo(Userinfo userinfo)
{
if (userinfo == null) return;
currentLoginUserinfo = userinfo;
// 登录状态
IS_LOGIN = true;
// 切换登录状态
@ -128,7 +130,9 @@ namespace AIProofread
public void ProcessLogout()
{
IS_LOGIN = false;
currentLoginUserinfo = null;
ToggleLogin();
Globals.ThisAddIn.HideAllPanel();
}
// 处理是否登录的展示
@ -151,9 +155,14 @@ namespace AIProofread
// 注销登录
private void btnLogout_Click(object sender, RibbonControlEventArgs e)
{
Globals.ThisAddIn.ActiveDocument.ShowDialog(currentLoginUserinfo.phone + " 退出AI校对王", "确定", "logout");
//Globals.ThisAddIn.ShowDialog("退出AI校对王",)
// 注销吧
Bridge.bridge.Logout(null);
Globals.ThisAddIn.HideAllPanel();
//Bridge.bridge.Logout(null);
//Globals.ThisAddIn.HideAllPanel();
//Globals.ThisAddIn.SendMessageToWeb("confirm-logout", null);
}

View File

@ -536,7 +536,7 @@ namespace AIProofread
}
catch (Exception)
{
Globals.ThisAddIn.ShowDialog("导出勘误表失败", null, null);
Globals.ThisAddIn.ShowDialog("导出勘误表失败,请重试", null, null);
}
}
@ -754,7 +754,8 @@ namespace AIProofread
// 保存到文件
book.Write(fs);
Globals.ThisAddIn.ShowMessage("导出成功", 3000);
//Globals.ThisAddIn.ShowMessage("导出成功", 3000);
Globals.ThisAddIn.ActiveDocument?.ShowMessage("导出勘误表成功", 3000, false);
}
}

124
updater/BaseWinForm.cs Normal file
View File

@ -0,0 +1,124 @@
using AntdUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace updater
{
public class BaseWinForm : Form
{
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("Gdi32.dll", EntryPoint = "CreateRoundRectRgn")]
private static extern IntPtr CreateRoundRectRgn(
int nLeftRect, // x-coordinate of upper-left corner
int nTopRect, // y-coordinate of upper-left corner
int nRightRect, // x-coordinate of lower-right corner
int nBottomRect, // y-coordinate of lower-right corner
int nWidthEllipse, // height of ellipse
int nHeightEllipse // width of ellipse
);
[DllImport("dwmapi.dll")]
public static extern int DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMarInset);
[DllImport("dwmapi.dll")]
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
[DllImport("dwmapi.dll")]
public static extern int DwmIsCompositionEnabled(ref int pfEnabled);
private bool m_aeroEnabled; // variables for box shadow
private const int CS_DROPSHADOW = 0x00020000;
private const int WM_NCPAINT = 0x0085;
private const int WM_ACTIVATEAPP = 0x001C;
public struct MARGINS // struct for box shadow
{
public int leftWidth;
public int rightWidth;
public int topHeight;
public int bottomHeight;
}
private const int WM_NCHITTEST = 0x84; // variables for dragging the form
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override CreateParams CreateParams
{
get
{
m_aeroEnabled = CheckAeroEnabled();
CreateParams cp = base.CreateParams;
if (!m_aeroEnabled)
cp.ClassStyle |= CS_DROPSHADOW;
return cp;
}
}
private bool CheckAeroEnabled()
{
if (Environment.OSVersion.Version.Major >= 6)
{
int enabled = 0;
DwmIsCompositionEnabled(ref enabled);
return (enabled == 1) ? true : false;
}
return false;
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
switch (m.Msg)
{
//阴影
case WM_NCPAINT:
if (m_aeroEnabled)
{
var v = 2;
DwmSetWindowAttribute(this.Handle, 2, ref v, 4);
MARGINS margins = new MARGINS()
{
bottomHeight = 1,
leftWidth = 1,
rightWidth = 1,
topHeight = 1
};
DwmExtendFrameIntoClientArea(this.Handle, ref margins);
}
break;
default:
break;
}
base.WndProc(ref m);
// 拖动
if (m.Msg == WM_NCHITTEST && (int)m.Result == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
}
public BaseWinForm()
{
m_aeroEnabled = false;
this.FormBorderStyle = FormBorderStyle.None;
}
protected void HandleMouseDownAndMove()
{
ReleaseCapture();
SendMessage(this.Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
}
}

View File

@ -31,47 +31,42 @@
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.LabelLog = new System.Windows.Forms.Label();
this.progressBar1 = new System.Windows.Forms.ProgressBar();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.ButtonProcess = new AntdUI.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.IconClose = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.IconClose)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// LabelLog
//
this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LabelLog.Location = new System.Drawing.Point(75, 24);
this.LabelLog.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.LabelLog.Location = new System.Drawing.Point(75, 57);
this.LabelLog.Name = "LabelLog";
this.LabelLog.Size = new System.Drawing.Size(254, 71);
this.LabelLog.TabIndex = 0;
this.LabelLog.Text = "正在检测。。。";
this.LabelLog.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.LabelLog.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
this.LabelLog.Click += new System.EventHandler(this.LabelLog_Click);
//
// progressBar1
//
this.progressBar1.Location = new System.Drawing.Point(29, 103);
this.progressBar1.Location = new System.Drawing.Point(29, 136);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(300, 14);
this.progressBar1.TabIndex = 3;
this.progressBar1.Visible = false;
//
// pictureBox1
//
this.pictureBox1.Image = global::updater.Properties.Resources.upgrade;
this.pictureBox1.Location = new System.Drawing.Point(29, 24);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(40, 40);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false;
//
// ButtonProcess
//
this.ButtonProcess.BackHover = System.Drawing.Color.FromArgb(((int)(((byte)(214)))), ((int)(((byte)(170)))), ((int)(((byte)(105)))));
this.ButtonProcess.DefaultBack = System.Drawing.Color.FromArgb(((int)(((byte)(201)))), ((int)(((byte)(160)))), ((int)(((byte)(99)))));
this.ButtonProcess.Font = new System.Drawing.Font("微软雅黑", 10F);
this.ButtonProcess.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255)))));
this.ButtonProcess.Location = new System.Drawing.Point(122, 125);
this.ButtonProcess.Location = new System.Drawing.Point(122, 158);
this.ButtonProcess.Name = "ButtonProcess";
this.ButtonProcess.Radius = 4;
this.ButtonProcess.Size = new System.Drawing.Size(136, 44);
@ -79,12 +74,58 @@
this.ButtonProcess.Text = "继续";
this.ButtonProcess.Click += new System.EventHandler(this.ButtonProcess_Click);
//
// panel1
//
this.panel1.BackgroundImage = global::updater.Properties.Resources.form_bg;
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.panel1.Controls.Add(this.IconClose);
this.panel1.Controls.Add(this.label1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(380, 46);
this.panel1.TabIndex = 7;
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panel1_MouseDown);
//
// IconClose
//
this.IconClose.BackColor = System.Drawing.Color.Transparent;
this.IconClose.Cursor = System.Windows.Forms.Cursors.Hand;
this.IconClose.Image = global::updater.Properties.Resources.icon_close;
this.IconClose.Location = new System.Drawing.Point(350, 15);
this.IconClose.Name = "IconClose";
this.IconClose.Size = new System.Drawing.Size(16, 16);
this.IconClose.TabIndex = 1;
this.IconClose.TabStop = false;
this.IconClose.Click += new System.EventHandler(this.IconClose_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label1.Location = new System.Drawing.Point(11, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(74, 21);
this.label1.TabIndex = 0;
this.label1.Text = "温馨提示";
//
// pictureBox1
//
this.pictureBox1.Image = global::updater.Properties.Resources.upgrade;
this.pictureBox1.Location = new System.Drawing.Point(29, 72);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(40, 40);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(364, 177);
this.ClientSize = new System.Drawing.Size(380, 216);
this.Controls.Add(this.panel1);
this.Controls.Add(this.ButtonProcess);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.progressBar1);
@ -98,6 +139,9 @@
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AI校对王更新";
this.Load += new System.EventHandler(this.Form1_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.IconClose)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
@ -109,6 +153,9 @@
private System.Windows.Forms.ProgressBar progressBar1;
private System.Windows.Forms.PictureBox pictureBox1;
private AntdUI.Button ButtonProcess;
private System.Windows.Forms.PictureBox IconClose;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Label label1;
}
}

View File

@ -15,7 +15,7 @@ using System.Windows.Forms;
namespace updater
{
public partial class Form1 : Form
public partial class Form1 : BaseWinForm
{
private UpgradeInfo localVersion;
private UpgradeInfo upgradeInfo;
@ -330,5 +330,16 @@ namespace updater
}
}
private void IconClose_Click(object sender, EventArgs e)
{
this.Close();
Application.Exit();
}
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
HandleMouseDownAndMove();
}
}
}

View File

@ -60,6 +60,26 @@ namespace updater.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap form_bg {
get {
object obj = ResourceManager.GetObject("form_bg", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap icon_close {
get {
object obj = ResourceManager.GetObject("icon_close", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>

View File

@ -121,4 +121,10 @@
<data name="upgrade" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\upgrade.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="form_bg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\form_bg.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon_close" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon_close.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 399 B

View File

@ -88,6 +88,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AppConfig.cs" />
<Compile Include="BaseWinForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
@ -131,6 +134,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="av802-h1xg6-001.ico" />
<None Include="Resources\icon_close.png" />
<None Include="Resources\form_bg.png" />
<None Include="Resources\upgrade.png" />
</ItemGroup>
<ItemGroup>