示例#1
0
        /// <summary>
        /// Helpful place to fix common issues with settings files
        /// </summary>
        private void SanitizeSettingsFile()
        {
            if (this._hotKeys == null)
            {
                return;
            }

            // Remove duplicate hotkeys
            this._hotKeys = this._hotKeys.Distinct(Hotkey.EqualityComparerOnAction).ToList();

            // Bring the Toast inside the working area if it is off-screen
            System.Windows.Rect toastRect = new System.Windows.Rect(this.PositionLeft, this.PositionTop, this.ToastWidth, this.ToastHeight);
            Vector offsetVector           = ScreenHelper.BringRectInsideWorkingArea(toastRect);

            this.PositionLeft += offsetVector.X;
            this.PositionTop  += offsetVector.Y;

            // Validate WindowsVolumeMixerIncrement: must be positive!
            this.WindowsVolumeMixerIncrement = Math.Abs(this.WindowsVolumeMixerIncrement);

            // Validate StartupWaitTimeout: it cannot be negative!
            this.StartupWaitTimeout = Math.Abs(this.StartupWaitTimeout);

            this.Save();
        }