FormSysConfig.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Configuration;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Net;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using DevComponents.DotNetBar;
  11. using parkMonitor.LOG;
  12. namespace centralController
  13. {
  14. public partial class FormSysConfig : DevComponents.DotNetBar.OfficeForm
  15. {
  16. public FormSysConfig()
  17. {
  18. InitializeComponent();
  19. tb_garageID.Text = Monitor.Monitor.garageID.ToString();
  20. tb_defaultLic.Text = Monitor.Monitor.defaultLic;
  21. lbx_logAddress.Text = "当前日志路径:"+ LogManager.logAddress;
  22. lbx_advertAddress.Text = "当前广告路径:" +Monitor.Monitor.advertPath;
  23. }
  24. private void cb_nmIP_DropDown(object sender, EventArgs e)
  25. {
  26. cb_nmIP.Items.Clear();
  27. Dictionary<string, int>.Enumerator enumer = Monitor.Monitor.numMachineLinker.GetIpIdMap().GetEnumerator();
  28. while (enumer.MoveNext())
  29. {
  30. cb_nmIP.Items.Add(enumer.Current.Key);
  31. }
  32. }
  33. /// <summary>
  34. /// 查询号牌机当前IP
  35. /// </summary>
  36. /// <param name="sender"></param>
  37. /// <param name="e"></param>
  38. private void btnx_nmSearch_Click(object sender, EventArgs e)
  39. {
  40. string selectedIP = (string)cb_nmIP.SelectedItem;
  41. Dictionary<string, int> dictionary = Monitor.Monitor.numMachineLinker.GetIpIdMap();
  42. if (dictionary != null && selectedIP != null)
  43. {
  44. int id=0;
  45. bool result = dictionary.TryGetValue(selectedIP, out id);
  46. if (result)
  47. tb_nmId.Text = id.ToString();
  48. else
  49. MessageBox.Show("未能找到该IP对应的号牌机ID", "查询失败");
  50. }
  51. else
  52. MessageBox.Show("当前未识别到号牌机", "查询失败");
  53. }
  54. /// <summary>
  55. /// 修改号牌机对应IP
  56. /// </summary>
  57. /// <param name="sender"></param>
  58. /// <param name="e"></param>
  59. private void btnx_nmIdAlter_Click(object sender, EventArgs e)
  60. {
  61. string selectedIP = (string)cb_nmIP.SelectedItem;
  62. if (selectedIP == null)
  63. {
  64. MessageBox.Show("未选择IP", "修改失败");
  65. return;
  66. }
  67. else
  68. {
  69. int id=0;
  70. if (int.TryParse(tb_nmId.Text, out id))
  71. {
  72. ConfigurationManager.AppSettings.Set(selectedIP, tb_nmId.Text);
  73. ConfModify(selectedIP, tb_nmId.Text);
  74. MessageBox.Show("修改ip " + selectedIP + "对应id为" + tb_nmId.Text + "\n编号将在重启后生效", "修改成功");
  75. }
  76. else
  77. {
  78. MessageBox.Show("识别到id并非整型数字", "修改失败");
  79. }
  80. }
  81. }
  82. /// <summary>
  83. /// 修改号牌筛选比例
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. private void btnx_nmRatioConfirm_Click(object sender, EventArgs e)
  88. {
  89. int ratio = sld_nmfilterRatio.Value / 10 * 10;
  90. Monitor.Monitor.numMachineLinker.SetRatio((ratio / 100.0));
  91. ConfModify("filterRatio", (ratio / 100.0).ToString());
  92. MessageBox.Show("号牌筛选比例已修改为" + (ratio / 100.0).ToString(), "修改成功");
  93. }
  94. /// <summary>
  95. /// 保存配置文件修改
  96. /// </summary>
  97. /// <param name="key"></param>
  98. /// <param name="value"></param>
  99. private void ConfModify(string key, string value)
  100. {
  101. Configuration conf = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
  102. if (conf.AppSettings.Settings[key] != null)
  103. conf.AppSettings.Settings[key].Value = value;
  104. //else
  105. // conf.AppSettings.Settings.Add(key, value);
  106. conf.Save(ConfigurationSaveMode.Modified);
  107. }
  108. /// <summary>
  109. /// 实时显示slider值
  110. /// </summary>
  111. /// <param name="sender"></param>
  112. /// <param name="e"></param>
  113. private void sld_nmfilterRatio_ValueChanged(object sender, EventArgs e)
  114. {
  115. sld_nmfilterRatio.Text = "号牌筛选比例:" +(sld_nmfilterRatio.Value/10*10)/100.0;
  116. }
  117. private void btnx_alterLogAddress_Click(object sender, EventArgs e)
  118. {
  119. }
  120. private void btnx_alterGarageId_Click(object sender, EventArgs e)
  121. {
  122. try
  123. {
  124. Monitor.Monitor.garageID = int.Parse(tb_garageID.Text);
  125. }
  126. catch { MessageBox.Show("请输入数字"); }
  127. }
  128. private void btnx_alterDefaultLic_Click(object sender, EventArgs e)
  129. {
  130. }
  131. }
  132. }