//Button// private void button1_Click(object sender, EventArgs e) { if (txtLocationLandmark.Text == "Select Location on Map") { MessageBox.Show("Please Select Location on Map", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cmbTypeLandmark.Text == "Please Select Type of Landmark") { MessageBox.Show("Please Select Type of Landmark", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (txtLabelLandmark.Text == "Short Name") { txtLabelLandmark.Text = ""; } var marker = new GmapMarkerWithLabel(PositionConverter.ParsePointFromString(txtLocationLandmark.Text), null, markerLandmark.icon, 20); GMapOverlay overlay = mainForm.GetInstance().GetOverlay("markersP"); MarkerLandmarkDetail detail = new MarkerLandmarkDetail(marker, cmbTypeLandmark.SelectedIndex, PositionConverter.ParsePointFromString(txtLocationLandmark.Text), txtNameLandmark.Text, txtLabelLandmark.Text); dicMarker.Add(marker, detail); marker.ToolTipText = "\n" + detail.Location.Lat.ToString() + " / " + detail.Location.Lng.ToString() + "\n" + detail.Label; marker.ToolTipMode = MarkerTooltipMode.OnMouseOver; overlay.Markers.Add(marker); mainForm.GetInstance().GetmainMap().Overlays.Add(overlay); txtLabelLandmark.Text = "Short Name"; txtLabelLandmark.ForeColor = Color.Gray; txtNameLandmark.Text = "Landmark Name"; txtNameLandmark.ForeColor = Color.Gray; cmbTypeLandmark.Text = "Please Select Type of Landmark"; cmbTypeLandmark.ForeColor = Color.Gray; }
private void btnAddMarker_Click(object sender, EventArgs e) { string name = txtNumber.Text; PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); foreach (Control c in Controls) { if (c is TextBox) { if (c.Text == "") { if (c != txtRemark) { MessageBox.Show("กรุณากรอกข้อมูลให้ครบถ้วน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } } if (editMode == true) { main.detailMarkers.Remove(getmarker); main.markerOverlay.Markers.Remove(getmarker); main.markerOverlay.Markers.Remove(getrect); AutoIncrementID -= 1; Image image = Image.FromFile("Images/icon/FIxedPoint.png"); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); //Add Data to dictionary FixedPoint fixedPoint = new FixedPoint("FP" + "0" + (AutoIncrementID += 1).ToString(), txtNumber.Text, checkType, txtLabel.Text, checkSIM, txtRemark.Text, point); main.detailMarkers.Add(marker, fixedPoint); // TODO : Manage data before adding to overlay main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); this.seteditMode(false); MessageBox.Show("แก้ไขสำเร็จ"); clearField(); } else { // TODO : Selecting image to display as marker Image image = Image.FromFile("Images/icon/FIxedPoint.png"); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); //Add Data to dictionary FixedPoint fixedPoint = new FixedPoint("FP" + "0" + (AutoIncrementID += 1).ToString(), txtNumber.Text, checkType, txtLabel.Text, checkSIM, txtRemark.Text, point); main.detailMarkers.Add(marker, fixedPoint); // TODO : Manage data before adding to overlay main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("เพิ่มมาร์คเกอร์ " + marker.Name + " บนแผนที่แล้ว", "FixedPoint Marker"); clearField(); } }
private void cmbPosition_SelectedIndexChanged(object sender, EventArgs e) { //Can change eographic coordinate system if (cmbPosition.SelectedIndex > -1 && txtPosition.Text != "") { PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); txtPosition.Text = PositionConverter.ParsePointToString(point, cmbPosition.Text); } }
private void btnCreate_Click(object sender, EventArgs e) { PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); int number; double speed, bearing, height; bool server = rdbServer.Checked; if (point.IsEmpty) { } else if (!int.TryParse(txtNumber.Text, out number)) { } else if (!double.TryParse(txtSpeed.Text, out speed)) { } else if (!double.TryParse(txtBearing.Text, out bearing)) { } else if (!double.TryParse(txtHeight.Text, out height)) { } else { TrackData faker = new TrackData { Source = RadarClient.Connected ? DataSource.Self : null, Number = number, Position = point, Speed = ScaleConverter.ConvertSpeed(speed, speedScale, "knots"), Bearing = ScaleConverter.ConvertBearing(bearing, bearingScale, "degree"), Height = ScaleConverter.ConvertHeight(height, heightScale, "ft"), LastUpdated = DateTime.Now }; if (server && !RadarClient.Connected) { } else { faker.Faker = server && RadarClient.Connected ? TrackFakerType.Server : TrackFakerType.Client; TrackCommandResponse response = main.trackHandler.CreateTrack(faker); if (response.Code == TrackCommandResponseCode.Success) { txtNumber.Text = ""; txtPosition.Text = ""; txtSpeed.Text = ""; txtBearing.Text = ""; txtHeight.Text = ""; } else { MessageBox.Show(response.Message); } } } }
private void btnAddMarker_Click(object sender, EventArgs e) { string name = txtName.Text; PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); Image image = Image.FromFile("Images/icon/City.png"); foreach (Control c in Controls) { if (c is TextBox) { if (c.Text == "") { if (c != txtRemark) { MessageBox.Show("กรุณากรอกข้อมูลให้ครบถ้วน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } } // TODO : Selecting image to display as marker if (editMode == true) { // If edit mode do this main.markerOverlay.Markers.Remove(getmarker); main.markerOverlay.Markers.Remove(getrect); AutoIncrementID -= 1; main.detailMarkers.Remove(getmarker); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); City city = new City("CI" + "0" + (AutoIncrementID += 1).ToString(), txtName.Text, txtLabel.Text, txtRemark.Text, point); main.detailMarkers.Add(marker, city); if (MainForm.isConnected) { city.Edit(); } main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("แก้ไขสำเร็จ"); ControlViews.CityCreation.setEditMode(false); clearField(); } else if (editMode == false) { // If on default mode do this GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); City city = new City("CI" + "0" + (AutoIncrementID += 1).ToString(), txtName.Text, txtLabel.Text, txtRemark.Text, point); main.detailMarkers.Add(marker, city); // TODO : Manage data before adding to overlay if (MainForm.isConnected) { city.Insert(); } main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("เพิ่มมาร์คเกอร์ " + marker.Name + " บนแผนที่แล้ว", "City Marker"); clearField(); } }
private void btnAddMarker_Click(object sender, EventArgs e) { string name = txtName.Text; PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); foreach (Control c in Controls) { if (c is TextBox) { if (c.Text == "") { MessageBox.Show("กรุณากรอกข้อมูลให้ครบถ้วน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } if (editMode == true) { main.detailMarkers.Remove(getmarker); main.markerOverlay.Markers.Remove(getmarker); main.markerOverlay.Markers.Remove(getrect); AutoIncrementID -= 1; Image image = Image.FromFile("Images/icon/Airport.png"); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); //Add Data to Dictionary Airport airport = new Airport("AP" + "0" + (AutoIncrementID += 1).ToString(), txtCountry.Text, txtName.Text, checkInter, txtICAO.Text, txtIATA.Text, point); main.detailMarkers.Add(marker, airport); // TODO : Manage data before adding to overlay if (MainForm.isConnected) { airport.Edit(); } main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); ControlViews.AirportCreation.setEditMode(false); MessageBox.Show("แก้ไขสำเร็จ"); clearField(); } else { Image image = Image.FromFile("Images/icon/Airport.png"); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); //Add Data to Dictionary Airport airport = new Airport("AP" + "0" + (AutoIncrementID += 1).ToString(), txtCountry.Text, txtName.Text, checkInter, txtICAO.Text, txtIATA.Text, point); main.detailMarkers.Add(marker, airport); // TODO : Manage data before adding to overlay if (MainForm.isConnected) { airport.Insert(); } main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("เพิ่มมาร์คเกอร์ " + marker.Name + " บนแผนที่แล้ว", "Airport Marker"); clearField(); } }
private void btnCreate_Click(object sender, EventArgs e) { string name = txtName.Text; PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); foreach (Control c in Controls) { if (c is TextBox) { if (c.Text == "") { MessageBox.Show("กรุณากรอกข้อมูลให้ครบถ้วน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } else if (c is ComboBox) { if (c.Text == "") { MessageBox.Show("กรุณาเลือกข้อมูลให้ครบถ้วน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } //if (String.IsNullOrWhiteSpace(txtName.Text) || String.IsNullOrWhiteSpace(cmbResponsibleUnit.Text) || String.IsNullOrWhiteSpace(cmbResponsiblePerson.Text) || String.IsNullOrWhiteSpace(txtPosition.Text) // || String.IsNullOrWhiteSpace(txtPriority.Text) || String.IsNullOrWhiteSpace(cmbProvince.Text) || String.IsNullOrWhiteSpace(txtSize.Text) || String.IsNullOrWhiteSpace(txtUnitStatus.Text)) //{ // MessageBox.Show("กรุณากรอกข้อมูลให้ครบทุกช่อง","คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); //} if (!int.TryParse(txtPriority.Text, out parsedValue)) { MessageBox.Show("ระดับความสำคัญใส่ได้เฉพาะตัวเลขจำนวนเต็มเท่านั้น", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (parsedValue > 99 || parsedValue <= 0) { //txtPriority.Text = txtPriority.Text.Substring(0, txtPriority.TextLength - 1); MessageBox.Show("ระดับความสำคัญ สามารถใส่ตัวเลขได้ระหว่าง 1-99 เท่านั้น", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (editMode == true) { main.markerOverlay.Markers.Remove(getmarker); main.markerOverlay.Markers.Remove(getrect); AutoIncrementID -= 1; main.detailMarkers.Remove(getmarker); Image image = Image.FromFile("Images/icon/VitalAsset.png"); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); //Add Data to dictionary VitalAsset vitalAsset = new VitalAsset("VA" + "0" + (AutoIncrementID += 1).ToString(), txtName.Text, cmbType.Text, Int32.Parse(txtPriority.Text), cmbProvince.Text, txtSize.Text, cmbResponsibleUnit.Text, txtUnitStatus.Text, cmbResponsiblePerson.Text, point); main.detailMarkers.Add(marker, vitalAsset); // TODO : Manage data before adding to overlay main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("แก้ไขสำเร็จ"); // Set edit mode to false and clearing textbox. ControlViews.CityCreation.setEditMode(false); clearField(); } else { // TODO : Selecting image to display as marker Image image = Image.FromFile("Images/icon/VitalAsset.png"); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); //Add Data to dictionary VitalAsset vitalAsset = new VitalAsset("VA" + "0" + (AutoIncrementID += 1).ToString(), txtName.Text, cmbType.Text, Int32.Parse(txtPriority.Text), cmbProvince.Text, txtSize.Text, cmbResponsibleUnit.Text, txtUnitStatus.Text, cmbResponsiblePerson.Text, point); main.detailMarkers.Add(marker, vitalAsset); // TODO : Manage data before adding to overlay main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("เพิ่มมาร์คเกอร์ " + marker.Name + " บนแผนที่แล้ว", "VitalAsset Marker"); clearField(); } } }
private void btnCreate_Click(object sender, EventArgs e) { PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); int number; double speed, bearing, height; if (point.IsEmpty) { } else if (!int.TryParse(txtNumber.Text, out number)) { } else if (!double.TryParse(txtSpeed.Text, out speed)) { } else if (!double.TryParse(txtBearing.Text, out bearing)) { } else if (!double.TryParse(txtHeight.Text, out height) && txtHeight.Text != "Unknown") { } else { var track = new TrackData { CallSign = txtCallSign.Text.ToUpper(), Status = (TrackStatus)Enum.Parse(typeof(TrackStatus), cmbStatus.Text), Number = number, Position = point, Speed = ScaleConverter.ConvertSpeed(speed, speedScale, "knots"), Bearing = ScaleConverter.ConvertBearing(bearing, bearingScale, "degree"), LastUpdated = DateTime.Now }; if (editMode) { MessageBox.Show("Passin"); if (this.track != null) { track.Faker = this.track.Faker; if (txtHeight.Text != "Unknown") { track.Height = ScaleConverter.ConvertHeight(height, heightScale, "ft"); } if (txtCallSign.Text == "") { track.CallSign = null; } if (track.Status == TrackStatus.Pending) { track.Status = TrackStatus.OverridePending; } CommandResponse response = ControlViews.Main.trackHandler.Update(track); if (response.Code == CommandResponseCode.Success) { ControlViews.Track.SetControl(ControlViews.TrackView); ControlViews.TrackView.setTrackInfo(track); } else { MessageBox.Show(response.Message); } } } else { MessageBox.Show("Passin2"); track.Faker = true; track.Height = ScaleConverter.ConvertHeight(height, heightScale, "ft"); CommandResponse response = ControlViews.Main.trackHandler.Create(track); if (response.Code == CommandResponseCode.Success) { clearFields(); } else { MessageBox.Show(response.Message); } } } }
private void btnAddMarker_Click(object sender, EventArgs e) { string name = txtLabel.Text; PointLatLng point = PositionConverter.ParsePointFromString(txtPosition.Text); foreach (Control c in Controls) { if (c is TextBox) { if (c.Text == "") { if (c != txtRemark) { MessageBox.Show("กรุณากรอกข้อมูลให้ครบถ้วน", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } } if (cmbType.Text == "") { //Check if user not seleted cmbType MessageBox.Show("กรุณาเลือกชนิด", "คำเตือน", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (editMode == true) { main.detailMarkers.Remove(getmarker); main.markerOverlay.Markers.Remove(getmarker); main.markerOverlay.Markers.Remove(getrect); GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); AutoIncrementID -= 1; //Add Data to Dictionary LandMark landMark = new LandMark("LM" + "0" + (AutoIncrementID += 1).ToString(), txtName.Text, txtLabel.Text, point, cmbType.SelectedItem.ToString(), txtRemark.Text); main.detailMarkers.Add(marker, landMark); // TODO : Manage data before adding to overlay if (MainForm.isConnected) { landMark.Edit(); } main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("แก้ไขสำเร็จ"); ControlViews.LandmarkCreation.setEditMode(false); clearField(); } else { // TODO : Selecting image to display as marker GMarker marker = new GMarker(point, name, image); GMarkerRect rect = new GMarkerRect(marker); //Add Data to Dictionary LandMark landMark = new LandMark("LM" + "0" + (AutoIncrementID += 1).ToString(), txtName.Text, txtLabel.Text, point, cmbType.SelectedItem.ToString(), txtRemark.Text); main.detailMarkers.Add(marker, landMark); // TODO : Manage data before adding to overlay if (MainForm.isConnected) { landMark.Insert(); } main.markerOverlay.Markers.Add(marker); main.markerOverlay.Markers.Add(rect); MessageBox.Show("เพิ่มมาร์คเกอร์ " + marker.Name + " บนแผนที่แล้ว", "LandMark Marker"); clearField(); } } }