public void Init(UnitedMarker unitedMarker, Size boundRect, Action bottomChanged) { this.bottomChanged = bottomChanged; this.uniMarker = unitedMarker; bountRct = boundRect; CheckAndCorrect(uniMarker); Display(); }
void CheckAndCorrect(UnitedMarker unitedMarker) { double topx = uniMarker.TopLeft.X < unitedMarker.BottomRight.X ? uniMarker.TopLeft.X : unitedMarker.BottomRight.X; double bottomx = uniMarker.TopLeft.X < unitedMarker.BottomRight.X ? unitedMarker.BottomRight.X : uniMarker.TopLeft.X; double topy = uniMarker.TopLeft.Y < unitedMarker.BottomRight.Y ? uniMarker.TopLeft.Y : unitedMarker.BottomRight.Y; double bottomy = uniMarker.TopLeft.Y < unitedMarker.BottomRight.Y ? unitedMarker.BottomRight.Y : uniMarker.TopLeft.Y; if (topx < 0) { topx = 0; } if (topy < 0) { topy = 0; } if (topx >= bountRct.Width) { topx = bountRct.Width - 1; } if (topy >= bountRct.Height) { topy = bountRct.Height - 1; } if (bottomx < 0) { bottomx = 0; } if (bottomy < 0) { bottomy = 0; } if (bottomx >= bountRct.Width) { bottomx = bountRct.Width - 1; } if (bottomy >= bountRct.Height) { bottomy = bountRct.Height - 1; } unitedMarker.TopLeft = new OPoint() { X = topx, Y = topy }; unitedMarker.BottomRight = new OPoint() { X = bottomx, Y = bottomy }; }
public void Init(UnitedMarkerCalibration uniCalibration, UnitedMarker unitedMarker, Size boundRect, Action bottomChanged, Action <int, bool> ScaleInfo) { this.bottomChanged = bottomChanged; this.ScaleInfo = ScaleInfo; uniMarker = unitedMarker; this.uniCalibration = uniCalibration; bountRct = boundRect; numtext.Text = uniMarker.ID.ToString(); CheckAndCorrect(uniMarker); Display(); }