c# - How to recognize if a rectangle contains a Text block within in -
i'm creating program in user drags/drops text block rectangle, , store contents of specific textblock when he/she drops rectangle.
i figured out how drag/drop, can't figure out how check if rectangle contains textblock.
here's code far:
bool captured = false; double x_shape, x_canvas, y_shape, y_canvas; uielement source = null; private void shape_mouseleftbuttondown(object sender, mousebuttoneventargs e) { source = (uielement)sender; mouse.capture(source); captured = true; x_shape = canvas.getleft(source); x_canvas = e.getposition(layoutroot).x; y_shape = canvas.gettop(source); y_canvas = e.getposition(layoutroot).y; } private void shape_mousemove(object sender, mouseeventargs e) { if (captured) { double x = e.getposition(layoutroot).x; double y = e.getposition(layoutroot).y; x_shape += x - x_canvas; canvas.setleft(source, x_shape); x_canvas = x; y_shape += y - y_canvas; canvas.settop(source, y_shape); y_canvas = y; } } private void shape_mouseleftbuttonup(object sender, mousebuttoneventargs e) { mouse.capture(null); captured = false; } private void rectangle1_mouseenter(object sender, mouseeventargs e) { if (mouse.capture(null)) { textbox1.text = "test"; } }
the "shape" events apply textblock way, clarification. tried find shortcut , make rectangle1_mouseenter event if mouse isn't clicked, store values (didn't include code storing values). however, problem is, idea doesn't work because textbox1.text="test" isn't registered, , don't see why isn't.
Comments
Post a Comment