Exemple #1
0
 internal void Update(DISP_Car car, VmPolyline zone, MovedLocationCollection routeOpacited)
 {
     if (!car.Equals(SelectedCar))
     {
         SelectedCar = car;
     }
     Application.Current.Dispatcher.BeginInvoke(new Action(() => CarsInOut.Clear()));
     foreach (var location in routeOpacited)
     {
         var inzone = CalcLeavingZone.Instance.FillContains(location, zone.MovedLocations);
         if (_findError)
         {
             if (inzone)
             {
                 continue;
             }
             AddCarToErrorLog(car, zone, location.Dates);
             _findError = false;
         }
         else
         {
             if (!inzone)
             {
                 continue;
             }
             AddBackCarToErrorLog(car, zone, location.Dates);
             _findError = true;
         }
     }
 }
Exemple #2
0
 void CarZoneChanged()
 {
     if (_selectedCar != null)
     {
         _zone = _zoneHandler.Zones.FirstOrDefault(o => o.ID == _selectedCar.ZoneData.ZoneId);
     }
 }
Exemple #3
0
 public void AddZone(VmPolyline z)
 {
     try
     {
         TCPConnection.Instance.SendData("FB" + ConvertZone(z));
     }
     catch { }
 }
Exemple #4
0
        private void AddCarToErrorLog(DISP_Car car, VmPolyline zone, DateTime dt)
        {
            var el = new CarInOutViewModel()
            {
                CarID       = car.ID,
                CarNumber   = car.Name,
                ZoneId      = zone.ID,
                ZoneName    = zone.Name,
                OutZoneDate = dt
            };

            el.PropertyChanged += CarInOut_PropertyChanged;
            Application.Current.Dispatcher.BeginInvoke(new Action(() => CarsInOut.Add(el)));
        }
        private void AddCarToErrorLog(DISP_Car car, VmPolyline zone)
        {
            var el = new CarInOutViewModel()
            {
                CarID       = car.ID,
                CarNumber   = car.Name,
                ZoneId      = zone.ID,
                ZoneName    = zone.Name,
                OutZoneDate = ToDate(car.Data.DateUpdate)
            };

            el.PropertyChanged += CarInOut_PropertyChanged;
            CarsInOut.Add(el);
            _inErrorCars.Add(car);
        }
        private void ChangeEnableEdit(VmPolyline obj, bool Enable)
        {
            int indx = Zones.IndexOf(obj);

            if (indx >= 0 && indx < Zones.Count)
            {
                Zones[indx].EnableEdit = Enable;
            }
            if (obj.MovedLocations != null && obj.MovedLocations.Count >= 0 && Enable)
            {
                var centerLocation = obj.MovedLocations.GetCenter();
                if (centerLocation.Latitude != 0 && centerLocation.Longitude != 0)
                {
                    MapCenterUser = centerLocation;
                }
            }
            EnableEditZone = !obj.IsPublic;
        }
Exemple #7
0
 private void FillZones(string row)
 {
     try
     {
         List <ZoneDataModel> zones = JsonConvert.DeserializeObject <List <ZoneDataModel> >(row);
         if (Application.Current != null)
         {
             Application.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 if (zones == null)
                 {
                     return;
                 }
                 _data = zones;
                 SaveToDisk();
                 Zones.Clear();
                 foreach (var item in zones)
                 {
                     VmPolyline vmp = new VmPolyline();
                     vmp.ID         = item.ID;
                     vmp.Name       = item.Name;
                     vmp.IsPublic   = item.IsPublic == 1;
                     //List<Location> locations = new List<Location>();
                     for (int i = 0; i < item.Points.Count(); i++)
                     {
                         //locations.Add(new Location
                         //{
                         //    Latitude = item.Points[i].Latitude / 10000.0,
                         //    Longitude = item.Points[i].Longitude / 10000.0
                         //});
                         vmp.AddLocation(new Location
                         {
                             Latitude  = item.Points[i].Latitude / 10000.0,
                             Longitude = item.Points[i].Longitude / 10000.0
                         }, false);
                     }
                     //vmp.Locations = new LocationCollection(locations);
                     Zones.Add(vmp);
                 }
             }));
         }
     }
     catch { }
 }
        private void MonitorCarInZone(DISP_Car car, VmPolyline zone)
        {
            var error = CalcLeavingZone.Instance.FillContains(car.Navigation.LocationPoint, zone.MovedLocations);
            var indx  = _inErrorCars.IndexOf(car);

            if (indx < 0)
            {
                if (error)
                {
                    AddCarToErrorLog(car, zone);
                }
            }
            else
            {
                if (!error)
                {
                    RemoveCarFromErrorLog(car, zone);
                }
            }
        }
Exemple #9
0
        private string ConvertZone(VmPolyline z)
        {
            ZoneDataModel model = new ZoneDataModel();

            model.ID   = z.ID;
            model.Name = z.Name;
            List <ZonePoint> points = new List <ZonePoint>();

            foreach (var item in z.Locations)
            {
                points.Add(new ZonePoint
                {
                    Latitude  = (int)(item.Latitude * 10000),
                    Longitude = (int)(item.Longitude * 10000)
                });
            }
            model.IsPublic = z.IsPublic ? 1 : 0;
            model.Points   = points;
            string req = JsonConvert.SerializeObject(model);

            return(req);
        }
 public ZoneMapViewModel()
 {
     MapCenter = MapCenterUser = new Location(55.75, 37.62);
     _zoneHandler.LoadCompleted += zoneHandler_LoadCompleted;
     _zoneHandler.Update();
     if (Zones.Count != 0)
     {
         return;
     }
     if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
     {
         ObservableCollection <Location> Points = new AsyncObservableCollection <Location>();
         Points.Add(new Location(55.758, 37.76));
         Points.Add(new Location(55.75, 37.5));
         Points.Add(new Location(55.8, 37.625));
         var z = new VmPolyline(Zones.Count);
         z.PropertyChanged += Zone_PropertyChanged;
         Zones.Add(z);
         Zones[0].AddLocation(Points[0], false);
         Zones[0].AddLocation(Points[1], false);
         Zones[0].AddLocation(Points[2], false);
     }
 }
Exemple #11
0
 public void DeleteZone(VmPolyline zone)
 {
     //throw new NotImplementedException();
 }