From 8c8b5156647c6bb77faf3fe3cf62436df8ae7bd6 Mon Sep 17 00:00:00 2001 From: cyf Date: Mon, 22 Jun 2026 03:11:46 +0000 Subject: [PATCH] SVN r1224 SVN-Revision: r1224 --- .../Control/BackgroundPanel.Designer.cs | 4 + 插件库/Lskj.Main/Control/BackgroundPanel.cs | 49 +++++++ 插件库/Lskj.Main/Control/BackgroundPanel.resx | 123 ++++++++++++++++++ .../Control/MainPanelControlEx.Designer.cs | 22 ++-- 4 files changed, 187 insertions(+), 11 deletions(-) create mode 100644 插件库/Lskj.Main/Control/BackgroundPanel.Designer.cs create mode 100644 插件库/Lskj.Main/Control/BackgroundPanel.cs create mode 100644 插件库/Lskj.Main/Control/BackgroundPanel.resx diff --git a/插件库/Lskj.Main/Control/BackgroundPanel.Designer.cs b/插件库/Lskj.Main/Control/BackgroundPanel.Designer.cs new file mode 100644 index 0000000..7b5cf1f --- /dev/null +++ b/插件库/Lskj.Main/Control/BackgroundPanel.Designer.cs @@ -0,0 +1,4 @@ + +namespace Lskj.Main.Control +{ + partial \ No newline at end of file diff --git a/插件库/Lskj.Main/Control/BackgroundPanel.cs b/插件库/Lskj.Main/Control/BackgroundPanel.cs new file mode 100644 index 0000000..3f260b6 --- /dev/null +++ b/插件库/Lskj.Main/Control/BackgroundPanel.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Lskj.Main.Control +{ + public partial class BackgroundPanel :Panel + { + private Image _originalBackgroundImage; + + // 公开属性:设置/获取背景图片 + public Image BackgroundImageCustom + { + get => _originalBackgroundImage; + set + { + _originalBackgroundImage = value; + Invalidate(); // 设置图片后立即重绘 + } + } + + public BackgroundPanel() + { + // 关键设置:关闭Panel默认背景,启用双缓冲减少闪烁 + this.BackgroundImage = null; + this.DoubleBuffered = true; + this.SetStyle(ControlStyles.UserPaint | + ControlStyles.AllPaintingInWmPaint | + ControlStyles.OptimizedDoubleBuffer, true); + } + + // 重写OnPaint方法,手动绘制背景图 + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + // 图片为空时直接返回 + if (_originalBackgroundImage == null) return; + + // 1. 计算等比缩放比例(以Panel的ClientSize为基准) + float scaleX = (float)this.ClientSize.Width / _originalBackgroundImage.Width; + float scaleY = (float)this.ClientSize.Height / _originalBackgroundImage.Height; + float scale = Math.Min(scaleX, sc \ No newline at end of file diff --git a/插件库/Lskj.Main/Control/BackgroundPanel.resx b/插件库/Lskj.Main/Control/BackgroundPanel.resx new file mode 100644 index 0000000..e5858cc --- /dev/null +++ b/插件库/Lskj.Main/Control/BackgroundPanel.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + \ No newline at end of file diff --git a/插件库/Lskj.Main/Control/MainPanelControlEx.Designer.cs b/插件库/Lskj.Main/Control/MainPanelControlEx.Designer.cs index 5eff1b2..69cb405 100644 --- a/插件库/Lskj.Main/Control/MainPanelControlEx.Designer.cs +++ b/插件库/Lskj.Main/Control/MainPanelControlEx.Designer.cs @@ -75,7 +75,6 @@ this.panel6 = new System.Windows.Forms.Panel(); this.lblShortcutset = new System.Windows.Forms.Label(); this.pl_center_left = new System.Windows.Forms.Panel(); - this.tv_left = new Lskj.Main.Control.TreeViewCustom(); this.xtpWorktop = new DevExpress.XtraTab.XtraTabPage(); this.workSplitMainControl = new DevExpress.XtraEditors.SplitContainerControl(); this.workTopPanel = new System.Windows.Forms.Panel(); @@ -115,6 +114,7 @@ this.mark_timer = new System.Windows.Forms.Timer(); this.autoGridLookUpEdit1View = new DevExpress.XtraGrid.Views.Grid.GridView(); this.awaitScreenControl = new Lskj.Main.Control.AwaitScreenControl(); + this.tv_left = new Lskj.Main.Control.TreeViewCustom(); this.toolStrip1.SuspendLayout(); this.pl_center.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tabMain)).BeginInit(); @@ -629,16 +629,6 @@ this.pl_center_left.Size = new System.Drawing.Size(140, 584); this.pl_center_left.TabIndex = 0; // - // tv_left - // - this.tv_left.AutoScroll = true; - this.tv_left.BackColor = System.Drawing.Color.Transparent; - this.tv_left.Dock = System.Windows.Forms.DockStyle.Fill; - this.tv_left.Location = new System.Drawing.Point(4, 4); - this.tv_left.Name = "tv_left"; - this.tv_left.Size = new System.Drawing.Size(132, 576); - this.tv_left.TabIndex = 1; - // // xtpWorktop // this.xtpWorktop.Controls.Add(this.workSplitMainControl); @@ -1152,6 +1142,16 @@ this.awaitScreenControl.TabIndex = 0; this.awaitScreenControl.Visible = false; // + // tv_left + // + this.tv_left.AutoScroll = true; + this.tv_left.BackColor = System.Drawing.Color.Transparent; + this.tv_left.Dock = System.Windows.Forms.DockStyle.Fill; + this.tv_left.Location = new System.Drawing.Point(4, 4); + this.tv_left.Name = "tv_left"; + this.tv_left.Size = new System.Drawing.Size(132, 576); + this.tv_left.TabIndex = 1; + // // MainPanelControlEx // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;