c# - Draw line after picture box zoom -



c# - Draw line after picture box zoom -

iam using user define image box on project, working fine zooming image , element drawn on image(line,text,shapes ......) element position transferred right position after zooming. problem appears when trying draw line after zooming, check image

the drawn element drawn offset mouse position, drawing code

this paint function within mt user define image box

protected override void onpaint(painteventargs e) { if (_image == null) { base.onpaintbackground(e); return; } matrix mx = new matrix(_zoom, 0, 0, _zoom, 0, 0); mx.translate(this.autoscrollposition.x / _zoom, this.autoscrollposition.y / _zoom); matrix tempmx = e.graphics.transform; e.graphics.transform = mx; e.graphics.interpolationmode = _interpolationmode;//cliprectangle = {x = 0 y = 0 width = 1234 height = 651} e.graphics.drawimage(_image, new rectangle(this.position.x, this.position.y, this._image.width, this._image.height), 0, 0, _image.width, _image.height, graphicsunit.pixel); base.onpaint(e); }

this paint function within line sprite

public override void draw(graphics g) { pen drawpen = new pen(new solidbrush(basecolor)); g.drawline(drawpen, this.position, this.position2); if (isselected) { pen blackpen = new pen(new solidbrush(color.black)); g.drawrectangle(blackpen, new rectangle(this.position.x, this.position.y, 5, 5)); g.drawrectangle(blackpen, new rectangle(this.position2.x, this.position2.y, 5, 5)); } }

i think problem due transform matrix not sure how solve it, help how solve ?

edit: if problem not clear, problem is: after zooming image in image box , trying draw line on image, drawn lin drawn offset mouse position not in same position, see thispicture when iam drawing without zooming(every thing fine)

this 1 after zooming(the line should drawn on mouse position when moving, see how been drawn offset)

c# drawing draw

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -