예제 #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.SafeDelete();
            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.SafeDelete();
            return(image);
        }
예제 #3
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;
            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.SafeDelete();
            return(image);
        }
        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.SafeDelete();

            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.SafeDelete();
            return(image);
        }
예제 #6
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.SafeDelete();
            return(shapeToReturn);
        }
        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.SafeDelete();
            return(image);
        }
예제 #8
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.SafeDelete();
            }
        }
예제 #9
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.SafeDelete();
                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);
            }
        }