lu
2024-10-28 bc4493dec762784f6695dd0723cbb0973f68a0ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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();
        }
    }
}