VectorDraw FAQ finishing: how to create a line with a string?

   VectorDraw Developer Framework (VDF) is an application for the visualization of graphics engine library. With VDF provides functionality that you can easily create, edit, manage, export, import and print 2D and 3D graphics files.   


  ask:

   Can I create a linear, in which the line passes through the text, for example: --------------------- my text here ---- --- ----------------. How does this line should be created?

answer:

    In order to make the text line is not covered, you need to add a hidden segment, the same or slightly larger than the length of the text in line with its size. See below for the code and instructions:

private void button10_Click(object sender, EventArgs e)
{
    vdDocument thisDocument = vdFramedControl1.BaseControl.ActiveDocument;
    vdLineType lt = thisDocument.LineTypes.Add("MyCustomLineType");
 
    lt = thisDocument.LineTypes.Add("MyCustomLineType");
    lt.Comment = "MyCustomLineType";
 
    lt.Segments.AddItem(new LineTypeSegment(1));
    lt.Segments.AddItem(new LineTypeSegment());
    lt.Segments[1].ShapeText = " Some Text Goes Here ";
    lt.Segments[1].ShapeStyle = thisDocument.TextStyles[0].GrTextStyle;
    lt.Segments[1].ShapeOffsetY = -.125;
    lt.Segments[1].Flag = LineTypeSegment.LineTypeElementType.TTF_TEXT;
    lt.Segments[1].ShapeScale = .25;
 
     // This is the method of calculating the length of text 
    vdText txt = new vdText (thisDocument, lt.Segments [1] .ShapeText, new gPoint (), lt.Segments [1] .ShapeScale); // same text 
    txt.Style = thisDocument.TextStyles [0]; // the same text 
    txt.Update (); 
    Double txtwidth = txt.BoundingBox.Width;  
    TXT = null; // the NOT the IS NEEDED the any More 
    
    lt.Segments [. 1] .ShapeOffsetX txtwidth = 0.1 * / 2.0; // 5% space before the text 
    
    // adding an invisible text segment above, accounting for 110% of the length of text 
    lt.Segments.AddItem (new LineTypeSegment (-1.0 * ( txtwidth + 2.0 * lt.Segments [1 ] .ShapeOffsetX))); // before the text and add a space after the invisible part of the large 
    lt.Segments.AddItem (new new LineTypeSegment (. 1)); 
    lt.Update (); 
 
    // for displaying 
    vdLine manuallyDrawnPline = new vdLine (thisDocument, new gPoint (), new gPoint (25, 5)); 
    thisDocument. Model.Entities.AddItem (manuallyDrawnPline);
    manuallyDrawnPline.LineType = lt;
    manuallyDrawnPline.Update();
    manuallyDrawnPline.Invalidate();
 
    thisDocument.CommandAction.Zoom("E", 0, 0);
}

    For more questions and answers, if you have any doubts can post in the comments section, we will respond promptly. This series of questions and answers tutorials we will continue to update, if you are interested, you can a lot of attention for this tutorial.


Guess you like

Origin blog.51cto.com/14477114/2466747