refactor(gui,api,logging): UI layout tweaks, cleanup, and improved diagnostics
- CbBxCamType now spans the full width of CbBxCameraModel - BtnTest_Click moved to the bottom of AiQ_GUI.cs for easier testing/navigation - Unused using directives removed across files - Login credentials factored out and reused in MobileAPI.cs - VLC.cs Capture function reviewed and superseded by TakeSnapshot - InsertCamTab implementation updated to avoid use of `var` - Misleading '// Non-ONVIF cameras' comment corrected - Added Level.Debug logging, accessible only to developers, for detailed diagnostics
This commit is contained in:
114
AiQ_GUI.cs
114
AiQ_GUI.cs
@@ -1,16 +1,10 @@
|
||||
using AiQ_GUI.AiQ_Tests;
|
||||
using AiQ_GUI.Mobile_Tests;
|
||||
using DocumentFormat.OpenXml.Drawing.Diagrams;
|
||||
using LibVLCSharp.Shared;
|
||||
using LibVLCSharp.WinForms;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using Newtonsoft.Json;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Net.Http.Json;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Forms;
|
||||
using Color = System.Drawing.Color;
|
||||
|
||||
namespace AiQ_GUI
|
||||
@@ -20,7 +14,8 @@ namespace AiQ_GUI
|
||||
ERROR,
|
||||
WARNING,
|
||||
LOG,
|
||||
Success
|
||||
Success,
|
||||
DEBUG
|
||||
}
|
||||
|
||||
public partial class MainForm : Form
|
||||
@@ -112,7 +107,6 @@ namespace AiQ_GUI
|
||||
await CheckHWOnline;
|
||||
Flags.Start = false;
|
||||
CbBxCamType.Text = "AiQ"; // Default to AiQ cameras
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -121,11 +115,11 @@ namespace AiQ_GUI
|
||||
// Remove previous tabs
|
||||
if (CurrentTabs != null)
|
||||
{
|
||||
foreach (var tab in CurrentTabs)
|
||||
foreach (TabPage tab in CurrentTabs)
|
||||
TabImagesandSettings.TabPages.Remove(tab);
|
||||
}
|
||||
|
||||
var tabsToInsert = new List<TabPage>();
|
||||
List<TabPage> tabsToInsert = new List<TabPage>();
|
||||
|
||||
if (camType == "Mobile")
|
||||
tabsToInsert.AddRange([Video, Mobile]);
|
||||
@@ -134,7 +128,7 @@ namespace AiQ_GUI
|
||||
|
||||
int idx = Math.Min(3, TabImagesandSettings.TabPages.Count);
|
||||
|
||||
foreach (var tab in tabsToInsert)
|
||||
foreach (TabPage tab in tabsToInsert)
|
||||
{
|
||||
if (!TabImagesandSettings.TabPages.Contains(tab))
|
||||
TabImagesandSettings.TabPages.Insert(idx++, tab);
|
||||
@@ -169,7 +163,7 @@ namespace AiQ_GUI
|
||||
|
||||
if (lds.User == "Bradley" || lds.User == "Sophie")
|
||||
BtnTest.Visible = true;
|
||||
|
||||
|
||||
TxBxCheckValid(TxBxPsuIP); // Set save button color if valid
|
||||
}
|
||||
|
||||
@@ -563,7 +557,7 @@ namespace AiQ_GUI
|
||||
return;
|
||||
}
|
||||
|
||||
// Non-ONVIF cameras
|
||||
// AiQ cameras
|
||||
if (!await Network.PingIP(ipOnly))
|
||||
{
|
||||
CbBxFoundCams.BackColor = Color.Red;
|
||||
@@ -660,31 +654,37 @@ namespace AiQ_GUI
|
||||
// ***** Helper functions *****
|
||||
public void AddToActionsList(string Mssg, Level Lvl = Level.LOG)
|
||||
{
|
||||
if (Lvl == Level.ERROR)
|
||||
{
|
||||
Logging.LogErrorMessage(Mssg);
|
||||
RhTxBxActions.SelectionColor = Color.IndianRed;
|
||||
}
|
||||
else if (Lvl == Level.WARNING)
|
||||
{
|
||||
Logging.LogWarningMessage(Mssg);
|
||||
RhTxBxActions.SelectionColor = Color.Orange;
|
||||
}
|
||||
else if (Lvl == Level.LOG)
|
||||
{
|
||||
Logging.LogMessage(Mssg);
|
||||
RhTxBxActions.SelectionColor = Color.White;
|
||||
}
|
||||
else if (Lvl == Level.Success)
|
||||
{
|
||||
Logging.LogMessage(Mssg);
|
||||
RhTxBxActions.SelectionColor = Color.LightGreen;
|
||||
}
|
||||
// DEBUG messages only visible to Bradley
|
||||
if (Lvl == Level.DEBUG && CbBxUserName.Text != "Bradley")
|
||||
return;
|
||||
|
||||
RhTxBxActions.AppendText(Mssg + Environment.NewLine);
|
||||
RhTxBxActions.SelectionStart = RhTxBxActions.Text.Length;
|
||||
RhTxBxActions.SelectionColor = SystemColors.Control;
|
||||
RhTxBxActions.ScrollToCaret();
|
||||
if (Lvl == Level.ERROR)
|
||||
Logging.LogErrorMessage(Mssg);
|
||||
|
||||
else if (Lvl == Level.WARNING)
|
||||
Logging.LogWarningMessage(Mssg);
|
||||
|
||||
else if (Lvl == Level.DEBUG)
|
||||
Logging.LogMessage("[DEBUG]" + Mssg);
|
||||
|
||||
else
|
||||
Logging.LogMessage(Mssg);
|
||||
|
||||
RhTxBxActions.SelectionColor = Lvl switch
|
||||
{
|
||||
Level.ERROR => Color.IndianRed,
|
||||
Level.WARNING => Color.Orange,
|
||||
Level.DEBUG => Color.LightBlue,
|
||||
Level.Success => Color.LightGreen,
|
||||
_ => Color.White
|
||||
};
|
||||
if (Lvl == Level.DEBUG)
|
||||
RhTxBxActions.AppendText("[DEBUG] " + Mssg + Environment.NewLine);
|
||||
else
|
||||
RhTxBxActions.AppendText(Mssg + Environment.NewLine);
|
||||
RhTxBxActions.SelectionStart = RhTxBxActions.Text.Length;
|
||||
RhTxBxActions.SelectionColor = SystemColors.Control;
|
||||
RhTxBxActions.ScrollToCaret();
|
||||
}
|
||||
|
||||
|
||||
@@ -1444,26 +1444,7 @@ namespace AiQ_GUI
|
||||
}
|
||||
BtnFactoryDefault.BackColor = Color.Green;
|
||||
}
|
||||
|
||||
// ***** Test & Debug *****
|
||||
private async void BtnTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
Stopwatch stopWatchTest = Stopwatch.StartNew();
|
||||
|
||||
//StatsExcel excelExporter = new();
|
||||
//excelExporter.ExportDatabaseToExcel();
|
||||
//await MobileTests.CheckFirmwareAsync();
|
||||
//FlexiAPI.GetVersions(CamOnTest.IP).Wait();
|
||||
//VLC.Play(VidView);
|
||||
//await Task.Delay(5000);
|
||||
//VLC.TakeSnapshot(VidView);
|
||||
SSH.MobiletxtCheck("100.118.196.113");
|
||||
|
||||
// await MobileAPI.SetDayModeAsync();
|
||||
|
||||
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.LOG);
|
||||
}
|
||||
public static Label MakeNewLabel(string text, bool isRed, int yLoc)
|
||||
public static Label MakeNewLabel(string text, bool isRed, int yLoc)
|
||||
{
|
||||
return new Label
|
||||
{
|
||||
@@ -1504,6 +1485,25 @@ namespace AiQ_GUI
|
||||
VLC.Play(VidView);
|
||||
}
|
||||
}
|
||||
// ***** Test & Debug *****
|
||||
private async void BtnTest_Click(object sender, EventArgs e)
|
||||
{
|
||||
Stopwatch stopWatchTest = Stopwatch.StartNew();
|
||||
|
||||
//StatsExcel excelExporter = new();
|
||||
//excelExporter.ExportDatabaseToExcel();
|
||||
//await MobileTests.CheckFirmwareAsync();
|
||||
//FlexiAPI.GetVersions(CamOnTest.IP).Wait();
|
||||
//VLC.Play(VidView);
|
||||
//await Task.Delay(5000);
|
||||
//VLC.TakeSnapshot(VidView);
|
||||
SSH.MobiletxtCheck("100.118.196.113");
|
||||
|
||||
// await MobileAPI.SetDayModeAsync();
|
||||
|
||||
AddToActionsList("RunTime " + stopWatchTest.Elapsed.ToString(@"hh\:mm\:ss\.ff"), Level.DEBUG);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user