优化代码:简化对象初始化并内联变量声明,修复IDE提示问题
This commit is contained in:
@@ -3007,10 +3007,12 @@ namespace JoyD.Windows.CS
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 弹出打开文件对话框
|
// 弹出打开文件对话框
|
||||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
OpenFileDialog openFileDialog = new OpenFileDialog
|
||||||
openFileDialog.Filter = "CSV文件 (*.csv)|*.csv|所有文件 (*.*)|*.*";
|
{
|
||||||
openFileDialog.Title = "选择测温区信息文件";
|
Filter = "CSV文件 (*.csv)|*.csv|所有文件 (*.*)|*.*",
|
||||||
openFileDialog.DefaultExt = "csv";
|
Title = "选择测温区信息文件",
|
||||||
|
DefaultExt = "csv"
|
||||||
|
};
|
||||||
|
|
||||||
// 显示打开文件对话框,如果用户点击了确定按钮
|
// 显示打开文件对话框,如果用户点击了确定按钮
|
||||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
@@ -3038,17 +3040,13 @@ namespace JoyD.Windows.CS
|
|||||||
// 分割CSV行数据
|
// 分割CSV行数据
|
||||||
string[] parts = line.Split(',');
|
string[] parts = line.Split(',');
|
||||||
|
|
||||||
// 解析数据(支持中英文标题的CSV文件)
|
|
||||||
int x, y, width, height;
|
|
||||||
Color color;
|
|
||||||
|
|
||||||
if (parts.Length >= 6)
|
if (parts.Length >= 6)
|
||||||
{
|
{
|
||||||
// 尝试解析数据(索引可能是从文件中读取的,也可能是我们自己分配的)
|
// 尝试解析数据(索引可能是从文件中读取的,也可能是我们自己分配的)
|
||||||
int.TryParse(parts[1], out x);
|
int.TryParse(parts[1], out int x);
|
||||||
int.TryParse(parts[2], out y);
|
int.TryParse(parts[2], out int y);
|
||||||
int.TryParse(parts[3], out width);
|
int.TryParse(parts[3], out int width);
|
||||||
int.TryParse(parts[4], out height);
|
int.TryParse(parts[4], out int height);
|
||||||
|
|
||||||
// 解析颜色
|
// 解析颜色
|
||||||
try
|
try
|
||||||
@@ -3116,11 +3114,13 @@ namespace JoyD.Windows.CS
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 弹出保存文件对话框
|
// 弹出保存文件对话框
|
||||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
SaveFileDialog saveFileDialog = new SaveFileDialog
|
||||||
saveFileDialog.Filter = "CSV文件 (*.csv)|*.csv|所有文件 (*.*)|*.*";
|
{
|
||||||
saveFileDialog.Title = "保存测温区信息";
|
Filter = "CSV文件 (*.csv)|*.csv|所有文件 (*.*)|*.*",
|
||||||
saveFileDialog.DefaultExt = "csv";
|
Title = "保存测温区信息",
|
||||||
saveFileDialog.FileName = "测温区信息.csv";
|
DefaultExt = "csv",
|
||||||
|
FileName = "测温区信息.csv"
|
||||||
|
};
|
||||||
|
|
||||||
// 显示保存文件对话框,如果用户点击了确定按钮
|
// 显示保存文件对话框,如果用户点击了确定按钮
|
||||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
|||||||
Reference in New Issue
Block a user