FlyADClientUI.cs 1.25 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Misc;
using System.Windows.Threading;
using FlyADBase;
namespace Flyad7_WPF
{
    public class FlyADClientUI : INotifyPropertyChanged
    {

14
        public DateTime Now { get; set; }
潘栩锋's avatar
潘栩锋 committed
15 16


17 18 19 20 21 22 23 24 25 26 27 28 29 30

        public int Position { get; set; }


        public int Speed { get; set; }


        public int Position2 { get; set; }
        
        public int Speed2 { get; set; }


        public int AD { get; set; }

潘栩锋's avatar
潘栩锋 committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

        private DispatcherTimer timer = new DispatcherTimer();
        private FlyAD7 flyad;
        public FlyADClientUI(FlyAD7 flyad)
        {
            Init(flyad);
        }
        void Init(FlyAD7 flyad)
        {
            this.flyad = flyad;
            timer.Interval = TimeSpan.FromSeconds(0.1);
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }

        void timer_Tick(object sender, EventArgs e)
        {
            Position = flyad.Position;
            Position2 = flyad.Position2;
            AD = flyad.AD;
            Speed = flyad.Speed;
            Speed2 = flyad.Speed2;
            Now = flyad.Now;
        }
        public event PropertyChangedEventHandler PropertyChanged;
    }
}