/// <summary> /// Update styles variation iamges before its flyout is open /// </summary> /// <param name="source"></param> /// <param name="contentSlide"></param> /// <param name="slideWidth"></param> /// <param name="slideHeight"></param> /// <param name="givenOptions"></param> /// <param name="givenVariants"></param> public void UpdateStyleVariationImagesWhenOpenFlyout(ImageItem source, Slide contentSlide, float slideWidth, float slideHeight, List <StyleOption> givenOptions = null, Dictionary <string, List <StyleVariant> > givenVariants = null) { Logger.Log("Variation stage is open"); var targetStyleItem = StylesPreviewListSelectedItem.ImageItem; StylesVariationList.Clear(); if (!IsAbleToUpdateStylesVariationImages(source, targetStyleItem, contentSlide)) { return; } InitStylesVariationCategories(givenOptions, givenVariants, targetStyleItem.Tooltip); if (Settings.GetDefaultAspectWhenCustomize() == Aspect.PictureAspect) { UpdateStylesVariationImages(source, contentSlide, slideWidth, slideHeight, isMockPreviewImages: true); } else { UpdateStylesVariationImages(source, contentSlide, slideWidth, slideHeight); } StylesVariationListSelectedId.Number = 0; View.SetVariationListBoxScrollOffset(0d); _isPictureVariationInit = false; if (Settings.GetDefaultAspectWhenCustomize() == Aspect.PictureAspect) { CurrentVariantCategoryId.Number = VariantsCategory.IndexOf(PictureSlidesLabText.VariantCategoryPicture); } Logger.Log("Variation open completed"); }
private void InitStylesVariationCategories(List <StyleOption> givenOptions, Dictionary <string, List <StyleVariant> > givenVariants, string targetStyle) { Logger.Log("Init variation stage begins"); _styleOptions = givenOptions ?? OptionsFactory.GetStylesVariationOptions(targetStyle); _styleVariants = givenVariants ?? VariantsFactory.GetVariants(targetStyle); VariantsCategory.Clear(); foreach (var styleVariant in _styleVariants.Keys) { VariantsCategory.Add(styleVariant); } CurrentVariantCategoryId.Number = 0; _previousVariantsCategory = VariantsCategory[0]; // default style options (in preview stage) var defaultStyleOptions = OptionsFactory.GetStylesPreviewOption(targetStyle); var currentVariants = _styleVariants.Values.First(); var variantIndexWithoutEffect = -1; for (var i = 0; i < currentVariants.Count; i++) { if (currentVariants[i].IsNoEffect(defaultStyleOptions)) { variantIndexWithoutEffect = i; break; } } // swap the no-effect variant with the current selected style's corresponding variant // so that to achieve continuity. // in order to swap, style option provided from StyleOptionsFactory should have // corresponding values specified in StyleVariantsFactory. e.g., an option generated // from factory has overlay transparency of 35, then in order to swap, it should have // a variant of overlay transparency of 35. Otherwise it cannot swap, because variants // don't match any values in the style options. if (variantIndexWithoutEffect != -1 && givenOptions == null) { // swap style variant var tempVariant = currentVariants[variantIndexWithoutEffect]; currentVariants[variantIndexWithoutEffect] = currentVariants[0]; currentVariants[0] = tempVariant; // swap default style options (in variation stage) var tempStyleOpt = _styleOptions[variantIndexWithoutEffect]; _styleOptions[variantIndexWithoutEffect] = _styleOptions[0]; _styleOptions[0] = tempStyleOpt; } for (var i = 0; i < currentVariants.Count && i < _styleOptions.Count; i++) { currentVariants[i].Apply(_styleOptions[i]); } Logger.Log("Init variation stage done"); }