public static void CreateRegion( Control Ctrl, Rectangle BoundsRect, int Radius, ToolTipRoundStyle RStyle) { using (GraphicsPath path = ToolTipGraphicsPathHelper.CreatePath(BoundsRect, Radius, RStyle, true)) { Region region = new Region(path); path.Widen(Pens.White); region.Union(path); if (Ctrl.Region != null) { Ctrl.Region.Dispose(); } Ctrl.Region = region; } }
internal static void RenderBackgroundInternal( Graphics G, Rectangle Rect, Color BaseColor, Color BorderColor, Color InnerBorderColor, ToolTipRoundStyle Style, int RoundWidth, float BasePosition, bool DrawBorder, bool DrawGlass, LinearGradientMode Mode) { if (DrawBorder) { Rect.Width--; Rect.Height--; } using (LinearGradientBrush brush = new LinearGradientBrush(Rect, Color.Transparent, Color.Transparent, Mode)) { Color[] colors = new Color[4]; colors[0] = GetColor(BaseColor, 0, 35, 24, 9); colors[1] = GetColor(BaseColor, 0, 13, 8, 3); colors[2] = BaseColor; colors[3] = GetColor(BaseColor, 0, 35, 24, 9); ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0.0f, BasePosition, BasePosition + 0.05f, 1.0f }; blend.Colors = colors; brush.InterpolationColors = blend; if (Style != ToolTipRoundStyle.None) { using (GraphicsPath path = ToolTipGraphicsPathHelper.CreatePath(Rect, RoundWidth, Style, false)) { G.FillPath(brush, path); } if (BaseColor.A > 80) { Rectangle rectTop = Rect; if (Mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * BasePosition); } else { rectTop.Width = (int)(Rect.Width * BasePosition); } using (GraphicsPath pathTop = ToolTipGraphicsPathHelper.CreatePath(rectTop, RoundWidth, ToolTipRoundStyle.Top, false)) { using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { G.FillPath(brushAlpha, pathTop); } } } if (DrawGlass) { RectangleF glassRect = Rect; if (Mode == LinearGradientMode.Vertical) { glassRect.Y = Rect.Y + Rect.Height * BasePosition; glassRect.Height = (Rect.Height - Rect.Height * BasePosition) * 2; } else { glassRect.X = Rect.X + Rect.Width * BasePosition; glassRect.Width = (Rect.Width - Rect.Width * BasePosition) * 2; } ToolTipControlPaintEx.DrawGlass(G, glassRect, 170, 0); } if (DrawBorder) { using (GraphicsPath path = ToolTipGraphicsPathHelper.CreatePath(Rect, RoundWidth, Style, false)) { using (Pen pen = new Pen(BorderColor)) { G.DrawPath(pen, path); } } Rect.Inflate(-1, -1); using (GraphicsPath path = ToolTipGraphicsPathHelper.CreatePath(Rect, RoundWidth, Style, false)) { using (Pen pen = new Pen(InnerBorderColor)) { G.DrawPath(pen, path); } } } } else { G.FillRectangle(brush, Rect); if (BaseColor.A > 80) { Rectangle rectTop = Rect; if (Mode == LinearGradientMode.Vertical) { rectTop.Height = (int)(rectTop.Height * BasePosition); } else { rectTop.Width = (int)(Rect.Width * BasePosition); } using (SolidBrush brushAlpha = new SolidBrush(Color.FromArgb(128, 255, 255, 255))) { G.FillRectangle(brushAlpha, rectTop); } } if (DrawGlass) { RectangleF glassRect = Rect; if (Mode == LinearGradientMode.Vertical) { glassRect.Y = Rect.Y + Rect.Height * BasePosition; glassRect.Height = (Rect.Height - Rect.Height * BasePosition) * 2; } else { glassRect.X = Rect.X + Rect.Width * BasePosition; glassRect.Width = (Rect.Width - Rect.Width * BasePosition) * 2; } ToolTipControlPaintEx.DrawGlass(G, glassRect, 200, 0); } if (DrawBorder) { using (Pen pen = new Pen(BorderColor)) { G.DrawRectangle(pen, Rect); } Rect.Inflate(-1, -1); using (Pen pen = new Pen(InnerBorderColor)) { G.DrawRectangle(pen, Rect); } } } } }