Skip to main content

Microsoft Silverlight

Answered Question Mouse drag and drop logicRSS Feed

(0)

TPS2008
TPS2008

Member

Member

14 points

15 Posts

Mouse drag and drop logic

Hi

http://www.tiffany.com/charms/default.aspx?backlink=category

we are trying to design a similar application in silverlight; we can easily achive simple drag and drop function with mouse capture event; However how to implement the fucntionality where in the pendent auto places itself correctly at the preset place.

For example if you will drag and drop a pendent/charm near the chain it goes and auto latches itself to a particular point

Can someone help with the logic

 

Thanks

Prashant

 

kwatts
kwatts

Contributor

Contributor

2129 points

436 Posts

Re: Mouse drag and drop logic

This should be fairly simple.  You'll need to keep track of a set of points which represent possible drop positions for when the user drops the image.  Then on the mouse up event that signals a drop action, just translate the image's position to the nearest of the possible drop points.  I hope that this helps!

-Ken

 


http://kenwatts.blogspot.com/


Please select "Mark as Answer" for posts that are helpful. Thanks!

TPS2008
TPS2008

Member

Member

14 points

15 Posts

Re: Mouse drag and drop logic

 Hello Ken

 

Thanks for the response

Could you please elaborate on how to implement  translate the image's position to the nearest of the possible drop points. would there any sample code available anywhere

 

Thanks

Prashant

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Mouse drag and drop logic

hI,

Check my Reply in this Post.

http://silverlight.net/forums/t/35417.aspx

Mark as answer if this post answered your question.

Harsh Bardhan

kwatts
kwatts

Contributor

Contributor

2129 points

436 Posts

Re: Mouse drag and drop logic

Prashant,

Here's a link to my Digital Logic Silmulator:

http://kenwatts.blogspot.com/2008/08/digital-logic-simulator-in-silverlight.html

I have a link to the source code at CodePlex from that blog entry.  Note that I just upgraded this to RC0, so if you're still running 2B2, you can view it from this link:

 http://msbluelight-0.agappdom.net/e1/d/61779/12958351/63359344800/0.vsxHPvfMaG-eYQr97Q-_wxZx4YA/zziframehtml2zz.html#%2f%2fappId%2fDigitalLogicSimulator.xap%2f%2f%2f%2f%2f%2f%2ftrue%2f2.0%2f0

I'm using drag and drop functionality for custom shape objects, and the same technique can be applied to images.  Let me know if this helps or if you need further elaboration.

-Ken 


http://kenwatts.blogspot.com/


Please select "Mark as Answer" for posts that are helpful. Thanks!

da_dotnetguru
da_dotne...

Member

Member

4 points

2 Posts

Re: Mouse drag and drop logic

Though I havent worked much with silverlight, but had been working in GDI over a long span & already been doing lot of such drag/drop stuff....hence, a suggestive raw logic could be..

Initially storing the co-ordinates(points) of the chain in an array. On the MouseUp event, reading the coordinates where its gonna be placed..

Now finding the nearest coordinate from the array(that should be a simplest logic) & simply setting the pendants coordinate to that of the nearest found point from that array.

 

TPS2008
TPS2008

Member

Member

14 points

15 Posts

Re: Mouse drag and drop logic

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}

 Hello Guys

 

I have implemented the logic by using simple minimum distance calculation formula from 8th grade 

it calculates distances and then sticks to nearest co-ordinates

you may view it on  http://spinelreview.com/silverlight.aspx

But i am now facing a different kind of problem

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;}


it works on some computers and does not work on others ; it shows download silverlight logo ; although silverlight is installed

 

The strange thing is other silverlight applications/web sites show up fine ; only our application is giving this problem

We have already set all correct MIME types and made application High trust (in case required)

All systems are using XP sp2 with IE or FireFox

 

Any suggestions

 

Thank You

 

prashant

 My Silverlight application not working on some computers

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: Mouse drag and drop logic

Hi,

When it is asking to install you can check which version is installed and which version it is asking to install.

Check in all same version message is coming or what.

it may be due to different versions installed in each machine..

Mark as answer if this post answered your question.

Harsh Bardhan

kwatts
kwatts

Contributor

Contributor

2129 points

436 Posts

Answered Question

Re: Mouse drag and drop logic

TPS2008:

it works on some computers and does not work on others ; it shows download silverlight logo ; although silverlight is installed

The strange thing is other silverlight applications/web sites show up fine ; only our application is giving this problem

 

Prashant,

For me it seems to work fine on my PC that has 2B2 installed and it's not working on my RC0 machine.  I would say that this is normal since RC0 does not support 2B2 and vice-versa.  This will get cleared up once Silverlight is finally released which should be soon, so you may want to consider upgrading your app to RC0 in preparation for this.  

-Ken 


http://kenwatts.blogspot.com/


Please select "Mark as Answer" for posts that are helpful. Thanks!
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities