private static void VerifyVariants(string styleName) { var variants = StyleVariantsFactory.GetVariants(styleName); var option = StyleOptionsFactory.GetStylesPreviewOption(styleName); var numberOfNoEffectVariant = 0; foreach (var variant in variants.Values) { Assert.AreEqual(8, variant.Count, "Each variant/category/aspect/dimension should have 8 variations"); foreach (var styleVariants in variant) { if (styleVariants.IsNoEffect(option)) { numberOfNoEffectVariant++; } } } Assert.AreEqual(variants.Values.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 UpdateStylesPreviewImages(ImageItem source, Slide contentSlide, float slideWidth, float slideHeight) { var selectedId = StylesPreviewListSelectedId.Number; StylesPreviewList.Clear(); if (!IsAbleToUpdateStylesPreviewImages(source, contentSlide)) { return; } try { foreach (var stylesPreviewOption in StyleOptionsFactory.GetAllStylesPreviewOptions()) { var previewInfo = Designer.PreviewApplyStyle(source, contentSlide, slideWidth, slideHeight, stylesPreviewOption); StylesPreviewList.Add(new ImageItem { ImageFile = previewInfo.PreviewApplyStyleImagePath, Tooltip = stylesPreviewOption.StyleName }); } } catch { View.ShowErrorMessageBox(TextCollection.PictureSlidesLabText.ErrorImageCorrupted); } StylesPreviewListSelectedId.Number = selectedId; }
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]); } }
public void Init() { _factory = new StyleOptionsFactory(); _designer = new StylesDesigner(App); _sourceImage = new ImageItem { ImageFile = PathUtil.GetDocTestPath() + "PictureSlidesLab\\koala.jpg", Tooltip = "some tooltip" }; _contentSlide = PpOperations.SelectSlide(1); }
private static List <StyleOptions> GetOptions(string styleName) { var options = StyleOptionsFactory.GetStylesVariationOptions(styleName); var variants = StyleVariantsFactory.GetVariants(styleName); for (var i = 0; i < options.Count; i++) { variants[variants.Keys.First()][i].Apply(options[i]); } return(options); }
private int MapStyleNameToStyleIndex(string styleName) { var allOptions = StyleOptionsFactory.GetAllStylesPreviewOptions(); for (var i = 0; i < allOptions.Count; i++) { if (allOptions[i].StyleName == styleName) { return(i); } } return(0); }
public void TestPreviewStyle() { TempPath.InitTempFolder(); foreach (var style in StyleOptionsFactory.GetAllStylesPreviewOptions()) { var previewInfo = _designer.PreviewApplyStyle(_sourceImage, _contentSlide, Pres.PageSetup.SlideWidth, Pres.PageSetup.SlideHeight, style); SlideUtil.IsSameLooking( new FileInfo(PathUtil.GetDocTestPath() + "PictureSlidesLab\\" + style.StyleName + ".jpg"), new FileInfo(previewInfo.PreviewApplyStyleImagePath)); } }
public void TestGetDirectTextOptions() { var option = StyleOptionsFactory.GetStylesPreviewOption( TextCollection.PictureSlidesLabText.StyleNameDirectText); Assert.AreEqual(TextCollection.PictureSlidesLabText.StyleNameDirectText, option.StyleName); var options = GetOptions(TextCollection.PictureSlidesLabText.StyleNameDirectText); Assert.AreEqual(8, GetExpectedCount( GetOptionsProperty(options, "IsUseOverlayStyle"), true)); Assert.AreEqual(8, options.Count); }
public void ApplyStyleInPreviewStage(Slide contentSlide, float slideWidth, float slideHeight) { try { var targetDefaultOptions = StyleOptionsFactory .GetStylesPreviewOption(StylesPreviewListSelectedItem.ImageItem.Tooltip); Designer.ApplyStyle(ImageSelectionListSelectedItem.ImageItem, contentSlide, slideWidth, slideHeight, targetDefaultOptions); View.ShowSuccessfullyAppliedDialog(); } catch (AssumptionFailedException) { View.ShowErrorMessageBox(TextCollection.PictureSlidesLabText.ErrorNoSelectedSlide); } }
public void TestGetBlurOptions() { var option = StyleOptionsFactory.GetStylesPreviewOption( TextCollection.PictureSlidesLabText.StyleNameBlur); Assert.AreEqual(TextCollection.PictureSlidesLabText.StyleNameBlur, option.StyleName); Assert.IsTrue(option.IsUseBlurStyle); var options = GetOptions(TextCollection.PictureSlidesLabText.StyleNameBlur); Assert.AreEqual(8, GetExpectedCount( GetOptionsProperty(options, "IsUseBlurStyle"), true)); Assert.AreEqual(8, options.Count); }
public PictureSlidesLabWindowViewModel(IPictureSlidesLabWindowView view, IStylesDesigner stylesDesigner = null) { Logger.Log("Init PSL View Model begins"); View = view; ImageDownloader = new ContextDownloader(View.GetThreadContext()); InitStorage(); InitUiModels(); InitFontFamilies(); CleanUnusedPersistentData(); Designer = stylesDesigner ?? new StylesDesigner(); Designer.SetSettings(Settings); OptionsFactory = new StyleOptionsFactory(); VariantsFactory = new StyleVariantsFactory(); Logger.Log("Init PSL View Model done"); }
public void TestApplyStyle() { TempPath.InitTempFolder(); foreach (var style in StyleOptionsFactory.GetAllStylesPreviewOptions()) { _designer.ApplyStyle(_sourceImage, _contentSlide, Pres.PageSetup.SlideWidth, Pres.PageSetup.SlideHeight, style); var imgPath = TempPath.GetPath("applystyle-" + Guid.NewGuid().ToString().Substring(0, 7) + "-" + DateTime.Now.GetHashCode()); _contentSlide.Export(imgPath, "JPG"); SlideUtil.IsSameLooking( new FileInfo(PathUtil.GetDocTestPath() + "PictureSlidesLab\\" + style.StyleName + ".jpg"), new FileInfo(imgPath)); } }
public PictureSlidesLabWindowViewModel(IPictureSlidesLabWindowView view, IStylesDesigner stylesDesigner = null) { Logger.Log("Init PSL View Model begins"); View = view; ImageDownloader = new ContextDownloader(View.GetThreadContext()); InitStorage(); InitUiModels(); InitFontFamilies(); CleanUnusedPersistentData(); Designer = stylesDesigner ?? new StylesDesigner(); Designer.SetSettings(Settings); OptionsFactory = new StyleOptionsFactory(); VariantsFactory = new StyleVariantsFactory(); var catalog = new AggregateCatalog( new AssemblyCatalog(Assembly.GetExecutingAssembly())); var container = new CompositionContainer(catalog); container.ComposeParts(this); Logger.Log("Init PSL View Model done"); }
public void Init() { _variantsFactory = new StyleVariantsFactory(); _optionsFactory = new StyleOptionsFactory(); }
public void TestGetAllPreviewStyleOptions() { var allOptions = StyleOptionsFactory.GetAllStylesPreviewOptions(); Assert.IsTrue(allOptions.Count > 0); }
public void Init() { _factory = new StyleOptionsFactory(); }
public void TestGetAllVariationStyleOptions() { var allOptions = StyleOptionsFactory.GetAllStylesVariationOptions(); Assert.IsTrue(allOptions.Count > 0); }