c# - WPF client to screen point transformation -


i'm looking way transofrm given points relative visual points on screen. found solution:

http://social.msdn.microsoft.com/forums/vstudio/en-us/b327c0bc-d27e-44fe-b833-c7db3400d632/how-to-get-control-location-in-screen-coordinate-system

i can't understand different beween pointroot , pointclient seem equal time:

// [...] // translate point visual root. generaltransform transformtoroot = relativeto.transformtoancestor(root); point pointroot = transformtoroot.transform(point);  // transform point root client coordinates. matrix m = matrix.identity; transform transform = visualtreehelper.gettransform(root); if (transform != null)     m = matrix.multiply(m, transform.value);  vector offset = visualtreehelper.getoffset(root); m.translate(offset.x, offset.y); point pointclient = m.transform(pointroot); // [...] 

(for full code click on link)

it seems visualtreehelper.getoffset(root) tries transform of window...

assuming visual comes button control... looking this?:

point locationfromwindow = button1.translatepoint(new point(0, 0), this);  point locationfromscreen = button1.pointtoscreen(locationfromwindow); 

note: these both methods of visual class, can call them visual directly.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -