Is it possible and How to drag and drop GDI object?
I have found this analog clock tutorial here:
http://www.codeproject.com/KB/selection/AnalogClockControl.aspx
Now is it possible to drag and drop the hand hour (how to detect the mouse on the hand hour ?) and show this hand hour moving while dragging it ?
I mean isn't anything included framework in .NET which allow me to detect 开发者_运维知识库that the mouse is ON a shape like for IPHONE sdk ?
You can do it if you draw the hands with the GraphicsPath class. Its IsVisible() method lets you implement hit-testing in the MouseDown event and detect that the mouse is over a hand.
I would suggest you to use what is called "Rx": reactive extensions, all you want you can do without it, but Rx makes your life better and easier :)
There is an Rx for .NET and Rx for Javascript, same stuff and you can have similar techniques wherever you want.
Here is a nice video how to do drag-n-drop using Rx in .NET (WPF in this example) and even if you do something else (winforms, silverlight, javascript) - watch this video anyway, it gives you the idea and the implementation is exactly the same for everything else: http://channel9.msdn.com/blogs/j.van.gogh/writing-your-first-rx-application
And here is a javascript specific drag-n-drop using Rx described: http://weblogs.asp.net/podwysocki/archive/2010/03/19/introduction-to-the-reactive-extensions-for-javascript-drag-and-drop.aspx
You will need to handle the MouseDown, MouseMove and MouseUp events.
Also you may break out the time-to-xy functions from the clock and write the inverse xy-to-time versions.
精彩评论