翻譯|使用教程|編輯:況魚杰|2019-10-21 13:35:44.793|閱讀 245 次
概述:本系列教程整理了VectorDraw Developer Framework(VDF)最常見問題,教程整理的很齊全,非常適合新手學(xué)習(xí),本文章將會(huì)介紹一種帶字符串的線型是如何創(chuàng)建的。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
VectorDraw Developer Framework(VDF)是一個(gè)用于應(yīng)用程序可視化的圖形引擎庫(kù)。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。  
VectorDraw Developer Framework試用版下載
點(diǎn)開本篇文章,是否對(duì)矢量圖形工具感興趣呢?來看看最新的矢量圖形工具測(cè)評(píng)吧!點(diǎn)擊此處>>即可直達(dá)哦!
問:
我是否可以創(chuàng)建一種線型,其中線穿過文本,例如:---------------------我的文本在這里---- -------------------。這種線型應(yīng)該如何創(chuàng)建?
答:
  為了使文本不被線段覆蓋,您需要添加一個(gè)隱藏的線段,其大小與線型中的文本長(zhǎng)度相同或稍大。具體請(qǐng)參見下面的代碼和說明:
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;
 
     // 這是計(jì)算文本長(zhǎng)度的方法
    vdText txt = new vdText(thisDocument, lt.Segments[1].ShapeText, new gPoint(), lt.Segments[1].ShapeScale); //與文字相同
    txt.Style = thisDocument.TextStyles[0]; //與文字相同
    txt.Update();
    double txtwidth = txt.BoundingBox.Width; 
    txt = null;  //IS NOT NEEDED any more
    
    lt.Segments[1].ShapeOffsetX = txtwidth * 0.1 / 2.0; // 在文字前加5%空格
    
    // 在文本上方添加不可見的段,占文本長(zhǎng)度的110%
    lt.Segments.AddItem(new LineTypeSegment(-1.0 * (txtwidth+ 2.0*lt.Segments[1].ShapeOffsetX)));// 在文本之前和之后添加一個(gè)空格,使不可見部分變大
    lt.Segments.AddItem(new LineTypeSegment(1));
    lt.Update();
 
    //用于顯示
    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);
}    對(duì)于以上問答,如果您有任何的疑惑都可以在評(píng)論區(qū)留言,我們會(huì)及時(shí)回復(fù)。此系列的問答教程我們會(huì)持續(xù)更新,如果您感興趣,可以多多關(guān)注本教程。
相關(guān)資料推薦:
點(diǎn)擊此處還有VectorDraw Developer Framework的demo示例等著你來體驗(yàn)哦!
    如果您對(duì)想要購(gòu)買正版授權(quán)VectorDraw Developer Framework(VDF),可以聯(lián)系咨詢相關(guān)問題。
關(guān)注慧聚IT微信公眾號(hào) ???,了解產(chǎn)品的最新動(dòng)態(tài)及最新資訊。

本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@ke049m.cn
文章轉(zhuǎn)載自: