fix(winforms): release module grid resources

This commit is contained in:
2026-08-26 01:10:27 +08:00
parent 6cde5df2f2
commit 1e06682a12
8 changed files with 491 additions and 85 deletions
+91 -72
View File
@@ -7433,104 +7433,123 @@ namespace Lskj.PubBill
/// <param name="e">The <see cref="PaintEventArgs"/> instance containing the event data.</param>
private void OnLabelTitlePaint(object sender, PaintEventArgs e)
{
if (this._waterMark != null)
{
GraphicsText graphicsText = new GraphicsText();
graphicsText.Graphics = e.Graphics;
if (this._waterMark == null)
return;
// 绘制围绕点旋转的文本
StringFormat format = new StringFormat();
GraphicsText graphicsText = new GraphicsText();
graphicsText.Graphics = e.Graphics;
// Every paint can allocate native GDI handles. Keep all temporary drawing
// objects scoped to this paint so closing a module can release them.
using (StringFormat format = new StringFormat())
{
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
// 绘制单据状态文本
if (!string.IsNullOrEmpty(this._waterMark.Text))
{
if (Business.Impl.LanguageTranslation.Translatable)
using (Font font = new Font("宋体", 12, FontStyle.Bold))
using (SolidBrush brush = new SolidBrush(Color.Red))
{
graphicsText.DrawString(this._waterMark.Text, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF(50, 21), format, 0f);
// 测量文本实际尺寸(含字体和格式影响)
SizeF textSize = e.Graphics.MeasureString(this._waterMark.Text, new Font("宋体", 12, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format);
int rectWidth = (int)textSize.Width + 10;
int rectHeight = (int)textSize.Height + 5;
// 文本中心点是(50,21),计算边框左上角坐标(确保边框围绕文本居中)
int rectX = 50 - rectWidth / 2;
int rectY = 21 - rectHeight / 2;
graphicsText.DrawString(this._waterMark.Text, font, brush, new PointF(50, 21), format,
Business.Impl.LanguageTranslation.Translatable ? 0f : -15f);
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(rectX, rectY, rectWidth, 21));
if (Business.Impl.LanguageTranslation.Translatable)
{
SizeF textSize = e.Graphics.MeasureString(this._waterMark.Text, font,
new SizeF(float.MaxValue, float.MaxValue), format);
int rectWidth = (int)textSize.Width + 10;
int rectHeight = (int)textSize.Height + 5;
int rectX = 50 - rectWidth / 2;
int rectY = 21 - rectHeight / 2;
using (Pen pen = new Pen(Color.Red, 2f))
{
e.Graphics.DrawRectangle(pen, new Rectangle(rectX, rectY, rectWidth, 21));
}
}
else
{
e.Graphics.TranslateTransform(0, 0);
e.Graphics.RotateTransform(-15f);
using (Pen pen = new Pen(Color.Red, 2f))
{
e.Graphics.DrawRectangle(pen, new Rectangle(14, 20, 55, 21));
}
}
}
else
{
graphicsText.DrawString(this._waterMark.Text, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF(50, 21), format, -15f);
e.Graphics.TranslateTransform(0, 0);
e.Graphics.RotateTransform(-15f);
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(14, 20, 55, 21));
}
}
// 绘制打印次数文本
e.Graphics.ResetTransform();
if (!string.IsNullOrEmpty(this._waterMark.Print))
{
if (Business.Impl.LanguageTranslation.Translatable)
int x = this.lbTitle.Width - 70;
using (Font font = new Font("宋体", 11, FontStyle.Bold))
using (SolidBrush brush = new SolidBrush(Color.Red))
{
graphicsText.DrawString(this._waterMark.Print, new Font("宋体", 11, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 70), 21), format, 0f);
// 测量文本实际尺寸(含字体和格式影响)
SizeF textSize = e.Graphics.MeasureString(this._waterMark.Print, new Font("宋体", 11, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format);
int rectWidth = (int)textSize.Width + 10;
int rectHeight = (int)textSize.Height + 5;
// 文本中心点是(this.lbTitle.Width - 70,21),计算边框左上角坐标(确保边框围绕文本居中)
int rectX = (this.lbTitle.Width - 70) - rectWidth / 2;
int rectY = 21 - rectHeight / 2;
graphicsText.DrawString(this._waterMark.Print, font, brush, new PointF(x, 21), format,
Business.Impl.LanguageTranslation.Translatable ? 0f : -15f);
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(rectX, rectY, rectWidth, 21));
if (Business.Impl.LanguageTranslation.Translatable)
{
SizeF textSize = e.Graphics.MeasureString(this._waterMark.Print, font,
new SizeF(float.MaxValue, float.MaxValue), format);
int rectWidth = (int)textSize.Width + 10;
int rectHeight = (int)textSize.Height + 5;
int rectX = x - rectWidth / 2;
int rectY = 21 - rectHeight / 2;
using (Pen pen = new Pen(Color.Red, 2f))
{
e.Graphics.DrawRectangle(pen, new Rectangle(rectX, rectY, rectWidth, 21));
}
}
else
{
e.Graphics.TranslateTransform(x, 21);
e.Graphics.RotateTransform(-15f);
using (Pen pen = new Pen(Color.Red, 2f))
{
e.Graphics.DrawRectangle(pen, new Rectangle(-35, -14, 70, 21));
}
}
}
else
{
graphicsText.DrawString(this._waterMark.Print, new Font("宋体", 11, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 70), 21), format, -15f);
e.Graphics.TranslateTransform(this.lbTitle.Width - 70, 21);
e.Graphics.RotateTransform(-15f);
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(-35, -14, 70, 21));
}
}
// 绘制收款文本
e.Graphics.ResetTransform();
if (!string.IsNullOrEmpty(this._waterMark.Collect))
{
if (Business.Impl.LanguageTranslation.Translatable)
int x = this.lbTitle.Width - 170;
using (Font font = new Font("宋体", 12, FontStyle.Bold))
using (SolidBrush brush = new SolidBrush(Color.Red))
{
graphicsText.DrawString(this._waterMark.Collect, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 170), 21), format, 0f);
// 测量文本实际尺寸(含字体和格式影响)
SizeF textSize = e.Graphics.MeasureString(this._waterMark.Collect, new Font("宋体", 12, FontStyle.Bold), new SizeF(float.MaxValue, float.MaxValue), format);
int rectWidth = (int)textSize.Width + 10;
int rectHeight = (int)textSize.Height + 5;
// 文本中心点是(this.lbTitle.Width - 170,21),计算边框左上角坐标(确保边框围绕文本居中)
int rectX = (this.lbTitle.Width - 170) - rectWidth / 2;
int rectY = 21 - rectHeight / 2;
graphicsText.DrawString(this._waterMark.Collect, font, brush, new PointF(x, 21), format,
Business.Impl.LanguageTranslation.Translatable ? 0f : -15f);
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(rectX, rectY, rectWidth, 21));
if (Business.Impl.LanguageTranslation.Translatable)
{
SizeF textSize = e.Graphics.MeasureString(this._waterMark.Collect, font,
new SizeF(float.MaxValue, float.MaxValue), format);
int rectWidth = (int)textSize.Width + 10;
int rectHeight = (int)textSize.Height + 5;
int rectX = x - rectWidth / 2;
int rectY = 21 - rectHeight / 2;
using (Pen pen = new Pen(Color.Red, 2f))
{
e.Graphics.DrawRectangle(pen, new Rectangle(rectX, rectY, rectWidth, 21));
}
}
else
{
e.Graphics.TranslateTransform(this.lbTitle.Width - 100, 21);
e.Graphics.RotateTransform(-15f);
using (Pen pen = new Pen(Color.Red, 2f))
{
e.Graphics.DrawRectangle(pen, new Rectangle(-100, -32, 55, 21));
}
}
}
else
{
graphicsText.DrawString(this._waterMark.Collect, new Font("宋体", 12, FontStyle.Bold), new SolidBrush(Color.Red), new PointF((this.lbTitle.Width - 170), 21), format, -15f);
e.Graphics.TranslateTransform(this.lbTitle.Width - 100, 21);
e.Graphics.RotateTransform(-15f);
e.Graphics.DrawRectangle(new Pen(Color.Red, 2f), new Rectangle(-100, -32, 55, 21));
}
}
e.Graphics.ResetTransform();
}
}
/// <summary>