public FlightBoard()
 {
     InitializeComponent();
     vm = new FlightBoardViewModel(FlightManagerModel.Instance);
     this.DataContext = vm;
     isFirst          = true;
 }
 public FlightBoard()
 {
     InitializeComponent();
     flightboardVM = new FlightBoardViewModel();
     DataContext   = flightboardVM;
     flightboardVM.PropertyChanged += Vm_PropertyChanged;
 }
Beispiel #3
0
 /**
  *  the constructor creates presentation of FlightBoard Control based on the xaml code
  *  and initialized his properties
  **/
 public FlightBoardControl()
 {
     InitializeComponent();
     vm = new FlightBoardViewModel();
     /* changes the data context to view model */
     DataContext = vm;
 }
        bool firstTime;                                     // boolean variable used to indicate whether the first value
                                                            // recived from data-set

        /**
         *  the constructor creates presentation of FlightBoard Control based on the xaml code
         *  and initialized his properties
         **/
        public FlightBoard()
        {
            InitializeComponent();
            DataContext = viewModel = new FlightBoardViewModel();
            viewModel.PropertyChanged += Vm_PropertyChanged;
            firstTime = false;
        }
Beispiel #5
0
 public FlightGrid()
 {
     InitializeComponent();
     vm_flightBoard   = new FlightBoardViewModel(new InfoServer());
     this.DataContext = vm_flightBoard;
     vm_flightBoard.PropertyChanged += Vm_PropertyChanged;
 }
        /// <summary>
        ///
        /// recives data from client
        /// </summary>
        /// <param name="viewModel"></param>
        public void RecieveCall(FlightBoardViewModel viewModel)
        {
            new Thread(() =>
            {
                int msg_num          = 0;
                NetworkStream stream = _client.GetStream();
                //loop until stop raises
                while (!stop)
                {
                    if (_client != null && _client.Available > 0)
                    {
                        Console.WriteLine("Recieved info , attemp num = {0}.", msg_num);
                        int recieved_len = _client.Available;
                        Console.WriteLine("Recieved len = {0}.", recieved_len);
                        Byte[] bytes = new byte[recieved_len];
                        stream.Read(bytes, 0, recieved_len);
                        string data = Encoding.ASCII.GetString(bytes);
                        Console.WriteLine(data.Length.ToString());
                        // Console.WriteLine("[{0}]", data);

                        string[] info = data.Split(',');
                        double lon    = Convert.ToDouble(info[0]);
                        double lat    = Convert.ToDouble(info[1]);
                        viewModel.Lon = lon;
                        viewModel.Lat = lat;

                        msg_num++;
                    }
                    //recieve massages frequencie
                    Thread.Sleep(FREQ);
                }
            }).Start();
        }
Beispiel #7
0
 public FlightBoard()
 {
     // Create Board VM, add observer to vm of flight board.
     vm = new FlightBoardViewModel();
     InitializeComponent();
     this.vm.PropertyChanged += Vm_PropertyChanged;
 }
 public FlightBoard()
 {
     InitializeComponent();
     //this.DataContext = new FlightBoardViewModel();
     flightBoardViewModel = new FlightBoardViewModel();
     flightBoardViewModel.PropertyChanged += Vm_PropertyChanged;
 }
Beispiel #9
0
 public FlightBoard()
 {
     InitializeComponent();
     vm                  = new FlightBoardViewModel();
     DataContext         = vm;
     vm.PropertyChanged += Vm_PropertyChanged;
 }
Beispiel #10
0
 public FlightBoard()
 {
     InitializeComponent();
     this.viewModel = new FlightBoardViewModel();
     this.viewModel.PropertyChanged += Vm_PropertyChanged;
     this.viewModel.Lon              = 3;
 }
Beispiel #11
0
 public FlightBoard()
 {
     InitializeComponent();
     vm = FlightBoardViewModel.Instance;
     this.DataContext    = vm;
     vm.PropertyChanged += Vm_PropertyChanged;
 }
Beispiel #12
0
 public FlightBoard()
 {
     this.vm = new FlightBoardViewModel(new FlightBoardModel());
     InitializeComponent();
     this.DataContext    = vm;
     vm.PropertyChanged += Vm_PropertyChanged;
 }
 /// <summary>
 /// setup a server
 /// </summary>
 /// <param name="viewModel"></param>
 public void Setup(FlightBoardViewModel viewModel)
 {
     /**
      * Open();
      * Thread t = new Thread(() =>
      * {
      *  AcceptCall();
      *  accepted = true;
      *  RecieveCall();
      * });
      * t.Start();
      * Thread.Sleep(TIMEOUT);
      * if (!accepted)
      * {
      *  Console.WriteLine("Server Could not connect . Timeout Occurred .");
      *
      * }
      */
     if (!connected)
     {
         Open();
         AcceptCall();
         RecieveCall(viewModel);
     }
 }
Beispiel #14
0
 public FlightBoard()
 {
     //set context to view model
     viewModel = new FlightBoardViewModel();
     InitializeComponent();
     this.DataContext           = viewModel;
     viewModel.PropertyChanged += Vm_PropertyChanged;
 }
 public FlightBoard()
 {
     InitializeComponent();
     vm = new FlightBoardViewModel(new FlightBoardModel());
     // When one of the view-model's properties have changed, it will execute the bottom function to display the new coordinates
     vm.PropertyChanged += (sender, args) => { Vm_PropertyChanged(sender, args); };
     DataContext         = vm;
 }
 public FlightBoard()
 {
     InitializeComponent();
     flightBoardView = new FlightBoardViewModel();
     // rigister the get notify from the view model
     flightBoardView.PropertyChanged += Vm_PropertyChanged;
     DataContext = flightBoardView;
 }
 /// <summary>
 /// this is the constructor of this class.
 /// </summary>
 public FlightBoard()
 {
     InitializeComponent();
     planeLocations = new ObservableDataSource <Point>();
     plotter.AddLineGraph(planeLocations, Colors.Blue, 2, "Route");
     viewModel   = new FlightBoardViewModel(planeLocations, plotter);
     DataContext = viewModel;
 }
Beispiel #18
0
        public FlightBoard()
        {
            InitializeComponent();
            vm = new FlightBoardViewModel(new FlightBoardModel());

            DataManager.Instance.PropertyChanged += new PropertyChangedEventHandler(Vm_PropertyChanged);
            this.DataContext = vm;
        }
 public FlightBoard()
 {
     InitializeComponent();
     this.vm             = new FlightBoardViewModel();
     vm.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e)
     { Vm_PropertyChanged(sender, e); };
     DataContext = vm;
 }
Beispiel #20
0
        public FlightBoard()
        {
            InitializeComponent();
            FlightBoardViewModel FBVM = new FlightBoardViewModel();

            FBVM.FVBMEvent  += Vm_PropertyChanged;
            this.DataContext = FBVM;
        }
 public FlightBoard()
 {
     InitializeComponent();
     vm = new FlightBoardViewModel(
         FlightSimulatorModel.Instance.SetTelnetClient(new TelnetClient()));
     this.DataContext    = vm;
     vm.PropertyChanged += Vm_PropertyChanged;
 }
 public FlightBoard()
 {
     InitializeComponent();
     vm = FlightBoardViewModel.Instance;
     vm.PropertyChanged += Vm_PropertyChanged;
     planeLocations      = null;
     DataContext         = vm;
 }
Beispiel #23
0
        public FlightBoardView()
        {
            InitializeComponent();
            FlightBoardViewModel vm = new FlightBoardViewModel();

            DataContext = vm;
            FlightBoard.setVM(vm);
        }
        public FlightBoard()
        {
            SimulatorModel simulator = SimulatorModel.Instance;

            vm = new FlightBoardViewModel(simulator);
            vm.PropertyChanged += this.Vm_PropertyChanged;
            InitializeComponent();
            this.DataContext = vm;
        }
Beispiel #25
0
        //ObservableDataSource<Point> planeLocations = null;
        public FlightBoard()
        {
            InitializeComponent();

            infoServer = InfoServer.Instance;

            flightBoardViewModel = new FlightBoardViewModel();
            flightBoardViewModel.PropertyChanged += Vm_PropertyChanged;
        }
Beispiel #26
0
        // open server
        public void OpenServer(string ip, int infoPort)
        {
            flight = FlightBoardViewModel.Instance;
            IPEndPoint  ep       = new IPEndPoint(IPAddress.Parse(ip), infoPort);
            TcpListener listener = new TcpListener(ep);

            listener.Start();
            Console.WriteLine("Waiting for client connections...");
            TcpClient client = listener.AcceptTcpClient();

            _isConnected = true;
            Console.WriteLine("----- server connected -----");
            using (NetworkStream stream = client.GetStream())
                using (BinaryReader reader = new BinaryReader(stream))
                    using (BinaryWriter writer = new BinaryWriter(stream))
                    {
                        while (_isConnected)
                        {
                            bool isNewLine = false;
                            var  charsData = new System.Text.StringBuilder();
                            char c;
                            while (!isNewLine)
                            {
                                //read until new line
                                c = reader.ReadChar();
                                switch (c)
                                {
                                case '\r':
                                    //unix case
                                    if (reader.PeekChar() == '\n')
                                    {
                                        reader.ReadChar();
                                    }
                                    isNewLine = true;
                                    break;

                                case '\n':
                                    //win case
                                    isNewLine = true;
                                    break;

                                default:
                                    //not new line case,so cintinu reading
                                    charsData.Append(c);
                                    break;
                                }
                            }
                            // get pocket of data from simulator
                            string data = charsData.ToString();
                            this.loadDataFromServer(data);
                            //     System.Threading.Thread.Sleep(1 * 1000);
                        }
                    }
            client.Close();
            listener.Stop();
            Console.WriteLine("----- Server closed -----");
        }//end of open server
 /*adds a new point that needs to be added to the graph*/
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     //only run if a new point needs to be added
     if (e.PropertyName.Equals("new point"))
     {
         FlightBoardViewModel data = sender as FlightBoardViewModel;
         //get the point
         Point toAdd = new Point(data.Lat, data.Lon);
         //add the point
         planeLocations.AppendAsync(Dispatcher, toAdd);
         //System.Diagnostics.Debug.WriteLine("new point added!");
     }
 }
Beispiel #28
0
 private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
 {
     if (!init)
     {
         init = true;
     }
     else
     {
         if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
         {
             FlightBoardViewModel vm = sender as FlightBoardViewModel;
             Point p1 = new Point(vm.Lat, vm.Lon);            // Fill here!
             planeLocations.AppendAsync(Dispatcher, p1);
             init = false;
         }
     }
 }
        private void Vm_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            FlightBoardViewModel fvm = sender as FlightBoardViewModel;

            if (fvm != null && fvm == vm)
            {
                if (e.PropertyName.Equals("Lat") || e.PropertyName.Equals("Lon"))
                {
                    Point p1 = new Point(vm.Lat, vm.Lon);
                    if (planeLocations.Collection.Contains <Point>(p1))
                    {
                        return;
                    }
                    planeLocations.AppendAsync(Dispatcher, p1);
                }
            }
        }
Beispiel #30
0
        public void StartServer()
        {
            //start listening to the socket
            tcpListener.Start();
            while (true)
            {
                //wait for a client (the simulator) to connect
                TcpClient client = tcpListener.AcceptTcpClient();
                while (client.Connected)
                {
                    NetworkStream clientStream = client.GetStream();
                    if (!clientStream.DataAvailable)
                    {
                        continue;
                    }

                    BinaryReader  reader = new BinaryReader(clientStream);
                    StringBuilder data   = new StringBuilder();
                    char          c;
                    //each iteration read a char from the socket and add it to data
                    while ((c = reader.ReadChar()) != '\n')
                    {
                        data.Append(c);
                    }
                    string[] separatedParam = data.ToString().Split(',');

                    object lonAndLatLocker             = new object();
                    FlightBoardViewModel flightBoardVM = FlightBoardViewModel.Instance;
                    lock (lonAndLatLocker)
                    {
                        //update lon and lat values
                        flightBoardVM.Lon = Double.Parse(separatedParam[0]);
                        flightBoardVM.Lat = Double.Parse(separatedParam[1]);
                    }
                }
                client?.GetStream()?.Close();
                client?.Close();
            }
        }