protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (base.Panel1Collapsed || base.Panel2Collapsed) { return; } Graphics g = e.Graphics; Rectangle rect = base.SplitterRectangle; bool bHorizontal = base.Orientation == Orientation.Horizontal; LinearGradientMode gradientMode = bHorizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; using (LinearGradientBrush brush = new LinearGradientBrush( rect, SystemColors.Control, SystemColors.Control, gradientMode)) { Blend blend = new Blend(); blend.Positions = new float[] { 0f, .5f, 1f }; blend.Factors = new float[] { .5F, 1F, .5F }; brush.Blend = blend; g.FillRectangle(brush, rect); } if (_collapsePanel == CollapsePanel.None) { return; } Rectangle arrowRect; Rectangle topLeftRect; Rectangle bottomRightRect; CalculateRect( CollapseRect, out arrowRect, out topLeftRect, out bottomRightRect); ArrowDirection direction = ArrowDirection.Left; switch (_collapsePanel) { case CollapsePanel.Panel1: if (bHorizontal) { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Down : ArrowDirection.Up; } else { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Right : ArrowDirection.Left; } break; case CollapsePanel.Panel2: if (bHorizontal) { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Up : ArrowDirection.Down; } else { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Left : ArrowDirection.Right; } break; } Color foreColor = _mouseState == ControlState.Hover ? Color.FromArgb(21, 66, 139) : Color.FromArgb(80, 136, 228); using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g)) { RenderHelper.RenderGrid(g, topLeftRect, new Size(3, 3), foreColor); RenderHelper.RenderGrid(g, bottomRightRect, new Size(3, 3), foreColor); using (Brush brush = new SolidBrush(foreColor)) { RenderHelper.RenderArrowInternal( g, arrowRect, direction, brush); } } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (base.Panel1Collapsed || base.Panel2Collapsed) { return; } Graphics g = e.Graphics; Rectangle rect = base.SplitterRectangle; bool bHorizontal = base.Orientation == Orientation.Horizontal; LinearGradientMode gradientMode = bHorizontal ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal; //using (LinearGradientBrush brush = new LinearGradientBrush( // rect, Color.FromArgb(206, 238, 255), // Color.FromArgb(105, 200, 254), gradientMode)) //{ // Blend blend = new Blend(); // blend.Positions = new float[] { 0f, .5f, 1f }; // blend.Factors = new float[] { .5F, 1F, .5F }; // brush.Blend = blend; // g.FillRectangle(brush, rect); //} //using (LinearGradientBrush brush = new LinearGradientBrush( // rect, Color.FromArgb(206, 238, 255), // Color.FromArgb(105, 200, 254), gradientMode)) //{ // Blend blend = new Blend(); // blend.Positions = new float[] { 0f, .5f, 1f }; // blend.Factors = new float[] { .5F, 1F, .5F }; // brush.Blend = blend; // g.FillRectangle(brush, rect); //} if (_collapsePanel == CollapsePanel.None) { return; } Rectangle arrowRect; Rectangle topLeftRect; Rectangle bottomRightRect; CalculateRect( CollapseRect, out arrowRect, out topLeftRect, out bottomRightRect); ArrowDirection direction = ArrowDirection.Left; switch (_collapsePanel) { case CollapsePanel.Panel1: if (bHorizontal) { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Down : ArrowDirection.Up; } else { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Right : ArrowDirection.Left; } break; case CollapsePanel.Panel2: if (bHorizontal) { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Up : ArrowDirection.Down; } else { direction = _spliterPanelState == SpliterPanelState.Collapsed ? ArrowDirection.Left : ArrowDirection.Right; } break; } Color foreColor = _mouseState == ControlState.Hover ? Color.FromArgb(21, 66, 139) : Color.FromArgb(80, 136, 228); using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g)) { RenderHelper.RenderGrid(g, topLeftRect, new Size(3, 3), foreColor); RenderHelper.RenderGrid(g, bottomRightRect, new Size(3, 3), foreColor); using (Brush brush = new SolidBrush(foreColor)) { RenderHelper.RenderArrowInternal( g, arrowRect, direction, brush); } } }
protected virtual void OnRenderThumb(PaintThumbEventArgs e) { Graphics g = e.Graphics; Rectangle rect = e.ClipRectangle; ControlState state = e.ControlState; ThumbArrowDirection direction = ThumbArrowDirection.None; Color begin = ColorTable.ThumbBackNormal; Color end = ColorTable.TrackInnerBorder; Color border = ColorTable.ThumbBorderNormal; float mode = base.Orientation == Orientation.Horizontal ? 90f : 0f; switch (base.Orientation) { case Orientation.Horizontal: switch (base.TickStyle) { case TickStyle.None: case TickStyle.BottomRight: direction = ThumbArrowDirection.Down; break; case TickStyle.TopLeft: direction = ThumbArrowDirection.Up; break; case TickStyle.Both: direction = ThumbArrowDirection.None; break; } break; case Orientation.Vertical: switch (base.TickStyle) { case TickStyle.TopLeft: direction = ThumbArrowDirection.Left; break; case TickStyle.None: case TickStyle.BottomRight: direction = ThumbArrowDirection.Right; break; case TickStyle.Both: direction = ThumbArrowDirection.None; break; } break; } switch (state) { case ControlState.Hover: begin = ColorTable.ThumbBackHover; border = ColorTable.ThumbBorderHover; break; } using (SmoothingModeGraphics sg = new SmoothingModeGraphics(g)) { using (GraphicsPath path = GraphicsPathHelper.CreateTrackBarThumbPath( rect, direction)) { using (LinearGradientBrush brush = new LinearGradientBrush( rect, begin, end, mode)) { Blend blend = new Blend(); blend.Positions = new float[] { 0, .2f, .5f, .8f, 1f }; blend.Factors = new float[] { 1f, .7f, 0, .7f, 1f }; brush.Blend = blend; g.FillPath(brush, path); } using (Pen pen = new Pen(border)) { g.DrawPath(pen, path); } } rect.Inflate(-1, -1); using (GraphicsPath path = GraphicsPathHelper.CreateTrackBarThumbPath( rect, direction)) { using (Pen pen = new Pen(ColorTable.TrackInnerBorder)) { g.DrawPath(pen, path); } } } }