[+] 添加简陋的公告模块

存在高dpi缩放问题未处理
This commit is contained in:
huiyadanli 2023-04-09 15:30:28 +08:00
parent 3407aff012
commit 3a2ed08d67
5 changed files with 86 additions and 21 deletions

View File

@ -17,8 +17,9 @@ namespace RevokeMsgPatcher
{ {
Apps = AppConfig(), Apps = AppConfig(),
LatestVersion = "1.6", LatestVersion = "1.6",
PatchVersion = 20230330, PatchVersion = 20230331,
Notice = "" Notice = "",
NoticeUrl = "",
}; };
} }

View File

@ -61,7 +61,10 @@
this.lblCategory = new System.Windows.Forms.Label(); this.lblCategory = new System.Windows.Forms.Label();
this.panelCategories = new System.Windows.Forms.FlowLayoutPanel(); this.panelCategories = new System.Windows.Forms.FlowLayoutPanel();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.panelNotice = new System.Windows.Forms.Panel();
this.labelNotice = new System.Windows.Forms.Label();
this.menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
this.panelNotice.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// lblPathTag // lblPathTag
@ -183,7 +186,7 @@
this.rbtWechat.Location = new System.Drawing.Point(126, 54); this.rbtWechat.Location = new System.Drawing.Point(126, 54);
this.rbtWechat.Margin = new System.Windows.Forms.Padding(4); this.rbtWechat.Margin = new System.Windows.Forms.Padding(4);
this.rbtWechat.Name = "rbtWechat"; this.rbtWechat.Name = "rbtWechat";
this.rbtWechat.Size = new System.Drawing.Size(69, 22); this.rbtWechat.Size = new System.Drawing.Size(62, 22);
this.rbtWechat.TabIndex = 12; this.rbtWechat.TabIndex = 12;
this.rbtWechat.TabStop = true; this.rbtWechat.TabStop = true;
this.rbtWechat.Text = "微信"; this.rbtWechat.Text = "微信";
@ -196,7 +199,7 @@
this.rbtQQ.Location = new System.Drawing.Point(213, 54); this.rbtQQ.Location = new System.Drawing.Point(213, 54);
this.rbtQQ.Margin = new System.Windows.Forms.Padding(4); this.rbtQQ.Margin = new System.Windows.Forms.Padding(4);
this.rbtQQ.Name = "rbtQQ"; this.rbtQQ.Name = "rbtQQ";
this.rbtQQ.Size = new System.Drawing.Size(51, 22); this.rbtQQ.Size = new System.Drawing.Size(44, 22);
this.rbtQQ.TabIndex = 13; this.rbtQQ.TabIndex = 13;
this.rbtQQ.Text = "QQ"; this.rbtQQ.Text = "QQ";
this.rbtQQ.UseVisualStyleBackColor = true; this.rbtQQ.UseVisualStyleBackColor = true;
@ -208,7 +211,7 @@
this.rbtTIM.Location = new System.Drawing.Point(282, 54); this.rbtTIM.Location = new System.Drawing.Point(282, 54);
this.rbtTIM.Margin = new System.Windows.Forms.Padding(4); this.rbtTIM.Margin = new System.Windows.Forms.Padding(4);
this.rbtTIM.Name = "rbtTIM"; this.rbtTIM.Name = "rbtTIM";
this.rbtTIM.Size = new System.Drawing.Size(60, 22); this.rbtTIM.Size = new System.Drawing.Size(53, 22);
this.rbtTIM.TabIndex = 14; this.rbtTIM.TabIndex = 14;
this.rbtTIM.Text = "TIM"; this.rbtTIM.Text = "TIM";
this.rbtTIM.UseVisualStyleBackColor = true; this.rbtTIM.UseVisualStyleBackColor = true;
@ -230,7 +233,7 @@
this.rbtQQLite.Location = new System.Drawing.Point(356, 54); this.rbtQQLite.Location = new System.Drawing.Point(356, 54);
this.rbtQQLite.Margin = new System.Windows.Forms.Padding(4); this.rbtQQLite.Margin = new System.Windows.Forms.Padding(4);
this.rbtQQLite.Name = "rbtQQLite"; this.rbtQQLite.Name = "rbtQQLite";
this.rbtQQLite.Size = new System.Drawing.Size(105, 22); this.rbtQQLite.Size = new System.Drawing.Size(98, 22);
this.rbtQQLite.TabIndex = 18; this.rbtQQLite.TabIndex = 18;
this.rbtQQLite.Text = "QQ轻聊版"; this.rbtQQLite.Text = "QQ轻聊版";
this.rbtQQLite.UseVisualStyleBackColor = true; this.rbtQQLite.UseVisualStyleBackColor = true;
@ -238,7 +241,6 @@
// //
// menuStrip1 // menuStrip1
// //
this.menuStrip1.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2);
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24); this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem, this.ToolStripMenuItem,
@ -247,7 +249,7 @@
this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional;
this.menuStrip1.Size = new System.Drawing.Size(735, 32); this.menuStrip1.Size = new System.Drawing.Size(735, 25);
this.menuStrip1.TabIndex = 19; this.menuStrip1.TabIndex = 19;
this.menuStrip1.Text = "menuStrip1"; this.menuStrip1.Text = "menuStrip1";
// //
@ -258,13 +260,13 @@
this.ToolStripMenuItem, this.ToolStripMenuItem,
this.ToolStripMenuItem}); this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "高级ToolStripMenuItem"; this.ToolStripMenuItem.Name = "高级ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(62, 28); this.ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
this.ToolStripMenuItem.Text = "高级"; this.ToolStripMenuItem.Text = "高级";
// //
// 特征码防撤回强制ToolStripMenuItem // 特征码防撤回强制ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "特征码防撤回强制ToolStripMenuItem"; this.ToolStripMenuItem.Name = "特征码防撤回强制ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(290, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.ToolStripMenuItem.Text = "特征码防撤回(强制)"; this.ToolStripMenuItem.Text = "特征码防撤回(强制)";
this.ToolStripMenuItem.Visible = false; this.ToolStripMenuItem.Visible = false;
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
@ -272,7 +274,7 @@
// 手动输入补丁信息ToolStripMenuItem // 手动输入补丁信息ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "手动输入补丁信息ToolStripMenuItem"; this.ToolStripMenuItem.Name = "手动输入补丁信息ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(290, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.ToolStripMenuItem.Text = "手动输入补丁信息"; this.ToolStripMenuItem.Text = "手动输入补丁信息";
this.ToolStripMenuItem.Visible = false; this.ToolStripMenuItem.Visible = false;
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
@ -280,7 +282,7 @@
// 通用微信多开工具ToolStripMenuItem // 通用微信多开工具ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "通用微信多开工具ToolStripMenuItem"; this.ToolStripMenuItem.Name = "通用微信多开工具ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(290, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(196, 22);
this.ToolStripMenuItem.Text = "通用微信多开工具"; this.ToolStripMenuItem.Text = "通用微信多开工具";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
@ -292,34 +294,34 @@
this.ToolStripMenuItem, this.ToolStripMenuItem,
this.ToolStripMenuItem}); this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "帮助ToolStripMenuItem"; this.ToolStripMenuItem.Name = "帮助ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(62, 28); this.ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
this.ToolStripMenuItem.Text = "帮助"; this.ToolStripMenuItem.Text = "帮助";
// //
// 支持版本ToolStripMenuItem // 支持版本ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "支持版本ToolStripMenuItem"; this.ToolStripMenuItem.Name = "支持版本ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(200, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.ToolStripMenuItem.Text = "支持版本"; this.ToolStripMenuItem.Text = "支持版本";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
// 常见问题ToolStripMenuItem // 常见问题ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "常见问题ToolStripMenuItem"; this.ToolStripMenuItem.Name = "常见问题ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(200, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.ToolStripMenuItem.Text = "常见问题"; this.ToolStripMenuItem.Text = "常见问题";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
// 防撤回原理ToolStripMenuItem // 防撤回原理ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "防撤回原理ToolStripMenuItem"; this.ToolStripMenuItem.Name = "防撤回原理ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(200, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.ToolStripMenuItem.Text = "防撤回原理"; this.ToolStripMenuItem.Text = "防撤回原理";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
// 完整文档ToolStripMenuItem // 完整文档ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "完整文档ToolStripMenuItem"; this.ToolStripMenuItem.Name = "完整文档ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(200, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(136, 22);
this.ToolStripMenuItem.Text = "完整文档"; this.ToolStripMenuItem.Text = "完整文档";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
@ -329,20 +331,20 @@
this.ToolStripMenuItem, this.ToolStripMenuItem,
this.ToolStripMenuItem}); this.ToolStripMenuItem});
this.ToolStripMenuItem.Name = "关于ToolStripMenuItem"; this.ToolStripMenuItem.Name = "关于ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(62, 28); this.ToolStripMenuItem.Size = new System.Drawing.Size(44, 21);
this.ToolStripMenuItem.Text = "关于"; this.ToolStripMenuItem.Text = "关于";
// //
// 作者ToolStripMenuItem // 作者ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "作者ToolStripMenuItem"; this.ToolStripMenuItem.Name = "作者ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(270, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.ToolStripMenuItem.Text = "关于"; this.ToolStripMenuItem.Text = "关于";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
// 主页ToolStripMenuItem // 主页ToolStripMenuItem
// //
this.ToolStripMenuItem.Name = "主页ToolStripMenuItem"; this.ToolStripMenuItem.Name = "主页ToolStripMenuItem";
this.ToolStripMenuItem.Size = new System.Drawing.Size(270, 34); this.ToolStripMenuItem.Size = new System.Drawing.Size(124, 22);
this.ToolStripMenuItem.Text = "软件主页"; this.ToolStripMenuItem.Text = "软件主页";
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
@ -365,11 +367,31 @@
this.panelCategories.Size = new System.Drawing.Size(590, 27); this.panelCategories.Size = new System.Drawing.Size(590, 27);
this.panelCategories.TabIndex = 22; this.panelCategories.TabIndex = 22;
// //
// panelNotice
//
this.panelNotice.BackColor = System.Drawing.SystemColors.Info;
this.panelNotice.Controls.Add(this.labelNotice);
this.panelNotice.Location = new System.Drawing.Point(24, 260);
this.panelNotice.Name = "panelNotice";
this.panelNotice.Size = new System.Drawing.Size(690, 41);
this.panelNotice.TabIndex = 23;
//
// labelNotice
//
this.labelNotice.BackColor = System.Drawing.Color.Transparent;
this.labelNotice.ForeColor = System.Drawing.SystemColors.MenuHighlight;
this.labelNotice.Location = new System.Drawing.Point(17, 11);
this.labelNotice.Name = "labelNotice";
this.labelNotice.Size = new System.Drawing.Size(661, 20);
this.labelNotice.TabIndex = 0;
this.labelNotice.Text = "测试测试测试测试";
//
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(735, 254); this.ClientSize = new System.Drawing.Size(735, 254);
this.Controls.Add(this.panelNotice);
this.Controls.Add(this.panelCategories); this.Controls.Add(this.panelCategories);
this.Controls.Add(this.lblCategory); this.Controls.Add(this.lblCategory);
this.Controls.Add(this.rbtQQLite); this.Controls.Add(this.rbtQQLite);
@ -398,6 +420,7 @@
this.Load += new System.EventHandler(this.FormMain_Load); this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false); this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout(); this.menuStrip1.PerformLayout();
this.panelNotice.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -435,6 +458,8 @@
private System.Windows.Forms.Label lblCategory; private System.Windows.Forms.Label lblCategory;
private System.Windows.Forms.FlowLayoutPanel panelCategories; private System.Windows.Forms.FlowLayoutPanel panelCategories;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
private System.Windows.Forms.Panel panelNotice;
private System.Windows.Forms.Label labelNotice;
} }
} }

View File

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Text;
using System.Web.Script.Serialization; using System.Web.Script.Serialization;
using System.Windows.Forms; using System.Windows.Forms;
@ -298,6 +299,7 @@ namespace RevokeMsgPatcher
private async void FormMain_Load(object sender, EventArgs e) private async void FormMain_Load(object sender, EventArgs e)
{ {
InitNoticeControls(null);
// 异步获取最新的补丁信息 // 异步获取最新的补丁信息
string json = await HttpUtil.GetPatchJsonAsync(); string json = await HttpUtil.GetPatchJsonAsync();
//string json = null; // local test //string json = null; // local test
@ -332,7 +334,9 @@ namespace RevokeMsgPatcher
qqLiteModifier.Config = newBag.Apps["QQLite"]; qqLiteModifier.Config = newBag.Apps["QQLite"];
getPatchJsonStatus = "SUCCESS"; getPatchJsonStatus = "SUCCESS";
bag = newBag;
InitControls(); InitControls();
InitNoticeControls(newBag);
InitEditorsAndUI(txtPath.Text); InitEditorsAndUI(txtPath.Text);
} }
else if (newBag.PatchVersion <= bag.PatchVersion) else if (newBag.PatchVersion <= bag.PatchVersion)
@ -498,5 +502,38 @@ namespace RevokeMsgPatcher
} }
} }
} }
private void InitNoticeControls(Bag b)
{
labelNotice.Cursor = Cursors.Default;
panelNotice.Visible = false;
labelNotice.Visible = false;
if (b != null && !string.IsNullOrEmpty(b.Notice))
{
labelNotice.Text = b.Notice;
// 一行26个中文字 // TODO 这种计算方式并不精确而且高dpi缩放问题会导致很多问题
int height = (int)((Encoding.Default.GetByteCount(b.Notice) / 2 - 26) * 20 * 1.0 / 26);
labelNotice.Size = new Size(labelNotice.Size.Width, labelNotice.Size.Height + height);
panelNotice.Size = new Size(panelNotice.Size.Width, panelNotice.Size.Height + height);
this.Size = new Size(this.Size.Width, this.Size.Height + panelNotice.Size.Height + 20);
if (!string.IsNullOrEmpty(b.NoticeUrl))
{
labelNotice.Cursor = Cursors.Hand;
this.labelNotice.MouseClick += new MouseEventHandler(this.labelNotice_MouseClick);
}
panelNotice.Visible = true;
labelNotice.Visible = true;
}
}
private void labelNotice_MouseClick(object sender, MouseEventArgs e)
{
if (bag.NoticeUrl != null && bag.NoticeUrl.ToLower().StartsWith("http"))
{
Process.Start(bag.NoticeUrl);
}
}
} }
} }

View File

@ -14,6 +14,8 @@ namespace RevokeMsgPatcher.Model
public string Notice { get; set; } public string Notice { get; set; }
public string NoticeUrl { get; set; }
public int PatchVersion { get; set; } public int PatchVersion { get; set; }
} }
} }

File diff suppressed because one or more lines are too long