public SettingsControl(SettingsFile settings)
            : this()
        {
            this.selectedDelay = settings.Delay;
            this.initialCommercialCount = settings.InitialCommercials;
            this.gameMinutesPerExtraCount = settings.GameMinutesPerExtra;
            this.minimumGameMinuteCount = settings.MinimumGameMinutes;
            this.replayDirectory = settings.ReplayDirectory;
            this.showOverlay = settings.ShowOverlay;

            this.cbxShowOverlay.IsChecked = this.showOverlay;

            this.UpdateCommercialValueText();
            this.UpdateDelayValueText();
            this.UpdateMinimumGameTimeValueText();
        }
        /// <summary> Initializes a new instance of the <see cref="ReplayMonitorControl"/> class. </summary>
        /// <param name="api"> The api instance. </param>
        public ReplayMonitorControl(SettingsFile settings, TwitchApiV2 api)
            : this()
        {
            this.twitchApi = api;
            this.twitchApi.CommercialPlayed += this.TwitchApiCommercialPlayed;

            this.settings = settings;

            this.replayCountTimer.AutoReset = false;
            this.replayCountTimer.Elapsed += this.replayCountTimer_Elapsed;

            this.updateTimer.AutoReset = true;
            this.updateTimer.Elapsed += this.updateTimer_Elapsed;
            this.updateTimer.Start();

            this.VerifyWhetherSetupIsComplete();
        }
        private void SaveSettingsClicked(object sender, RoutedEventArgs e)
        {
            this.showOverlay = cbxShowOverlay.IsChecked == true;

            // Save the settings to a file.
            var file = new SettingsFile
                {
                    MinimumGameMinutes = this.minimumGameMinuteCount,
                    InitialCommercials = this.initialCommercialCount,
                    GameMinutesPerExtra = this.gameMinutesPerExtraCount,
                    Delay = this.selectedDelay,
                    ReplayDirectory = this.replayDirectory,
                    ShowOverlay = this.showOverlay
                };

            file.Save();

            var handler = this.SettingsClose;
            if (handler != null)
            {
                this.SettingsClose(this, EventArgs.Empty);
            }
        }