AddMathShape

ShapeCollection.AddMathShape méthode

Crée une nouvelle forme Autoshape adaptée du modèle par défaut au contenu mathématique et l’ajoute à la fin de la collection.

public IAutoShape AddMathShape(float x, float y, float width, float height)
ParamètreTypeDescription
xSingleLa coordonnée X pour le côté gauche du cadre de la forme.
ySingleLa coordonnée Y pour le côté supérieur du cadre de la forme.
widthSingleLa largeur du cadre de la forme.
heightSingleLa hauteur du cadre de la forme.

Valeur de Retour

Objet AutoShape créé.

Exemples

L’exemple suivant montre comment ajouter une Équation Mathématique dans une Présentation PowerPoint.

[C#]
using (Presentation pres = new Presentation())
{
   IAutoShape mathShape = pres.Slides[0].Shapes.AddMathShape(0, 0, 720, 150);
   var mathParagraph = (mathShape.TextFrame.Paragraphs[0].Portions[0] as MathPortion).MathParagraph;
   var fraction = new MathematicalText("x").Divide("y");
   mathParagraph.Add(new MathBlock(fraction));
   var mathBlock = new MathematicalText("c")
        .SetSuperscript("2")
        .Join("=")
        .Join(new MathematicalText("a").SetSuperscript("2"))
        .Join("+")
        .Join(new MathematicalText("b").SetSuperscript("2"));
    mathParagraph.Add(mathBlock);
    pres.Save("math.pptx", SaveFormat.Pptx);
}

Voir Aussi