VDF常見問題整理(二十一):如何將選擇集的第一個對象設(shè)置為不同的突出顯示顏色
VectorDraw Developer Framework(VDF)是一個用于應(yīng)用程序可視化的圖形引擎庫。有了VDF提供的功能,您可以輕松地創(chuàng)建、編輯、管理、輸出、輸入和打印2D和3D圖形文件。
VectorDraw Developer Framework試用版下載
點開本篇文章,是否對矢量圖形工具感興趣呢?來看看最新的矢量圖形工具測評吧!點擊此處>>即可直達哦!
問:
如何才能突出顯示顏色?當(dāng)想要突出顯示選中的對象時,如何才能為選擇集的第一個對象設(shè)置不同的突出顯示顏色?
答:
此問題只能在OnDrawFigure事件中完成,在該事件中,您可以檢查選定對象是否在臨時選擇中,在這種情況下,請使用其他顏色替換該對象,例如:
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; }
熱門文章推薦:
如何排除GroundSurface對象的三角形區(qū)域?
點擊此處還有VectorDraw Developer Framework的demo示例等著你來體驗哦!
如果您對想要購買正版授權(quán)VectorDraw Developer Framework(VDF),可以聯(lián)系在線客服>>咨詢相關(guān)問題。
關(guān)注慧聚IT微信公眾號 ???,了解產(chǎn)品的最新動態(tài)及最新資訊。