private void DrawGradientToolSplitItem(Graphics g, ToolStripSplitButton splitButton, GradientItemColors colorsButton, GradientItemColors colorsDrop, GradientItemColors colorsSplit) { // Create entire area and just the drop button area rectangles Rectangle backRect = new Rectangle(Point.Empty, splitButton.Bounds.Size); Rectangle backRectDrop = splitButton.DropDownButtonBounds; // Cannot paint zero sized areas if ((backRect.Width > 0) && (backRectDrop.Width > 0) && (backRect.Height > 0) && (backRectDrop.Height > 0)) { // Area that is the normal button starts as everything Rectangle backRectButton = backRect; // The X offset to draw the split line int splitOffset; // Is the drop button on the right hand side of entire area? if (backRectDrop.X > 0) { backRectButton.Width = backRectDrop.Left; backRectDrop.X -= 1; backRectDrop.Width++; splitOffset = backRectDrop.X; } else { backRectButton.Width -= backRectDrop.Width - 2; backRectButton.X = backRectDrop.Right - 1; backRectDrop.Width++; splitOffset = backRectDrop.Right - 1; } // Create border path around the item using (GraphicsPath borderPath = CreateBorderPath(backRect, _cutItemMenu)) { // Draw the normal button area background colorsButton.DrawBack(g, backRectButton); // Draw the drop button area background colorsDrop.DrawBack(g, backRectDrop); // Draw the split line between the areas using (LinearGradientBrush splitBrush = new LinearGradientBrush(new Rectangle(backRect.X + splitOffset, backRect.Top, 1, backRect.Height + 1), colorsSplit.Border1, colorsSplit.Border2, 90f)) { // Convert the brush to a pen for DrawPath call using (Pen splitPen = new Pen(splitBrush)) g.DrawLine(splitPen, backRect.X + splitOffset, backRect.Top + 1, backRect.X + splitOffset, backRect.Bottom - 1); } // Draw the border of the entire item colorsButton.DrawBorder(g, backRect); } } }