Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5ab9f487c6 | |||
| 40a9b653b2 | |||
| 31477b99a0 | |||
| c731b34b36 | |||
| eb0d30384d | |||
| de4d535edc | |||
| c0f6277265 | |||
| 606b92fd32 | |||
| 72501532fe |
77
MainForm.Designer.cs
generated
77
MainForm.Designer.cs
generated
@@ -33,26 +33,26 @@
|
|||||||
statusStripMain = new StatusStrip();
|
statusStripMain = new StatusStrip();
|
||||||
toolStripStatusLabel = new ToolStripStatusLabel();
|
toolStripStatusLabel = new ToolStripStatusLabel();
|
||||||
toolStripStatusDisco = new ToolStripStatusLabel();
|
toolStripStatusDisco = new ToolStripStatusLabel();
|
||||||
menuStrip1 = new MenuStrip();
|
menuStrip = new MenuStrip();
|
||||||
discoveryToolStripMenuItem = new ToolStripMenuItem();
|
discoveryToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
discoverToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
toolStripSeparator2 = new ToolStripSeparator();
|
||||||
manualAddToolStripMenuItem = new ToolStripMenuItem();
|
manualAddToolStripMenuItem = new ToolStripMenuItem();
|
||||||
toolStripSeparator1 = new ToolStripSeparator();
|
toolStripSeparator1 = new ToolStripSeparator();
|
||||||
saveToolStripMenuItem = new ToolStripMenuItem();
|
saveToolStripMenuItem = new ToolStripMenuItem();
|
||||||
loadToolStripMenuItem = new ToolStripMenuItem();
|
loadToolStripMenuItem = new ToolStripMenuItem();
|
||||||
toolStripSeparator2 = new ToolStripSeparator();
|
aboutStripMenuItem = new ToolStripMenuItem();
|
||||||
discoverToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
statusStripMain.SuspendLayout();
|
statusStripMain.SuspendLayout();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// lbMain
|
// lbMain
|
||||||
//
|
//
|
||||||
lbMain.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
lbMain.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
lbMain.FormattingEnabled = true;
|
lbMain.FormattingEnabled = true;
|
||||||
lbMain.ItemHeight = 15;
|
lbMain.Location = new Point(12, 38);
|
||||||
lbMain.Location = new Point(12, 23);
|
|
||||||
lbMain.Name = "lbMain";
|
lbMain.Name = "lbMain";
|
||||||
lbMain.Size = new Size(776, 394);
|
lbMain.Size = new Size(776, 379);
|
||||||
lbMain.TabIndex = 0;
|
lbMain.TabIndex = 0;
|
||||||
lbMain.MouseDoubleClick += lbMain_MouseDoubleClick;
|
lbMain.MouseDoubleClick += lbMain_MouseDoubleClick;
|
||||||
//
|
//
|
||||||
@@ -73,17 +73,16 @@
|
|||||||
// toolStripStatusDisco
|
// toolStripStatusDisco
|
||||||
//
|
//
|
||||||
toolStripStatusDisco.Name = "toolStripStatusDisco";
|
toolStripStatusDisco.Name = "toolStripStatusDisco";
|
||||||
toolStripStatusDisco.Size = new Size(111, 17);
|
toolStripStatusDisco.Size = new Size(0, 17);
|
||||||
toolStripStatusDisco.Text = "";
|
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip
|
||||||
//
|
//
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { discoveryToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { discoveryToolStripMenuItem, aboutStripMenuItem });
|
||||||
menuStrip1.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip1.Name = "menuStrip1";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip1.Size = new Size(800, 24);
|
menuStrip.Size = new Size(800, 24);
|
||||||
menuStrip1.TabIndex = 2;
|
menuStrip.TabIndex = 2;
|
||||||
menuStrip1.Text = "menuStrip1";
|
menuStrip.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// discoveryToolStripMenuItem
|
// discoveryToolStripMenuItem
|
||||||
//
|
//
|
||||||
@@ -92,42 +91,51 @@
|
|||||||
discoveryToolStripMenuItem.Size = new Size(70, 20);
|
discoveryToolStripMenuItem.Size = new Size(70, 20);
|
||||||
discoveryToolStripMenuItem.Text = "Discovery";
|
discoveryToolStripMenuItem.Text = "Discovery";
|
||||||
//
|
//
|
||||||
|
// discoverToolStripMenuItem
|
||||||
|
//
|
||||||
|
discoverToolStripMenuItem.Name = "discoverToolStripMenuItem";
|
||||||
|
discoverToolStripMenuItem.Size = new Size(166, 22);
|
||||||
|
discoverToolStripMenuItem.Text = "Discover cameras";
|
||||||
|
discoverToolStripMenuItem.Click += discoverToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// toolStripSeparator2
|
||||||
|
//
|
||||||
|
toolStripSeparator2.Name = "toolStripSeparator2";
|
||||||
|
toolStripSeparator2.Size = new Size(163, 6);
|
||||||
|
//
|
||||||
// manualAddToolStripMenuItem
|
// manualAddToolStripMenuItem
|
||||||
//
|
//
|
||||||
manualAddToolStripMenuItem.Name = "manualAddToolStripMenuItem";
|
manualAddToolStripMenuItem.Name = "manualAddToolStripMenuItem";
|
||||||
manualAddToolStripMenuItem.Size = new Size(180, 22);
|
manualAddToolStripMenuItem.Size = new Size(166, 22);
|
||||||
manualAddToolStripMenuItem.Text = "Add manually";
|
manualAddToolStripMenuItem.Text = "Add manually";
|
||||||
manualAddToolStripMenuItem.Click += manualAddToolStripMenuItem_Click;
|
manualAddToolStripMenuItem.Click += manualAddToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// toolStripSeparator1
|
// toolStripSeparator1
|
||||||
//
|
//
|
||||||
toolStripSeparator1.Name = "toolStripSeparator1";
|
toolStripSeparator1.Name = "toolStripSeparator1";
|
||||||
toolStripSeparator1.Size = new Size(177, 6);
|
toolStripSeparator1.Size = new Size(163, 6);
|
||||||
//
|
//
|
||||||
// saveToolStripMenuItem
|
// saveToolStripMenuItem
|
||||||
//
|
//
|
||||||
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
saveToolStripMenuItem.Name = "saveToolStripMenuItem";
|
||||||
saveToolStripMenuItem.Size = new Size(180, 22);
|
saveToolStripMenuItem.Size = new Size(166, 22);
|
||||||
saveToolStripMenuItem.Text = "Save";
|
saveToolStripMenuItem.Text = "Save";
|
||||||
saveToolStripMenuItem.Click += saveToolStripMenuItem_Click;
|
saveToolStripMenuItem.Click += saveToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// loadToolStripMenuItem
|
// loadToolStripMenuItem
|
||||||
//
|
//
|
||||||
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
loadToolStripMenuItem.Name = "loadToolStripMenuItem";
|
||||||
loadToolStripMenuItem.Size = new Size(180, 22);
|
loadToolStripMenuItem.Size = new Size(166, 22);
|
||||||
loadToolStripMenuItem.Text = "Load";
|
loadToolStripMenuItem.Text = "Load";
|
||||||
loadToolStripMenuItem.Click += loadToolStripMenuItem_Click;
|
loadToolStripMenuItem.Click += loadToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// toolStripSeparator2
|
// aboutStripMenuItem
|
||||||
//
|
//
|
||||||
toolStripSeparator2.Name = "toolStripSeparator2";
|
aboutStripMenuItem.Alignment = ToolStripItemAlignment.Right;
|
||||||
toolStripSeparator2.Size = new Size(177, 6);
|
aboutStripMenuItem.Name = "aboutStripMenuItem";
|
||||||
//
|
aboutStripMenuItem.Size = new Size(52, 20);
|
||||||
// discoverToolStripMenuItem
|
aboutStripMenuItem.Text = "About";
|
||||||
//
|
aboutStripMenuItem.Click += aboutStripMenuItem_Click;
|
||||||
discoverToolStripMenuItem.Name = "discoverToolStripMenuItem";
|
|
||||||
discoverToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
discoverToolStripMenuItem.Text = "Discover cameras";
|
|
||||||
//
|
//
|
||||||
// MainForm
|
// MainForm
|
||||||
//
|
//
|
||||||
@@ -135,16 +143,16 @@
|
|||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(statusStripMain);
|
Controls.Add(statusStripMain);
|
||||||
Controls.Add(menuStrip1);
|
Controls.Add(menuStrip);
|
||||||
Controls.Add(lbMain);
|
Controls.Add(lbMain);
|
||||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||||
MainMenuStrip = menuStrip1;
|
MainMenuStrip = menuStrip;
|
||||||
Name = "MainForm";
|
Name = "MainForm";
|
||||||
Text = "RoboSpot MotionCamera finder";
|
Text = "RoboSpot MotionCamera finder";
|
||||||
statusStripMain.ResumeLayout(false);
|
statusStripMain.ResumeLayout(false);
|
||||||
statusStripMain.PerformLayout();
|
statusStripMain.PerformLayout();
|
||||||
menuStrip1.ResumeLayout(false);
|
menuStrip.ResumeLayout(false);
|
||||||
menuStrip1.PerformLayout();
|
menuStrip.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@@ -154,7 +162,7 @@
|
|||||||
private ListBox lbMain;
|
private ListBox lbMain;
|
||||||
private StatusStrip statusStripMain;
|
private StatusStrip statusStripMain;
|
||||||
private ToolStripStatusLabel toolStripStatusLabel;
|
private ToolStripStatusLabel toolStripStatusLabel;
|
||||||
private MenuStrip menuStrip1;
|
private MenuStrip menuStrip;
|
||||||
private ToolStripMenuItem discoveryToolStripMenuItem;
|
private ToolStripMenuItem discoveryToolStripMenuItem;
|
||||||
private ToolStripMenuItem saveToolStripMenuItem;
|
private ToolStripMenuItem saveToolStripMenuItem;
|
||||||
private ToolStripMenuItem loadToolStripMenuItem;
|
private ToolStripMenuItem loadToolStripMenuItem;
|
||||||
@@ -163,5 +171,6 @@
|
|||||||
private ToolStripMenuItem manualAddToolStripMenuItem;
|
private ToolStripMenuItem manualAddToolStripMenuItem;
|
||||||
private ToolStripMenuItem discoverToolStripMenuItem;
|
private ToolStripMenuItem discoverToolStripMenuItem;
|
||||||
private ToolStripSeparator toolStripSeparator2;
|
private ToolStripSeparator toolStripSeparator2;
|
||||||
|
private ToolStripMenuItem aboutStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
166
MainForm.cs
166
MainForm.cs
@@ -14,10 +14,13 @@ namespace robospot_camera_finder
|
|||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
public string VERSION = "1.0.0";
|
// Version
|
||||||
|
public string VERSION = "1.2.0";
|
||||||
|
|
||||||
|
// Main list containing all cameras
|
||||||
private BindingList<Camera> all_cameras = new();
|
private BindingList<Camera> all_cameras = new();
|
||||||
|
|
||||||
|
// Camera credentials
|
||||||
public static string cam_username = "admin";
|
public static string cam_username = "admin";
|
||||||
public static string cam_password = "RoboSpot10";
|
public static string cam_password = "RoboSpot10";
|
||||||
|
|
||||||
@@ -28,29 +31,29 @@ namespace robospot_camera_finder
|
|||||||
private const byte DEF_REQ_SCAN = 1;
|
private const byte DEF_REQ_SCAN = 1;
|
||||||
private const byte RES_REQ_SCAN = 11;
|
private const byte RES_REQ_SCAN = 11;
|
||||||
|
|
||||||
|
// UDP clients
|
||||||
private UdpClient sendClient;
|
private UdpClient sendClient;
|
||||||
private UdpClient receiveClient;
|
private UdpClient receiveClient;
|
||||||
private bool isDiscovering = false;
|
private bool isDiscovering = false;
|
||||||
|
|
||||||
|
// Camera class
|
||||||
public class Camera
|
public class Camera
|
||||||
{
|
{
|
||||||
public Camera(string name, string ip, string location, string serial)
|
public Camera(string name, string ip, string id)
|
||||||
{
|
{
|
||||||
camera_name = name;
|
camera_name = name;
|
||||||
camera_ip = ip;
|
camera_ip = ip;
|
||||||
camera_location = location;
|
camera_id = id;
|
||||||
camera_serial = serial;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string camera_name { get; set; }
|
public string camera_name { get; set; }
|
||||||
|
|
||||||
public string camera_ip { get; set; }
|
public string camera_ip { get; set; }
|
||||||
|
|
||||||
public string camera_location { get; set; }
|
public string camera_id { get; set; }
|
||||||
|
|
||||||
public string camera_serial { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Discovery packet struc
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||||
public struct DataPacketIPv4
|
public struct DataPacketIPv4
|
||||||
{
|
{
|
||||||
@@ -139,9 +142,10 @@ namespace robospot_camera_finder
|
|||||||
InitializeUdpClients();
|
InitializeUdpClients();
|
||||||
|
|
||||||
// Discover cameras
|
// Discover cameras
|
||||||
discover_cameras();
|
DiscoverCameras();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inits UDP clients
|
||||||
private void InitializeUdpClients()
|
private void InitializeUdpClients()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -157,7 +161,8 @@ namespace robospot_camera_finder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add_camera(Camera new_camera)
|
// Add cameras to the main list
|
||||||
|
private void AddCamera(Camera new_camera)
|
||||||
{
|
{
|
||||||
if (all_cameras.Count == 0)
|
if (all_cameras.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -165,7 +170,7 @@ namespace robospot_camera_finder
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Camera find_cam = all_cameras.FirstOrDefault(cam => cam.camera_serial == new_camera.camera_serial);
|
Camera find_cam = all_cameras.FirstOrDefault(cam => cam.camera_id == new_camera.camera_id);
|
||||||
|
|
||||||
if (find_cam != null)
|
if (find_cam != null)
|
||||||
{
|
{
|
||||||
@@ -179,67 +184,6 @@ namespace robospot_camera_finder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lbMain_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
||||||
{
|
|
||||||
if (lbMain.SelectedItem != null)
|
|
||||||
{
|
|
||||||
toolStripStatusLabel.Text = "Loading camera...";
|
|
||||||
Camera camera = all_cameras.FirstOrDefault<Camera>(cam => cam.camera_ip.ToString() == lbMain.SelectedValue.ToString());
|
|
||||||
Form viewer = new StreamViewer(lbMain.GetItemText(lbMain.SelectedItem), lbMain.SelectedValue.ToString(), camera, this);
|
|
||||||
viewer.Show();
|
|
||||||
toolStripStatusLabel.Text = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string json = "";
|
|
||||||
OpenFileDialog openFile = new OpenFileDialog();
|
|
||||||
openFile.Filter = "json file (*.json)|*.json";
|
|
||||||
openFile.RestoreDirectory = true;
|
|
||||||
|
|
||||||
if (openFile.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
json = File.ReadAllText(openFile.FileName);
|
|
||||||
|
|
||||||
List<Camera> cameras_in_file = JsonSerializer.Deserialize<List<Camera>>(json);
|
|
||||||
|
|
||||||
foreach (Camera new_camera in cameras_in_file)
|
|
||||||
{
|
|
||||||
add_camera(new_camera);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
string json = JsonSerializer.Serialize<BindingList<Camera>>(all_cameras, new JsonSerializerOptions
|
|
||||||
{
|
|
||||||
WriteIndented = true
|
|
||||||
});
|
|
||||||
SaveFileDialog saveFile = new SaveFileDialog();
|
|
||||||
saveFile.Filter = "json file (*.json)|*.json";
|
|
||||||
saveFile.RestoreDirectory = true;
|
|
||||||
|
|
||||||
if (saveFile.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
File.WriteAllText(saveFile.FileName, json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void manualAddToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
Manual_IP_Form manualForm = new Manual_IP_Form();
|
|
||||||
|
|
||||||
if (manualForm.ShowDialog(this) == DialogResult.OK)
|
|
||||||
{
|
|
||||||
string ipAddress = manualForm.ipAddress;
|
|
||||||
|
|
||||||
Camera camera_to_add = new Camera("Camera " + ipAddress, ipAddress, "", "CAM_FINDER_" + DateTime.Now.Ticks.ToString());
|
|
||||||
add_camera(camera_to_add);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper method to convert structure to byte array
|
// Helper method to convert structure to byte array
|
||||||
private byte[] StructureToByteArray(DataPacketIPv4 packet)
|
private byte[] StructureToByteArray(DataPacketIPv4 packet)
|
||||||
{
|
{
|
||||||
@@ -423,14 +367,13 @@ namespace robospot_camera_finder
|
|||||||
Camera discoveredCamera = new Camera(
|
Camera discoveredCamera = new Camera(
|
||||||
$"{deviceName} - ({cameraIP})",
|
$"{deviceName} - ({cameraIP})",
|
||||||
cameraIP,
|
cameraIP,
|
||||||
$"MAC: {macAddress}",
|
packetId
|
||||||
packetId // Using packet_id as serial for uniqueness
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// Add camera to list (must be done on UI thread)
|
// Add camera to list (must be done on UI thread)
|
||||||
this.Invoke(new Action(() =>
|
this.Invoke(new Action(() =>
|
||||||
{
|
{
|
||||||
add_camera(discoveredCamera);
|
AddCamera(discoveredCamera);
|
||||||
toolStripStatusLabel.Text = $"Found camera: {cameraName} ({cameraIP})";
|
toolStripStatusLabel.Text = $"Found camera: {cameraName} ({cameraIP})";
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
@@ -446,7 +389,7 @@ namespace robospot_camera_finder
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Main discovery method
|
// Main discovery method
|
||||||
private async void discover_cameras()
|
private async void DiscoverCameras()
|
||||||
{
|
{
|
||||||
if (isDiscovering)
|
if (isDiscovering)
|
||||||
{
|
{
|
||||||
@@ -466,6 +409,7 @@ namespace robospot_camera_finder
|
|||||||
|
|
||||||
isDiscovering = true;
|
isDiscovering = true;
|
||||||
toolStripStatusLabel.Text = "Discovering cameras...";
|
toolStripStatusLabel.Text = "Discovering cameras...";
|
||||||
|
discoverToolStripMenuItem.Enabled = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -491,6 +435,68 @@ namespace robospot_camera_finder
|
|||||||
{
|
{
|
||||||
isDiscovering = false;
|
isDiscovering = false;
|
||||||
toolStripStatusLabel.Text = $"Discovery complete. Found {all_cameras.Count} cameras.";
|
toolStripStatusLabel.Text = $"Discovery complete. Found {all_cameras.Count} cameras.";
|
||||||
|
discoverToolStripMenuItem.Enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lbMain_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (lbMain.SelectedItem != null)
|
||||||
|
{
|
||||||
|
toolStripStatusLabel.Text = "Loading camera...";
|
||||||
|
Camera camera = all_cameras.FirstOrDefault<Camera>(cam => cam.camera_ip.ToString() == lbMain.SelectedValue.ToString());
|
||||||
|
Form viewer = new StreamViewer(camera, this);
|
||||||
|
viewer.Show();
|
||||||
|
toolStripStatusLabel.Text = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string json = "";
|
||||||
|
OpenFileDialog openFile = new OpenFileDialog();
|
||||||
|
openFile.Filter = "json file (*.json)|*.json";
|
||||||
|
openFile.RestoreDirectory = true;
|
||||||
|
|
||||||
|
if (openFile.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
json = File.ReadAllText(openFile.FileName);
|
||||||
|
|
||||||
|
List<Camera> cameras_in_file = JsonSerializer.Deserialize<List<Camera>>(json);
|
||||||
|
|
||||||
|
foreach (Camera new_camera in cameras_in_file)
|
||||||
|
{
|
||||||
|
AddCamera(new_camera);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string json = JsonSerializer.Serialize<BindingList<Camera>>(all_cameras, new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true
|
||||||
|
});
|
||||||
|
SaveFileDialog saveFile = new SaveFileDialog();
|
||||||
|
saveFile.Filter = "json file (*.json)|*.json";
|
||||||
|
saveFile.RestoreDirectory = true;
|
||||||
|
|
||||||
|
if (saveFile.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
File.WriteAllText(saveFile.FileName, json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void manualAddToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Manual_IP_Form manualForm = new Manual_IP_Form();
|
||||||
|
|
||||||
|
if (manualForm.ShowDialog(this) == DialogResult.OK)
|
||||||
|
{
|
||||||
|
string ipAddress = manualForm.ipAddress;
|
||||||
|
|
||||||
|
Camera camera_to_add = new Camera("Camera " + ipAddress, ipAddress, ipAddress);
|
||||||
|
AddCamera(camera_to_add);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,5 +514,15 @@ namespace robospot_camera_finder
|
|||||||
|
|
||||||
base.OnFormClosing(e);
|
base.OnFormClosing(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void discoverToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DiscoverCameras();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void aboutStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
MessageBox.Show("RoboSpot Camera Finder v" + VERSION, "RoboSpot Camera Finder", MessageBoxButtons.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
<metadata name="statusStripMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="statusStripMain.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>153, 17</value>
|
<value>153, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
|
|||||||
16
Properties/PublishProfiles/Windows x64.pubxml
Normal file
16
Properties/PublishProfiles/Windows x64.pubxml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||||
|
<Project>
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
<PublishDir>bin\Release\net9.0-windows\publish\</PublishDir>
|
||||||
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
|
<_TargetId>Folder</_TargetId>
|
||||||
|
<TargetFramework>net9.0-windows</TargetFramework>
|
||||||
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<SelfContained>false</SelfContained>
|
||||||
|
<PublishSingleFile>true</PublishSingleFile>
|
||||||
|
<PublishReadyToRun>false</PublishReadyToRun>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
4
StreamViewer.Designer.cs
generated
4
StreamViewer.Designer.cs
generated
@@ -1,6 +1,4 @@
|
|||||||
using LibVLCSharp.Forms.Shared;
|
namespace robospot_camera_finder
|
||||||
|
|
||||||
namespace robospot_camera_finder
|
|
||||||
{
|
{
|
||||||
partial class StreamViewer
|
partial class StreamViewer
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,29 +8,30 @@ namespace robospot_camera_finder
|
|||||||
public LibVLC _libVLC;
|
public LibVLC _libVLC;
|
||||||
public MediaPlayer _mp;
|
public MediaPlayer _mp;
|
||||||
|
|
||||||
string cam_ip = "";
|
MainForm.Camera camera;
|
||||||
|
|
||||||
int max_zoom_pulse = 9999;
|
const int MAX_ZOOM_PULSE = 9999;
|
||||||
int min_zoom_pulse = 10;
|
const int MIN_ZOOM_PULSE = 10;
|
||||||
|
|
||||||
bool zoomTestSeqFlag = false;
|
bool zoomTestSeqFlag = false;
|
||||||
|
|
||||||
public StreamViewer(string name, string ip, MainForm.Camera camera, MainForm mainForm)
|
public StreamViewer(MainForm.Camera cam, MainForm mainForm)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
_libVLC = new LibVLC();
|
_libVLC = new LibVLC();
|
||||||
_mp = new MediaPlayer(_libVLC);
|
_mp = new MediaPlayer(_libVLC);
|
||||||
|
|
||||||
cam_ip = ip;
|
camera = cam;
|
||||||
this.Text = name;
|
|
||||||
|
|
||||||
if (!cam_ip.StartsWith("10."))
|
this.Text = camera.camera_name;
|
||||||
|
|
||||||
|
if (!cam.camera_ip.StartsWith("10."))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Camera is not on the 10.0.0.0/8 network, the RoboSpot might not find it.", "Wrong IP", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show("Camera is not on the 10.0.0.0/8 network, the RoboSpot might not find it.", "Wrong IP", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
string rtsp_link = "rtsp://" + ip + "/profile2/media.smp";
|
string rtsp_link = "rtsp://" + camera.camera_ip + "/profile2/media.smp";
|
||||||
|
|
||||||
updateZoomSlider();
|
updateZoomSlider();
|
||||||
|
|
||||||
@@ -45,7 +46,7 @@ namespace robospot_camera_finder
|
|||||||
|
|
||||||
private void updateZoomSlider()
|
private void updateZoomSlider()
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + cam_ip + "/stw-cgi/ptzcontrol.cgi?msubmenu=query&action=view&Query=Zoom");
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + camera.camera_ip + "/stw-cgi/ptzcontrol.cgi?msubmenu=query&action=view&Query=Zoom");
|
||||||
request.Credentials = new NetworkCredential(MainForm.cam_username, MainForm.cam_password);
|
request.Credentials = new NetworkCredential(MainForm.cam_username, MainForm.cam_password);
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||||
string text;
|
string text;
|
||||||
@@ -59,16 +60,16 @@ namespace robospot_camera_finder
|
|||||||
private void sendZoomValue(string zoom_pulse)
|
private void sendZoomValue(string zoom_pulse)
|
||||||
{
|
{
|
||||||
// clamp values to allowed range
|
// clamp values to allowed range
|
||||||
if (int.Parse(zoom_pulse) < min_zoom_pulse)
|
if (int.Parse(zoom_pulse) < MIN_ZOOM_PULSE)
|
||||||
{
|
{
|
||||||
zoom_pulse = min_zoom_pulse.ToString();
|
zoom_pulse = MIN_ZOOM_PULSE.ToString();
|
||||||
}
|
}
|
||||||
if (int.Parse(zoom_pulse) > max_zoom_pulse)
|
if (int.Parse(zoom_pulse) > MAX_ZOOM_PULSE)
|
||||||
{
|
{
|
||||||
zoom_pulse = max_zoom_pulse.ToString();
|
zoom_pulse = MAX_ZOOM_PULSE.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + cam_ip + "/stw-cgi/ptzcontrol.cgi?msubmenu=absolute&action=control&ZoomPulse=" + zoom_pulse);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + camera.camera_ip + "/stw-cgi/ptzcontrol.cgi?msubmenu=absolute&action=control&ZoomPulse=" + zoom_pulse);
|
||||||
request.Credentials = new NetworkCredential(MainForm.cam_username, MainForm.cam_password);
|
request.Credentials = new NetworkCredential(MainForm.cam_username, MainForm.cam_password);
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||||
}
|
}
|
||||||
@@ -76,7 +77,7 @@ namespace robospot_camera_finder
|
|||||||
|
|
||||||
private void sendZoomValueManual(string zoom_value)
|
private void sendZoomValueManual(string zoom_value)
|
||||||
{
|
{
|
||||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + cam_ip + "/stw-cgi/ptzcontrol.cgi?msubmenu=continuous&NormalizedSpeed=True&action=control&Channel=0&Zoom=" + zoom_value);
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + camera.camera_ip + "/stw-cgi/ptzcontrol.cgi?msubmenu=continuous&NormalizedSpeed=True&action=control&Channel=0&Zoom=" + zoom_value);
|
||||||
request.Credentials = new NetworkCredential(MainForm.cam_username, MainForm.cam_password);
|
request.Credentials = new NetworkCredential(MainForm.cam_username, MainForm.cam_password);
|
||||||
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
|
||||||
}
|
}
|
||||||
@@ -105,13 +106,13 @@ namespace robospot_camera_finder
|
|||||||
|
|
||||||
private void btnZoomMax_Click(object sender, EventArgs e)
|
private void btnZoomMax_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
tbZoom.Value = max_zoom_pulse;
|
tbZoom.Value = MAX_ZOOM_PULSE;
|
||||||
sendZoomValue(tbZoom.Value.ToString());
|
sendZoomValue(tbZoom.Value.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnZoomMin_Click(object sender, EventArgs e)
|
private void btnZoomMin_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
tbZoom.Value = min_zoom_pulse;
|
tbZoom.Value = MIN_ZOOM_PULSE;
|
||||||
sendZoomValue(tbZoom.Value.ToString());
|
sendZoomValue(tbZoom.Value.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,12 +131,12 @@ namespace robospot_camera_finder
|
|||||||
{
|
{
|
||||||
if (zoomTestSeqFlag)
|
if (zoomTestSeqFlag)
|
||||||
{
|
{
|
||||||
tbZoom.Value = min_zoom_pulse;
|
tbZoom.Value = MIN_ZOOM_PULSE;
|
||||||
sendZoomValue(tbZoom.Value.ToString());
|
sendZoomValue(tbZoom.Value.ToString());
|
||||||
zoomTestSeqFlag = false;
|
zoomTestSeqFlag = false;
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
tbZoom.Value = max_zoom_pulse;
|
tbZoom.Value = MAX_ZOOM_PULSE;
|
||||||
sendZoomValue(tbZoom.Value.ToString());
|
sendZoomValue(tbZoom.Value.ToString());
|
||||||
zoomTestSeqFlag = true;
|
zoomTestSeqFlag = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net9.0-windows7.0</TargetFramework>
|
<TargetFramework>net9.0-windows</TargetFramework>
|
||||||
<RootNamespace>robospot_camera_finder</RootNamespace>
|
<RootNamespace>robospot_camera_finder</RootNamespace>
|
||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
@@ -13,13 +13,20 @@
|
|||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<DebugType>none</DebugType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="favicon.ico" />
|
<Content Include="favicon.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="LibVLCSharp" Version="3.8.2" />
|
<PackageReference Include="LibVLCSharp" Version="3.8.2" />
|
||||||
<PackageReference Include="LibVLCSharp.Forms" Version="3.8.2" />
|
|
||||||
<PackageReference Include="LibVLCSharp.WinForms" Version="3.8.2" />
|
<PackageReference Include="LibVLCSharp.WinForms" Version="3.8.2" />
|
||||||
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.20" />
|
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.20" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user