private static void VerifyVariants2(string styleName) { var variants = StyleVariantsFactory.GetVariants(styleName); var options = StyleOptionsFactory.GetStylesVariationOptions(styleName); for (var i = 0; i < options.Count; i++) { variants[variants.Keys.First()][i].Apply(options[i]); } var numberOfNoEffectVariant = 0; foreach (var variant in variants.Values) { foreach (var styleVariants in variant) { foreach (var option in options) { if (styleVariants.IsNoEffect(option)) { numberOfNoEffectVariant++; } } } } Assert.AreEqual(variants.Values.Count * options.Count, numberOfNoEffectVariant, "In order to swap no effect variant with the style correctly, it is assumed that " + "number of no effect variant should be equal to number of variants/category/aspect/dimension. " + "Please modify a variation to have no effect on the style. Ref: issue #802."); }
private void InitStylesVariationCategories(List <StyleOptions> givenOptions, Dictionary <string, List <StyleVariants> > givenVariants, string targetStyle) { _styleOptions = givenOptions ?? StyleOptionsFactory.GetStylesVariationOptions(targetStyle); _styleVariants = givenVariants ?? StyleVariantsFactory.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 = StyleOptionsFactory.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]); } }
private List <StyleOption> GetOptions(string styleName) { var options = _factory.GetStylesVariationOptions(styleName); var variants = new StyleVariantsFactory().GetVariants(styleName); for (var i = 0; i < options.Count; i++) { variants[variants.Keys.First()][i].Apply(options[i]); } return(options); }
private void VerifyVariants2(string styleName) { Dictionary <string, List <StyleVariant> > variants = _variantsFactory.GetVariants(styleName); List <StyleOption> options = _optionsFactory.GetStylesVariationOptions(styleName); for (int i = 0; i < options.Count; i++) { variants[variants.Keys.First()][i].Apply(options[i]); } int numberOfNoEffectVariant = 0; foreach (string key in variants.Keys) { if (key == PictureSlidesLabText.VariantCategoryFontFamily) { continue; } List <StyleVariant> variant = variants[key]; foreach (StyleVariant styleVariants in variant) { foreach (StyleOption option in options) { if (styleVariants.IsNoEffect(option)) { numberOfNoEffectVariant++; } } } } Assert.AreEqual((variants.Values.Count - 1) * options.Count, numberOfNoEffectVariant, "In order to swap no effect variant with the style correctly, it is assumed that " + "number of no effect variant should be equal to number of variants/category/aspect/dimension. " + "Please modify a variation to have no effect on the style. Ref: issue #802."); }