/// <summary> /// 描画処理の拡張 /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { int clheight = DisplayRectangle.Height; int clwidth = DisplayRectangle.Width; e.Graphics.TranslateTransform(DisplayRectangle.X, DisplayRectangle.Y); if (IsTab) { Brush foreBrush = new SolidBrush(ButtonLabelForeColor); Color fc = ButtonLabelForeColor; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; int labelHeight = FontHeight + CaptionMargin.Vertical + 6; Control selected = null; Rectangle cr = e.ClipRectangle; e.Graphics.SetClip(new Rectangle(5, 0, clwidth - 10, clheight)); for (int i = Controls.Count - 1; i >= 0; i--) { Control c = Controls[i]; if (TabVisible(c)) { //タブ描画 if (!c.Visible) { if (i >= LeftTab - 1) { Rectangle r = TabRect(LeftTab, c); if (r.Left < clwidth) { Rectangle rt = r; if (i > 0) { rt.X -= 6; rt.Width += 6; } rt.Y += 2; rt.Height -= 2; CaptionBasePanel cbp = c as CaptionBasePanel; Color bc = CaptionGraphics.BlendColor((cbp != null) ? cbp.ButtonLabelBackColor : ButtonLabelBackColor, Color.White, 60); GraphicsPath gp = CaptionGraphics.CreateRoundRectPath(rt, 4, 4, true, true, false, false); CaptionGraphics.DrawShadow(e.Graphics, gp, 1, 3, 20); e.Graphics.FillPath((HoverControl == c) ? new SolidBrush(CaptionGraphics.BlendColor(ClickableColor, bc, 20)) : new SolidBrush(bc), gp); if (cbp != null) { cbp.DrawMarkAndText(e.Graphics, Font, ButtonLabelForeColor, ButtonLabelForeColor, new Point(r.Left + CaptionMargin.Left, rt.Y + CaptionMargin.Top), true); } else { e.Graphics.FillEllipse(foreBrush, r.Left + CaptionMargin.Left, rt.Y + CaptionMargin.Top, FontHeight, FontHeight); TextRenderer.DrawText(e.Graphics, c.Text, Font, new Point(r.Left + (int)(1.5f * FontHeight), rt.Y + CaptionMargin.Top), ButtonLabelForeColor); } } } } else { selected = c; } } } e.Graphics.SetClip(cr); if (selected != null) { CaptionBasePanel cbp = selected as CaptionBasePanel; Rectangle sr = TabRect(LeftTab, selected); GraphicsPath gp = CaptionGraphics.CreateRoundRectPath(sr, 4, 4, true, true, false, false); CaptionGraphics.DrawShadow(e.Graphics, gp); //複雑な形状なので全体再描画 Rectangle r = new Rectangle(6, labelHeight, clwidth - 12, clheight - labelHeight - 6); GraphicsPath gpf = CaptionGraphics.CreateRoundRectPath(r, 2, 2, false, true, true, true); CaptionGraphics.DrawShadow(e.Graphics, gpf); Color blb = ButtonLabelBackColor; Color bbc = BackColor; if (cbp != null) { blb = cbp.ButtonLabelBackColor; bbc = cbp.BackColor; } Brush brush = new SolidBrush((HoverControl == selected) ? ClickableColor : blb); e.Graphics.FillPath(new SolidBrush(bbc), gpf); Pen p = new Pen(blb, 2); e.Graphics.DrawPath(p, gpf); e.Graphics.FillPath(brush, gp); e.Graphics.DrawPath(new Pen(brush, 2), gp); if (Focused) { e.Graphics.DrawPath(new Pen(ButtonLabelFocusBackColor, 1), gp); } Icon ico = null; if (selected is InnerTab) { InnerTab it = selected as InnerTab; Form fm = it.MainControl as Form; if (fm != null) { ico = fm.Icon; } } if (cbp != null) { cbp.DrawMarkAndText(e.Graphics, Font, Focused ? ButtonLabelFocusBackColor : fc, fc, new Point(sr.Left + CaptionMargin.Left, sr.Top + CaptionMargin.Top)); } else { e.Graphics.FillEllipse(new SolidBrush(Focused ? ButtonLabelFocusBackColor : fc), sr.Left + CaptionMargin.Left, CaptionMargin.Top + 1, FontHeight, FontHeight); TextRenderer.DrawText(e.Graphics, selected.Text, Font, new Point(CaptionMargin.Left + sr.Left + (int)(1.5f * FontHeight), CaptionMargin.Top + 1), fc); } } else { //複雑な形状なので全体再描画 Rectangle r = new Rectangle(6, labelHeight, clwidth - 12, clheight - labelHeight - 6); GraphicsPath gpf = CaptionGraphics.CreateRoundRectPath(r, 2, 2, false, true, true, true); CaptionGraphics.DrawShadow(e.Graphics, gpf); e.Graphics.FillPath(Brushes.Gainsboro, gpf); e.Graphics.DrawPath(new Pen(Color.Silver, 2), gpf); } if (TabRightOver()) { //コントローラー描画 Brush brush = new SolidBrush(ButtonLabelBackColor); int ar = CONTROLER_WIDTH / 8; //CONTROLER_WIDTH Rectangle r = new Rectangle(clwidth - CONTROLER_WIDTH - 6, 0, CONTROLER_WIDTH / 2, CONTROLER_WIDTH / 2); GraphicsPath gp = CaptionGraphics.CreateRoundRectPath(r, 4, 4); CaptionGraphics.DrawShadow(e.Graphics, gp); e.Graphics.FillPath((LeftTab > 0) ? brush : Brushes.Silver, gp); e.Graphics.FillPolygon(foreBrush, new Point[] { new Point(r.X + ar, r.Y + r.Height / 2), new Point(r.X + ar * 3, r.Y + r.Height / 2 + ar), new Point(r.X + ar * 3, r.Y + r.Height / 2 - ar) }); r = new Rectangle(clwidth - CONTROLER_WIDTH / 2 - 5, 0, CONTROLER_WIDTH / 2, CONTROLER_WIDTH / 2); gp = CaptionGraphics.CreateRoundRectPath(r, 4, 4); CaptionGraphics.DrawShadow(e.Graphics, gp); e.Graphics.FillPath((RightTab < Controls.Count - 1) ? brush : Brushes.Silver, gp); e.Graphics.FillPolygon(foreBrush, new Point[] { new Point(r.X + ar * 3, r.Y + r.Height / 2), new Point(r.X + ar, r.Y + r.Height / 2 + ar), new Point(r.X + ar, r.Y + r.Height / 2 - ar) }); } } e.Graphics.TranslateTransform(-DisplayRectangle.X, -DisplayRectangle.Y); base.OnPaint(e); }
/// <summary> /// 描画処理の拡張 /// </summary> /// <param name="e"></param> protected override void OnPaint(PaintEventArgs e) { Brush brush = new SolidBrush(ClickableColor); //Pen pen = new Pen(ButtonLabelFocusBackColor); Color fc = ButtonLabelForeColor; Color mfc = ButtonLabelForeColor; e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; int clheight = DisplayRectangle.Height; int clwidth = DisplayRectangle.Width; e.Graphics.TranslateTransform(DisplayRectangle.X, DisplayRectangle.Y); if (TextVisible) { if (!string.IsNullOrEmpty(Text) || Foldable) { if (Foldable) { GraphicsPath gp; if (FolderOpened) { Rectangle r = new Rectangle(6, LabelSize.Height + 6 - 4, clwidth - 12, clheight - LabelSize.Height - 12 + 4); GraphicsPath gpf = CaptionGraphics.CreateRoundRectPath(r, 4, 4, false, true, true, true); CaptionGraphics.DrawShadow(e.Graphics, gpf); e.Graphics.FillPath(new SolidBrush(BackColor), gpf); Pen p = new Pen(ButtonLabelBackColor, 2); e.Graphics.DrawPath(p, gpf); gp = CaptionGraphics.CreateRoundRectPath(new Rectangle(6, 2, LabelSize.Width, LabelSize.Height), 4, 4, true, true, false, false); e.Graphics.FillPath(brush, gp); e.Graphics.DrawPath(new Pen(brush, 2), gp); DrawMarkAndText(e.Graphics, Font, (Focused) ? ButtonLabelFocusBackColor : mfc, fc, new Point(CaptionMargin.Left + 6, CaptionMargin.Top + 2)); } else { Rectangle r = new Rectangle(6, 2, clwidth - 12, LabelSize.Height); gp = CaptionGraphics.CreateRoundRectPath(r, 4, 4, true, true, true, true); CaptionGraphics.DrawShadow(e.Graphics, gp); e.Graphics.FillPath(brush, gp); Pen p = new Pen(brush, 2); e.Graphics.DrawPath(p, gp); CaptionInformationEventArgs ev = new CaptionInformationEventArgs(Information); OnCaptionInformation(ev); DrawMarkAndText(e.Graphics, Font, (Focused) ? ButtonLabelFocusBackColor : mfc, fc, new Rectangle(CaptionMargin.Left + 6, CaptionMargin.Top + 2, clwidth - 12 - CaptionMargin.Horizontal, LabelSize.Height), false, ev.Information); } } else { Rectangle r = new Rectangle(6, 2, clwidth - 12, clheight - 8); GraphicsPath gpf = CaptionGraphics.CreateRoundRectPath(r, 4, 4, true, true, true, true); CaptionGraphics.DrawShadow(e.Graphics, gpf); e.Graphics.FillPath(new SolidBrush(BackColor), gpf); Pen p = new Pen(ButtonLabelBackColor, 2); e.Graphics.DrawPath(p, gpf); GraphicsPath gp = CaptionGraphics.CreateRoundRectPath(new Rectangle(6, 2, clwidth - 12, LabelSize.Height), 4, 4, true, true, false, false); e.Graphics.FillPath(brush, gp); CaptionInformationEventArgs ev = new CaptionInformationEventArgs(Information); OnCaptionInformation(ev); //DrawMarkAndText(e.Graphics, Font, (Focused) ? ButtonLabelFocusBackColor : mfc, fc, new Point(CaptionMargin.Left + 6, CaptionMargin.Top + 2)); DrawMarkAndText(e.Graphics, Font, (Focused) ? ButtonLabelFocusBackColor : mfc, fc, new Rectangle(CaptionMargin.Left + 6, CaptionMargin.Top + 2, clwidth - 12 - CaptionMargin.Horizontal, LabelSize.Height), false, ev.Information); } } else { Rectangle r = new Rectangle(6, 6, clwidth - 12, clheight - 12); GraphicsPath gpf = CaptionGraphics.CreateRoundRectPath(r, 4, 4, true, true, true, true); CaptionGraphics.DrawShadow(e.Graphics, gpf); e.Graphics.FillPath(new SolidBrush(BackColor), gpf); Pen p = new Pen(ButtonLabelBackColor, 2); e.Graphics.DrawPath(p, gpf); } } e.Graphics.TranslateTransform(-DisplayRectangle.X, -DisplayRectangle.Y); base.OnPaint(e); }