📄 clienttest.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using GPSClassLibrary;
namespace GPSGuider
{
public partial class ClientTest : Form
{
GPSComport gpscomport;
public ClientTest()
{
InitializeComponent();
}
private void ClientTest_Load(object sender, EventArgs e)
{
// 设置串口传输
using (SettingsForm form = new SettingsForm())
{
while (form.ShowDialog() == DialogResult.OK)
{
gpscomport = new GPSClassLibrary.GPSComport(form.PortName, form.BaudRate, form.DataBits, form.StopBits, form.Parity);
if (!gpscomport.OpenPort())
{
MessageBox.Show("打开串口不成功,请重新设置", "提示");
continue;
}
else
{
//MessageBox.Show("连接成功!");
break;
}
}
if (form.DialogResult == DialogResult.Cancel)
this.Dispose();
}
}
private void button3_Click(object sender, EventArgs e)
{
GPPI gppi = new GPPI();
if (radioLocated.Checked)
gppi.GPSState = GPSState.Located;
else
if (radioUnlocated.Checked)
gppi.GPSState = GPSState.Unlocated;
else
gppi.GPSState = GPSState.Calculating;
gppi.Latitude = double.Parse(txbLati.Text);
gppi.LatitudeType = chckbLatiType.Checked ? LatitudeType.South : LatitudeType.North;
gppi.Longitude = double.Parse(txbLongi.Text);
gppi.LongitudeType = chckbLongi.Checked ? LongitudeType.West : LongitudeType.East;
gppi.Height = double.Parse(txbHeight.Text);
gpscomport.SendData(gppi.ToString());
}
private void button2_Click(object sender, EventArgs e)
{
GPSI gpsi = new GPSI();
gpsi.Heavyness = int.Parse(txbHeaviness.Text);
gpsi.OilSurplus = float.Parse(txbOilCur.Text);
gpsi.EngineTemperature = float.Parse(txbEngineTemperature.Text);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -