You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using System.Windows.Forms;
using BirdyFlash.Lib;
using MaterialSkin;
using MaterialSkin.Controls;
namespace BirdyFlash
{
partial class ScanningPagersDialog : MaterialForm
{
public ScanningPagersDialog()
{
InitializeComponent();
}
List<string> portList = new List<string>();
int resultCount = 0;
private void ScanningPagersDialog_Load(object sender, EventArgs e) {
MaterialSkinManager.Instance.AddFormToManage(this);
}
internal void Setup(List<string> portList)
{
this.portList = portList;
}
private async void TestPort(string portName)
{
using (var comm = new Lib.BirdyComm())
{
comm.SetPort(CommPort.From(portName));
try
{
var data = await comm.TryGetDeviceInfo();
Console.WriteLine(data.deviceSerial);
this.Invoke(new Action(() =>
{
txtLog.AppendText(string.Format("{0} type {1} serial {2}\n", portName, data.model, data.deviceSerial));
}));
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
this.Invoke(new Action(() =>
{
txtLog.AppendText(string.Format("{0} timeout\n", portName));
}));
}
}
}
private void ScanningPagersDialog_Shown(object sender, EventArgs e) {
/*foreach(string portName in this.portList)
{
Task.Run(() => TestPort(portName));
}*/
}
}
}