c# - Picturebox ablt to allow label 'x' to be moved around freely -
i doing project have display picture in picturebox , when part clicked on 'x' appear , there textboxes display x , y axis. problem project need coordinates of person face displayed in picturebox. how ensure 'x' can produced twice in picturebox. how allow 'x' able moved in case user has accidentally chosen wrong spot. below codes, hope help.
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; namespace camera { public partial class camdisplay : form { public camdisplay() { initializecomponent(); this.picturebox1.imagelocation = @"c:\center90\center90(1).jpg"; } bool mousedclicked = true; private void picturebox1_mouseclick(object sender, mouseeventargs e) { base.onmouseclick(e); if (mousedclicked == true) { txtxaxis.text = e.x.tostring(); txtyaxis.text = e.y.tostring(); mousedclicked = false; } else { txtrxaxis.text = e.x.tostring(); txtryaxis.text = e.y.tostring(); } } private void picturebox1_mousedown(object sender, mouseeventargs e) { using (graphics g = graphics.fromhwnd(picturebox1.handle)) { using (font myfont = new font("calibri", 8)) { g.drawstring("x", myfont, brushes.red, new pointf(e.x, e.y)); } } } } }
thanks in advance!
Comments
Post a Comment