using System;
using System;
using System.IO.Ports;
using System.Windows.Forms;
using GMap.NET;
using GMap.NET.MapProviders;
using GMap.NET.WindowsForms;
using GMap.NET.WindowsForms.Markers;
namespace FlightMonitor
{
public partial class MainForm : Form
{
private SerialPort serialPort;
private GMapOverlay markersOverlay;
private GMapMarker currentLocationMarker;
public MainForm()
{
InitializeComponent();
InitializeGMap();
InitializeSerialPort();
}
if (currentLocationMarker == null)
{
currentLocationMarker = new GMarkerGoogle(point,
GMarkerGoogleType.red_dot);
markersOverlay.Markers.Add(currentLocationMarker);
}
else
{
currentLocationMarker.Position = point;
}
gMapControl1.Refresh();
}
private void btnConnect_Click(object sender, EventArgs e)
{
if (!serialPort.IsOpen)
{
serialPort.PortName = comboBoxPorts.Text;
serialPort.Open();
btnConnect.Text = "Disconnect";
}
else
{
serialPort.Close();
btnConnect.Text = "Connect";
}
}
// Thông báo
MessageBox.Show($"Waypoint '{waypointName}' added at
({point.Lat:F6}, {point.Lng:F6}).");
}
}
private void SendCoordinatesToDrone(double latitude, double longitude)
{
if (serialPort != null && serialPort.IsOpen)
{
try
{
// Định dạng chuỗi tọa độ
string dataToSend = $"{latitude:F6},{longitude:F6}";
}
}