Exemplo n.º 1
0
        public void TestCopy()
        {
            variant.Set("TextBoxPosition", 999);
            variant.Set("OptionName", "test option name");
            variant = variant.Copy(new StyleOptions());

            var option = new StyleOptions();

            option.TextBoxPosition = 999;
            option.OptionName      = "test option name";

            variant.Apply(option);
            Assert.AreEqual(5, option.TextBoxPosition);
            Assert.AreEqual("Reloaded", option.OptionName);
        }
Exemplo n.º 2
0
 public void Init()
 {
     variant = new StyleVariants(new Dictionary <string, object>());
 }
Exemplo n.º 3
0
        /// <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 StyleVariants(new Dictionary <string, object>
                {
                    { "FontColor", _styleOptions[targetVariationSelectedIndex].FontColor }
                });
                foreach (var option in _styleOptions)
                {
                    fontColorVariant.Apply(option);
                }
            }

            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;
            UpdateStylesVariationImagesAfterOpenFlyout(source, contentSlide,
                                                       slideWidth, slideHeight);
        }