check ip interface before start
This commit is contained in:
30
MainForm.cs
30
MainForm.cs
@@ -1,8 +1,11 @@
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Web;
|
||||
using Tmds.MDns;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace robospot_camera_finder
|
||||
{
|
||||
@@ -44,6 +47,33 @@ namespace robospot_camera_finder
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
bool got_proper_ip = false;
|
||||
foreach (var net_interface in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
IPInterfaceProperties prop = net_interface.GetIPProperties();
|
||||
foreach (var ip in prop.UnicastAddresses)
|
||||
{
|
||||
if (ip.Address.ToString().StartsWith("10."))
|
||||
{
|
||||
if (ip.IPv4Mask.ToString() == "255.0.0.0")
|
||||
{
|
||||
got_proper_ip = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!got_proper_ip)
|
||||
{
|
||||
DialogResult open_netsettings = MessageBox.Show("No Ethernet interface on the 10.0.0.0/8 subnet found. Cameras might not be detected. Do you want to open network settings ?", "Wrong IP configuration", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
|
||||
if (open_netsettings == DialogResult.Yes)
|
||||
{
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo("NCPA.cpl");
|
||||
startInfo.UseShellExecute = true;
|
||||
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
}
|
||||
|
||||
browser.StartBrowse("_rtsp._tcp");
|
||||
|
||||
lbMain.DataSource = all_cameras;
|
||||
|
||||
Reference in New Issue
Block a user