public void BindStyleVariant(StyleVariant variant, int value)
        {
            variant.Set("OptionName", "Customized");
            variant.Set("IsUseBlurStyle", true);
            int variantValue = (value == 0) ? 0 : 50 + (value / 2);

            variant.Set("BlurDegree", variantValue);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        public void BindStyleVariant(StyleVariant variant, int value)
        {
            variant.Set("OptionName", "Customized");
            variant.Set("IsUseOverlayStyle", true);

            if (value > 100)
            {
                variant.Set("OverlayColor", "#FFFFFF");
                variant.Set("OverlayTransparency", 200 - value);
            }
            else
            {
                variant.Set("OverlayColor", "#000000");
                variant.Set("OverlayTransparency", value);
            }
        }
        private Dictionary <string, List <StyleVariant> > ConstructVariantsFromStyle(StyleOption opt)
        {
            Dictionary <string, List <StyleVariant> > variants = ViewModel.VariantsFactory.GetVariants(opt.StyleName);

            // replace each category/aspect's variant
            // with the new variant from the given style options
            foreach (KeyValuePair <string, List <StyleVariant> > pair in variants)
            {
                StyleVariant firstVariant    = pair.Value[0];
                StyleVariant newFirstVariant = firstVariant.Copy(opt);
                for (int i = 0; i < pair.Value.Count; i++)
                {
                    // try to swap out the 'no-effect' style options
                    if (pair.Value[i].IsNoEffect(opt))
                    {
                        pair.Value[i] = firstVariant;
                        break;
                    }
                }
                pair.Value[0] = newFirstVariant;
            }
            return(variants);
        }
Beispiel #5
0
 public void BindStyleVariant(StyleVariant variant, int value)
 {
     variant.Set("OptionName", "Customized");
     variant.Set(PropName, value);
 }
Beispiel #6
0
 public void Init()
 {
     variant = new StyleVariant(new Dictionary <string, object>());
 }
        /// <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");
        }