c# - GraphicsPath.AddPolygon not rendering properly -
basically have form , trying "dim" areas of draw focus part of form. i'm using form no border , 50% opacity, aligned actual form. area trying mask dark gray area, roughly, pictured:
to "u"-shaped form, i'm using graphicspath
addpolygon
, calculating points of each vertex:
var p = new graphicspath(); var origin = new point(top, left); var maxextentpt = new point(origin.x + width, origin.y + height); point[] points = { origin, new point(origin.x + leftpanel.width, origin.y), new point(origin.x + leftpanel.width, maxextentpt.y - bottompanel.height), new point(maxextentpt.x - rightpanel.width, maxextentpt.y- bottompanel.height), new point(maxextentpt.x - rightpanel.width, origin.y), new point(maxextentpt.x, origin.y), maxextentpt, new point(origin.x, maxextentpt.y), origin }; p.addpolygon(points); overlayform.region = new region(p); overlayform.location = pointtoscreen(point.empty);
the 3 panels in code masking, using dimensions calculate points. instead of getting expected result, mask looks this, size changing resize main form (i recalculate region on move , resize):
is there limitation of graphicspath.addpolygon
i'm not aware of? double-checked (quadruple-checked, really) results of calculations, including taking coordinates each point , plugging them ipe see if shape correct... was. not in program!
edit: here values of each point, when hit breakpoint @ p.addpolygon(points);
i'm starting in upper left-hand corner , going around clockwise:
looks points wrong after all.
everything ought in coordinates of clientrectangle
, so
origin
should not new point(top, left)
location
of form
. should point.empty
or (0,0)
. or use leftpanel.location
.
and
maxextentpt = new point(origin.x + width, origin.y + height);
should read:
var maxextentpt = new point(origin.x + clientsize.width, origin.y + clientsize.height);
(the difference size of border+title..)
let me know if works better!
Comments
Post a Comment