示例#1
0
文件: Form1.cs 项目: junkissa/CubeR
 private EasingTimer(int n, TimerFunction func, List<angleXYZ> angles, int dir, rotateAxisType rotateAxis, timerUPFunction funcUp = null)
     : base(100)
 {
     this.firstAngle = 0;
     this.rotateN = n;
     this.begin_time = DateTime.Now;
     this.func = new ElapsedEventHandler(func);
     this.Elapsed += this.func;
     this._run = false;
     this.dir = dir;
     this.rotateAxis = rotateAxis;
     this.funcUp = funcUp;
 }
示例#2
0
文件: Form1.cs 项目: junkissa/CubeR
        public static void rotate(int n, TimerFunction func, List<angleXYZ> angles, int dir, rotateAxisType rotateAxis, timerUPFunction funcUp = null)
        {
            if (t == null)
            {
                //MessageBox.Show("firstAngle = " + firstAngle.ToString());
                t = new EasingTimer(n, func, angles, dir, rotateAxis, funcUp);
                t.rotateAxis = rotateAxis;
            }
            else
            {
                //если прокручивание работает, то просто возвращаем таймер
                //если прокручинваие уже не работает, то заново инициализируем переменные, как бы вызываем конструктор
                if (!t._run)
                {
                    //MessageBox.Show("2: firstAngle = " + firstAngle.ToString());
                    t.firstAngle = 0;
                    t.rotateN = n;
                    t.begin_time = DateTime.Now;
                    t.Elapsed -= t.func;
                    t.func = new ElapsedEventHandler(func);
                    t.Elapsed += t.func;
                    t.dir = dir;
                    t.rotateAxis = rotateAxis;
                    t.funcUp = funcUp;
                }
            }

            //Если уже пошёл процесс кручения, то выходим
            if (t._run)
            {
                return;
            }

            t._run = true;
            t.Start();
        }