private void Init() { if (Quadrants.Count > 0) { Quadrants.Clear(); } foreach (Quadrant q in _DataService.GetQuadrants().OrderBy(o => o.QuadrantDescription)) { Quadrants.Add(q); } }
private void LoadWorkspace() { List <string> settings = File.ReadLines(@"Data\settings").ToList(); // Set map position: string[] mapPos = settings[0].Split(','); DefinedMapPosition = new PointLatLng(ParseDouble(mapPos[0]), ParseDouble(mapPos[1])); Map.Position = DefinedMapPosition; settings.RemoveAt(0); // Set map zoom: InitialZoom = ParseDouble(settings[0]); Map.Zoom = InitialZoom; settings.RemoveAt(0); // Set cell size and grid coordinates: string[] qSize = settings[0].Split(','); QSize = new SizeF(ParseFloat(qSize[0]), ParseFloat(qSize[1])); GPoint mapPixelPos = Map.MapProvider.Projection.FromLatLngToPixel(Map.Position, (int)Map.Zoom); PointLatLng bottomLeftPoint = Map.MapProvider.Projection.FromPixelToLatLng( new GPoint(mapPixelPos.X - Width / 2, mapPixelPos.Y + Height / 2), (int)Map.Zoom); PointLatLng topRightPoint = Map.MapProvider.Projection.FromPixelToLatLng( new GPoint(mapPixelPos.X + Width / 2, mapPixelPos.Y - Height / 2), (int)Map.Zoom); GridCoordinates = new double[] { bottomLeftPoint.Lat, topRightPoint.Lat, bottomLeftPoint.Lng, topRightPoint.Lng }; settings.RemoveAt(0); // Load quadrants of operation: List <string> quads = File.ReadLines(@"Data\areaofoperation").ToList(); foreach (var i in quads) { string[] info = i.Split(','); Quadrants.Add(new Tuple <double, double>( ParseDouble(info[0]), ParseDouble(info[1]) )); } _areaDefined = Quadrants.Count > 0; InitGrid(); // Load other settings: IsSupervisor = settings[0] == "1"; settings.RemoveAt(0); SupervisingPort = settings[0]; settings.RemoveAt(0); // Load UAVs and coordinators: List <string> conns = File.ReadLines(@"Data\connections").ToList(); foreach (var i in conns) { string[] info = i.Split(','); try { AddConnection(info[0], info[1], info[2], int.Parse(info[3]), Color.FromArgb(int.Parse(info[4])), info[5], info[6]); } catch (Exception) { } } }