public void UpdatePictureInPictureVariationWhenDeleteSome() { Logger.Log("Check for update picture in picture aspect when deleted some"); Logger.Log("is in picture aspect: " + IsInPictureVariation()); if (!IsInPictureVariation()) { return; } for (var i = 0; i < _8PicturesInPictureVariation.Count; i++) { var imageItem = _8PicturesInPictureVariation[i]; if (ImageSelectionList.IndexOf(imageItem) == -1) { _8PicturesInPictureVariation[i] = View.CreateDefaultPictureItem(); } } }
public void ApplyStyleInVariationStage(Slide contentSlide, float slideWidth, float slideHeight) { Logger.Log("Apply style in variation stage begins"); var copiedPicture = LoadClipboardPicture(); try { Designer.ApplyStyle( IsInPictureVariation() ? GetSelectedPictureInPictureVariation( StylesVariationListSelectedId.Number) : ImageSelectionListSelectedItem.ImageItem, contentSlide, slideWidth, slideHeight); if (IsInPictureVariation()) { // select the picture if possible var targetPicture = GetSelectedPictureInPictureVariation( StylesVariationListSelectedId.Number); if (targetPicture.ImageFile != StoragePath.NoPicturePlaceholderImgPath) { var indexForTargetPicture = ImageSelectionList.IndexOf(targetPicture); if (indexForTargetPicture == -1) { ImageSelectionList.Add(targetPicture); ImageSelectionListSelectedId.Number = ImageSelectionList.Count - 1; } else { ImageSelectionListSelectedId.Number = indexForTargetPicture; } } } View.ShowSuccessfullyAppliedDialog(); } catch (Exception e) { View.ShowErrorMessageBox(PictureSlidesLabText.ErrorNoSelectedSlide); Logger.LogException(e, "ApplyStyleInVariationStage"); } SaveClipboardPicture(copiedPicture); Logger.Log("Apply style in variation stage done"); }
/// <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"); }