public void TestApply() { variant.Set("OptionName", "test option name"); var option = new StyleOption(); variant.Apply(option); Assert.AreEqual("test option name", option.OptionName); }
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) { Logger.Log("Check for step by step preview"); Logger.Log("current variation list selected id is " + StylesVariationListSelectedId.Number); Logger.Log("variants category count is " + VariantsCategory.Count); if (StylesVariationListSelectedId.Number < 0 || VariantsCategory.Count == 0) { return; } Logger.Log("Step by step preview begins"); var targetVariationSelectedIndex = StylesVariationListSelectedId.Number; var targetVariant = _styleVariants[_previousVariantsCategory][targetVariationSelectedIndex]; foreach (var option in _styleOptions) { targetVariant.Apply(option); } var currentVariantsCategory = CurrentVariantCategory.Text; if (currentVariantsCategory != PictureSlidesLabText.VariantCategoryFontColor && _previousVariantsCategory != 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 == 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 == PictureSlidesLabText.VariantCategoryPicture && !_isPictureVariationInit) { _8PicturesInPictureVariation = GetLast8Pictures(targetVariationSelectedIndex); _isPictureVariationInit = true; } // Enter picture variation again else if (CurrentVariantCategory.Text == 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 == 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.EnterDefaultPictureMode(); 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; Logger.Log("picture index to select is " + pictureIndexToSelect); if (pictureIndexToSelect == -1 || pictureIndexToSelect == ImageSelectionListSelectedId.Number) { UpdateStylesVariationImagesAfterOpenFlyout(source, contentSlide, slideWidth, slideHeight); } else { ImageSelectionListSelectedId.Number = pictureIndexToSelect; } Logger.Log("Step by step preview done"); }