private static void DrawInnerBorders(Graphics graphics, XPanderPanel xpanderPanel) { if (xpanderPanel.ShowBorder == true) { using (GraphicsPath graphicsPath = new GraphicsPath()) { Rectangle captionRectangle = xpanderPanel.CaptionRectangle; XPanderPanelList xpanderPanelList = xpanderPanel.Parent as XPanderPanelList; if ((xpanderPanelList != null) && (xpanderPanelList.Dock == DockStyle.Fill)) { Kesoft.Windows.Forms.Panels.Panel panel = xpanderPanelList.Parent as Kesoft.Windows.Forms.Panels.Panel; XPanderPanel parentXPanderPanel = xpanderPanelList.Parent as XPanderPanel; if (((panel != null) && (panel.Padding == new Padding(0))) || ((parentXPanderPanel != null) && (parentXPanderPanel.Padding == new Padding(0)))) { //Left vertical borderline graphicsPath.AddLine(captionRectangle.X, captionRectangle.Y + captionRectangle.Height, captionRectangle.X, captionRectangle.Y + Constants.BorderThickness); if (xpanderPanel.Top == 0) { //Upper horizontal borderline graphicsPath.AddLine(captionRectangle.X, captionRectangle.Y, captionRectangle.X + captionRectangle.Width, captionRectangle.Y); } else { //Upper horizontal borderline graphicsPath.AddLine(captionRectangle.X, captionRectangle.Y + Constants.BorderThickness, captionRectangle.X + captionRectangle.Width, captionRectangle.Y + Constants.BorderThickness); } } } else { //Left vertical borderline graphicsPath.AddLine(captionRectangle.X + Constants.BorderThickness, captionRectangle.Y + captionRectangle.Height, captionRectangle.X + Constants.BorderThickness, captionRectangle.Y); if (xpanderPanel.Top == 0) { //Upper horizontal borderline graphicsPath.AddLine(captionRectangle.X + Constants.BorderThickness, captionRectangle.Y + Constants.BorderThickness, captionRectangle.X + captionRectangle.Width - Constants.BorderThickness, captionRectangle.Y + Constants.BorderThickness); } else { //Upper horizontal borderline graphicsPath.AddLine(captionRectangle.X + Constants.BorderThickness, captionRectangle.Y, captionRectangle.X + captionRectangle.Width - Constants.BorderThickness, captionRectangle.Y); } } using (Pen borderPen = new Pen(xpanderPanel.PanelColors.InnerBorderColor)) { graphics.DrawPath(borderPen, graphicsPath); } } } }
private static void DrawBorders(Graphics graphics, XPanderPanel xpanderPanel) { if (xpanderPanel.ShowBorder == true) { using (GraphicsPath graphicsPath = new GraphicsPath()) { using (Pen borderPen = new Pen(xpanderPanel.PanelColors.BorderColor, Constants.BorderThickness)) { Rectangle captionRectangle = xpanderPanel.CaptionRectangle; Rectangle borderRectangle = captionRectangle; if (xpanderPanel.Expand == true) { borderRectangle = xpanderPanel.ClientRectangle; graphics.DrawLine( borderPen, captionRectangle.Left, captionRectangle.Top + captionRectangle.Height - Constants.BorderThickness, captionRectangle.Left + captionRectangle.Width, captionRectangle.Top + captionRectangle.Height - Constants.BorderThickness); } XPanderPanelList xpanderPanelList = xpanderPanel.Parent as XPanderPanelList; if ((xpanderPanelList != null) && (xpanderPanelList.Dock == DockStyle.Fill)) { Kesoft.Windows.Forms.Panels.Panel panel = xpanderPanelList.Parent as Kesoft.Windows.Forms.Panels.Panel; XPanderPanel parentXPanderPanel = xpanderPanelList.Parent as XPanderPanel; if (((panel != null) && (panel.Padding == new Padding(0))) || ((parentXPanderPanel != null) && (parentXPanderPanel.Padding == new Padding(0)))) { if (xpanderPanel.Top != 0) { graphicsPath.AddLine( borderRectangle.Left, borderRectangle.Top, borderRectangle.Left + captionRectangle.Width, borderRectangle.Top); } // Left vertical borderline graphics.DrawLine(borderPen, borderRectangle.Left, borderRectangle.Top, borderRectangle.Left, borderRectangle.Top + borderRectangle.Height); // Right vertical borderline graphics.DrawLine(borderPen, borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top, borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top + borderRectangle.Height); } else { // Upper horizontal borderline only at the top xpanderPanel if (xpanderPanel.Top == 0) { graphicsPath.AddLine( borderRectangle.Left, borderRectangle.Top, borderRectangle.Left + borderRectangle.Width, borderRectangle.Top); } // Left vertical borderline graphicsPath.AddLine( borderRectangle.Left, borderRectangle.Top, borderRectangle.Left, borderRectangle.Top + borderRectangle.Height); //Lower horizontal borderline graphicsPath.AddLine( borderRectangle.Left, borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness, borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness); // Right vertical borderline graphicsPath.AddLine( borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top, borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top + borderRectangle.Height); } } else { // Upper horizontal borderline only at the top xpanderPanel if (xpanderPanel.Top == 0) { graphicsPath.AddLine( borderRectangle.Left, borderRectangle.Top, borderRectangle.Left + borderRectangle.Width, borderRectangle.Top); } // Left vertical borderline graphicsPath.AddLine( borderRectangle.Left, borderRectangle.Top, borderRectangle.Left, borderRectangle.Top + borderRectangle.Height); //Lower horizontal borderline graphicsPath.AddLine( borderRectangle.Left, borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness, borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top + borderRectangle.Height - Constants.BorderThickness); // Right vertical borderline graphicsPath.AddLine( borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top, borderRectangle.Left + borderRectangle.Width - Constants.BorderThickness, borderRectangle.Top + borderRectangle.Height); } } using (Pen borderPen = new Pen(xpanderPanel.PanelColors.BorderColor, Constants.BorderThickness)) { graphics.DrawPath(borderPen, graphicsPath); } } } }