using DevExpress.XtraEditors; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Gs.DevApp.UserControl { public partial class XtraUserControl1 : DevExpress.XtraEditors.XtraUserControl { private Timer timer; private int angle = 0; public XtraUserControl1() { InitializeComponent(); this.DoubleBuffered = true; timer = new Timer(); timer.Interval = 1000 / 60; // 60帧/秒 timer.Tick += Timer_Tick; } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); DrawLoadingCircle(e.Graphics); } private void DrawLoadingCircle(Graphics g) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; int radius = Math.Min(this.Width, this.Height) / 2 - 5; Rectangle rect = new Rectangle(this.Width / 2 - radius, this.Height / 2 - radius, radius * 2, radius * 2); using (SolidBrush brush = new SolidBrush(Color.FromArgb(128, Color.Blue))) { g.FillPie(brush, rect, angle, 90); } labelControl1.Text = DateTime.Now.ToString(); } private void Timer_Tick(object sender, EventArgs e) { angle = (angle + 30) % 360; this.Invalidate(); } public void Start() { timer.Start(); } public void Stop() { timer.Stop(); } } }