欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Winform圆形环绕的Loading动画

程序员文章站 2022-04-14 10:15:00
之前写了一个wpf的圆形环绕的loading动画,现在写一个winform的圆形环绕的loading动画。 1.新建winform项目,添加一个picturebox控件,命名为:picturebox...

之前写了一个wpf的圆形环绕的loading动画,现在写一个winform的圆形环绕的loading动画。

1.新建winform项目,添加一个picturebox控件,命名为:picturebox;

2.引用中添加using system.drawing.drawing2d;

3.form窗体命名为:loading,cs全部代码如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.linq;
using system.text;
using system.windows.forms;
using system.collections;
using system.drawing.drawing2d;

namespace circle_processbar
{
    public partial class loading : form
    {
        private int count = -1;
        private arraylist images = new arraylist();
        public bitmap[] bitmap = new bitmap[8];
        private int _value = 1;
        private color _circlecolor = color.red;
        private float _circlesize = 0.8f;
        
        public loading()
        {
            initializecomponent();       
        }

        public color circlecolor
        {
            get { return _circlecolor; }
            set
            {
                _circlecolor = value;
                invalidate();
            }
        }

        public float circlesize
        {
            get { return _circlesize; }
            set
            {
                if (value  4.0f ? 4.0f : value;
                invalidate();
            }
        }

        public bitmap drawcircle(int j)
        {
            const float angle = 360.0f / 8; bitmap map = new bitmap(150, 150);
            graphics g = graphics.fromimage(map);
            
            g.translatetransform(width / 2.0f, height / 2.0f);
            g.rotatetransform(angle * _value);
            g.interpolationmode = interpolationmode.highqualitybicubic;
            g.smoothingmode = smoothingmode.antialias;
            int[] a = new int[8] { 25, 50, 75, 100, 125, 150, 175, 200 };
            for (int i = 1; i 
4.效果如图:

Winform圆形环绕的Loading动画