c# - WPF client to screen point transformation -
i'm looking way transofrm given points relative visual points on screen. found solution:
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
Post a Comment