c# - Make Picture boxes transparent, each overlapping the other with a corner? -
tl;dr: @ picture below
so i'm trying make little picture, , , people around me kinda out of ideas.
i have table (the sitting+eating one) in middle (seen above), , people sitting around it. people round, isthe table.
every person has own picturebox, use 1 picture, rotate it, , set image in next box.
thep roblem is: pictureboxes of people on corners overlap table empty corner, in image there transparency there. should show table below it, instead shows background of form :(
edit: backgrounds set transparent, form has marble background , white ("window") background colour.
i put 1 person in , 1 in front, it's easy see:
edit 2 (same ocmment):
in last 2 days read question 10 times, , not 1 described exact problem has had actual answer. when trying push 1 of those, told should post new question.
example: how make picturebox transparent?
transparency in winforms kind of misleading, since it's not transparency.
winforms controls mimic transparency painting part of parent control hide instead of own background.
however, not paint other controls might partially covered them.
reason top picture boxes hides big picture box.
you can overcome creating custom control inherits picturebox
, override onpaintbackground
method (taken, slight adjustments, this code project article):
protected override void onpaintbackground(painteventargs e) { base.onpaintbackground(e); graphics g = e.graphics; if (this.parent != null) { var index = parent.controls.getchildindex(this); (var = parent.controls.count - 1; > index; i--) { var c = parent.controls[i]; if (c.bounds.intersectswith(bounds) && c.visible) { using (var bmp = new bitmap(c.width, c.height, g)) { c.drawtobitmap(bmp, c.clientrectangle); g.translatetransform(c.left - left, c.top - top); g.drawimageunscaled(bmp, point.empty); g.translatetransform(left - c.left, top - c.top); } } } } }
microsoft have published knowledge base article solve problem long time ago, it's bit out-dated , it's code sample in vb.net.
another option paint images yourself, without picture boxes hold them, using graphics.drawimage
method.
best place in onpaint
method of form.
Comments
Post a Comment