コード例 #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;
            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);
        }
コード例 #2
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);
        }
コード例 #3
0
        private Bitmap[] ShapeTypesToBitmaps(Array types, string shapeType)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();

            Bitmap[] bitmaps = new Bitmap[types.Length];
            for (int i = 0; i < types.Length; i++)
            {
                if (!((MsoAutoShapeType)types.GetValue(i)).ToString().Contains(shapeType))
                {
                    continue;
                }
                try
                {
                    Shape shape = shapes.AddShape(
                        (MsoAutoShapeType)types.GetValue(i), 0, 0,
                        TooltipsLabConstants.DisplayImageSize.Width,
                        TooltipsLabConstants.DisplayImageSize.Height);
                    ShapeUtil.FormatCalloutToDefaultStyle(shape);
                    bitmaps[i] = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));
                    shape.SafeDelete();
                }
                catch
                {
                }
            }
            return(bitmaps);
        }
コード例 #4
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.Delete();
            return(image);
        }
コード例 #5
0
 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));
 }
コード例 #6
0
        private void CopyButton_Click(object sender, RoutedEventArgs e)
        {
            Selection selection = this.GetCurrentSelection();

            if ((selection.Type != PpSelectionType.ppSelectionShapes &&
                 selection.Type != PpSelectionType.ppSelectionText) ||
                selection.ShapeRange.Count != 1)
            {
                MessageBox.Show(SyncLabText.ErrorCopySelectionInvalid, SyncLabText.ErrorDialogTitle);
                return;
            }

            Shape shape = selection.ShapeRange[1];

            if (shape.Type == MsoShapeType.msoSmartArt)
            {
                MessageBox.Show(SyncLabText.ErrorSmartArtUnsupported, SyncLabText.ErrorDialogTitle);
                return;
            }

            if (selection.HasChildShapeRange)
            {
                if (selection.ChildShapeRange.Count != 1)
                {
                    MessageBox.Show(SyncLabText.ErrorCopySelectionInvalid, SyncLabText.ErrorDialogTitle);
                    return;
                }
                shape = selection.ChildShapeRange[1];
            }

            bool canSyncPlaceHolder =
                shape.Type == MsoShapeType.msoPlaceholder &&
                ShapeUtil.CanCopyMsoPlaceHolder(shape, SyncFormatUtil.GetTemplateShapes());

            if (shape.Type != MsoShapeType.msoAutoShape &&
                shape.Type != MsoShapeType.msoLine &&
                shape.Type != MsoShapeType.msoPicture &&
                shape.Type != MsoShapeType.msoTextBox &&
                !canSyncPlaceHolder)
            {
                MessageBox.Show(SyncLabText.ErrorCopySelectionInvalid, SyncLabText.ErrorDialogTitle);
                return;
            }
            Dialog            = new SyncFormatDialog(shape);
            Dialog.ObjectName = shape.Name;
            bool?result = Dialog.ShowDialog();

            if (!result.HasValue || !(bool)result)
            {
                return;
            }
            AddFormatToList(shape, Dialog.ObjectName, Dialog.Formats);
            Dialog = null;
        }
コード例 #7
0
        public override Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddLine(
                0, SyncFormatConstants.DisplayImageSize.Height,
                SyncFormatConstants.DisplayImageSize.Width, 0);

            SyncFormat(formatShape, shape);
            Bitmap image = GraphicsUtil.ShapeToBitmap(shape);

            shape.Delete();
            return(image);
        }
コード例 #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;
            SyncFormat(formatShape, shape);
            Bitmap image = new Bitmap(GraphicsUtil.ShapeToBitmap(shape));

            shape.Delete();
            return(image);
        }
コード例 #9
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 = formatShape.Line.ForeColor;
            Bitmap image = GraphicsUtil.ShapeToBitmap(shape);

            shape.SafeDelete();
            return(image);
        }
コード例 #10
0
        public static Bitmap DisplayImage(Shape formatShape)
        {
            Shapes shapes = SyncFormatUtil.GetTemplateShapes();
            Shape  shape  = shapes.AddLine(
                0, SyncFormatConstants.DisplayImageSize.Height,
                SyncFormatConstants.DisplayImageSize.Width, 0);

            SyncFormat(formatShape, shape);
            shape.Line.ForeColor.RGB = SyncFormatConstants.ColorBlack;
            shape.Line.Weight        = SyncFormatConstants.DisplayLineWeight;
            Bitmap image = GraphicsUtil.ShapeToBitmap(shape);

            shape.Delete();
            return(image);
        }
コード例 #11
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.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);
        }
コード例 #12
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;
            shape.Fill.ForeColor.RGB = formatShape.TextFrame.TextRange.Font.Color.RGB;
            shape.Fill.BackColor.RGB = formatShape.TextFrame.TextRange.Font.Color.RGB;
            shape.Fill.Solid();
            Bitmap image = GraphicsUtil.ShapeToBitmap(shape);

            shape.Delete();
            return(image);
        }
コード例 #13
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);

            // 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);
        }