- Replaced single TabPage CurrentTab with List<TabPage> CurrentTabs to support multiple tabs.

- Added new tab called Video

- Removed unused tabs on load (Soak, Mobile, Video, Images).

- Refactored InsertCamTab():

- Uses CurrentTabs to manage multiple tabs per camera type.

Mobile → inserts Video + Mobile tabs.
AiQ → inserts Images + Soak tabs.

-Cleans up previous tabs before inserting new ones.

-Updated BtnTest_Click():
Added 5-second delay before snapshot.
Takes snapshot after video starts playing.

- New file created VLC.cs
Streams the given IP into the Video tab and takes a snapshot
This commit is contained in:
2026-01-12 16:30:04 +00:00
parent 90b3f7caff
commit 4a2e874b9d
5 changed files with 200 additions and 18 deletions

View File

@@ -1,4 +1,6 @@
using AiQ_GUI.AiQ_Tests;
using LibVLCSharp.Shared;
using LibVLCSharp.WinForms;
using Newtonsoft.Json;
using System.ComponentModel;
using System.Diagnostics;
@@ -38,7 +40,8 @@ namespace AiQ_GUI
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public static MainForm? Instance { get; private set; }
private TabPage CurrentTab; // remember what's currently inserted
private List<TabPage> CurrentTabs;
public MainForm()
{
@@ -56,6 +59,9 @@ namespace AiQ_GUI
Network.Initialize("admin", "admin"); // Initialise HTTP client with basic auth creds.
VidView.MediaPlayer = new MediaPlayer(VLC.libVLC); // Initialize VideoView's MediaPlayer
if (await Network.PingIP("8.8.8.8")) // Ping to check if we're online
{
if (!GoogleAPI.Setup())
@@ -70,6 +76,8 @@ namespace AiQ_GUI
// Hide on default so will only show based on the camera type selected later
TabImagesandSettings.TabPages.Remove(TabSoak);
TabImagesandSettings.TabPages.Remove(Mobile);
TabImagesandSettings.TabPages.Remove(Video);
TabImagesandSettings.TabPages.Remove(TabImages);
GUIUpdate.GUIVerShort = await guiVerTask; // Guess the GUI version will be first to finish
this.Name = "AiQ GUI V" + GUIUpdate.GUIVerShort;
@@ -106,28 +114,32 @@ namespace AiQ_GUI
private void InsertCamTab(string camType)
{
// Remove previously inserted tab if present
if (CurrentTab != null && TabImagesandSettings.TabPages.Contains(CurrentTab))
TabImagesandSettings.TabPages.Remove(CurrentTab);
// Choose desired tab
TabPage desired = null;
if (camType == "Mobile") desired = Mobile;
else if (camType == "AiQ") desired = TabSoak;
// Insert desired tab if any
if (desired != null && !TabImagesandSettings.TabPages.Contains(desired))
// Remove previous tabs
if (CurrentTabs != null)
{
int idx = Math.Min(3, TabImagesandSettings.TabPages.Count);
TabImagesandSettings.TabPages.Insert(idx, desired);
CurrentTab = desired;
foreach (var tab in CurrentTabs)
TabImagesandSettings.TabPages.Remove(tab);
}
else
var tabsToInsert = new List<TabPage>();
if (camType == "Mobile")
tabsToInsert.AddRange([Video, Mobile]);
else if (camType == "AiQ")
tabsToInsert.AddRange([TabImages, TabSoak]);
int idx = Math.Min(3, TabImagesandSettings.TabPages.Count);
foreach (var tab in tabsToInsert)
{
CurrentTab = desired; // may be null
if (!TabImagesandSettings.TabPages.Contains(tab))
TabImagesandSettings.TabPages.Insert(idx++, tab);
}
CurrentTabs = tabsToInsert;
}
private async void CbBxCamType_SelectedIndexChanged(object sender, EventArgs e)
{
CbBxCameraModel.Items.Clear();
@@ -1437,6 +1449,10 @@ namespace AiQ_GUI
//StatsExcel excelExporter = new();
//excelExporter.ExportDatabaseToExcel();
//await MobilePreTest.CheckFirmwareAsync();
VLC.Play(VidView);
await Task.Delay(5000);
VLC.TakeSnapshot(VidView);
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.LOG);
}
@@ -1466,3 +1482,4 @@ namespace AiQ_GUI
}
}