473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Advanced Events

Good Morning All,
I am working on a CAD application. At the time of this writing I am
currently working on the GraphicsEngine. The structure is as follows:

GraphicsObject (Base Class, Must Inherit)
ShapeObject (Must Inherit)
Derived Classes()
TestObject (Must Inherite)
Derived Classes()
Derived Classes()

GraphicsObject does not inherit form anyone.
I am working with VB.NET 2005 enterprise edition.

My problem is as such: I need to handle mouse events. I can easly
enough fire them using an outside class and performing a HitTest on the
region. However I would like the indivudal objects to handle there own
events to some extend.
E.G:
If a rectangle is draw on the screen. The rectangle is a derived class
of the shapeObject. When the mouse is clicked inside its bounds the
border should be "Selected." As I said I know how to do this from
another class, but I can't figure out how to link the mouse/ keyboard
events to the base class.

Thank You,
Frank

Mar 27 '06 #1
2 1185

frank wrote:
Good Morning All,
I am working on a CAD application. At the time of this writing I am
currently working on the GraphicsEngine. The structure is as follows:

GraphicsObject (Base Class, Must Inherit)
ShapeObject (Must Inherit)
Derived Classes()
TestObject (Must Inherite)
Derived Classes()
Derived Classes()

GraphicsObject does not inherit form anyone.
I am working with VB.NET 2005 enterprise edition.

My problem is as such: I need to handle mouse events. I can easly
enough fire them using an outside class and performing a HitTest on the
region. However I would like the indivudal objects to handle there own
events to some extend.
E.G:
If a rectangle is draw on the screen. The rectangle is a derived class
of the shapeObject.
Careful - it might be that you have a Ractangle derived from
ShapeObject, but the thing that's actually *drawn* is just some pixels
on an image.
When the mouse is clicked inside its bounds the
border should be "Selected." As I said I know how to do this from
another class, but I can't figure out how to link the mouse/ keyboard
events to the base class.


Yes, this is the key to the problem. How about this: when you ask the
objects to draw themselves on some Graphics, also ask them to return a
Region representing their presence on the Graphics. Each time you
refresh the drawing, recreate a map (hashtable) of
Region->GraphicsObject. When you receive a mouse click (or whatever),
go through that map and check Region.IsVisible for the point where the
mouse was clicked. If you get a hit, then call (say)
GraphicsObject.OnClick for that object. Make OnClick a MustInherit
method in the base base class.

There might be issues with z-ordering with this method, so I suppose
store a z-order with each region and only OnMouseClick for the latest
drawn GraphicsObject.

Actually wiring up events direct to the objects without any middle
layer looks hard to me, since in the first instance it's always a
PictureBox or whatever that actually receives the Click event.

--
Larry Lard
Replies to group please

Mar 27 '06 #2
Larry,
It's good to "meet" you. Thank you for the advice. I will look into it
this afternoon. I'll let you know how I turn out, and provide some more
information. I realize that there is probally not enough space for all
the infomation needed here.

Best regards,
Frank

Mar 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: George | last post by:
I need help with the code listed below. See the line below the comment-// *** This displays the error *** I want to be able to have the event handler call the function based on the reference...
4
by: Nhmiller | last post by:
This is directly from Access' Help: "About designing a query When you open a query in Design view, or open a form, report, or datasheet and show the Advanced Filter/Sort window (Advanced...
0
by: Rmontela | last post by:
I want to bind events to words of generated text in a windows form application. For instance, when mouse enters the rectangle bounding box of a word inside the text, a method is called that uses...
3
by: Brian Keating EI9FXB | last post by:
Hello again, I've already placed a few posts on this topic. This time i've a simple application that exhibits my problem, I've placed sample solution 8k on my website should anyone be interested...
2
by: Marcos Ribeiro | last post by:
Hi I was trying to code the DragEnter event on a RichTextBox on the IDE Code editor but I could not Find that member on the events ComboBox. So I tried seting the option (Tools menu) Text...
2
by: awebguynow | last post by:
It seems like I've been reading the code to Google Suggest (GS) for about a week, and I'm going to have to wrap it up shortly. I'm OK with many of the subjects, and I would say I have...
2
by: kristian.freed | last post by:
Hi, I currently work in a project written fully in C# where we make extensive use of delegates and events. We have a model where a "state", an object holding data but not much code but which...
0
ADezii
by: ADezii | last post by:
Not all ADO Power Users realize that there are Events, specifically related to the Connection and Recordset Objects, for which they can write code for. If one is aware of these Events, it is not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.