iSpyApplication.Controls.FloorPlanControl.GetButtonIndexByLocation C# (CSharp) Method

GetButtonIndexByLocation() private method

private GetButtonIndexByLocation ( Point xy ) : int
xy Point
return int
        private int GetButtonIndexByLocation(Point xy)
        {
            var rBp = ButtonPanel;
            if (xy.X >= rBp.X && xy.Y > rBp.Y - 25 && xy.X <= rBp.X + rBp.Width && xy.Y <= rBp.Y + rBp.Height)
            {
                if (xy.Y < rBp.Y)
                    return -1;//seek

                if (xy.Y > 25)
                {
                    double x = xy.X - rBp.X;
                    return Convert.ToInt32(Math.Ceiling((x / rBp.Width) * ButtonCount)) - 1;
                }
            }
            return -999;//nothing
        }