C#: Map screen absolute to relative screen coordinates in multiple screen environment -
C#: Map screen absolute to relative screen coordinates in multiple screen environment -
i need way map absolutes coordinates (relative main screen) relative coordinates screen.
for example, if have 2 screens configured, if main screen 1 of right, there valid negative coordinates point left screen. need convert these absolute coordinates positive number relative left screen.
edit: goal know if absolute coordinates valid in available screen using
screen.workingarea.contains(thepoint),
iterating on available screens.
thank you
this should screen configuration:
static point getrelativecoordinates(point absolutecoordinates) { var screen = screen.frompoint(absolutecoordinates); homecoming new point(absolutecoordinates.x - screen.bounds.left, absolutecoordinates.y - screen.bounds.top); }
the bound
property stores absolute coordinates of top
, left
corners of screen ([0, 0]
beingness top, left of primary screen) converting absolute coordinates relative ones pretty straightforward no matter how many screens have.
i haven't tested code should work.
c# screen coordinates
Comments
Post a Comment