/// <summary> /// Draw a 3D border inside the specified rectangle using a linear gradient border color. /// </summary> /// <param name="g"></param> /// <param name="p_HeaderRectangle"></param> /// <param name="p_BackColor"></param> /// <param name="p_DarkColor"></param> /// <param name="p_LightColor"></param> /// <param name="p_DarkGradientNumber">The width of the dark border</param> /// <param name="p_LightGradientNumber">The width of the light border</param> /// <param name="p_Style"></param> public static void DrawGradient3DBorder(Graphics g, Rectangle p_HeaderRectangle, Color p_BackColor, Color p_DarkColor, Color p_LightColor, int p_DarkGradientNumber, int p_LightGradientNumber, Gradient3DBorderStyle p_Style) { Color l_TopLeft, l_BottomRight; int l_TopLeftWidth, l_BottomRightWidth; if (p_Style == Gradient3DBorderStyle.Raised) { l_TopLeft = p_LightColor; l_TopLeftWidth = p_LightGradientNumber; l_BottomRight = p_DarkColor; l_BottomRightWidth = p_DarkGradientNumber; } else { l_TopLeft = p_DarkColor; l_TopLeftWidth = p_DarkGradientNumber; l_BottomRight = p_LightColor; l_BottomRightWidth = p_LightGradientNumber; } //TopLeftBorder Color[] l_TopLeftGradient = CalculateColorGradient(p_BackColor, l_TopLeft, l_TopLeftWidth); using (Pen l_Pen = new Pen(l_TopLeftGradient[0])) { for (int i = 0; i < l_TopLeftGradient.Length; i++) { l_Pen.Color = l_TopLeftGradient[l_TopLeftGradient.Length - (i + 1)]; //top g.DrawLine(l_Pen, p_HeaderRectangle.Left + i, p_HeaderRectangle.Top + i, p_HeaderRectangle.Right - (i + 1), p_HeaderRectangle.Top + i); //Left g.DrawLine(l_Pen, p_HeaderRectangle.Left + i, p_HeaderRectangle.Top + i, p_HeaderRectangle.Left + i, p_HeaderRectangle.Bottom - (i + 1)); } } //BottomRightBorder Color[] l_BottomRightGradient = CalculateColorGradient(p_BackColor, l_BottomRight, l_BottomRightWidth); using (Pen l_Pen = new Pen(l_BottomRightGradient[0])) { for (int i = 0; i < l_BottomRightGradient.Length; i++) { l_Pen.Color = l_BottomRightGradient[l_BottomRightGradient.Length - (i + 1)]; //bottom g.DrawLine(l_Pen, p_HeaderRectangle.Left + i, p_HeaderRectangle.Bottom - (i + 1), p_HeaderRectangle.Right - (i + 1), p_HeaderRectangle.Bottom - (i + 1)); //right g.DrawLine(l_Pen, p_HeaderRectangle.Right - (i + 1), p_HeaderRectangle.Top + i, p_HeaderRectangle.Right - (i + 1), p_HeaderRectangle.Bottom - (i + 1)); } } }
/// <summary> /// Draw a 3D border inside the specified rectangle using a linear gradient border color. /// </summary> /// <param name="g"></param> /// <param name="p_HeaderRectangle"></param> /// <param name="p_BackColor"></param> /// <param name="p_DarkColor"></param> /// <param name="p_LightColor"></param> /// <param name="p_DarkGradientNumber">The width of the dark border</param> /// <param name="p_LightGradientNumber">The width of the light border</param> /// <param name="p_Style"></param> public static void DrawGradient3DBorder(Graphics g, Rectangle p_HeaderRectangle, Color p_BackColor, Color p_DarkColor, Color p_LightColor, int p_DarkGradientNumber, int p_LightGradientNumber, Gradient3DBorderStyle p_Style) { Color l_TopLeft, l_BottomRight; int l_TopLeftWidth, l_BottomRightWidth; if (p_Style == Gradient3DBorderStyle.Raised) { l_TopLeft = p_LightColor; l_TopLeftWidth = p_LightGradientNumber; l_BottomRight = p_DarkColor; l_BottomRightWidth = p_DarkGradientNumber; } else { l_TopLeft = p_DarkColor; l_TopLeftWidth = p_DarkGradientNumber; l_BottomRight = p_LightColor; l_BottomRightWidth = p_LightGradientNumber; } //TopLeftBorder Color[] l_TopLeftGradient = CalculateColorGradient(p_BackColor, l_TopLeft, l_TopLeftWidth); using (Pen l_Pen = new Pen(l_TopLeftGradient[0])) { for (int i = 0; i < l_TopLeftGradient.Length; i++) { l_Pen.Color = l_TopLeftGradient[l_TopLeftGradient.Length - (i+1)]; //top g.DrawLine(l_Pen, p_HeaderRectangle.Left+i, p_HeaderRectangle.Top+i, p_HeaderRectangle.Right-(i+1), p_HeaderRectangle.Top+i); //Left g.DrawLine(l_Pen, p_HeaderRectangle.Left+i, p_HeaderRectangle.Top+i, p_HeaderRectangle.Left+i, p_HeaderRectangle.Bottom-(i+1)); } } //BottomRightBorder Color[] l_BottomRightGradient = CalculateColorGradient(p_BackColor, l_BottomRight, l_BottomRightWidth); using (Pen l_Pen = new Pen(l_BottomRightGradient[0])) { for (int i = 0; i < l_BottomRightGradient.Length; i++) { l_Pen.Color = l_BottomRightGradient[l_BottomRightGradient.Length - (i+1)]; //bottom g.DrawLine(l_Pen, p_HeaderRectangle.Left+i, p_HeaderRectangle.Bottom-(i+1), p_HeaderRectangle.Right-(i+1), p_HeaderRectangle.Bottom-(i+1)); //right g.DrawLine(l_Pen, p_HeaderRectangle.Right-(i+1), p_HeaderRectangle.Top+i, p_HeaderRectangle.Right-(i+1), p_HeaderRectangle.Bottom-(i+1)); } } }