public static Point GetUnitRectanglePosition(Unit u, double cellSizeX, double cellSizeY, double left, double top) { UnitPosition unitPosition = GetUnitPosition(u, cellSizeX, cellSizeY); Point p = new Point(unitPosition.OffsetX + left, unitPosition.OffsetY + top); return(p); }
// left top width height public static UnitPosition GetUnitPosition(Unit u, double cellSizeX, double cellSizeY) { UnitPosition position = new UnitPosition(); UnitSize unitSize = u.UnitSize; double w = (int)unitSize * cellSizeX / 100; double h = (int)unitSize * cellSizeY / 100; double offsetX = 0; double offsetY = 0; offsetX = (cellSizeX - w) / 2; offsetY = (cellSizeY - h) / 2; position.Height = h; position.Width = w; position.OffsetX = offsetX; position.OffsetY = offsetY; return(position); }