在VB.Net PictureBox中绘制项目 [英] Drawing Items in a VB.Net PictureBox

查看:70
本文介绍了在VB.Net PictureBox中绘制项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



第一个定时器问题所以我很抱歉,如果它们有点模糊或在错误的区域。



我正在编写一个程序,它接口到一些真实世界的电子产品,并希望通过PictureBox以图形方式表示项目。绘制项目没有问题,但我希望Item改变颜色以改变状态。例如,如果阀门关闭/打开,它可能是红色/绿色,相应的管道也可能会改变颜色。



我的问题是,一旦绘制了项目,就会出现除了重新扫描对象之外,无法改变它。对象是否可以某种方式被标记以包含一些可以随后更改的属性?



我曾想过连接到像MS Visio这样的东西但是会我希望能够将整个解决方案打包在一个包装中。我使用的是Visual Basic 2010.



干杯

杰夫

Hi All,

First timer questions so my apologies if they are a bit vague or in the wrong area.

I am writing a program that interfaces to some real world electronics and would like to represent the items graphically via PictureBox. Drawing the items is no problem, however I would like the Item to change colour for a change of state. eg if a Valve is off/on it may be red/green and the corresponding pipe may change colour also.

My problem is that once the item is drawn there appears no way to change it other than redawing the object. Can the object be ''tagged'' in some way to contain some attributes that could then be changed?

I have thought of interfacing to something like MS Visio but would prefer to be able to package the whole solution in one package. I am using Visual Basic 2010.

Cheers
Jeff

推荐答案

简单的答案是不。



PictureBox中的图像本质上是一个位图 - 这意味着它只是一系列与之无关的单个像素彼此。你不能用它们标记这些在一起,将它们全部改为绿色,因为图像中不包含任何与像素相关的信息。



如果您使用的是Winforms,那么我建议您使用Panel而不是PictureBox来处理它的Paint事件。然后,您可以在更改状态时让每个对象(例如阀门)自行绘制。
The simple answer is "no".

The image in a PictureBox is in essence a Bitmap - which means it is just a sequence of individual pixels which have no relation to each other. You can''t tag them to say "these are together, change them all to green" because the image does not contain any information which relates pixels to each other.

If you are using Winforms, then I would suggest that instead of a PictureBox, you use a Panel and handle it''s Paint event. You can then get each object (such as a valve) to draw itself when it changes state.


确定。感谢您的答复。我有点期待这种情况。我现在会往下看另一条大道。



干杯

杰夫
Ok. Thank-you for the reply. I sort of expected this to be the case. I will look down another avenue now.

Cheers
Jeff


这篇关于在VB.Net PictureBox中绘制项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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