欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Winform圓形環(huán)繞的Loading動(dòng)畫實(shí)現(xiàn)代碼

 更新時(shí)間:2014年01月22日 16:11:16   作者:  
這篇文章主要介紹了Winform圓形環(huán)繞的Loading動(dòng)畫實(shí)現(xiàn)代碼,有需要的朋友可以參考一下

之前寫了一個(gè)WPF的圓形環(huán)繞的Loading動(dòng)畫,現(xiàn)在寫一個(gè)Winform的圓形環(huán)繞的Loading動(dòng)畫。

1.新建Winform項(xiàng)目,添加一個(gè)pictureBox控件,命名為:pictureBox;

2.引用中添加using System.Drawing.Drawing2D;

3.Form窗體命名為:Loading,cs全部代碼如下:

復(fù)制代碼 代碼如下:

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 <= 0.0F)
                    _circleSize = 0.05F;
                else
                    _circleSize = 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 <= 8; i++)
            {
                int alpha = a[(i + j - 1) % 8];
                Color drawColor = Color.FromArgb(alpha, _circleColor);
                using (SolidBrush brush = new SolidBrush(drawColor))
                {
                    float sizeRate = 3.5F / _circleSize;
                    float size = Width / (6 * sizeRate);

                    float diff = (Width / 10.0F) - size;

                    float x = (Width / 80.0F) + diff;
                    float y = (Height / 80.0F) + diff;
                    g.FillEllipse(brush, x, y, size, size);
                    g.RotateTransform(angle);
                }
            }
            return map;
        }


        public void Draw()
        {
            for (int j = 0; j < 8; j++)
            {
                bitmap[7-j] = DrawCircle(j);
            }
        }
        protected override void OnResize(EventArgs e)
        {
            SetNewSize();
            base.OnResize(e);
        }

        protected override void OnSizeChanged(EventArgs e)
        {
            SetNewSize();
            base.OnSizeChanged(e);
        }

        private void SetNewSize()
        {
            int size = Math.Max(Width, Height);
            Size = new Size(size, size);
        }

        public void set()
        {
            for (int i = 0; i < 8; i++)
            {
                Draw();

                Bitmap map = new Bitmap((bitmap[i]), new Size(120, 110));

                images.Add(map);
            }
            pictureBox.Image = (Image)images[0];
           pictureBox.Size = pictureBox.Image.Size;

        }
        private void pictureBox_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            base.Dispose();
        }

        private void Timer_Tick(object sender, EventArgs e)
        {
            set();
            count = (count + 1) % 8;
            pictureBox.Image = (Image)images[count];

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            base.Dispose();
        }
    }
}


4.效果如圖:

相關(guān)文章

  • C#多種操作excel的方法比較

    C#多種操作excel的方法比較

    本文詳細(xì)講解了C#多種操作excel的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-12-12
  • C#如何使用Task類解決線程的等待問題

    C#如何使用Task類解決線程的等待問題

    這篇文章主要介紹了C#如何使用Task類解決線程的等待問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-06-06
  • C#自動(dòng)給文章關(guān)鍵字加鏈接實(shí)現(xiàn)代碼

    C#自動(dòng)給文章關(guān)鍵字加鏈接實(shí)現(xiàn)代碼

    這篇文章主要介紹了C#自動(dòng)給文章關(guān)鍵字加鏈接實(shí)現(xiàn)代碼,有需要的朋友可以參考一下
    2013-12-12
  • VS2017使用Git進(jìn)行源代碼管理的實(shí)現(xiàn)

    VS2017使用Git進(jìn)行源代碼管理的實(shí)現(xiàn)

    這篇文章主要介紹了VS2017使用Git進(jìn)行源代碼管理的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 深入理解C#索引器(一種支持參數(shù)的屬性)與屬性的對(duì)比

    深入理解C#索引器(一種支持參數(shù)的屬性)與屬性的對(duì)比

    本篇文章是對(duì)C#索引器(一種支持參數(shù)的屬性)與屬性的對(duì)比進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-06-06
  • C# 動(dòng)態(tài)調(diào)用WebService的示例

    C# 動(dòng)態(tài)調(diào)用WebService的示例

    這篇文章主要介紹了C# 動(dòng)態(tài)調(diào)用WebService的示例,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下
    2020-11-11
  • C#自定義的方法實(shí)現(xiàn)堆棧類設(shè)計(jì)

    C#自定義的方法實(shí)現(xiàn)堆棧類設(shè)計(jì)

    這篇文章主要為大家詳細(xì)介紹了如何使用C#創(chuàng)建一個(gè)帶有Push方法和Clist類的CStack類,并如何在其中添加和遍歷堆棧數(shù)據(jù),感興趣的可以了解下
    2024-03-03
  • 親自教你實(shí)現(xiàn)棧及C#中Stack源碼分析

    親自教你實(shí)現(xiàn)棧及C#中Stack源碼分析

    大家都知道棧的實(shí)現(xiàn)方式有兩種,一種是基于數(shù)組實(shí)現(xiàn)的順序棧,另一種是基于鏈表實(shí)現(xiàn)的鏈?zhǔn)綏!_@篇文章主要介紹了手把手教你實(shí)現(xiàn)棧以及C#中Stack源碼分析,需要的朋友可以參考下
    2021-09-09
  • 實(shí)例講解C#中的職責(zé)鏈模式

    實(shí)例講解C#中的職責(zé)鏈模式

    這篇文章主要介紹了C#中的職責(zé)鏈模式的相關(guān)資料,文中示例代碼非常詳細(xì),幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • C# 中SharpMap的簡單使用實(shí)例詳解

    C# 中SharpMap的簡單使用實(shí)例詳解

    SharpMap是一個(gè)基于.net 2.0使用C#開發(fā)的Map渲染類庫,可以渲染各類GIS數(shù)據(jù)(目前支持ESRI Shape和PostGIS格式),可應(yīng)用于桌面和Web程序,具體內(nèi)容詳情大家參考下本文吧
    2017-08-08

最新評(píng)論