private int _maxTry = 3; //最大嘗試次數 #endregion Fields #region Constructors public CCSLightControlForm() { InitializeComponent(); _configModel = ConfigHelper.GetConfigModel(); initLightControlSettings(); LightConnectTimer.Tick += LightConnectTimer_Tick; }
private void init() { _settings = ConfigHelper.GetConfigModel(); HeartBeatEnableCheckBox.Checked = _settings.HeartBeatEnable; HearbeatIntervalTextBox.Enabled = HeartBeatEnableCheckBox.Checked; HearbeatIntervalTextBox.Text = _settings.HeartBeatInterval.ToString(); CH1CheckBox.Checked = _settings.EnableChannels.Contains("00"); CH2CheckBox.Checked = _settings.EnableChannels.Contains("01"); CH3CheckBox.Checked = _settings.EnableChannels.Contains("02"); CH1CheckBox.CheckedChanged += new EventHandler(channelEnableChanged); CH2CheckBox.CheckedChanged += new EventHandler(channelEnableChanged); CH3CheckBox.CheckedChanged += new EventHandler(channelEnableChanged); }
public static CCSConfigSettingModel GetConfigModel() { var appSettings = ConfigurationManager.AppSettings; var heartBeatEnable = appSettings["HeartbeatEnabled"] ?? "false"; var heartBeatInterval = appSettings["HeartbeatInterval"] ?? "500"; var enabledChannels = appSettings["EnableChannels"] ?? "00"; var tryConnectionTimes = appSettings[""] ?? "3"; var timeout = appSettings["ConnectionTimeout"] ?? "500"; List<string> channels = new List<string>(); channels.AddRange(enabledChannels.Split(',')); CCSConfigSettingModel settings = new CCSConfigSettingModel() { HeartBeatEnable = Convert.ToBoolean(heartBeatEnable), HeartBeatInterval = Convert.ToInt32(heartBeatInterval), EnableChannels = channels, TryConnectionTimes = Convert.ToInt32(tryConnectionTimes), Timeout = Convert.ToInt32(timeout), }; return settings; }
private void SettingButton_Click(object sender, EventArgs e) { //Original var heartBeatEnable = _configModel.HeartBeatEnable; //var hearBeatInterval = _configModel.HeartBeatInterval; var form = new SettingForm(); form.ShowDialog(); _configModel = ConfigHelper.GetConfigModel(); initLightControlSettings(); }