修复代码警告:1. 简化对象初始化 2. 设置只读字段

This commit is contained in:
zqm
2025-10-30 15:51:42 +08:00
parent 63ebe4faa1
commit 3c14188938
4 changed files with 8 additions and 10 deletions

View File

@@ -118,8 +118,7 @@ namespace JoyD.Windows.CS.Toprie
using (Font font = new Font("Arial", 48, FontStyle.Bold))
using (SolidBrush textBrush = new SolidBrush(textColor))
{
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
StringFormat format = new StringFormat() { Alignment = StringAlignment.Center };
// 将主文本居中显示
g.DrawString(text, font, textBrush,
@@ -155,8 +154,7 @@ namespace JoyD.Windows.CS.Toprie
using (Font font = new Font("Arial", 48, FontStyle.Bold))
using (SolidBrush textBrush = new SolidBrush(textColor))
{
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
StringFormat format = new StringFormat() { Alignment = StringAlignment.Center };
// 将主文本居中显示
g.DrawString(text, font, textBrush,

View File

@@ -182,7 +182,7 @@ namespace JoyD.Windows.CS.Toprie
// 是否已释放
private bool _isDisposed = false;
// 图像模式
private ImageMode _currentImageMode = ImageMode.Infrared;
private readonly ImageMode _currentImageMode = ImageMode.Infrared;
// 当前色彩模式
private PaletteType _currentPaletteType = PaletteType.WhiteHot;
// 当前视频模式

View File

@@ -69,8 +69,7 @@ namespace JoyD.Windows.CS.Toprie
// 启动工作线程
_isRunning = true;
_workerThread = new Thread(ProcessRequests);
_workerThread.IsBackground = true;
_workerThread = new Thread(ProcessRequests) { IsBackground = true };
_workerThread.Start();
Console.WriteLine("UDP通信管理器已初始化");

View File

@@ -1129,9 +1129,10 @@ namespace JoyD.Windows.CS.Toprie
if (SendCommand(command, out string response))
{
// 创建默认的ImagePos对象
SharedStructures.ImagePos data = new SharedStructures.ImagePos();
data.area = new SharedStructures.AreaPos[6];
data.spot = new SharedStructures.SpotPos[6];
SharedStructures.ImagePos data = new SharedStructures.ImagePos() {
area = new SharedStructures.AreaPos[6],
spot = new SharedStructures.SpotPos[6]
};
// 这里应该解析完整的响应数据
// 简化实现,返回默认值