TweenAnimationModel.cs 3.5 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TheMachine.Model;

namespace AGVMapDemo.DemoModel
{
    public class TweenAnimationModel
    {
        public uint CTUID { get; set; }
        public CTUPointCode PrePoint { get; set; }
        public CTUPointCode CurrPoint { get; set; }
        public DateTime PreTime { get; set; }
        public DateTime CurrTime { get; set; }
        public DateTime UILaterTime { get; set; }
        private float CTU_RunTime
        {
            get
            {
                float value = 0;
                if (PreTime != DateTime.MinValue && CurrTime != DateTime.MinValue)
                {
                    value = (float)(CurrTime - PreTime).TotalMilliseconds;
                }
                return value;
            }
            set
            {

            }
        }
        //public double CTU_Time()
        //{
        //    if (PreTime != null&& CurrTime!=null)
        //    {
        //        CTU_RunTime = (PreTime - CurrTime).TotalMilliseconds;
        //    }
        //    else { CTU_RunTime = 0; }

        //    return CTU_RunTime;
        //}
        private float CTU_Speed
        {
            get
            {
                float distance = 0;
                float Speed = 0;
                if (PrePoint != null && CurrPoint != null && CTU_RunTime != 0)
                {
                    distance =(float) Math.Sqrt(Math.Pow(CurrPoint.X - PrePoint.X, 2) + Math.Pow(CurrPoint.Y - PrePoint.Y, 2));
                    Speed = (float)Math.Round(distance / CTU_RunTime, 2);
                }
                return Speed;
            }
        }

        private float UIUpdateTime
        {
            get
            {
                float value = 0;
                if (UILaterTime != DateTime.MinValue)
                {
                    value = (float) (DateTime.Now - UILaterTime).TotalMilliseconds;
                }
                return value;
            }
            set { }
        }
        private float Factor
        {
            get
            {
                //float value = 0;
                //value = Math.Min(UIUpdateTime * CTU_Speed, 1);
                //return value;

                float value = 0;
                value = Math.Min((float)Math.Round(UIUpdateTime/ CTU_RunTime,2), 1);
                return value;
            }
            set
            {

            }
        }
        private bool Stop
        {
            get
            {
                if (Factor >= 1)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            set
            {

            }
        }
        public float AddX
        {
            get
            {
                float value = 0;
                if (PrePoint != null && CurrPoint != null)
                {
                    value = PrePoint.X+ Factor*(CurrPoint.X-PrePoint.X);
                }
                return value;
            }
            set
            {

            }
        }
        public float AddY
        {
            get
            {
                float value = 0;
                if (PrePoint != null && CurrPoint != null)
                {
                    value = PrePoint.Y + Factor * (CurrPoint.Y - PrePoint.Y);
                }
                return value;
            }
            set
            {

            }
        }

      
    }
}