Image Annotation in C#
-
Hello everyone , i am designing an image annotation tool . In any image annotation tool , it enables you to drag a rectangle which for example shows an image , text or any other stuff inside of it , then when you click and drag the rectangle resizes itself accordingly over the shown image . The question is : which is the best programming practice for this task ???? , is it either to create a rectangle and keep track of the x,y coordinates and change the size of the rectangle accordingly ???? or to inherit from the CONTROL Class and implement its methods like onMouseDown , OnMouseMove ....etc ???? Second thing ..... : i need to know how can i place handles surrounding the rectangle ? and enable the user to change its Size according to its movement either to the right , left , top or bottom .????? any help or existing examples to see ... Any help will be greatly appreciated.... Thank you
Human knowledge belongs to the world.
-
Hello everyone , i am designing an image annotation tool . In any image annotation tool , it enables you to drag a rectangle which for example shows an image , text or any other stuff inside of it , then when you click and drag the rectangle resizes itself accordingly over the shown image . The question is : which is the best programming practice for this task ???? , is it either to create a rectangle and keep track of the x,y coordinates and change the size of the rectangle accordingly ???? or to inherit from the CONTROL Class and implement its methods like onMouseDown , OnMouseMove ....etc ???? Second thing ..... : i need to know how can i place handles surrounding the rectangle ? and enable the user to change its Size according to its movement either to the right , left , top or bottom .????? any help or existing examples to see ... Any help will be greatly appreciated.... Thank you
Human knowledge belongs to the world.
I would be tempted to create a rectangle control here. The interaction logic for sizing/moving the rectangle would be contained in this class, then all your image control would need to do would be to hold references to the rectangle. The rectangle drawing could implement a simple handle drawing algorithm which drew a square at the corners. If you want to see some sample code that does this, you can take a look at the Netron library here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
-
Hello everyone , i am designing an image annotation tool . In any image annotation tool , it enables you to drag a rectangle which for example shows an image , text or any other stuff inside of it , then when you click and drag the rectangle resizes itself accordingly over the shown image . The question is : which is the best programming practice for this task ???? , is it either to create a rectangle and keep track of the x,y coordinates and change the size of the rectangle accordingly ???? or to inherit from the CONTROL Class and implement its methods like onMouseDown , OnMouseMove ....etc ???? Second thing ..... : i need to know how can i place handles surrounding the rectangle ? and enable the user to change its Size according to its movement either to the right , left , top or bottom .????? any help or existing examples to see ... Any help will be greatly appreciated.... Thank you
Human knowledge belongs to the world.
When in doubt, I'm inclined to not use Controls and create my own classes of visible, drawable, movable parts. Takes some more code, but leads to snappier behavior as soon as you need lots of them. It also could offer more functionality, e.g. an easier selection of objects (select nearest, select by clicking through hollow shapes, etc). As I understand your requirements (only a few controls involved), it wouldn't matter much, provided you don't get into transparency problems. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
I would be tempted to create a rectangle control here. The interaction logic for sizing/moving the rectangle would be contained in this class, then all your image control would need to do would be to hold references to the rectangle. The rectangle drawing could implement a simple handle drawing algorithm which drew a square at the corners. If you want to see some sample code that does this, you can take a look at the Netron library here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
Netron Library couldn't be downloaded .. if you have it , please send me a working download link . so for good programming practice, you recommend me to create a rectangle object not to inherit from the control class and do the work inside ???? did i understand you correctly ?
Human knowledge belongs to the world.
-
Hello everyone , i am designing an image annotation tool . In any image annotation tool , it enables you to drag a rectangle which for example shows an image , text or any other stuff inside of it , then when you click and drag the rectangle resizes itself accordingly over the shown image . The question is : which is the best programming practice for this task ???? , is it either to create a rectangle and keep track of the x,y coordinates and change the size of the rectangle accordingly ???? or to inherit from the CONTROL Class and implement its methods like onMouseDown , OnMouseMove ....etc ???? Second thing ..... : i need to know how can i place handles surrounding the rectangle ? and enable the user to change its Size according to its movement either to the right , left , top or bottom .????? any help or existing examples to see ... Any help will be greatly appreciated.... Thank you
Human knowledge belongs to the world.
I believe you're looking for a C# version of a
CRectTracker
[^]. See this[^] article. /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
Netron Library couldn't be downloaded .. if you have it , please send me a working download link . so for good programming practice, you recommend me to create a rectangle object not to inherit from the control class and do the work inside ???? did i understand you correctly ?
Human knowledge belongs to the world.
You did. If the link isn't working there, there's a version on Sourceforge[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith
As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.