private Rectangle DropDownDirectionToDropDownBounds(ToolStripDropDownDirection dropDownDirection, Rectangle dropDownBounds) { Point offset = Point.Empty; switch (dropDownDirection) { case ToolStripDropDownDirection.AboveLeft: offset.X = -dropDownBounds.Width + this.Width; offset.Y = -dropDownBounds.Height + 1; break; case ToolStripDropDownDirection.AboveRight: offset.Y = -dropDownBounds.Height + 1; break; case ToolStripDropDownDirection.BelowRight: offset.Y = this.Height - 1; break; case ToolStripDropDownDirection.BelowLeft: offset.X = -dropDownBounds.Width + this.Width; offset.Y = this.Height - 1; break; case ToolStripDropDownDirection.Right: offset.X = this.Width; if (!IsOnDropDown) { // overlap the toplevel toolstrip offset.X -= 1; } break; case ToolStripDropDownDirection.Left: offset.X = -dropDownBounds.Width; break; } Point itemScreenLocation = this.TranslatePoint(Point.Empty, ToolStripPointType.ToolStripItemCoords, ToolStripPointType.ScreenCoords); dropDownBounds.Location = new Point(itemScreenLocation.X + offset.X, itemScreenLocation.Y + offset.Y); dropDownBounds = WindowsFormsUtils.ConstrainToScreenWorkingAreaBounds(dropDownBounds); return(dropDownBounds); }
private Rectangle DropDownDirectionToDropDownBounds(ToolStripDropDownDirection dropDownDirection, Rectangle dropDownBounds) { Point empty = Point.Empty; switch (dropDownDirection) { case ToolStripDropDownDirection.AboveLeft: empty.X = -dropDownBounds.Width + base.Width; empty.Y = -dropDownBounds.Height + 1; break; case ToolStripDropDownDirection.AboveRight: empty.Y = -dropDownBounds.Height + 1; break; case ToolStripDropDownDirection.BelowLeft: empty.X = -dropDownBounds.Width + base.Width; empty.Y = base.Height - 1; break; case ToolStripDropDownDirection.BelowRight: empty.Y = base.Height - 1; break; case ToolStripDropDownDirection.Left: empty.X = -dropDownBounds.Width; break; case ToolStripDropDownDirection.Right: empty.X = base.Width; if (!base.IsOnDropDown) { empty.X--; } break; } Point point2 = base.TranslatePoint(Point.Empty, ToolStripPointType.ToolStripItemCoords, ToolStripPointType.ScreenCoords); dropDownBounds.Location = new Point(point2.X + empty.X, point2.Y + empty.Y); dropDownBounds = WindowsFormsUtils.ConstrainToScreenWorkingAreaBounds(dropDownBounds); return(dropDownBounds); }