Example #1
0
        public override Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddShape(
                MsoAutoShapeType.msoShapeRectangle, 0, 0,
                SyncFormatConstants.DisplayImageSize.Width,
                SyncFormatConstants.DisplayImageSize.Height);

            shape.Line.Visible = MsoTriState.msoFalse;
            shape.ThreeD.Depth = SyncFormatConstants.DisplayImageDepth;

            // don't set type if type is TypeMixed, it throws an exception
            if (formatShape.ThreeD.BevelTopType != MsoBevelType.msoBevelTypeMixed)
            {
                shape.ThreeD.BevelTopType = formatShape.ThreeD.BevelTopType;
                // set depth & inset only if type is not none,
                // adjusting these 2 will automatically set type from None to Round
                if (shape.ThreeD.BevelTopType != MsoBevelType.msoBevelNone)
                {
                    shape.ThreeD.BevelTopDepth = SyncFormatConstants.DisplayBevelHeight;
                    shape.ThreeD.BevelTopInset = SyncFormatConstants.DisplayBevelWidth;
                }
            }
            shape.ThreeD.BevelBottomType = MsoBevelType.msoBevelNone;
            shape.ThreeD.SetPresetCamera(MsoPresetCamera.msoCameraPerspectiveAbove);
            shape.ThreeD.PresetLighting = MsoLightRigType.msoLightRigBalanced;
            Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));

            shape.Delete();
            return(image);
        }
        public override Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddShape(
                MsoAutoShapeType.msoShapeRectangle, 0, 0,
                SyncFormatConstants.DisplayImageSize.Width,
                SyncFormatConstants.DisplayImageSize.Height);

            shape.Line.Visible            = MsoTriState.msoFalse;
            shape.ThreeD.Depth            = SyncFormatConstants.DisplayImageDepth;
            shape.ThreeD.BevelTopType     = SyncFormatConstants.DisplayBevelType;
            shape.ThreeD.BevelTopDepth    = SyncFormatConstants.DisplayBevelHeight;
            shape.ThreeD.BevelTopInset    = SyncFormatConstants.DisplayBevelWidth;
            shape.ThreeD.BevelBottomType  = SyncFormatConstants.DisplayBevelType;
            shape.ThreeD.BevelBottomDepth = SyncFormatConstants.DisplayBevelHeight;
            shape.ThreeD.BevelBottomInset = SyncFormatConstants.DisplayBevelWidth;
            // setting mixed throws an exception
            // show flat type instead, which looks very similar
            if (formatShape.ThreeD.PresetMaterial == MsoPresetMaterial.msoPresetMaterialMixed)
            {
                shape.ThreeD.PresetMaterial = MsoPresetMaterial.msoMaterialFlat;
            }
            else
            {
                shape.ThreeD.PresetMaterial = formatShape.ThreeD.PresetMaterial;
            }
            shape.ThreeD.SetPresetCamera(SyncFormatConstants.DisplayCameraPreset);
            Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));

            shape.Delete();
            return(image);
        }
        public override Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddShape(
                MsoAutoShapeType.msoShapeRectangle, 0, 0,
                SyncFormatConstants.DisplayImageSize.Width,
                SyncFormatConstants.DisplayImageSize.Height);

            shape.Line.Visible            = MsoTriState.msoFalse;
            shape.ThreeD.Depth            = SyncFormatConstants.DisplayImageDepth;
            shape.ThreeD.BevelTopType     = SyncFormatConstants.DisplayBevelType;
            shape.ThreeD.BevelTopDepth    = SyncFormatConstants.DisplayBevelHeight;
            shape.ThreeD.BevelTopInset    = SyncFormatConstants.DisplayBevelWidth;
            shape.ThreeD.BevelBottomType  = SyncFormatConstants.DisplayBevelType;
            shape.ThreeD.BevelBottomDepth = SyncFormatConstants.DisplayBevelHeight;
            shape.ThreeD.BevelBottomInset = SyncFormatConstants.DisplayBevelWidth;

            // setting mixed throws an exception
            if (formatShape.ThreeD.PresetLighting != MsoLightRigType.msoLightRigMixed)
            {
                shape.ThreeD.PresetLighting = formatShape.ThreeD.PresetLighting;
            }
            shape.ThreeD.SetPresetCamera(SyncFormatConstants.DisplayCameraPreset);

            Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));

            shape.Delete();
            return(image);
        }
        public void NoContentShapeUnsuccessful()
        {
            PpOperations.SelectSlide(1);
            Microsoft.Office.Interop.PowerPoint.Shape contentShape = PpOperations.SelectShapesByPrefix("PptLabsAgenda_&^@ContentShape")[1];
            contentShape.Delete();

            MessageBoxUtil.ExpectMessageBoxWillPopUp(
                "Unable to execute action",
                "The current reference slide is invalid. Either replace the reference slide or regenerate the agenda.",
                PplFeatures.SynchronizeAgenda);
        }
Example #5
0
        public void NoHighlightedTextUnsuccessful()
        {
            PpOperations.SelectSlide(1);
            Microsoft.Office.Interop.PowerPoint.Shape highlightedText = PpOperations.RecursiveGetShapeWithPrefix("PptLabsAgenda_&^@BeamShapeMainGroup",
                                                                                                                 "PptLabsAgenda_&^@BeamShapeHighlightedText");
            highlightedText.Delete();

            MessageBoxUtil.ExpectMessageBoxWillPopUp(
                "Unable to execute action",
                "The current reference slide is invalid. Either replace the reference slide or regenerate the agenda.",
                PplFeatures.SynchronizeAgenda);
        }
        public override Bitmap DisplayImage(Shape formatShape)
        {
            // change transparency to make shadow more visible in preview
            // don't bother changing fill transparency, it does not affect picture type shapes

            // setting transparency will change the ShadowFormat.Type to MixedType
            // use a duplicate to avoid complex control flow required for restoring ShadowFormat.Type
            Shape duplicate = formatShape.Duplicate()[1];

            duplicate.Shadow.Transparency = 0.3f;

            Bitmap image = GraphicsUtil.ShapeToBitmap(duplicate);

            duplicate.Delete();

            return(image);
        }
        public override Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddShape(
                MsoAutoShapeType.msoShapeRectangle, 0, 0,
                SyncFormatConstants.DisplayImageSize.Width,
                SyncFormatConstants.DisplayImageSize.Height);

            shape.Fill.ForeColor.RGB          = formatShape.ThreeD.ContourColor.RGB;
            shape.Fill.ForeColor.TintAndShade = formatShape.ThreeD.ContourColor.TintAndShade;

            shape.Line.Visible = MsoTriState.msoFalse;
            Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));

            shape.Delete();
            return(image);
        }
Example #8
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);
        }
Example #9
0
        public static Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddShape(
                Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 0, 0,
                SyncFormatConstants.DisplayImageSize.Width,
                SyncFormatConstants.DisplayImageSize.Height);

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

            int guessedColor = ShapeUtil.GuessTextColor(formatShape);

            shape.Fill.ForeColor.RGB = guessedColor;
            shape.Fill.BackColor.RGB = guessedColor;
            shape.Fill.Solid();
            Bitmap image = GraphicsUtil.ShapeToBitmap(shape);

            shape.Delete();
            return(image);
        }
Example #10
0
        public override Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddShape(
                Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 0, 0,
                SyncFormatConstants.DisplayImageSize.Width,
                SyncFormatConstants.DisplayImageSize.Height);

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

            shape.Fill.ForeColor.RGB          = formatShape.Glow.Color.RGB;
            shape.Fill.ForeColor.Brightness   = formatShape.Glow.Color.Brightness;
            shape.Fill.ForeColor.TintAndShade = formatShape.Glow.Color.TintAndShade;
            shape.Fill.Solid();

            Bitmap image = GraphicsUtil.ShapeToBitmap(shape);

            shape.Delete();
            return(image);
        }
Example #11
0
        /// <summary>
        /// Save the coordinates of nodes
        /// </summary>
        private void SetPoints(bool isConvertToFreeform = false)
        {
            if (!(_shape.Type == MsoShapeType.msoAutoShape || _shape.Type == MsoShapeType.msoFreeform) ||
                _shape.Nodes.Count < 1)
            {
                return;
            }

            Microsoft.Office.Interop.PowerPoint.Shape shape = _shape;

            if (!isConvertToFreeform)
            {
                shape      = _shape.Duplicate()[1];
                shape.Left = _shape.Left;
                shape.Top  = _shape.Top;
            }

            // Convert AutoShape to Freeform shape
            if (shape.Type == MsoShapeType.msoAutoShape)
            {
                shape.Nodes.Insert(1, MsoSegmentType.msoSegmentLine, MsoEditingType.msoEditingAuto, 0, 0);
                shape.Nodes.Delete(2);
            }

            _points = new List <PointF>();

            for (int i = 1; i <= shape.Nodes.Count; i++)
            {
                Microsoft.Office.Interop.PowerPoint.ShapeNode node = shape.Nodes[i];
                dynamic point    = node.Points;
                PointF  newPoint = new PointF(point[1, 1], point[1, 2]);

                _points.Add(newPoint);
            }

            if (!isConvertToFreeform)
            {
                shape.Delete();
            }
        }
Example #12
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);
            }
        }