public void TestCopy()
        {
            variant.Set("TextBoxPosition", 999);
            variant.Set("OptionName", "test option name");
            variant = variant.Copy(new StyleOption());

            var option = new StyleOption();
            option.TextBoxPosition = 999;
            option.OptionName = "test option name";

            variant.Apply(option);
            Assert.AreEqual(5, option.TextBoxPosition);
            Assert.AreEqual("Reloaded", option.OptionName);
        }
        /// <summary>
        /// This method implements the way to guide the user step by step to customize
        /// style
        /// </summary>
        public void UpdateStepByStepStylesVariationImages(ImageItem source, Slide contentSlide, 
            float slideWidth, float slideHeight)
        {
            if (StylesVariationListSelectedId.Number < 0
                || VariantsCategory.Count == 0) return;

            var targetVariationSelectedIndex = StylesVariationListSelectedId.Number;
            var targetVariant = _styleVariants[_previousVariantsCategory][targetVariationSelectedIndex];
            foreach (var option in _styleOptions)
            {
                targetVariant.Apply(option);
            }
            
            var currentVariantsCategory = CurrentVariantCategory.Text;
            if (currentVariantsCategory != TextCollection.PictureSlidesLabText.VariantCategoryFontColor
                && _previousVariantsCategory != TextCollection.PictureSlidesLabText.VariantCategoryFontColor)
            {
                // apply font color variant,
                // because default styles may contain special font color settings, but not in variants
                var fontColorVariant = new StyleVariant(new Dictionary<string, object>
                {
                    {"FontColor", _styleOptions[targetVariationSelectedIndex].FontColor}
                });
                foreach (var option in _styleOptions)
                {
                    fontColorVariant.Apply(option);
                }
            }

            var nextCategoryVariants = _styleVariants[currentVariantsCategory];
            if (currentVariantsCategory == TextCollection.PictureSlidesLabText.VariantCategoryFontFamily)
            {
                var isFontInVariation = false;
                var currentFontFamily = _styleOptions[targetVariationSelectedIndex].FontFamily;
                foreach (var variant in nextCategoryVariants)
                {
                    if (currentFontFamily == (string) variant.Get("FontFamily"))
                    {
                        isFontInVariation = true;
                    }
                }
                if (!isFontInVariation 
                    && targetVariationSelectedIndex >= 0 
                    && targetVariationSelectedIndex < nextCategoryVariants.Count)
                {
                    nextCategoryVariants[targetVariationSelectedIndex]
                        .Set("FontFamily", currentFontFamily);
                    nextCategoryVariants[targetVariationSelectedIndex]
                        .Set("OptionName", currentFontFamily);
                }
            }
            
            int pictureIndexToSelect = -1;
            // Enter picture variation for the first time
            if (CurrentVariantCategory.Text == TextCollection.PictureSlidesLabText.VariantCategoryPicture
                && !_isPictureVariationInit)
            {
                _8PicturesInPictureVariation = GetLast8Pictures(targetVariationSelectedIndex);
                _isPictureVariationInit = true;
            }
            // Enter picture variation again
            else if (CurrentVariantCategory.Text == TextCollection.PictureSlidesLabText.VariantCategoryPicture
                     && _isPictureVariationInit)
            {
                var isPictureSwapped = false;
                for (var i = 0; i < _8PicturesInPictureVariation.Count; i++)
                {
                    // swap the picture to the current selected id in
                    // variation list
                    var picture = _8PicturesInPictureVariation[i];
                    if ((ImageSelectionListSelectedItem.ImageItem == null 
                        && picture.ImageFile == StoragePath.NoPicturePlaceholderImgPath) || 
                            (ImageSelectionListSelectedItem.ImageItem != null
                            && picture.ImageFile == ImageSelectionListSelectedItem.ImageItem.ImageFile))
                    {
                        var tempPic = _8PicturesInPictureVariation[targetVariationSelectedIndex];
                        _8PicturesInPictureVariation[targetVariationSelectedIndex]
                            = picture;
                        _8PicturesInPictureVariation[i] = tempPic;
                        isPictureSwapped = true;
                        break;
                    }
                }
                if (!isPictureSwapped)
                {
                    // if the current picture doesn't exist in the _8PicturesInPictureVariation
                    // directly overwrite the existing one at the selected id
                    UpdateSelectedPictureInPictureVariation();
                }
            }
            // Exit picture variation
            else if (_previousVariantsCategory == TextCollection.PictureSlidesLabText.VariantCategoryPicture)
            {
                // use the selected picture in the picture variation to preview
                var targetPicture = _8PicturesInPictureVariation[targetVariationSelectedIndex];
                if (targetPicture.ImageFile != StoragePath.NoPicturePlaceholderImgPath)
                {
                    var indexForTargetPicture = ImageSelectionList.IndexOf(targetPicture);
                    if (indexForTargetPicture == -1)
                    {
                        ImageSelectionList.Add(targetPicture);
                        pictureIndexToSelect = ImageSelectionList.Count - 1;
                    }
                    else
                    {
                        pictureIndexToSelect = indexForTargetPicture;
                    }
                }
                else // target picture is the default picture
                {
                    // enter default picture mode
                    View.DisableUpdatingPreviewImages();
                    ImageSelectionListSelectedId.Number = -1;
                    source = View.CreateDefaultPictureItem();
                }
            }

            var variantIndexWithoutEffect = -1;
            for (var i = 0; i < nextCategoryVariants.Count; i++)
            {
                if (nextCategoryVariants[i].IsNoEffect(_styleOptions[targetVariationSelectedIndex]))
                {
                    variantIndexWithoutEffect = i;
                    break;
                }
            }
            // swap the no-effect variant with the current selected style's corresponding variant
            // so that to achieve an effect: jumpt between different category wont change the
            // selected style
            if (variantIndexWithoutEffect != -1)
            {
                var temp = nextCategoryVariants[variantIndexWithoutEffect];
                nextCategoryVariants[variantIndexWithoutEffect] =
                    nextCategoryVariants[targetVariationSelectedIndex];
                nextCategoryVariants[targetVariationSelectedIndex] = temp;
            }

            for (var i = 0; i < nextCategoryVariants.Count && i < _styleOptions.Count; i++)
            {
                nextCategoryVariants[i].Apply(_styleOptions[i]);
            }

            _previousVariantsCategory = currentVariantsCategory;
            if (pictureIndexToSelect == -1
                || pictureIndexToSelect == ImageSelectionListSelectedId.Number)
            {
                UpdateStylesVariationImagesAfterOpenFlyout(source, contentSlide,
                    slideWidth, slideHeight);
            }
            else
            {
                ImageSelectionListSelectedId.Number = pictureIndexToSelect;
            }
        }
        /// <summary>
        /// This method implements the way to guide the user step by step to customize
        /// style
        /// </summary>
        public void UpdateStepByStepStylesVariationImages(ImageItem source, Slide contentSlide, 
            float slideWidth, float slideHeight)
        {
            if (StylesVariationListSelectedId.Number < 0
                || VariantsCategory.Count == 0) return;

            var targetVariationSelectedIndex = StylesVariationListSelectedId.Number;
            var targetVariant = _styleVariants[_previousVariantsCategory][targetVariationSelectedIndex];
            foreach (var option in _styleOptions)
            {
                targetVariant.Apply(option);
            }

            var currentVariantsCategory = CurrentVariantCategory.Text;
            if (currentVariantsCategory != TextCollection.PictureSlidesLabText.VariantCategoryFontColor
                && _previousVariantsCategory != TextCollection.PictureSlidesLabText.VariantCategoryFontColor)
            {
                // apply font color variant,
                // because default styles may contain special font color settings, but not in variants
                var fontColorVariant = new StyleVariant(new Dictionary<string, object>
                {
                    {"FontColor", _styleOptions[targetVariationSelectedIndex].FontColor}
                });
                foreach (var option in _styleOptions)
                {
                    fontColorVariant.Apply(option);
                }
            }

            int pictureIndexToSelect = -1;
            // Enter picture variation
            if (CurrentVariantCategory.Text == TextCollection.PictureSlidesLabText.VariantCategoryPicture)
            {
                _lastSelectedPictureIndexForPicturevariation = targetVariationSelectedIndex;
                _last8PicturesForPictureVariation = GetLast8PicturesFromImageSelectionList(targetVariationSelectedIndex);
            }
            // Exit picture variation
            else if (_previousVariantsCategory == TextCollection.PictureSlidesLabText.VariantCategoryPicture)
            {
                var targetPicture = _last8PicturesForPictureVariation[targetVariationSelectedIndex];
                if (targetPicture.ImageFile != StoragePath.NoPicturePlaceholderImgPath)
                {
                    var indexForTargetPicture = ImageSelectionList.IndexOf(targetPicture);
                    if (indexForTargetPicture == -1)
                    {
                        ImageSelectionList.Add(targetPicture);
                        pictureIndexToSelect = ImageSelectionList.Count - 1;
                    }
                    else
                    {
                        pictureIndexToSelect = indexForTargetPicture;
                    }
                }
            }

            var nextCategoryVariants = _styleVariants[currentVariantsCategory];
            var variantIndexWithoutEffect = -1;
            for (var i = 0; i < nextCategoryVariants.Count; i++)
            {
                if (nextCategoryVariants[i].IsNoEffect(_styleOptions[targetVariationSelectedIndex]))
                {
                    variantIndexWithoutEffect = i;
                    break;
                }
            }
            // swap the no-effect variant with the current selected style's corresponding variant
            // so that to achieve an effect: jumpt between different category wont change the
            // selected style
            if (variantIndexWithoutEffect != -1)
            {
                var temp = nextCategoryVariants[variantIndexWithoutEffect];
                nextCategoryVariants[variantIndexWithoutEffect] =
                    nextCategoryVariants[targetVariationSelectedIndex];
                nextCategoryVariants[targetVariationSelectedIndex] = temp;
            }

            for (var i = 0; i < nextCategoryVariants.Count && i < _styleOptions.Count; i++)
            {
                nextCategoryVariants[i].Apply(_styleOptions[i]);
            }

            _previousVariantsCategory = currentVariantsCategory;
            if (pictureIndexToSelect == -1
                || pictureIndexToSelect == ImageSelectionListSelectedId.Number)
            {
                UpdateStylesVariationImagesAfterOpenFlyout(source, contentSlide,
                    slideWidth, slideHeight);
            }
            else
            {
                ImageSelectionListSelectedId.Number = pictureIndexToSelect;
            }
        }
 public void Init()
 {
     variant = new StyleVariant(new Dictionary<string, object>());
 }