开发者

Multiple GDI Transforms for 2D Graphics in C#

开发者 https://www.devze.com 2023-03-04 19:11 出处:网络
I\'m writing a graphics app that can perform global transformations (rotate and translate) using mouse control. Does anyone have a sample showing how to implement this with the following methods:

I'm writing a graphics app that can perform global transformations (rotate and translate) using mouse control. Does anyone have a sample showing how to implement this with the following methods:

MouseDown(object sender, MouseEventArgs e) - set the translate/rotate offset
MouseMove(object sender, MouseEventArgs e) - increment translate/rotate variables
OnPaint(Graphics graphics, float time)开发者_运维技巧     - use Matrix object to do global transform

The problem: after rotating the graphics, when i then translate them they move according to the rotate transform. Do I need to compensate for this rotation in MouseDown and MouseMove where I'm setting the translate variable?


Remember, MouseDown is only proceed once. I think in the MouseDown event, beside setting the offset you need to transform it. And also you need a variable perhaps

bool isMouseDown = true;

to help MouseMove indicate that it is in "after mouseDown" state.

And in the MouseMove event, basically you are doing the same process as in the MouseDown event, the diffrerence is only the coordinate of the mouse.

0

精彩评论

暂无评论...
验证码 换一张
取 消