c# - What are some different methods to drag and move objects around without using Horizontal or Vertical Alignment set to Left and Top -
i developing dashboard application user able resize , move chart widgets please. have had problems being able move , resize @ same time. reason why when chart alignments set following:
chart.horizontalalignment = horizontalalignment.left; chart.verticalalignment = verticalalignment.top; ...the move work perfectly, resize go crazy in undetectable directions. if switch alignments following :
chart.horizontalalignment = horizontalalignment.stretch; chart.verticalalignment = verticalalignment.stretch; ...the move off resize work decently.
the move code follows :
public void chart_mousemove(object sender, mouseeventargs e) { c1chart chart = sender c1chart; if (!modifierkey) { if (ismousecaptured) { // calculate current position of object. double deltav = e.getposition(null).y - mouseverticalposition; double deltah = e.getposition(null).x - mousehorizontalposition; double newtop = deltav + (double)chart.margin.top; double newleft = deltah + (double)chart.margin.left; // set new position of object. chart.margin = new thickness(newleft, newtop, 0, 0); // update position global variables. mouseverticalposition = e.getposition(null).y; mousehorizontalposition = e.getposition(null).x; } } } the mouseverticalposition, mousehorizontalposition, ismousecaptured assigned in chart mouse down event , modifierkey boolean tell if of keyboard modifiers pressed know whether or not move. code taken off of msdn, open alternate solutions.
the resize code can found here(microsoft example) or here(denis vuyka blog). here question : is there different way drag & move or resizing (adorner class) not seeing. or, there way use code alignment hack.
have looked mousedragelementbehavior? http://blogs.msdn.com/b/dphill/archive/2009/09/25/blend-behaviors.aspx
Comments
Post a Comment