Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
I'm making an application for the construction industry, so using flowcharts. So when I have a rectangle and then I drag a line, as soon as it reaches to the rectangle I want rectangle surface get selected or highlighted.

Will wait for suggestion.

(I edited this as best I could, but there was guesswork involved- if I guessed wrong you'll need to rephrase it- _Maxxx_) :)
Posted
Updated 8-Feb-11 16:01pm
v3
Comments
Sergey Alexandrovich Kryukov 8-Feb-11 19:58pm    
You text is not simply inaccurate, it's rude! Spell check it and use proper grammar and full punctuation (don't tell me English is not your native, it's not mine, too, the more difficult to read; and you claim you work in USA!). Don't hope anyone would be interested in writing such boring code for you; write yours and ask questions.
--SA
Yusuf 8-Feb-11 21:15pm    
What have you tried so far? Show us where are you stuck
shakil0304003 8-Feb-11 22:48pm    
What you tried?

If you do an internet search for c# diagram designer you will find lots of examples with source code that you can look at for ideas.

There are a couple here on CP such as this 4 part article by sukram[^], although that one requires WPF.
 
Share this answer
 
You'll have to check whether the line is over any part of any of the rectangles you have - assuming you can grab the line from any point. Assuming you only want the rectangle highlighted if one of the line's end points are over it, then you'd need to iterate your collection of rectangles, comparing top left and bottom right with the line's endpoints; if the endpoint is inside the rectangle and the rectangle is not highlighted, then highlight it; conversely if the endpoint is not inside the rectangle but the rectangle is highlighted, you need to de-highlight it (assuming only one highlightable object is allowed)
I assume for highlighting you just want to change the colour or outline - that should be trivial; if you can't do that then really your project is over ambitious for your skills.
Personally I would abstract the whole thing - so you have a collection of objects representing the flowchart items, and a method for them to be drawn; you can then have properties of these objects, such as IsHightlighted, which will help I think.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900