视觉修改
This commit is contained in:
		
							
								
								
									
										74
									
								
								Check.Main/UI/FormImageDisplay.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										74
									
								
								Check.Main/UI/FormImageDisplay.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,74 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.ComponentModel; | ||||
| using System.Data; | ||||
| using System.Drawing; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using System.Windows.Forms; | ||||
| using WeifenLuo.WinFormsUI.Docking; | ||||
|  | ||||
| namespace Check.Main.UI | ||||
| { | ||||
|     public partial class FormImageDisplay : DockContent | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// 相机名称 | ||||
|         /// </summary> | ||||
|         public string CameraName { get; set; } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 当此显示窗口发生特定事件时(如ROI裁剪),触发此事件以通知外部(如日志系统) | ||||
|         /// </summary> | ||||
|         public event Action<string> OnDisplayEvent; | ||||
|  | ||||
|         // 使用我们全新的自定义控件 | ||||
|         private ZoomPictureBox zoomPictureBox; | ||||
|         public FormImageDisplay() | ||||
|         { | ||||
|             InitializeComponent(); | ||||
|  | ||||
|             // 实例化新的控件 | ||||
|             zoomPictureBox = new ZoomPictureBox | ||||
|             { | ||||
|                 Dock = DockStyle.Fill, | ||||
|                 // 其他属性可以在这里设置,例如 | ||||
|                 // RectangleColor = Color.LawnGreen, | ||||
|                 // BackgroundFillColor = Color.FromArgb(45, 45, 48) | ||||
|             }; | ||||
|             this.Controls.Add(zoomPictureBox); | ||||
|  | ||||
|             // 订阅自定义控件的ROI裁剪完成事件 | ||||
|             zoomPictureBox.CroppingEnabled = false; | ||||
|             //zoomPictureBox.Cropped += ZoomPictureBox_Cropped; | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// 更新显示的图像(线程安全)。 | ||||
|         /// 此方法现在将图像设置到 ZoomPictureBox1 控件中。 | ||||
|         /// </summary> | ||||
|         /// <param name="image">从相机事件传来的原始Bitmap</param> | ||||
|         public void UpdateImage(Bitmap image) | ||||
|         { | ||||
|             if (zoomPictureBox != null && !zoomPictureBox.IsDisposed) | ||||
|             { | ||||
|                 zoomPictureBox.SetImageThreadSafe(image); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 // 如果PictureBox已经被释放,那么我们也应该释放这个多余的图像 | ||||
|                 image?.Dispose(); | ||||
|             } | ||||
|         } | ||||
|         // 重写 Close 方法,确保在窗口关闭时,内部的控件和资源也能被妥善处理 | ||||
|         public new void Close() | ||||
|         { | ||||
|             // 取消事件订阅,防止内存泄漏 | ||||
|             if (zoomPictureBox != null) | ||||
|             { | ||||
|                 //zoomPictureBox.Cropped -= ZoomPictureBox_Cropped; | ||||
|             } | ||||
|             base.Close(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user