예제 #1
0
        protected override void RestoreImageSettingsCore(CodedImage image)
        {
            base.RestoreImageSettingsCore(image);

            using (SuspendCallManipulations())
            {
                PaletteName = image.Palette.Name;

                int maxColorsValue;
                MaxColorsCount = image.TryGetAdditionalValueAsInt(nameof(MaxColorsCount), out maxColorsValue) ? maxColorsValue : image.Palette.Count;

                string comparisonTypeValue;
                if (image.TryGetAdditionalDataAsString(nameof(ColorComparisonType), out comparisonTypeValue))
                {
                    ColorComparisonTypes comparisonType;
                    if (Enum.TryParse(comparisonTypeValue, out comparisonType))
                    {
                        ColorComparisonType = comparisonType;
                    }
                }

                bool ensureBlackAndWhiteValue;
                if (image.TryGetAdditionalValueAsBool(nameof(EnsureBlackAndWhiteColors), out ensureBlackAndWhiteValue))
                {
                    EnsureBlackAndWhiteColors = ensureBlackAndWhiteValue;
                }

                int ditherLevelValue;
                if (image.TryGetAdditionalValueAsInt(nameof(DitherLevel), out ditherLevelValue))
                {
                    DitherLevel = ditherLevelValue;
                }
            }
        }
예제 #2
0
        protected override void RestoreImageSettingsCore(CodedImage image)
        {
            base.RestoreImageSettingsCore(image);

            string rotateHistory;

            if (image.TryGetAdditionalDataAsString(nameof(ImageRotateController), out rotateHistory))
            {
                Manipulator.RestoreManipulations(rotateHistory);
            }
        }
예제 #3
0
        protected override void RestoreImageSettingsCore(CodedImage image)
        {
            base.RestoreImageSettingsCore(image);

            using (SuspendCallManipulations())
            {
                string cropKindText;
                if (image.TryGetAdditionalDataAsString(nameof(CropKind), out cropKindText))
                {
                    ImageCropper.CropKind cropKindValue;
                    if (Enum.TryParse(cropKindText, out cropKindValue))
                    {
                        CropKind = cropKindValue;
                    }
                }

                if (CropKind != ImageCropper.CropKind.None)
                {
                    string cropRectText;
                    if (image.TryGetAdditionalDataAsString(nameof(CropRect), out cropRectText))
                    {
                        var cropRectComponents = cropRectText.Split(',')
                                                 .Select(componentText =>
                        {
                            int componentValue;
                            return(int.TryParse(componentText, out componentValue) ? componentValue : -1);
                        })
                                                 .ToList();
                        if (cropRectComponents.Count == 4 && cropRectComponents.All(c => c >= 0))
                        {
                            CropRect = new Rectangle(cropRectComponents[0], cropRectComponents[1], cropRectComponents[2], cropRectComponents[3]);
                        }
                    }
                }
            }
        }