Movie类

/// <summary>
    /// 3D动画类
    /// </summary>
    public class Movie
    {
        Timer _timer = new Timer();

        public Movie()
        {
            _timer.Enabled = false;
            _timer.Tick += new EventHandler(timer_Tick);
        }

        void timer_Tick(object sender, EventArgs e)
        {
            if(Refrash!=null)
                Refrash();
            //如果有计数
            if (_RunTimes >= 1)
            {
                _nowCount++;
                //到达次数
                if (_nowCount == _RunTimes)
                    IsRunning = false;
            }
        }

        /// <summary>
        /// 运行状态
        /// </summary>
        public bool IsRunning
        {
            get { return _timer.Enabled; }
            set { _timer.Enabled = value; }
        }

        /// <summary>
        /// 刷新的动作
        /// </summary>
        public Action Refrash;

        /// <summary>
        /// 执行刷新动作的间隔时间(毫秒)
        /// </summary>
        public int Interval
        {
            get { return _timer.Interval; }
            set { _timer.Interval = value; }
        }

        int _nowCount=0;

        int _RunTimes = 0;
        /// <summary>
        /// 总共运行次数[为0则不计次数]
        /// </summary>
        public int RunTimes
        {
            get { return _RunTimes; }
            set
            {
                //重置当运行的次数
                _nowCount = 0;
                //关闭运行
                IsRunning = false;
                _RunTimes = value;
            }
        }
    }

原文地址:https://www.cnblogs.com/gxlinhai/p/1977191.html