这里写一下另一种方法,即从CreateLastRunRecord().SubRecords[0]中将所有的图形Record提取出来,添加到display控件上,以下为代码:
此帖售价 2 金币,已有 56 人购买 [记录]
/// [p]/// 提取出ICogRecord中所有的图形,并将其显示到Display控件中
/// [/p]
/// 要显示的Display控件
/// 要提取的Record
private void AddGraphicsContent(CogRecordDisplay display, ICogRecord parent)
{
// 遍历所有parent中的record
foreach (CogRecord record in parent.SubRecords)
{
// A single graphic.
if (typeof(ICogGraphic).IsAssignableFrom(record.ContentType))
{
if (record.Content != null)
display.InteractiveGraphics.Add(record.Content as ICogGraphicInteractive, "IDResult", false);
}
// A list of graphics.
else if (typeof(CogGraphicCollection).IsAssignableFrom(record.ContentType))
{
if (record.Content != null)
{
CogGraphicCollection graphics = record.Content as CogGraphicCollection;
foreach (ICogGraphic graphic in graphics)
{
display.InteractiveGraphics.Add(graphic as ICogGraphicInteractive, "Result", false);
}
}
}
else if (typeof(CogGraphicInteractiveCollection).IsAssignableFrom(record.ContentType))
{
if (record.Content != null)
{
display.InteractiveGraphics.AddList(record.Content as CogGraphicInteractiveCollection, "IDResult", false);
}
}
// Add the sub-records, if any.
AddGraphicsContent(display, record);
}
}
另外关于上面我提到的blob数量较多时,图形添加有明显的渲染卡顿的问题,在这里记录一下解决方法:
1.
本部分设定了隐藏,您已回复过了,以下是隐藏的内容
可以新建一个shape,先将blob都添加到这一个shape上,最后将这个shape添加到display控件上。CogCompositeShape shape = new CogCompositeShape();
int count = cbt.Results.GetBlobs().Count;
for (int i = 0; i < count; i++)
{
CogCompositeShape blob = cbt.Results.GetBlobs().CreateResultGraphics(CogBlobResultGraphicConstants.Boundary);
blob.SelectedSpaceName = "$";
shape.Shapes.Add(blob);
}
cogRecordDisplay1.InteractiveGraphics.Add(shape, "test", true);
同样。也可以直接用cogRecordDisplay1.InteractiveGraphics.AddList函数添加多个图形。但是这里由于bolb工具的结果时Results,没有找到创建图形队列的函数,故没有采用
2.
本部分设定了隐藏,您已回复过了,以下是隐藏的内容
display控件的DrawingEnabled属性,这个东西很强大、好用,成为了解决图形过多时添加缓慢问题的关键一步。用法就是在给display控件添加图形之前,把DrawingEnabled属性设置为false。等所有的图形添加过后,再把DrawingEnabled属性设置true即可。 标签:控件,Content,record,shape,添加,RecordDispaly,Blob,display From: https://www.cnblogs.com/qq1151219115/p/16846658.html