文档半岛外围网上直营>>VectorDraw Developer Framework使用教程>>VDF常见问题整理(二十一):如何将选择集的第一个对象设置为不同的突出显示颜色
VDF常见问题整理(二十一):如何将选择集的第一个对象设置为不同的突出显示颜色
VectorDraw Developer Framework(VDF)是一个用于应用程序可视化的图形引擎库。有了VDF提供的功能,您可以轻松地创建、编辑、管理、输出、输入和打印2D和3D图形文件。
VectorDraw Developer Framework试用版下载
点开本篇文章,是否对矢量图形工具感兴趣呢?来看看最新的矢量图形工具测评吧!点击此处>>即可直达哦!
问:
如何才能突出显示颜色?当想要突出显示选中的对象时,如何才能为选择集的第一个对象设置不同的突出显示颜色?
答:
此问题只能在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;
}热门文章推荐:
点击此处还有VectorDraw Developer Framework的demo示例等着你来体验哦!
如果您对想要购买正版授权VectorDraw Developer Framework(VDF),可以联系咨询相关问题。
关注慧聚IT微信公众号 ???,了解产品的最新动态及最新资讯。


QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线