public override void DrawMask(Graphics gr) { base.DrawMask(gr); //gr.DrawRectangle(maskPen, rect); gr.DrawRectangle(maskPen, MathFunctions.recalculateRectangle(percentRectangle, gr.ClipBounds).Round()); }
private void addMask(DrawStyle style, RectangleF percentRectangle, string tag) { if (percentRectangle.Bottom > 100 || percentRectangle.Top < 0 || percentRectangle.Left < 0 || percentRectangle.Right > 100) { MessageBox.Show($"The mask '{tag}' is out of bounds.", "Out of bounds", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } IMask <AForge.Point> mask = null; RectangleF realRectangle = MathFunctions.recalculateRectangle(percentRectangle, VideoBox.Image.Size); switch (style) { case DrawStyle.Curve: //TODO: implement curve function //containFunction = ??? break; case DrawStyle.Ellipse: mask = new EllipMask(realRectangle, percentRectangle, tag); break; case DrawStyle.Rectangle: mask = new RectMask(realRectangle, percentRectangle, tag); break; //because of 'isOkayToDraw' testing in 'maskingEventHanlder', this part of switch ought to never occur, //therefore 'containFunction' should be assigned properly case DrawStyle.None: default: break; } maskControlContainer.Items.Add(mask); if (!blobKeepers.Any(keeper => keeper.Tag == tag)) { blobKeepers.Add(new BlobKeeperRevalidatingAssignment(tossThreshold, tag, historyCount, penaltyValue)); if (Outputs != null) { Outputs.AddStream(tag); } } }