VDF常見(jiàn)問(wèn)題整理(二十一):如何將選擇集的第一個(gè)對(duì)象設(shè)置為不同的突出顯示顏色
VectorDraw Developer Framework(VDF)是一個(gè)用于應(yīng)用程序可視化的圖形引擎庫(kù)。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
點(diǎn)開(kāi)本篇文章,是否對(duì)矢量圖形工具感興趣呢?來(lái)看看最新的矢量圖形工具測(cè)評(píng)吧!點(diǎn)擊此處>>即可直達(dá)哦!
問(wèn):
如何才能突出顯示顏色?當(dāng)想要突出顯示選中的對(duì)象時(shí),如何才能為選擇集的第一個(gè)對(duì)象設(shè)置不同的突出顯示顏色?
答:
此問(wèn)題只能在OnDrawFigure事件中完成,在該事件中,您可以檢查選定對(duì)象是否在臨時(shí)選擇中,在這種情況下,請(qǐng)使用其他顏色替換該對(duì)象,例如:
private void button1_Click(object sender, EventArgs e) { vdDocument doc = vdFramed1.BaseControl.ActiveDocument; doc.FreezeEntityDrawEvents.Push(false); //Enable draw events doc.OnDrawFigure+=new vdDocument.FigureDrawEventHandler(doc_OnDrawFigure); //add the event andler } void doc_OnDrawFigure(object sender, VectorDraw.Render.vdRender render, ref bool cancel) { if (sender == null) return; vdDocument doc = vdFramed1.BaseControl.ActiveDocument; vdSelection selected = doc.Selections.FindName("VDRAW_TEMPORARY_SELSET"); // get the selection that contains the items if (selected == null || selected.Count < 1) return; vdFigure fig = sender as vdFigure; if (fig==null) return; if (selected.FindItem(fig)) // if the fig is in this selection (is selected) { double pix_size = render.PixelSize; if (ReferenceEquals(fig, selected[0])) { // push a different color to the render if this object is the first selected render.PushPenstyle(Color.Red, 4*pix_size); } else { render.PushPenstyle(Color.Yellow, 1*pix_size); } doc.FreezeEntityDrawEvents.Push(true); // disable the event as fig.Draw() will make it fire again fig.Draw(render); // draw the object with the penstyle pushed before doc.FreezeEntityDrawEvents.Pop(); // pop the event..... ALL PUSH must be followed by POP render.PopPenstyle(); //pop the penstyle ..... ALL PUSH must be followed by POP cancel = true; // do not allow vdraw to draw this item it is already draw by fig.Draw() above } else cancel = false; }
熱門(mén)文章推薦:
如何排除GroundSurface對(duì)象的三角形區(qū)域?
點(diǎn)擊此處還有VectorDraw Developer Framework的demo示例等著你來(lái)體驗(yàn)哦!
如果您對(duì)想要購(gòu)買(mǎi)正版授權(quán)VectorDraw Developer Framework(VDF),可以聯(lián)系咨詢(xún)相關(guān)問(wèn)題。
關(guān)注慧聚IT微信公眾號(hào) ???,了解產(chǎn)品的最新動(dòng)態(tài)及最新資訊。