Exemplo n.º 1
0
        private PowerPoint.Shape ApplyCircleOverlayEffect(string color, int transparency,
                                                          float left, float top, float width, float height, bool isOutline)
        {
            float radius      = (float)Math.Sqrt(width * width / 4 + height * height / 4);
            float circleLeft  = left - radius + width / 2;
            float circleTop   = top - radius + height / 2;
            float circleWidth = radius * 2;

            PowerPoint.Shape overlayShape = Shapes.AddShape(MsoAutoShapeType.msoShapeOval, circleLeft, circleTop,
                                                            circleWidth, circleWidth);
            overlayShape.Fill.Solid();
            overlayShape.Fill.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(color));
            overlayShape.Fill.Transparency  = (float)transparency / 100;
            overlayShape.Line.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(color));
            overlayShape.Line.Transparency  = (float)transparency / 100;
            overlayShape.Line.Weight        = 5;
            if (isOutline)
            {
                overlayShape.Fill.Visible = MsoTriState.msoFalse;
                overlayShape.Line.Visible = MsoTriState.msoTrue;
            }
            else
            {
                overlayShape.Fill.Visible = MsoTriState.msoTrue;
                overlayShape.Line.Visible = MsoTriState.msoFalse;
            }
            // as picture shape
            overlayShape.Cut();
            overlayShape      = Shapes.PasteSpecial(PowerPoint.PpPasteDataType.ppPastePNG)[1];
            overlayShape.Left = circleLeft;
            overlayShape.Top  = circleTop;
            ChangeName(overlayShape, EffectName.Overlay);
            return(overlayShape);
        }
        public PowerPoint.Shape ApplyAlbumFrameEffect(string overlayColor, int transparency)
        {
            int   halfFrameWidth = 15;
            float width          = SlideWidth - halfFrameWidth * 2;
            float height         = SlideHeight - halfFrameWidth * 2;

            PowerPoint.Shape frameShape = Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, halfFrameWidth, halfFrameWidth,
                                                          width, height);
            ChangeName(frameShape, EffectName.Overlay);
            frameShape.Fill.Transparency  = 1f;
            frameShape.Line.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(overlayColor));
            frameShape.Line.Transparency  = (float)transparency / 100;
            frameShape.Line.Weight        = 30;
            frameShape.Line.Visible       = MsoTriState.msoTrue;
            return(frameShape);
        }
 // add overlay layer
 public PowerPoint.Shape ApplyOverlayEffect(string color, int transparency,
                                            float left = 0, float top = 0, float?width = null, float?height = null)
 {
     width  = width ?? SlideWidth;
     height = height ?? SlideHeight;
     PowerPoint.Shape overlayShape = Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle, left, top,
                                                     width.Value, height.Value);
     ChangeName(overlayShape, EffectName.Overlay);
     overlayShape.Fill.Solid();
     overlayShape.Fill.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(color));
     overlayShape.Fill.Transparency  = (float)transparency / 100;
     overlayShape.Line.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(color));
     overlayShape.Line.Transparency  = (float)transparency / 100;
     overlayShape.Line.Weight        = 5;
     overlayShape.Line.Visible       = MsoTriState.msoFalse;
     return(overlayShape);
 }
Exemplo n.º 4
0
        // apply text formats to textbox & placeholer
        public void ApplyTextEffect(string fontFamily, string fontColor, int fontSizeToIncrease, int fontTransparency)
        {
            var shape = ShapeUtil.GetTextShapeToProcess(Shapes);

            if (shape == null)
            {
                return;
            }

            // a hack to enable the textbox layout
            shape.Width = shape.Width;

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

            var font = shape.TextFrame2.TextRange.TrimText().Font;

            if (!string.IsNullOrEmpty(fontColor))
            {
                font.Fill.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(fontColor));
            }

            if (!StringUtil.IsEmpty(fontFamily))
            {
                shape.TextEffect.FontName = fontFamily;
            }

            if (StringUtil.IsEmpty(shape.Tags[Tag.OriginalFontSize]))
            {
                shape.Tags.Add(Tag.OriginalFontSize, shape.TextEffect.FontSize.ToString(CultureInfo.InvariantCulture));
            }

            if (fontSizeToIncrease != -1)
            {
                shape.TextFrame.AutoSize  = PowerPoint.PpAutoSize.ppAutoSizeNone;
                shape.TextEffect.FontSize = float.Parse(shape.Tags[Tag.OriginalFontSize]) + fontSizeToIncrease;
            }

            if (fontTransparency != -1)
            {
                font.Fill.Transparency = (float)fontTransparency / 100;
            }
        }
        public PowerPoint.Shape ApplyTriangleEffect(string overlayColor1, string overlayColor2, int transparency)
        {
            var width1      = SlideHeight;
            var height1     = SlideWidth;
            var centerLeft1 = SlideWidth / 2;
            var centerTop1  = SlideHeight / 2;
            // the bigger triangle
            var triangle1 = Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscelesTriangle,
                                            centerLeft1 - centerTop1, centerLeft1 + centerTop1 - SlideWidth, width1, height1);

            triangle1.Rotation = 90;
            ChangeName(triangle1, EffectName.Overlay);
            triangle1.Fill.Solid();
            triangle1.Fill.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(overlayColor1));
            triangle1.Fill.Transparency  = (float)transparency / 100;
            triangle1.Line.Visible       = MsoTriState.msoFalse;

            var width2      = SlideHeight / 2;
            var height2     = SlideWidth / 2;
            var centerLeft2 = SlideWidth / 4 * 3;
            var centerTop2  = SlideHeight / 4 * 3;
            // the smaller triangle
            var triangle2 = Shapes.AddShape(MsoAutoShapeType.msoShapeIsoscelesTriangle,
                                            centerLeft2 + centerTop2 - SlideHeight,
                                            centerTop2 + SlideWidth / 2 - centerLeft2,
                                            width2,
                                            height2);

            triangle2.Rotation = 270;
            ChangeName(triangle2, EffectName.Overlay);
            triangle2.Fill.Solid();
            triangle2.Fill.ForeColor.RGB = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(overlayColor2));
            triangle2.Fill.Transparency  = (float)transparency / 100;
            triangle2.Line.Visible       = MsoTriState.msoFalse;

            var result = Shapes.Range(new[] { triangle1.Name, triangle2.Name }).Group();

            ChangeName(result, EffectName.Overlay);
            return(result);
        }
        public void ApplyImageReferenceInsertion(string source, string fontFamily, string fontColor,
                                                 int fontSize, string textBoxColor, Alignment citationTextAlignment)
        {
            Microsoft.Office.Interop.PowerPoint.Shape imageRefShape = Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, 0, 0, SlideWidth,
                                                                                        20);
            imageRefShape.TextFrame2.TextRange.Text = "Picture taken from: " + source;

            if (!StringUtil.IsEmpty(textBoxColor))
            {
                imageRefShape.Fill.BackColor.RGB
                    = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(textBoxColor));
                imageRefShape.Fill.Transparency = 0.2f;
            }
            imageRefShape.TextFrame2.TextRange.TrimText().Font.Fill.ForeColor.RGB
                = GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(fontColor));
            imageRefShape.TextEffect.FontName  = StringUtil.IsEmpty(fontFamily) ? "Tahoma" : fontFamily;
            imageRefShape.TextEffect.FontSize  = fontSize;
            imageRefShape.TextEffect.Alignment = AlignmentToMsoTextEffectAlignment(citationTextAlignment);
            imageRefShape.Top = SlideHeight - imageRefShape.Height;

            AddTag(imageRefShape, Tag.ImageReference, "true");
            ChangeName(imageRefShape, EffectName.ImageReference);
        }
        public void ApplyTextGlowEffect(bool isUseTextGlow, string textGlowColor)
        {
            PowerPoint.Shape shape = ShapeUtil.GetTextShapeToProcess(Shapes);
            if (shape == null)
            {
                return;
            }

            if (isUseTextGlow)
            {
                shape.TextFrame2.TextRange.Font.Glow.Radius    = 8;
                shape.TextFrame2.TextRange.Font.Glow.Color.RGB =
                    GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(textGlowColor));
                shape.TextFrame2.TextRange.Font.Glow.Transparency = 0.6f;
            }
            else
            {
                shape.TextFrame2.TextRange.Font.Glow.Radius    = 0;
                shape.TextFrame2.TextRange.Font.Glow.Color.RGB =
                    GraphicsUtil.ConvertColorToRgb(StringUtil.GetColorFromHexValue(textGlowColor));
                shape.TextFrame2.TextRange.Font.Glow.Transparency = 0.0f;
            }
        }