public void UpdatePersonnelInfoListView(object sender, EventArgs e) { Personnel p = personnelScreen.curPersonnel; personnelScreen.personnelNameLabel.Text = "Name: " + p.Name; personnelScreen.personnelTypeLabel.Text = "Class: " + p.Class.ToString(); personnelScreen.personnelXCordLabel.Text = "Latitude: " + p.Coord.Position.Lat.ToString(); personnelScreen.personnelYCordLabel.Text = "Longitude: " + p.Coord.Position.Lng.ToString(); personnelScreen.locationTitleLabel.Text = "Локация: "; personnelScreen.personnelAreaLabel.Text = Territory.Check(p.Coord.Position.Lat, p.Coord.Position.Lng); }
public void UpdatePersonnelInfoMarker(GMap.NET.WindowsForms.GMapMarker item, MouseEventArgs e) { if (item.Tag == null) { Personnel p = personnelScreen.mapControl1.curPersonnel; personnelScreen.personnelNameLabel.Text = "Name: " + p.Name; personnelScreen.personnelTypeLabel.Text = "Class: " + p.Class.ToString(); personnelScreen.personnelXCordLabel.Text = "Latitude: " + p.Coord.Position.Lat.ToString(); personnelScreen.personnelYCordLabel.Text = "Longitude: " + p.Coord.Position.Lng.ToString(); personnelScreen.locationTitleLabel.Text = "Локация: "; personnelScreen.personnelAreaLabel.Text = Territory.Check(p.Coord.Position.Lat, p.Coord.Position.Lng); } }
public void gMapControl1_OnMarkerClick(GMap.NET.WindowsForms.GMapMarker item, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (item.Tag == null) { Personnel p = (from x in MainForm.staff where x.Coord == item select x).First(); curPersonnel = p; } else { return; } } }
private void personnelList_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { if (personnelList.FocusedItem.Bounds.Contains(e.Location)) { int id = Convert.ToInt32(personnelList.FocusedItem.Name); curPersonnel = MainForm.staff.Where(x => x.ID == id).First(); } else { return; } } }
private void gMapControl1_MouseClick(object sender, MouseEventArgs e) { double lat = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lat; double lng = gMapControl1.FromLocalToLatLng(e.X, e.Y).Lng; if (e.Button == MouseButtons.Right) { OrderForm order = new OrderForm(lng, lat); if (order.ShowDialog() == DialogResult.Cancel) { return; } else { int requestedPersonnelAmount = 0; //по-хорошему при создании чп указать необходимое количество сотрудников List <Personnel> competentPersonnel = new List <Personnel>(); List <Personnel> nearestPersonnel = new List <Personnel>(); foreach (var personnel in MainForm.staff) { if (personnel.Class.ToString() == order.personeTypeComboBox.SelectedItem.ToString()) { competentPersonnel.Add(personnel); } } //вдруг компетентнвых сотрудников меньше 5 if (competentPersonnel.Count > 5) { requestedPersonnelAmount = 5; } else { requestedPersonnelAmount = competentPersonnel.Count; } for (int i = 0; i < requestedPersonnelAmount; i++) //выбираем requestedPersonnelAmount ближайших сотрудников { Personnel minDistPersonnel = null; double minDist = double.MaxValue; foreach (var personnel in competentPersonnel) //проходим по каждому сотруднику - ищем ближайших { GMap.NET.WindowsForms.Markers.GMarkerGoogle coords; coords = personnel.Coord; GeoCoordinate personnelPosition = new GeoCoordinate(coords.Position.Lat, coords.Position.Lng); GeoCoordinate orderPosition = new GeoCoordinate(lat, lng); double minDistCurrent = orderPosition.GetDistanceTo(personnelPosition); if (minDistCurrent < minDist) { minDist = minDistCurrent; minDistPersonnel = personnel; } } nearestPersonnel.Add(minDistPersonnel); competentPersonnel.Remove(minDistPersonnel); } //test zone StringBuilder sb = new StringBuilder(); foreach (var a in nearestPersonnel) { sb.Append(a.Name + "\n"); } MessageBox.Show("Ближайшие компетентные сотрудники: \n\n" + sb.ToString() + "\n (отправляем им уведомления)"); //test zone GMap.NET.WindowsForms.GMapMarker marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle( new GMap.NET.PointLatLng(lat, lng), GMap.NET.WindowsForms.Markers.GMarkerGoogleType.blue_pushpin); markers.Markers.Add(marker); marker.Tag = "warning"; } } }
public void SetPersonal() { string[] serverData = File.ReadAllLines(Environment.CurrentDirectory + "\\testCoords.txt"); foreach (string dataRow in serverData) { Bitmap bm = null; Personnel psn = null; GMap.NET.WindowsForms.Markers.GMarkerGoogle marker = null; int id = int.Parse(dataRow.Split(' ')[0]); //string name = dataRow.Split('"')[0]; string name = dataRow.Remove(0, dataRow.IndexOf('"') + 1); name = name.Remove(name.LastIndexOf('"')); double x = double.Parse(dataRow.Split(' ')[1].Trim(',')); double y = double.Parse(dataRow.Split(' ')[2]); //Personnel.Type type; switch (dataRow.Split(' ')[3]) { case "Engineer": //type = Personnel.Type.Engineer; bm = new Bitmap(Properties.Resources.personnelEngineerIcon, new Size(35, 35)); marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(new GMap.NET.PointLatLng(x, y), bm); marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; psn = new Personnel(id, name, Personnel.Type.Engineer, marker); marker.ToolTipText = psn.Name; break; case "Assistant": //type = Personnel.Type.Assistant; bm = new Bitmap(Properties.Resources.personnelAssistantIcon, new Size(35, 35)); marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(new GMap.NET.PointLatLng(x, y), bm); marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; psn = new Personnel(id, name, Personnel.Type.Assistant, marker); marker.ToolTipText = psn.Name; break; case "Carrier": //type = Personnel.Type.Carrier; bm = new Bitmap(Properties.Resources.personnelCarrierIcon, new Size(35, 35)); marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(new GMap.NET.PointLatLng(x, y), bm); marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; psn = new Personnel(id, name, Personnel.Type.Carrier, marker); marker.ToolTipText = psn.Name; break; case "Police": //type = Personnel.Type.Police; bm = new Bitmap(Properties.Resources.personnelPoliceIcon, new Size(35, 35)); marker = new GMap.NET.WindowsForms.Markers.GMarkerGoogle(new GMap.NET.PointLatLng(x, y), bm); marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; psn = new Personnel(id, name, Personnel.Type.Police, marker); marker.ToolTipText = psn.Name; break; } staff.Add(psn); personnelScreen.mapControl1.markers.Markers.Add(marker); } }