Ejemplo n.º 1
0
        /// <summary>
        /// process how to handle a style based on the given source and style option
        /// </summary>
        /// <param name="designer"></param>
        /// <param name="source"></param>
        /// <param name="isActualSize"></param>
        private void ApplyStyle(EffectsDesigner designer, ImageItem source, bool isActualSize)
        {
            Shape imageShape;
            if (Option.IsUseSpecialEffectStyle)
            {
                imageShape = designer.ApplySpecialEffectEffect(Option.GetSpecialEffect(), isActualSize);
            }
            else // non-special-effect style, e.g. direct text style
            {
                imageShape = designer.ApplyBackgroundEffect();
            }

            var resultShapes = new List<Shape>();
            foreach (var styleWorker in WorkerFactory.StyleWorkers)
            {
                resultShapes.AddRange(
                    styleWorker.Execute(Option, designer, source, imageShape));
            }
            // Those workers executed at the beginning will have the output
            // put at the back.
            resultShapes.Reverse();
            SendToBack(resultShapes.ToArray());
            imageShape.ZOrder(MsoZOrderCmd.msoSendToBack);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// process how to handle a style based on the given source and style option
        /// </summary>
        /// <param name="designer"></param>
        /// <param name="source"></param>
        /// <param name="isActualSize"></param>
        private void ApplyStyle(EffectsDesigner designer, ImageItem source, bool isActualSize)
        {
            if (Options.IsUseBannerStyle 
                && (Options.TextBoxPosition == 4/*left*/
                    || Options.TextBoxPosition == 5/*centered*/
                    || Options.TextBoxPosition == 6/*right*/))
            {
                designer.ApplyTextWrapping();
            }
            else if (Options.IsUseCircleStyle
                     || Options.IsUseOutlineStyle)
            {
                designer.ApplyTextWrapping();
            }
            else
            {
                designer.RecoverTextWrapping();
            }

            ApplyTextEffect(designer);

            // store style options information into original image shape
            // return original image and cropped image
            var metaImages = designer.EmbedStyleOptionsInformation(
                source.OriginalImageFile, source.FullSizeImageFile, 
                source.ContextLink, source.Rect, Options);
            Shape originalImage = null;
            Shape croppedImage = null;
            if (metaImages.Count == 2)
            {
                originalImage = metaImages[0];
                croppedImage = metaImages[1];
            }

            Shape imageShape;
            if (Options.IsUseSpecialEffectStyle)
            {
                imageShape = designer.ApplySpecialEffectEffect(Options.GetSpecialEffect(), isActualSize, Options.ImageOffset);
            }
            else // Direct Text style
            {
                imageShape = designer.ApplyBackgroundEffect(Options.ImageOffset);
            }

            Shape backgroundOverlayShape = null;
            if (Options.IsUseOverlayStyle)
            {
                backgroundOverlayShape = designer.ApplyOverlayEffect(Options.OverlayColor, Options.Transparency);
            }

            Shape blurImageShape = null;
            if (Options.IsUseBlurStyle)
            {
                blurImageShape = Options.IsUseSpecialEffectStyle
                    ? designer.ApplyBlurEffect(source.SpecialEffectImageFile, Options.BlurDegree, Options.ImageOffset)
                    : designer.ApplyBlurEffect(degree: Options.BlurDegree, offset: Options.ImageOffset);
            }

            Shape bannerOverlayShape = null;
            if (Options.IsUseBannerStyle)
            {
                bannerOverlayShape = ApplyBannerStyle(designer, imageShape);
            }

            if (Options.IsUseTextBoxStyle)
            {
                designer.ApplyTextboxEffect(Options.TextBoxColor, Options.TextBoxTransparency);
            }

            Shape outlineOverlayShape = null;
            if (Options.IsUseOutlineStyle)
            {
                outlineOverlayShape = designer.ApplyRectOutlineEffect(imageShape, Options.FontColor, 0);
            }

            Shape frameOverlayShape = null;
            if (Options.IsUseFrameStyle)
            {
                frameOverlayShape = designer.ApplyAlbumFrameEffect(Options.FrameColor, Options.FrameTransparency);
            }

            Shape circleOverlayShape = null;
            if (Options.IsUseCircleStyle)
            {
                circleOverlayShape = designer.ApplyCircleRingsEffect(Options.CircleColor, Options.CircleTransparency);
            }

            Shape triangleOverlayShape = null;
            if (Options.IsUseTriangleStyle)
            {
                triangleOverlayShape = designer.ApplyTriangleEffect(Options.TriangleColor, Options.FontColor,
                    Options.TriangleTransparency);
            }

            SendToBack(
                triangleOverlayShape,
                circleOverlayShape,
                frameOverlayShape,
                outlineOverlayShape,
                bannerOverlayShape,
                backgroundOverlayShape,
                blurImageShape,
                imageShape,
                croppedImage,
                originalImage);

            designer.ApplyImageReference(source.ContextLink);
            if (Options.IsInsertReference)
            {
                designer.ApplyImageReferenceInsertion(source.ContextLink, Options.GetFontFamily(), Options.FontColor);
            }
        }