Пример #1
0
 // save to json
 public void SaveConfig()
 {
     try
     {
         TranslateOverlayConfig config = new TranslateOverlayConfig();
         config.translateAPIKey = TRANSLATE_API_KEY;
         config.ocrAPIKey       = OCR_API_KEY;
         config.language        = language;
         string data = JsonConvert.SerializeObject(config);
         System.IO.File.WriteAllText(CONFIG_DATA_PATH, data);
     }catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }
Пример #2
0
 public void LoadConfig()
 {
     if (System.IO.File.Exists(CONFIG_DATA_PATH))
     {
         try
         {
             string data = System.IO.File.ReadAllText(CONFIG_DATA_PATH);
             TranslateOverlayConfig config = JsonConvert.DeserializeObject <TranslateOverlayConfig>(data);
             OCR_API_KEY              = config.ocrAPIKey;
             TRANSLATE_API_KEY        = config.translateAPIKey;
             language                 = config.language;
             ocrKeyTextbox.Text       = OCR_API_KEY;
             translateKeyTextBox.Text = TRANSLATE_API_KEY;
             languageTextbox.Text     = language;
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
             MessageBox.Show(e.Message);
         }
     }
 }