نص رياضي
Contents
[
Hide
]
يوضح العمل مع أشكال النص الرياضي وتنسيق المعادلات باستخدام Aspose.Slides for .NET.
إضافة نص رياضي
إنشاء شكل رياضي يحتوي على كسر وصيغة فيثاغورس.
static void Add_Math_Text()
{
using var pres = new Presentation();
var slide = pres.Slides[0];
// إضافة شكل رياضي إلى الشريحة
var mathShape = slide.Shapes.AddMathShape(0, 0, 720, 150);
// الوصول إلى الفقرة الرياضية
var mathParagraph = ((MathPortion)mathShape.TextFrame.Paragraphs[0].Portions[0]).MathParagraph;
// إضافة كسر بسيط: x / y
var fraction = new MathematicalText("x").Divide("y");
mathParagraph.Add(new MathBlock(fraction));
// إضافة معادلة: c² = a² + b²
var mathBlock = new MathematicalText("c")
.SetSuperscript("2")
.Join("=")
.Join(new MathematicalText("a").SetSuperscript("2"))
.Join("+")
.Join(new MathematicalText("b").SetSuperscript("2"));
mathParagraph.Add(mathBlock);
}
الوصول إلى نص رياضي
العثور على شكل يحتوي على فقرة رياضية في الشريحة.
static void Access_Math_Text()
{
using var pres = new Presentation();
var slide = pres.Slides[0];
// العثور على الشكل الأول الذي يحتوي على فقرة رياضية
var mathShape = slide.Shapes
.OfType<IAutoShape>()
.FirstOrDefault(s =>
s.TextFrame != null &&
s.TextFrame.Paragraphs.Any(p =>
p.Portions.Any(portion => portion is MathPortion)));
if (mathShape != null)
{
var mathParagraph = ((MathPortion)mathShape.TextFrame.Paragraphs[0].Portions[0]).MathParagraph;
// مثال: إنشاء كسر (لم يتم إضافته هنا)
var fraction = new MathematicalText("x").Divide("y");
// استخدم mathParagraph أو fraction حسب الحاجة...
}
}
إزالة نص رياضي
حذف شكل رياضي من الشريحة.
static void Remove_Math_Text()
{
using var pres = new Presentation();
var slide = pres.Slides[0];
var mathShape = slide.Shapes.AddMathShape(50, 50, 100, 50);
var mathParagraph = ((MathPortion)mathShape.TextFrame.Paragraphs[0].Portions[0]).MathParagraph;
var fraction = new MathematicalText("x").Divide("y");
mathParagraph.Add(new MathBlock(fraction));
slide.Shapes.Remove(mathShape);
}
تنسيق نص رياضي
تعيين خصائص الخط لجزء رياضي.
static void Format_Math_Text()
{
using var pres = new Presentation();
var slide = pres.Slides[0];
var mathShape = slide.Shapes.AddMathShape(50, 50, 100, 50);
var mathParagraph = ((MathPortion)mathShape.TextFrame.Paragraphs[0].Portions[0]).MathParagraph;
var fraction = new MathematicalText("x").Divide("y");
mathParagraph.Add(new MathBlock(fraction));
mathShape.TextFrame.Paragraphs[0].Portions[0].PortionFormat.FontHeight = 20;
}