private static void BindHotkeys() { _binder = new HotkeyBinder(); var hotkeySettings = new Dictionary<Type, SettingType> { [typeof(UserSelectionTemplate)] = SettingType.SelectAreaHotkey, [typeof(SelectWindowTemplate)] = SettingType.SelectWindowHotkey, [typeof(FullScreenTemplate)] = SettingType.FullscreenHotkey }; var failedHotkeys = new List<SettingType>(); foreach (var hotkeySetting in hotkeySettings) { var hotkey = Settings.GetSetting<Hotkey>(hotkeySetting.Value); if (_binder.IsHotkeyAlreadyBound(hotkey)) { failedHotkeys.Add(hotkeySetting.Value); _log.Warn($"Hotkey {hotkeySetting.Value} is already bound. Therefor the hotkey will not be set."); continue; } _binder.Bind(hotkey, args => HandleHotkey(hotkeySetting.Key)); } if (failedHotkeys.SequenceEqual(hotkeySettings.Select(s => s.Value))) { _log.Fatal("All hotkeys failed to bind. Exiting.."); NotificationProvider.Show("Lensert Closing", "All hotkeys failed to bind"); Environment.Exit(0); } else if (failedHotkeys.Any()) { var message = $"Failed to bind: {string.Join(", ", failedHotkeys)}"; NotificationProvider.Show("Error", message, Util.OpenLog); } }
//End of the code for the window moving. /// <summary> /// Initial constructor. /// </summary> public FaceSplit() { InitializeComponent(); this.ConfigureFilesDialogs(); this.layoutSettings = new Model.LayoutSettings(); if (!Settings.Default.LayoutSettingsFile.Equals("")) { this.layoutSettings.File = Settings.Default.LayoutSettingsFile; } this.hotkeyBinder = new HotkeyBinder(); this.BindHotkeys(); this.globalHotkeysActive = true; segmentsRectangles = new List<Rectangle>(); watchRectangle = new Rectangle(ZERO, ZERO, DEFAULT_WIDTH, DEFAULT_HEIGHT); this.displayMode = DisplayMode.TIMER_ONLY; this.watchColor = Settings.Default.TimerNotRunningColor; this.segmentWatchColor = Settings.Default.SegmentTimerNotRunningColor; informations = new List<Information>(); this.splitY_start = 0; base.Paint += new PaintEventHandler(this.DrawFaceSplit); base.Size = new Size(DEFAULT_WIDTH, DEFAULT_HEIGHT); base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true); watch = new Stopwatch(); segmentWatch = new Stopwatch(); this.ticksTimer.Enabled = true; }