public void ApplyFrostedGlassTextBoxEffect(string overlayColor, int transparency, Shape blurImage, int fontSizeToIncrease)
        {
            var shape = ShapeUtil.GetTextShapeToProcess(Shapes);
            if (shape == null)
                return;

            var margin = CalculateTextBoxMargin(fontSizeToIncrease);
            // multiple paragraphs.. 
            foreach (TextRange2 textRange in shape.TextFrame2.TextRange.Paragraphs)
            {
                if (StringUtil.IsNotEmpty(textRange.TrimText().Text))
                {
                    var paragraph = textRange.TrimText();
                    var left = paragraph.BoundLeft - margin;
                    var top = paragraph.BoundTop - margin;
                    var width = paragraph.BoundWidth + margin * 2;
                    var height = paragraph.BoundHeight + margin * 2;

                    var blurTextBox = blurImage.Duplicate()[1];
                    blurTextBox.Left = blurImage.Left;
                    blurTextBox.Top = blurImage.Top;
                    CropPicture(blurTextBox, left, top, width, height);
                    ChangeName(blurTextBox, EffectName.TextBox);

                    var overlayShape = ApplyOverlayEffect(overlayColor, transparency,
                        left, top, width, height);
                    ChangeName(overlayShape, EffectName.TextBox);

                    Graphics.MoveZToJustBehind(blurTextBox, shape);
                    Graphics.MoveZToJustBehind(overlayShape, shape);
                }
            }
        }
        public Shape ApplyFrostedGlassBannerEffect(BannerDirection direction, Position textPos, Shape blurImage,
                                                   string overlayColor, int transparency)
        {
            TextBoxInfo tbInfo =
                new TextBoxes(Shapes.Range(), SlideWidth, SlideHeight)
                .GetTextBoxesInfo();

            if (tbInfo == null)
            {
                return(null);
            }

            TextBoxes.AddMargin(tbInfo);

            Shape overlayShape;
            Shape blurBanner = blurImage.Duplicate()[1];

            blurBanner.Left = blurImage.Left;
            blurBanner.Top  = blurImage.Top;
            direction       = HandleAutoDirection(direction, textPos);
            switch (direction)
            {
            case BannerDirection.Horizontal:
                overlayShape = ApplyOverlayEffect(overlayColor, transparency, 0, tbInfo.Top, SlideWidth,
                                                  tbInfo.Height);
                CropPicture(blurBanner, 0, tbInfo.Top, SlideWidth, tbInfo.Height);
                break;

            // case BannerDirection.Vertical:
            default:
                overlayShape = ApplyOverlayEffect(overlayColor, transparency, tbInfo.Left, 0, tbInfo.Width,
                                                  SlideHeight);
                CropPicture(blurBanner, tbInfo.Left, 0, tbInfo.Width, SlideHeight);
                break;
            }
            ChangeName(overlayShape, EffectName.Banner);
            ChangeName(blurBanner, EffectName.Banner);
            overlayShape.ZOrder(MsoZOrderCmd.msoSendToBack);
            Utils.ShapeUtil.MoveZToJustBehind(blurBanner, overlayShape);

            Microsoft.Office.Interop.PowerPoint.ShapeRange range = Shapes.Range(new[] { blurBanner.Name, overlayShape.Name });
            Shape resultShape = range.Group();

            ChangeName(resultShape, EffectName.Banner);
            return(resultShape);
        }
        public void ApplyFrostedGlassTextBoxEffect(string overlayColor, int transparency, Shape blurImage)
        {
            foreach (Shape shape in Shapes)
            {
                if ((shape.Type != MsoShapeType.msoPlaceholder
                        && shape.Type != MsoShapeType.msoTextBox)
                        || shape.TextFrame.HasText == MsoTriState.msoFalse
                        || StringUtil.IsNotEmpty(shape.Tags[Tag.AddedTextbox])
                        || StringUtil.IsNotEmpty(shape.Tags[Tag.ImageReference]))
                {
                    continue;
                }

                // multiple paragraphs.. 
                foreach (TextRange2 textRange in shape.TextFrame2.TextRange.Paragraphs)
                {
                    if (StringUtil.IsNotEmpty(textRange.TrimText().Text))
                    {
                        var paragraph = textRange.TrimText();
                        var left = paragraph.BoundLeft - 10;
                        var top = paragraph.BoundTop - 10;
                        var width = paragraph.BoundWidth + 20;
                        var height = paragraph.BoundHeight + 20;

                        var blurTextBox = blurImage.Duplicate()[1];
                        blurTextBox.Left = blurImage.Left;
                        blurTextBox.Top = blurImage.Top;
                        CropPicture(blurTextBox, left, top, width, height);
                        ChangeName(blurTextBox, EffectName.TextBox);

                        var overlayShape = ApplyOverlayEffect(overlayColor, transparency,
                            left, top, width, height);
                        ChangeName(overlayShape, EffectName.TextBox);

                        Graphics.MoveZToJustBehind(blurTextBox, shape);
                        Graphics.MoveZToJustBehind(overlayShape, shape);
                        shape.Tags.Add(Tag.AddedTextbox, overlayShape.Name);
                    }
                }
            }
            foreach (Shape shape in Shapes)
            {
                shape.Tags.Add(Tag.AddedTextbox, "");
            }
        }
예제 #4
0
        public static Shape FillInShapeWithImage(PowerPointSlide currentSlide, string imageFile, Shape shape,
                                                 double magnifyRatio = 1.0, bool isInPlace = false)
        {
            CreateFillInBackgroundForShape(imageFile, shape, magnifyRatio);
            shape.Fill.UserPicture(FillInBackgroundPicture);

            shape.Line.Visible = Office.MsoTriState.msoFalse;

            if (isInPlace)
            {
                return(shape);
            }

            Shape shapeToReturn = shape.Duplicate()[1];

            shape.Delete();
            return(shapeToReturn);
        }
        public Shape ApplyFrostedGlassBannerEffect(BannerDirection direction, Position textPos, Shape blurImage,
            string overlayColor, int transparency)
        {
            var tbInfo =
                new TextBoxes(Shapes.Range(), SlideWidth, SlideHeight)
                .GetTextBoxesInfo();
            if (tbInfo == null)
                return null;

            TextBoxes.AddMargin(tbInfo);

            Shape overlayShape;
            var blurBanner = blurImage.Duplicate()[1];
            blurBanner.Left = blurImage.Left;
            blurBanner.Top = blurImage.Top;
            direction = HandleAutoDirection(direction, textPos);
            switch (direction)
            {
                case BannerDirection.Horizontal:
                    overlayShape = ApplyOverlayEffect(overlayColor, transparency, 0, tbInfo.Top, SlideWidth,
                        tbInfo.Height);
                    CropPicture(blurBanner, 0, tbInfo.Top, SlideWidth, tbInfo.Height);
                    break;
                // case BannerDirection.Vertical:
                default:
                    overlayShape = ApplyOverlayEffect(overlayColor, transparency, tbInfo.Left, 0, tbInfo.Width,
                        SlideHeight);
                    CropPicture(blurBanner, tbInfo.Left, 0, tbInfo.Width, SlideHeight);
                    break;
            }
            ChangeName(overlayShape, EffectName.Banner);
            ChangeName(blurBanner, EffectName.Banner);
            overlayShape.ZOrder(MsoZOrderCmd.msoSendToBack);
            Graphics.MoveZToJustBehind(blurBanner, overlayShape);

            var range = Shapes.Range(new[] {blurBanner.Name, overlayShape.Name});
            var resultShape = range.Group();
            ChangeName(resultShape, EffectName.Banner);
            return resultShape;
        }
예제 #6
0
        public static Shape Crop(PowerPointSlide currentSlide, ShapeRange shapeRange,
                                 double magnifyRatio = 1.0, bool isInPlace = false, bool handleError = true)
        {
            try
            {
                bool  hasManyShapes = shapeRange.Count > 1;
                Shape shape         = hasManyShapes ? shapeRange.Group() : shapeRange[1];
                float left          = shape.Left;
                float top           = shape.Top;
                shapeRange = shape.Duplicate();
                shape.Delete();
                shapeRange.Left = left;
                shapeRange.Top  = top;
                if (hasManyShapes)
                {
                    shapeRange = shapeRange.Ungroup();
                }

                TakeScreenshotProxy(currentSlide, shapeRange);

                ShapeRange   ungroupedRange = EffectsLabUtil.UngroupAllShapeRange(currentSlide, shapeRange);
                List <Shape> shapeList      = new List <Shape>();

                for (int i = 1; i <= ungroupedRange.Count; i++)
                {
                    Shape filledShape = FillInShapeWithImage(currentSlide, SlidePicture, ungroupedRange[i], magnifyRatio, isInPlace);
                    shapeList.Add(filledShape);
                }

                ShapeRange croppedRange = currentSlide.ToShapeRange(shapeList);
                Shape      croppedShape = (croppedRange.Count == 1) ? croppedRange[1] : croppedRange.Group();

                return(croppedShape);
            }
            catch (Exception e)
            {
                throw new CropLabException(e.Message);
            }
        }
        public void ApplyFrostedGlassTextBoxEffect(string overlayColor, int transparency, Shape blurImage, int fontSizeToIncrease)
        {
            Shape shape = Util.ShapeUtil.GetTextShapeToProcess(Shapes);

            if (shape == null)
            {
                return;
            }

            int margin = CalculateTextBoxMargin(fontSizeToIncrease);

            // multiple paragraphs..
            foreach (TextRange2 textRange in shape.TextFrame2.TextRange.Paragraphs)
            {
                if (StringUtil.IsNotEmpty(textRange.TrimText().Text))
                {
                    TextRange2 paragraph = textRange.TrimText();
                    float      left      = paragraph.BoundLeft - margin;
                    float      top       = paragraph.BoundTop - margin;
                    float      width     = paragraph.BoundWidth + margin * 2;
                    float      height    = paragraph.BoundHeight + margin * 2;

                    Shape blurTextBox = blurImage.Duplicate()[1];
                    blurTextBox.Left = blurImage.Left;
                    blurTextBox.Top  = blurImage.Top;
                    CropPicture(blurTextBox, left, top, width, height);
                    ChangeName(blurTextBox, EffectName.TextBox);

                    Shape overlayShape = ApplyOverlayEffect(overlayColor, transparency,
                                                            left, top, width, height);
                    ChangeName(overlayShape, EffectName.TextBox);

                    Utils.ShapeUtil.MoveZToJustBehind(blurTextBox, shape);
                    Utils.ShapeUtil.MoveZToJustBehind(overlayShape, shape);
                }
            }
        }