WrapSide

WrapSide enumeration

يحدد أي جانب من الشكل أو الصورة يلتف حوله النص.

public enum WrapSide

قيم

اسمقيمةوصف
Both0يلتف نص المستند على جانبي الشكل.
Left1يلتف نص المستند على يسار الشكل فقط. توجد مساحة خالية من النص على يمين الشكل.
Right2يلتف نص المستند على الجانب الأيمن من الشكل فقط. توجد مساحة خالية من النص على الجانب الأيسر منه.
Largest3يلتف نص المستند على جانب الشكل الأبعد عن هامش الصفحة، مما يترك مساحة نصية خالية على الجانب الآخر من الشكل.
Default0القيمة الافتراضية هيBoth .

أمثلة

يوضح كيفية استبدال كافة أشكال مربع النص بأشكال الصور.

Document doc = new Document(MyDir + "Textboxes in drawing canvas.docx");

Shape[] shapes = doc.GetChildNodes(NodeType.Shape, true).OfType<Shape>().ToArray();

Assert.AreEqual(3, shapes.Count(s => s.ShapeType == ShapeType.TextBox));
Assert.AreEqual(1, shapes.Count(s => s.ShapeType == ShapeType.Image));

foreach (Shape shape in shapes)
{
    if (shape.ShapeType == ShapeType.TextBox)
    {
        Shape replacementShape = new Shape(doc, ShapeType.Image);
        replacementShape.ImageData.SetImage(ImageDir + "Logo.jpg");
        replacementShape.Left = shape.Left;
        replacementShape.Top = shape.Top;
        replacementShape.Width = shape.Width;
        replacementShape.Height = shape.Height;
        replacementShape.RelativeHorizontalPosition = shape.RelativeHorizontalPosition;
        replacementShape.RelativeVerticalPosition = shape.RelativeVerticalPosition;
        replacementShape.HorizontalAlignment = shape.HorizontalAlignment;
        replacementShape.VerticalAlignment = shape.VerticalAlignment;
        replacementShape.WrapType = shape.WrapType;
        replacementShape.WrapSide = shape.WrapSide;

        shape.ParentNode.InsertAfter(replacementShape, shape);
        shape.Remove();
    }
}

shapes = doc.GetChildNodes(NodeType.Shape, true).OfType<Shape>().ToArray();

Assert.AreEqual(0, shapes.Count(s => s.ShapeType == ShapeType.TextBox));
Assert.AreEqual(4, shapes.Count(s => s.ShapeType == ShapeType.Image));

doc.Save(ArtifactsDir + "Shape.ReplaceTextboxesWithImages.docx");

أنظر أيضا