学了点GDI+ 做了一个滑动的效果
代码很简单,写成控件,定义一个角度的属性,然后改动属性重绘。
public UserControl1() { InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.SetStyle(ControlStyles.UserPaint, true); this.SetStyle(ControlStyles.SupportsTransparentBackColor, true); this.SetStyle(ControlStyles.Selectable, true); } int arcAngle; public int ArcAngle { get { return arcAngle; } set { arcAngle = value; this.Invalidate(); } } protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Rectangle rec = new Rectangle(0, 0, this.Width, this.Height); SolidBrush solidBrush1 = new SolidBrush(Color.Red); SolidBrush solidBrush2 = new SolidBrush(Color.Blue); g.FillPie(solidBrush1, rec, 180+arcAngle,180-arcAngle); g.FillPie(solidBrush2, rec, 180, arcAngle); base.OnPaint(e); }