private void ShowApiSecurityInfo() { FrmInput frm = new FrmInput(); frm.ShowDialog(); if (frm.IsSubmit == true) { ApiSecurityInfo toAdd = new ApiSecurityInfo() { ApiID = frm.ApiID, ApiKey = frm.ApiKey, SecretKey = frm.SecretKey }; string jsonStr = string.Empty; if (System.IO.File.Exists(App.FullName)) { jsonStr = System.IO.File.ReadAllText(App.FullName); } List <ApiSecurityInfo> list = Util.JsonUtils.DeserializeObject <List <ApiSecurityInfo> >(jsonStr); if (list == null || list.Count <= 0) { list = new List <ApiSecurityInfo>(); list.Add(toAdd); } else { if (list.Exists(i => i.Equals(toAdd)) == false) { list.Add(toAdd); } } jsonStr = Util.JsonUtils.SerializeObject(list); System.IO.File.WriteAllText(App.FullName, jsonStr); initData(); } else { initData(); } }
private void CbxBaiduApiKey_SelectionChanged(object sender, SelectionChangedEventArgs e) { ApiSecurityInfo selected = cbxBaiduApiKey.SelectedItem as ApiSecurityInfo; OCRUtils_Baidu.SetBaiduKey(selected); }