显示数百个矩形 [英] Display several hundreds of rectangles

查看:82
本文介绍了显示数百个矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 

我正在研究监督不同设备(机器)的应用程序

I'm working on an application which supervises different equipments (machines)

我想建立一个窗口,通过绘制一个宽度与事件持续时间相对应的彩色矩形,为每个设备显示事件的时间线。见图。在现实生活中,所有矩形都是不同的(不同的宽度和不同的
颜色)。

I would like to build a window that shows the timeline of events, for each equipment, by drawing a colored rectangle whose width corresponds to the duration of the event. See picture. In real life, all rectangles are different (different width and different color).

在8到12小时的时间段内,可能有数百个这样的矩形。我关注该屏幕的响应时间。

Over a time period of 8 to 12 hours, there might be several hundreds of such rectangles. I am concerned with the response time of that screen.

获得此类结果的最佳方式(最佳性能)是什么?

What is the best way (best performance) of obtaining such a result ?

  - 矩形形状?

 - The Rectangle shape ?

  - RectangleGeometry?

 - The RectangleGeometry ?

  - DrawRectangle?

 - The DrawRectangle ?

  - 别的什么?

 - something else ?

谢谢

推荐答案

最佳性能相对难以实现,但使用writeablebitmap绘制。

Best performance would be relatively hard to implement but draw it using writeablebitmap.

这非常快。

我计算并建立一张图片1155 x 805 in 在我们的应用程序中大约29毫秒。

I calculate and build a picture 1155 x 805 in  about 29ms in our app.

更容易实现的是在项目控件中创建这些矩形。

Easier to implement would be to make those rectangles in an itemscontrol.

使stackpanel成为它的itemspanel水平定位。

Make the stackpanel which is it's itemspanel orientate horizontally.

将填充物绑定颜色。它是一个画笔。

Bind the fill for colour. It's a brush.

你也可以将轮廓绑定或设置为另一个画笔。

You could also bind or set the outline to a different brush.

并使用样式绑定itemcontainer的宽度。

And bind the width of the itemcontainer using a style.

<ItemsControl.ItemContainerStyle>
       <Style TargetType="ContentPresenter">
             <Setter Property="Width" Value="{Binding YourWidth">

然后,您可以将一个observabletelection视图模型绑定到itemscontrol。

You can then bind an observablecollection of viewmodels to the itemscontrol.

每个都会公开YourWidth和YourFillBrush的公共属性

Each would expose public properties for YourWidth and YourFillBrush

在此虚拟机上实施inotifypropertychanged。

Implement inotifypropertychanged on this vm.


这篇关于显示数百个矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆