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
            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 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 static bool IsPlaceholderSyncable(this Shape shape)
 {
     if (shape.Type != MsoShapeType.msoPlaceholder)
     {
         return(false);
     }
     Microsoft.Office.Interop.PowerPoint.Shapes templateShapes =
         SyncFormatUtil.GetTemplateShapes();
     return(ShapeUtil.CanCopyMsoPlaceHolder(shape, templateShapes));
 }
        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);
        }
        public override Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddShape(
                MsoAutoShapeType.msoShapeRectangle, 0, 0,
                SyncFormatConstants.DisplayImageSize.Width,
                SyncFormatConstants.DisplayImageSize.Height);

            // do not sync extrusion theme color with forecolor, it throws an exception
            shape.Fill.ForeColor.RGB          = formatShape.ThreeD.ExtrusionColor.RGB;
            shape.Fill.ForeColor.TintAndShade = formatShape.ThreeD.ExtrusionColor.TintAndShade;
            shape.Line.Visible = MsoTriState.msoFalse;
            Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));

            shape.SafeDelete();
            return(image);
        }
        public void RemoveShape(string shapeKey)
        {
            int    index  = 1;
            Shapes shapes = Slides[0].Shapes;

            while (index <= shapes.Count)
            {
                if (shapes[index].Name.Equals(shapeKey))
                {
                    shapes[index].Delete();
                    _backupArtisticEffects.Remove(shapeKey);
                }
                else
                {
                    index++;
                }
            }
        }
Exemple #8
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);
        }
        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);
        }
        public Shape GetShape(string shapeKey)
        {
            Shapes shapes = Slides[0].Shapes;

            for (int i = 1; i <= shapes.Count; i++)
            {
                if (shapes[i].Name.Equals(shapeKey))
                {
                    Shape shape = shapes[i];
                    if (_backupArtisticEffects.ContainsKey(shapeKey))
                    {
                        // apply artistic effect from backup only when shape is retrieved, to reduce loading time of CopyShape
                        List <MsoPictureEffectType> extractedEffects = _backupArtisticEffects[shapeKey];
                        ArtisticEffectFormat.ClearArtisticEffects(shape);
                        ArtisticEffectFormat.ApplyArtisticEffects(shape, extractedEffects);
                    }
                    return(shape);
                }
            }
            return(null);
        }
Exemple #11
0
        private static void GetPowerPointData(Microsoft.Office.Interop.PowerPoint.Presentation presen)
        {
            //ファイル名の出力
            Console.WriteLine("file:" + presen.FullName);

            Microsoft.Office.Interop.PowerPoint.Slides AllSlide = presen.Slides;
            Microsoft.Office.Interop.PowerPoint.Slide  slide    = AllSlide[1];
            Microsoft.Office.Interop.PowerPoint.Shapes shapes   = slide.Shapes;

            foreach (Microsoft.Office.Interop.PowerPoint.Shape shape in shapes)
            {
                string title = shape.TextFrame.TextRange.Text;
                title = title.Replace("\r", "");
                //文字列の出力
                Console.WriteLine(title);
            }
            Console.WriteLine();

            if (SaveImage)
            {
                SaveSlideImage(presen);
            }
            presen.Close();
        }