AddMathShape

ShapeCollection.AddMathShape Methode

Erstellt eine neue Autoshape, die aus der Standardvorlage für mathematische Inhalte angepasst ist, und fügt sie am Ende der Sammlung hinzu.

public IAutoShape AddMathShape(float x, float y, float width, float height)
ParameterTypBeschreibung
xEinzelDie X-Koordinate für die linke Seite des Rahmens der Form.
yEinzelDie Y-Koordinate für die obere Seite des Rahmens der Form.
widthEinzelDie Breite des Rahmens der Form.
heightEinzelDie Höhe des Rahmens der Form.

Rückgabewert

Erstelltes AutoShape-Objekt.

Beispiele

Das folgende Beispiel zeigt, wie man eine mathematische Gleichung in einer PowerPoint-Präsentation hinzufügt.

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

Siehe Auch