/// <summary> /// 绘制拖动条箭头 /// </summary> /// <param name="rect">拖动条箭头坐标</param> /// <returns></returns> private void RenderThumArrow(PaintEventArgs e, Rectangle thumbRect, ThumDirection dir) { Color thumbArrowColor = ThumbArrowSchema.BackNormalStyle.Color1; if (Enabled) { switch (ThumbState) { case ControlState.Hover: case ControlState.Pressed: thumbArrowColor = ThumbArrowSchema.BackHoverStyle.Color1; break; case ControlState.Normal: thumbArrowColor = ThumbArrowSchema.BackNormalStyle.Color1; break; } } else { thumbArrowColor = ThumbArrowSchema.BackDisabledStyle.Color1; } switch (dir) { case ThumDirection.Left: { using (GraphicsPath gp = new GraphicsPath()) { if (_orientation == Orientation.Horizontal) { gp.AddLine(thumbRect.Left + thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2, thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 - 4); gp.AddLine(thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 - 4, thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 + 4); gp.AddLine(thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 + 4, thumbRect.Left + thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2); } else { gp.AddLine(thumbRect.Left + thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2, thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 - 4); gp.AddLine(thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 - 4, thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 + 4); gp.AddLine(thumbRect.Left + thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2 + 4, thumbRect.Left + thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2); } gp.CloseFigure(); using (SolidBrush br = new SolidBrush(thumbArrowColor)) { e.Graphics.FillPath(br, gp); } } } break; case ThumDirection.Right: { using (GraphicsPath gp = new GraphicsPath()) { if (_orientation == Orientation.Horizontal) { gp.AddLine(thumbRect.Right - thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2, thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 - 4); gp.AddLine(thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 - 4, thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 + 4); gp.AddLine(thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 + 4, thumbRect.Right - thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2); } else { gp.AddLine(thumbRect.Right - thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2, thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 - 4); gp.AddLine(thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 - 4, thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 + 4); gp.AddLine(thumbRect.Right - thumbRect.Width / 2 - 2, thumbRect.Top + thumbRect.Height / 2 + 4, thumbRect.Right - thumbRect.Width / 2 + 2, thumbRect.Top + thumbRect.Height / 2); } gp.CloseFigure(); using (SolidBrush br = new SolidBrush(thumbArrowColor)) { e.Graphics.FillPath(br, gp); } } } break; } }
/// <summary> /// 绘制拖动条 /// </summary> protected virtual void RenderThumb(PaintEventArgs e, GraphicsPath thumbPath, Rectangle thumbRect, ThumDirection dir) { Color color1 = ThumbFaceSchema.BackNormalStyle.Color1; Color color2 = ThumbFaceSchema.BackNormalStyle.Color2; Color borderColor = ThumbFaceSchema.BorderNormalStyle.Color1; if (Enabled) { switch (ThumbState) { case ControlState.Hover: case ControlState.Pressed: color1 = ThumbFaceSchema.BackHoverStyle.Color1; color2 = ThumbFaceSchema.BackHoverStyle.Color2; borderColor = ThumbFaceSchema.BorderHoverStyle.Color1; break; } } else { color1 = ThumbFaceSchema.BackDisabledStyle.Color1; color2 = ThumbFaceSchema.BackDisabledStyle.Color2; borderColor = ThumbFaceSchema.BorderDisabledStyle.Color1; } if (thumbRectL.Width != 0 && thumbRect.Height != 0) { using ( LinearGradientBrush lgbThumb = new LinearGradientBrush(thumbRect, color1, color2, gradientOrientation)) { //lgbThumb.WrapMode = WrapMode.TileFlipXY; e.Graphics.FillPath(lgbThumb, thumbPath); using (Pen p = new Pen(borderColor)) { e.Graphics.DrawPath(p, thumbPath); } } } RenderThumArrow(e, thumbRect, dir); }