GenerateParams.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. using static System.Net.WebRequestMethods;
  14. namespace Welling_Motor_Debug_Tool
  15. {
  16. public partial class GenerateParams : Form
  17. {
  18. //存储路径文件
  19. LocalInfo localInfo = new LocalInfo();
  20. //服务器配置
  21. string IP, Port, User, PassWD, ModelPath;
  22. //FTP
  23. ftp myFtp = new ftp();
  24. public GenerateParams()
  25. {
  26. InitializeComponent();
  27. }
  28. private void GenerateParams_Load(object sender, EventArgs e)
  29. {
  30. //导入网络配置
  31. if (System.IO.File.Exists(localInfo.LocalPath + localInfo.ConfigFileName)) //存在配置文件,导入配置信息
  32. {
  33. //打开文件
  34. StreamReader objReader = new StreamReader(localInfo.LocalPath + localInfo.ConfigFileName);
  35. string sLine = "";
  36. ArrayList array_CfgInfo = new ArrayList();
  37. array_CfgInfo.Clear();
  38. while (sLine != null)
  39. {
  40. sLine = objReader.ReadLine();
  41. array_CfgInfo.Add(sLine);
  42. }
  43. objReader.Close();
  44. //解析配置文件
  45. try
  46. {
  47. //Server Set IP, Port, User, PassWS, ModelPath;
  48. IP = array_CfgInfo[12].ToString().Split(':')[1];
  49. Port = array_CfgInfo[13].ToString().Split(':')[1];
  50. User = array_CfgInfo[14].ToString().Split(':')[1];
  51. PassWD = array_CfgInfo[15].ToString().Split(':')[1];
  52. ModelPath = "ParamsMode";
  53. myFtp.FtpOption(IP, Port, User, PassWD);
  54. }
  55. catch (System.Exception)
  56. {
  57. MessageBox.Show("参数格式错误,写入默认值!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  58. }
  59. }
  60. else
  61. {
  62. MessageBox.Show("参数文件丢失!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  63. this.Close();
  64. }
  65. //检查网络
  66. if (myFtp.CheckFtp() == false)
  67. {
  68. label_Server_ComStatus.Text = "网络已断开";
  69. label_ServerStatus.BackColor = Color.Red;
  70. MessageBox.Show("网络断开!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  71. }
  72. else
  73. {
  74. label_Server_ComStatus.Text = "网络已连接";
  75. label_ServerStatus.BackColor = Color.Green;
  76. }
  77. //加载模板文件
  78. string[] FileList = { "" };
  79. FileList = myFtp.GetFileNameList(ModelPath);
  80. comboBox_ModelFile.Items.Clear();
  81. foreach (var file in FileList)
  82. {
  83. if (file.Contains(".src"))
  84. {
  85. comboBox_ModelFile.Items.Add(file.Substring(file.LastIndexOf("\\") + 1));
  86. }
  87. }
  88. }
  89. private void radioButton_Simple_Click(object sender, EventArgs e)
  90. {
  91. tabPage_Simple.Select();
  92. }
  93. private void radioButton_Advance_Click(object sender, EventArgs e)
  94. {
  95. tabPage_Advance.Select();
  96. }
  97. private void comboBox_ModelFile_SelectedIndexChanged(object sender, EventArgs e)
  98. {
  99. tabControl1.Enabled = true;
  100. radioButton_Simple.Enabled = true;
  101. radioButton_Advance.Enabled = true;
  102. button_ExportParams.Enabled = true;
  103. //加载文件
  104. do //基础参数界面
  105. {
  106. } while (false);
  107. do //高级参数界面
  108. {
  109. } while (false);
  110. }
  111. private void button_GenerateModelFile_Click(object sender, EventArgs e)
  112. {
  113. //填写文件名
  114. Scan ModeFileName = new Scan();
  115. ModeFileName.ShowDialog();
  116. if (ModeFileName.textBox_Scan.Text == string.Empty)
  117. {
  118. MessageBox.Show("文件名为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  119. return;
  120. }
  121. string fileName = ModeFileName.textBox_Scan.Text;
  122. //核对文件名格式
  123. }
  124. private void button_ExportParams_Click(object sender, EventArgs e)
  125. {
  126. }
  127. }
  128. }