private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            GlobalSettings.TryApplySettings();
            LogWriter.Write("Main window loaded");
            this.InputMonitorTooltip = "Click to expand/collapse the input device monitor.\r\n" +
                                       "It will autocollapse after " + this.autoCollapseSpan.TotalSeconds + " seconds to save CPU time.";

            XinputWrapper.XinputController.StartPolling();

            var inputDevices = KeyboardSplitter.Managers.InputManager.ConnectedInputDevices;

            if (inputDevices.Count == 0)
            {
                // We have some error or nothing is attached to the system.
                LogWriter.Write("No input devices were detected! Terminating application.");
                Controls.MessageBox.Show(
                    "No input devices were detected!\r\nApplication will now close!",
                    ApplicationInfo.AppName,
                    MessageBoxButton.OK,
                    MessageBoxImage.Error);

                Environment.Exit(0);
            }

            if (!GlobalSettings.Instance.SuggestInputDevicesForNewSlots)
            {
                this.SlotsCount = 1;
            }
            else
            {
                var keyboardsCount = inputDevices.Where(x => x.IsKeyboard).Count();
                var miceCount      = inputDevices.Count - keyboardsCount;

                this.SlotsCount = Math.Min(Math.Max(keyboardsCount, miceCount), 4);
            }
        }