private static void DrawTextArea(Graphics g, Rectangle bounds, DropdownButtonSide side) { Color c = _TextAreaColor; Rectangle r = Rectangle.Inflate(bounds, -3, -3); switch (side) { case DropdownButtonSide.Right: using (SolidBrush b = new SolidBrush(c)) { r.Width = r.Width - 18; _textBounds = r; g.FillRectangle(b, r); } break; case DropdownButtonSide.Left: using (SolidBrush b = new SolidBrush(c)) { r.X = r.X + 18; r.Width = r.Width - 18; _textBounds = r; g.FillRectangle(b, r); } break; } }
/// <summary> /// A Rectangle that represents the dropdown button area of the control. /// </summary> /// <param name="rec">Rectangle of the control.</param> /// <param name="side">Placement of the dropdown button.</param> /// <returns>Rectangle defining the button area.</returns> public static Rectangle ButtonBounds(Rectangle rec, DropdownButtonSide side) { Rectangle r = new Rectangle(0, 0, rec.Width, rec.Height); if (side == DropdownButtonSide.Right) { return(new Rectangle(r.Width - 18, r.Y, 18, r.Height)); } else { return(new Rectangle(0, 0, 18, r.Height)); } }
/// <summary> /// A Rectangle that represents the text box area of the control. /// </summary> /// <param name="bounds">Rectangle bounds of the control.</param> /// <param name="side">Placement of the dropdown button.</param> /// <returns>Rectangle defining the text box area.</returns> public static Rectangle TextBoxBounds(Rectangle bounds, DropdownButtonSide side) { Rectangle tb = new Rectangle(); Rectangle r = Rectangle.Inflate(bounds, -3, -3); switch (side) { case DropdownButtonSide.Right: r.Width = r.Width - 18; tb = r; break; case DropdownButtonSide.Left: r.X = r.X + 18; r.Width = r.Width - 18; tb = r; break; } return(tb); }