public MainForm() { InitializeComponent(); if (!Directory.Exists(BASE_PATH)) { Directory.CreateDirectory(BASE_PATH); } if (File.Exists(CONFIG_FILE)) { try { _config = Config.Parse(CONFIG_FILE); } catch (Exception e) { HandleError("Failed to parse _config, loading defaults:", e); _config = Config.Default(); _config.Save(CONFIG_FILE); } } else { _config = Config.Default(); _config.Save(CONFIG_FILE); MessageBox.Show($"You had no config; I created a default one for you.\r\nYou probably want to edit '{CONFIG_FILE}'.", "PonyShots4Win"); } _ponyShots = new PonyShots { UploadUrl = _config.UploadUrl, ImageBaseUrl = _config.BaseUrl, Username = _config.Username, ApiKey = _config.ApiKey }; _hotKeys = new HotKeys(Handle); _hotKeys.OnHotKey += this.OnHotKey; foreach (var k in new Keys[] {Keys.D2, Keys.D3, Keys.D4, Keys.D5}) { _hotKeys.RegisterHotKey(k, KeyModifier.Control | KeyModifier.Shift); } /* WinApi.RegisterHotKey(this.Handle, 0, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D2.GetHashCode()); WinApi.RegisterHotKey(this.Handle, 1, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D3.GetHashCode()); WinApi.RegisterHotKey(this.Handle, 2, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D4.GetHashCode()); WinApi.RegisterHotKey(this.Handle, 3, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D5.GetHashCode()); */ }
public MainForm() { InitializeComponent(); if (!Directory.Exists(BASE_PATH)) { Directory.CreateDirectory(BASE_PATH); } if (File.Exists(CONFIG_FILE)) { try { _config = Config.Parse(CONFIG_FILE); } catch (Exception e) { HandleError("Failed to parse _config, loading defaults:", e); _config = Config.Default(); _config.Save(CONFIG_FILE); } } else { _config = Config.Default(); _config.Save(CONFIG_FILE); MessageBox.Show($"You had no config; I created a default one for you.\r\nYou probably want to edit '{CONFIG_FILE}'.", "PonyShots4Win"); } _ponyShots = new PonyShots { UploadUrl = _config.UploadUrl, ImageBaseUrl = _config.BaseUrl, Username = _config.Username, ApiKey = _config.ApiKey }; _hotKeys = new HotKeys(Handle); _hotKeys.OnHotKey += this.OnHotKey; foreach (var k in new Keys[] { Keys.D2, Keys.D3, Keys.D4, Keys.D5 }) { _hotKeys.RegisterHotKey(k, KeyModifier.Control | KeyModifier.Shift); } /* * WinApi.RegisterHotKey(this.Handle, 0, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D2.GetHashCode()); * WinApi.RegisterHotKey(this.Handle, 1, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D3.GetHashCode()); * WinApi.RegisterHotKey(this.Handle, 2, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D4.GetHashCode()); * WinApi.RegisterHotKey(this.Handle, 3, ((int)KeyModifier.Control | (int)KeyModifier.Shift), Keys.D5.GetHashCode()); */ }