private void SetSetting(string setting, string value) { PropertyInfo? prop = GetProperty(setting); if (prop != null) { try { var changed = Convert.ChangeType(value, prop.PropertyType); prop?.SetValue(_settings, changed); } catch (Exception) { Console.WriteLine("Can't convert {0} to type {1}", value, prop.PropertyType); } AppSettingHandler.SaveAppSettings(_settings); } }
private void btnOK_Click(object sender, EventArgs e) { if (chkAutoDigits.Checked) { AppSettingHandler.ModifyConfig("DecimalDigits", (-1).ToString()); } else { try { AppSettingHandler.ModifyConfig("DecimalDigits", int.Parse(txtDigits.Text).ToString()); } catch { MessageBoxEx.Show("数字位数有误,请重新输入!"); return; } } MessageBoxEx.Show("修改成功!"); this.Close(); }
private bool NeedUpdate(string remoteVersion) { string localVersion = AppSettingHandler.ReadConfig("Version"); return(string.Compare(localVersion, remoteVersion) < 0); }