private void autoFlyingSettingButton_Click(object sender, System.EventArgs e) { try { if (this.Root == null) { return; } if (this.Root.AutoFlight.IsFlying) { return; } if (this.Root.Bebop2.GPS.IsValid == false) { throw new Exception("현재 드론의 위치정보가 없습니다."); } var dialog = new Fire_Detector.Dialog.AutoFlyingDialog(this.Root.Bebop2.GPS); //var dialog = new Fire_Detector.Dialog.AutoFlyingDialog(new GCS(37.3403904, 126.7334985)); if (dialog.ShowDialog(this.Root) != DialogResult.OK) { return; } // 자율비행 시작점과 종료점 마크 var marker = new OYOGmapMarker(dialog.Begin, dialog.End); this._gmap.ClearMarkers(); this._gmap.AddMarker("point", marker, false); // 자율비행 이동경로 this._points = dialog.Points; var path = new OYOGmapPath(this._points); this._gmap.ClearPath(false); this._gmap.AddPath("path", path); // 위치와 구글맵 요청 this._gmap.RequestAddress("begin", dialog.Begin); this._gmap.RequestAddress("end", dialog.End); this._gmap.RequestGmap(); // 면적 계산 var width = OYOGmap.GetDistance(dialog.Begin.lat, dialog.Begin.lon, dialog.Begin.lat, dialog.End.lon) * 1000.0; var height = OYOGmap.GetDistance(dialog.Begin.lat, dialog.Begin.lon, dialog.End.lat, dialog.Begin.lon) * 1000.0; this.areaLabel.Text = string.Format("{0} ㎡", (width * height).ToString("0.00")); } catch (Exception exc) { var messageBox = new MessageDialog(exc.Message); messageBox.ShowDialog(this.Root); } }
private void gmapBox_MouseUp(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } var moved = System.Drawing.Point.Empty; if (this._drag.End(e.X, e.Y, out moved) == false) { return; } if (moved == System.Drawing.Point.Empty) { if (this._begin.IsEmpty || !this._end.IsEmpty) { this._gmap.RemovePolygon("area"); this._begin = new System.Drawing.Point(e.X, e.Y); this._end = System.Drawing.Point.Empty; var path = new OYOGmapPath(this._gmap.Pixel2Coord(this._begin)); this._gmap.DrawMarker = true; this._gmap.AddPath("begin", path); this._gmap.RequestGmap(); } else { this._gmap.DrawMarker = false; this._gmap.ClearPath(); this._end = new System.Drawing.Point(e.X, e.Y); var left_bot = new System.Drawing.Point(this._begin.X, this._end.Y); var right_top = new System.Drawing.Point(this._end.X, this._begin.Y); var polygon = new OYOGmapPolygon(3, Color.FromArgb(64, Color.Blue), Color.Transparent, this._gmap.Pixel2Coord(this._begin), this._gmap.Pixel2Coord(left_bot), this._gmap.Pixel2Coord(this._end), this._gmap.Pixel2Coord(right_top)); this._gmap.AddPolygon("area", polygon, true); this.Points = this.GetPoints(this._begin, this._end); this.Begin = this._gmap.Pixel2Coord(this._begin); this.End = this._gmap.Pixel2Coord(this._end); } } else { this._gmap.SetPosition(this._drag.BeginPoint.X - moved.X, this._drag.BeginPoint.Y - moved.Y, true); } }