VDF常见问题整理(二十一):如何将选择集的第一个对象设置为不同的突出显示颜色

本系列教程整理了VectorDraw Developer Framework(VDF)最常见问题,教程整理的很齐全,非常适合新手学习,本章将会介绍当想要突出显示选中的对象时,如何才能为选择集的第一个对象设置不同的突出显示颜色的代码。

   VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。   

VectorDraw Developer Framework试用版下载


    点开本篇文章,是否对矢量图形工具感兴趣呢看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!

问:

    如何才能突出显示颜色想要突出显示选中的对象时,如何才能为选择集的第一个对象设置不同的突出显示颜色/p>

答:

    此问题只能在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对象的三角形区域/strong>

复杂自定义对象的入门指南

点击此处还有VectorDraw Developer Framework的demo示例等着你来体验哦!


    如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系在线客服>>咨询相关问题。

    关注慧聚IT微信公众号 了解产品的最新动态及最新资讯。

标签:

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2019年9月5日
下一篇 2019年9月5日

相关推荐

发表回复

登录后才能评论