コード例 #1
0
ファイル: CoreConfiguration.cs プロジェクト: cailh/greenshot
        /// <summary>
        /// This method will be called after reading the configuration, so eventually some corrections can be made
        /// </summary>
        public override void AfterLoad()
        {
            // Comment with releases
            // CheckForUnstable = true;

            if (string.IsNullOrEmpty(LastSaveWithVersion))
            {
                try {
                    // Store version, this can be used later to fix settings after an update
                    LastSaveWithVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
                }
                catch
                {
                    // ignored
                }
                // Disable the AutoReduceColors as it causes issues with Mozzila applications and some others
                OutputFileAutoReduceColors = false;
            }

            // Fix for excessive feed checking
            if (UpdateCheckInterval != 0 && UpdateCheckInterval <= 7 && LastSaveWithVersion.StartsWith("1.2"))
            {
                UpdateCheckInterval = 14;
            }
            if (UpdateCheckInterval > 365)
            {
                UpdateCheckInterval = 365;
            }

            // Enable OneNote if upgrading from 1.1
            if (ExcludeDestinations != null && ExcludeDestinations.Contains("OneNote"))
            {
                if (LastSaveWithVersion != null && LastSaveWithVersion.StartsWith("1.1"))
                {
                    ExcludeDestinations.Remove("OneNote");
                }
                else
                {
                    // TODO: Remove with the release
                    ExcludeDestinations.Remove("OneNote");
                }
            }

            if (OutputDestinations == null)
            {
                OutputDestinations = new List <string>();
            }

            // Make sure there is an output!
            if (OutputDestinations.Count == 0)
            {
                OutputDestinations.Add("Editor");
            }

            // Prevent both settings at once, bug #3435056
            if (OutputDestinations.Contains("Clipboard") && OutputFileCopyPathToClipboard)
            {
                OutputFileCopyPathToClipboard = false;
            }

            // Make sure we have clipboard formats, otherwise a paste doesn't make sense!
            if (ClipboardFormats == null || ClipboardFormats.Count == 0)
            {
                ClipboardFormats = new List <ClipboardFormat> {
                    ClipboardFormat.PNG, ClipboardFormat.HTML, ClipboardFormat.DIB
                };
            }

            // Make sure the lists are lowercase, to speedup the check
            if (NoGDICaptureForProduct != null)
            {
                // Fix error in configuration
                if (NoGDICaptureForProduct.Count >= 2)
                {
                    if ("intellij".Equals(NoGDICaptureForProduct[0]) && "idea".Equals(NoGDICaptureForProduct[1]))
                    {
                        NoGDICaptureForProduct.RemoveRange(0, 2);
                        NoGDICaptureForProduct.Add("Intellij Idea");
                        IsDirty = true;
                    }
                }
                for (int i = 0; i < NoGDICaptureForProduct.Count; i++)
                {
                    NoGDICaptureForProduct[i] = NoGDICaptureForProduct[i].ToLower();
                }
            }
            if (NoDWMCaptureForProduct != null)
            {
                // Fix error in configuration
                if (NoDWMCaptureForProduct.Count >= 3)
                {
                    if ("citrix".Equals(NoDWMCaptureForProduct[0]) && "ica".Equals(NoDWMCaptureForProduct[1]) && "client".Equals(NoDWMCaptureForProduct[2]))
                    {
                        NoDWMCaptureForProduct.RemoveRange(0, 3);
                        NoDWMCaptureForProduct.Add("Citrix ICA Client");
                        IsDirty = true;
                    }
                }
                for (int i = 0; i < NoDWMCaptureForProduct.Count; i++)
                {
                    NoDWMCaptureForProduct[i] = NoDWMCaptureForProduct[i].ToLower();
                }
            }

            if (AutoCropDifference < 0)
            {
                AutoCropDifference = 0;
            }
            if (AutoCropDifference > 255)
            {
                AutoCropDifference = 255;
            }
            if (OutputFileReduceColorsTo < 2)
            {
                OutputFileReduceColorsTo = 2;
            }
            if (OutputFileReduceColorsTo > 256)
            {
                OutputFileReduceColorsTo = 256;
            }

            if (WebRequestTimeout <= 10)
            {
                WebRequestTimeout = 100;
            }
            if (WebRequestReadWriteTimeout < 1)
            {
                WebRequestReadWriteTimeout = 100;
            }
        }
コード例 #2
0
        /// <summary>
        /// This method will be called after reading the configuration, so eventually some corrections can be made
        /// </summary>
        public override void AfterLoad()
        {
            base.AfterLoad();
            // Comment with releases
            // CheckForUnstable = true;

            if (string.IsNullOrEmpty(LastSaveWithVersion))
            {
                // Store version, this can be used later to fix settings after an update
                LastSaveWithVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();
                // Disable the AutoReduceColors as it causes issues with Mozzila applications and some others
                OutputFileAutoReduceColors = false;
            }

            if (OutputDestinations == null)
            {
                OutputDestinations = new List <string>();
            }

            // Make sure there is an output!
            if (OutputDestinations.Count == 0)
            {
                OutputDestinations.Add("Editor");
            }

            // Prevent both settings at once, bug #3435056
            if (OutputDestinations.Contains("Clipboard") && OutputFileCopyPathToClipboard)
            {
                OutputFileCopyPathToClipboard = false;
            }

            // Make sure the lists are lowercase, to speedup the check
            if (NoGDICaptureForProduct != null)
            {
                // Fix error in configuration
                if (NoGDICaptureForProduct.Count == 1)
                {
                    if ("intellij idea".Equals(NoGDICaptureForProduct[0]))
                    {
                        NoGDICaptureForProduct[0] = "intellij,idea";
                        this.IsDirty = true;
                    }
                }
                for (int i = 0; i < NoGDICaptureForProduct.Count; i++)
                {
                    NoGDICaptureForProduct[i] = NoGDICaptureForProduct[i].ToLower();
                }
            }
            if (NoDWMCaptureForProduct != null)
            {
                // Fix error in configuration
                if (NoDWMCaptureForProduct.Count == 1)
                {
                    if ("citrix ica client".Equals(NoDWMCaptureForProduct[0]))
                    {
                        NoDWMCaptureForProduct[0] = "citrix,ica,client";
                        this.IsDirty = true;
                    }
                }
                for (int i = 0; i < NoDWMCaptureForProduct.Count; i++)
                {
                    NoDWMCaptureForProduct[i] = NoDWMCaptureForProduct[i].ToLower();
                }
            }
        }