العمل مع مربعات النص
في Aspose.Words، يتم استخدام فئة TextBox لتحديد كيفية عرض النص داخل الشكل. يعرض خاصية عامة تسمى Parent للحصول على الشكل الأصلي لمربع النص بحيث يمكن للعميل العثور على Shape المرتبط من TextBox المرتبط.
إنشاء رابط
توفر فئة TextBox طريقة IsValidLinkTarget للتحقق مما إذا كان من الممكن ربط TextBox بـ Textbox الهدف.
يوضح مثال التعليمات البرمجية التالي كيفية التحقق من إمكانية ربط TextBox
بمربع النص الهدف:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(); | |
Shape shape1 = new Shape(doc, ShapeType.TextBox); | |
Shape shape2 = new Shape(doc, ShapeType.TextBox); | |
TextBox textBox1 = shape1.TextBox; | |
TextBox textBox2 = shape2.TextBox; | |
if (textBox1.IsValidLinkTarget(textBox2)) | |
textBox1.Next = textBox2; |
التحقق من تسلسل مربع النص
هناك عدة طرق لعرض النص في شكل ما. يمكن أن يكون TextBox هو رأس التسلسل أو وسطه أو ذيله.
يوضح مثال التعليمات البرمجية التالي كيفية التحقق مما إذا كان TextBox هو رأس أو ذيل أو منتصف التسلسل:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(); | |
Shape shape = new Shape(doc, ShapeType.TextBox); | |
TextBox textBox = shape.TextBox; | |
if ((textBox.Next != null) && (textBox.Previous == null)) | |
{ | |
Console.WriteLine("The head of the sequence"); | |
} | |
if ((textBox.Next != null) && (textBox.Previous != null)) | |
{ | |
Console.WriteLine("The Middle of the sequence."); | |
} | |
if ((textBox.Next == null) && (textBox.Previous != null)) | |
{ | |
Console.WriteLine("The Tail of the sequence."); | |
} |
كسر الارتباط
باستخدام طريقة BreakForwardLink، يمكنك قطع الرابط إلى TextBox التالي.
يوضح مثال التعليمات البرمجية التالي كيفية قطع رابط لـ TextBox:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET | |
Document doc = new Document(); | |
Shape shape = new Shape(doc, ShapeType.TextBox); | |
TextBox textBox = shape.TextBox; | |
// Break a forward link | |
textBox.BreakForwardLink(); | |
// Break a forward link by setting a null | |
textBox.Next = null; | |
// Break a link, which leads to this textbox | |
if (textBox.Previous != null) | |
textBox.Previous.BreakForwardLink(); |