| 3 | using WakaTime; |
| 4 | |
| 5 | public partial class SettingsForm: Window |
| 6 | { |
| 7 | internal event EventHandler ConfigSaved; |
| 8 | |
| 9 | public SettingsForm() |
| 10 | : base(WindowType.Toplevel) |
| 11 | { |
| 12 | Build(); |
| 13 | SettingsForm_Load(); |
| 14 | } |
| 15 | |
| 16 | void SettingsForm_Load() |
| 17 | { |
| 18 | try |
| 19 | { |
| 20 | txtAPIKey.Text = WakaTimeConfigFile.ApiKey; |
| 21 | txtProxy.Text = WakaTimeConfigFile.Proxy; |
| 22 | chkDebugMode.Active = WakaTimeConfigFile.Debug; |
| 23 | } |
| 24 | catch (Exception ex) |
| 25 | { |
| 26 | Logger.Error("Error when loading form SettingsForm:", ex); |
| 27 | MessageBox.Show(ex.Message); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | void OnDeleteEvent(object sender, DeleteEventArgs a) |
| 32 | { |
| 33 | a.RetVal = true; |
| 34 | Destroy(); |
| 35 | } |
| 36 | |
| 37 | void btnCancel_Clicked(object sender, EventArgs e) |
| 38 | { |
| 39 | Destroy(); |
| 40 | } |
| 41 | |
| 42 | void btnOK_Clicked(object sender, EventArgs e) |
| 43 | { |
| 44 | try |
| 45 | { |
| 46 | Guid apiKey; |
| 47 | var parse = Guid.TryParse(txtAPIKey.Text.Trim(), out apiKey); |
| 48 | |
| 49 | if (parse) |
| 50 | { |
| 51 | WakaTimeConfigFile.ApiKey = apiKey.ToString(); |
| 52 | WakaTimeConfigFile.Proxy = txtProxy.Text.Trim(); |
| 53 | WakaTimeConfigFile.Debug = chkDebugMode.Active; |
| 54 | WakaTimeConfigFile.Save(); |
| 55 | OnConfigSaved(); |
| 56 | Destroy(); |
| 57 | } |
| 58 | else |
| 59 | { |
| 60 | MessageBox.Show(@"Please enter valid Api Key."); // do not close dialog box |
| 61 | } |
| 62 | } |
nothing calls this directly
no outgoing calls
no test coverage detected