Generally, the drag program implements the mouseleftbuttondown, mouseleftbuttonup, and mousemove events. In most cases, the control coordinates are set in the mousemove function during the drag process.
The following code is only a little different. During the drag process, the original control is still in the original position, but a new shadow image generated according to the shape of the control is generated, then set the position of the Shadow image. Finally, when the mouse leaves, set the position of the original control...
Private void containerpanel_mouseleftbuttondown (Object sender, mousebuttoneventargs e) {If (E. clickcount <= 1) & (sender! = E. Source) {elementui source = E. source as elementui; this. selecteditem = source; nodeui Eui = E. source as nodeui; If (EUI! = NULL) & Eui. datasource. candrag) {nodeui = (nodeui) E. source; point = new point (nodeui. centerx, nodeui. centery); this. startpoint = base. toplot (E. getposition (this); this. offsetvector = (vector) (this. startpoint-point); this. createdragshade (nodeui); this. dragshade. capturemouse (); // shadow capture mouse E. handled = true ;}} private void containerpanel_mouseleftbuttonup (Object sender, mousebutto Neventargs e) {If (E. clickcount <= 1) {nodeui selecteditem = This. selecteditem as nodeui; If (selecteditem! = NULL) & this. dragshade. ismousecaptured) {point = base. toplot (E. getposition (this); double dx = point. x-this. startpoint. x; double DY = point. y-this. startpoint. y; node datasource = selecteditem. datasource; If (datasource! = NULL) & datasource. candrag) {datasource. export mdrag (dx, Dy) ;}} this. dragshade. releasemousecapture (); this. dragshade. visibility = visibility. hidden; base. children. remove (this. dragshade) ;}} private void containerpanel_mousemove (Object sender, mouseeventargs e) {If (E. leftbutton = mousebuttonstate. pressed) & this. dragshade. ismousecaptured) {point = base. toplot (E. getposition (this); plotpanel. setcenterx (this. dragshade, point. x-this. offsetvector. x); plotpanel. setcentery (this. dragshade, point. y-this. offsetvector. y) ;}} private void createdragshade (nodeui) {visualbrush brush = new visualbrush (); brush. stretch = stretch. fill; brush. visual = nodeui; brush. opacity = 0.6; this. dragshade. width = nodeui. actualwidth; this. dragshade. height = nodeui. actualheight; this. dragshade. stroke = brushes. transparent; this. dragshade. fill = brush; this. dragshade. stretch = stretch. fill; plotpanel. setcenterx (this. dragshade, nodeui. centerx); plotpanel. setcentery (this. dragshade, nodeui. centery); this. dragshade. visibility = visibility. visible; base. children. add (this. dragshade );}