123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Configuration;
- using System.Data;
- using System.Drawing;
- using System.Net;
- using System.Text;
- using System.Windows.Forms;
- using DevComponents.DotNetBar;
- using parkMonitor.LOG;
- namespace centralController
- {
- public partial class FormSysConfig : DevComponents.DotNetBar.OfficeForm
- {
- public FormSysConfig()
- {
- InitializeComponent();
- tb_garageID.Text = Monitor.Monitor.garageID.ToString();
- tb_defaultLic.Text = Monitor.Monitor.defaultLic;
- lbx_logAddress.Text = "当前日志路径:"+ LogManager.logAddress;
- lbx_advertAddress.Text = "当前广告路径:" +Monitor.Monitor.advertPath;
- }
- private void cb_nmIP_DropDown(object sender, EventArgs e)
- {
- cb_nmIP.Items.Clear();
- Dictionary<string, int>.Enumerator enumer = Monitor.Monitor.numMachineLinker.GetIpIdMap().GetEnumerator();
- while (enumer.MoveNext())
- {
- cb_nmIP.Items.Add(enumer.Current.Key);
- }
- }
- /// <summary>
- /// 查询号牌机当前IP
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnx_nmSearch_Click(object sender, EventArgs e)
- {
- string selectedIP = (string)cb_nmIP.SelectedItem;
- Dictionary<string, int> dictionary = Monitor.Monitor.numMachineLinker.GetIpIdMap();
- if (dictionary != null && selectedIP != null)
- {
- int id=0;
- bool result = dictionary.TryGetValue(selectedIP, out id);
- if (result)
- tb_nmId.Text = id.ToString();
- else
- MessageBox.Show("未能找到该IP对应的号牌机ID", "查询失败");
- }
- else
- MessageBox.Show("当前未识别到号牌机", "查询失败");
- }
- /// <summary>
- /// 修改号牌机对应IP
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnx_nmIdAlter_Click(object sender, EventArgs e)
- {
- string selectedIP = (string)cb_nmIP.SelectedItem;
- if (selectedIP == null)
- {
- MessageBox.Show("未选择IP", "修改失败");
- return;
- }
- else
- {
- int id=0;
- if (int.TryParse(tb_nmId.Text, out id))
- {
- ConfigurationManager.AppSettings.Set(selectedIP, tb_nmId.Text);
- ConfModify(selectedIP, tb_nmId.Text);
- MessageBox.Show("修改ip " + selectedIP + "对应id为" + tb_nmId.Text + "\n编号将在重启后生效", "修改成功");
- }
- else
- {
- MessageBox.Show("识别到id并非整型数字", "修改失败");
- }
- }
- }
- /// <summary>
- /// 修改号牌筛选比例
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnx_nmRatioConfirm_Click(object sender, EventArgs e)
- {
- int ratio = sld_nmfilterRatio.Value / 10 * 10;
- Monitor.Monitor.numMachineLinker.SetRatio((ratio / 100.0));
- ConfModify("filterRatio", (ratio / 100.0).ToString());
- MessageBox.Show("号牌筛选比例已修改为" + (ratio / 100.0).ToString(), "修改成功");
- }
- /// <summary>
- /// 保存配置文件修改
- /// </summary>
- /// <param name="key"></param>
- /// <param name="value"></param>
- private void ConfModify(string key, string value)
- {
- Configuration conf = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
- if (conf.AppSettings.Settings[key] != null)
- conf.AppSettings.Settings[key].Value = value;
- //else
- // conf.AppSettings.Settings.Add(key, value);
- conf.Save(ConfigurationSaveMode.Modified);
- }
- /// <summary>
- /// 实时显示slider值
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void sld_nmfilterRatio_ValueChanged(object sender, EventArgs e)
- {
- sld_nmfilterRatio.Text = "号牌筛选比例:" +(sld_nmfilterRatio.Value/10*10)/100.0;
- }
- private void btnx_alterLogAddress_Click(object sender, EventArgs e)
- {
- }
- private void btnx_alterGarageId_Click(object sender, EventArgs e)
- {
- try
- {
- Monitor.Monitor.garageID = int.Parse(tb_garageID.Text);
- }
- catch { MessageBox.Show("请输入数字"); }
- }
- private void btnx_alterDefaultLic_Click(object sender, EventArgs e)
- {
- }
- }
- }
|