using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; using static System.Net.WebRequestMethods; namespace Welling_Motor_Debug_Tool { public partial class GenerateParams : Form { //存储路径文件 LocalInfo localInfo = new LocalInfo(); //服务器配置 string IP, Port, User, PassWD, ModelPath; //FTP ftp myFtp = new ftp(); public GenerateParams() { InitializeComponent(); } private void GenerateParams_Load(object sender, EventArgs e) { //导入网络配置 if (System.IO.File.Exists(localInfo.LocalPath + localInfo.ConfigFileName)) //存在配置文件,导入配置信息 { //打开文件 StreamReader objReader = new StreamReader(localInfo.LocalPath + localInfo.ConfigFileName); string sLine = ""; ArrayList array_CfgInfo = new ArrayList(); array_CfgInfo.Clear(); while (sLine != null) { sLine = objReader.ReadLine(); array_CfgInfo.Add(sLine); } objReader.Close(); //解析配置文件 try { //Server Set IP, Port, User, PassWS, ModelPath; IP = array_CfgInfo[12].ToString().Split(':')[1]; Port = array_CfgInfo[13].ToString().Split(':')[1]; User = array_CfgInfo[14].ToString().Split(':')[1]; PassWD = array_CfgInfo[15].ToString().Split(':')[1]; ModelPath = "ParamsMode"; myFtp.FtpOption(IP, Port, User, PassWD); } catch (System.Exception) { MessageBox.Show("参数格式错误,写入默认值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("参数文件丢失!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); this.Close(); } //检查网络 if (myFtp.CheckFtp() == false) { label_Server_ComStatus.Text = "网络已断开"; label_ServerStatus.BackColor = Color.Red; MessageBox.Show("网络断开!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { label_Server_ComStatus.Text = "网络已连接"; label_ServerStatus.BackColor = Color.Green; } //加载模板文件 string[] FileList = { "" }; FileList = myFtp.GetFileNameList(ModelPath); comboBox_ModelFile.Items.Clear(); foreach (var file in FileList) { if (file.Contains(".src")) { comboBox_ModelFile.Items.Add(file.Substring(file.LastIndexOf("\\") + 1)); } } } private void radioButton_Simple_Click(object sender, EventArgs e) { tabPage_Simple.Select(); } private void radioButton_Advance_Click(object sender, EventArgs e) { tabPage_Advance.Select(); } private void comboBox_ModelFile_SelectedIndexChanged(object sender, EventArgs e) { tabControl1.Enabled = true; radioButton_Simple.Enabled = true; radioButton_Advance.Enabled = true; button_ExportParams.Enabled = true; //加载文件 do //基础参数界面 { } while (false); do //高级参数界面 { } while (false); } private void button_GenerateModelFile_Click(object sender, EventArgs e) { //填写文件名 Scan ModeFileName = new Scan(); ModeFileName.ShowDialog(); if (ModeFileName.textBox_Scan.Text == string.Empty) { MessageBox.Show("文件名为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string fileName = ModeFileName.textBox_Scan.Text; //核对文件名格式 } private void button_ExportParams_Click(object sender, EventArgs e) { } } }