diff --git a/PettingZoo.Settings.LiteDB/LiteDBConnectionSettingsRepository.cs b/PettingZoo.Settings.LiteDB/LiteDBConnectionSettingsRepository.cs
index 757ea86..41f237c 100644
--- a/PettingZoo.Settings.LiteDB/LiteDBConnectionSettingsRepository.cs
+++ b/PettingZoo.Settings.LiteDB/LiteDBConnectionSettingsRepository.cs
@@ -22,7 +22,7 @@ namespace PettingZoo.Settings.LiteDB
var lastUsed = await collection.FindOneAsync(r => true);
if (lastUsed == null)
- return new StoredConnectionSettings(Guid.Empty, "", false, ConnectionSettings.Default);
+ return new StoredConnectionSettings(Guid.Empty, "", true, ConnectionSettings.Default);
return new StoredConnectionSettings(
Guid.Empty,
diff --git a/PettingZoo/Images/Connecting.svg b/PettingZoo/Images/Connecting.svg
new file mode 100644
index 0000000..59b1de6
--- /dev/null
+++ b/PettingZoo/Images/Connecting.svg
@@ -0,0 +1,123 @@
+
+
+
+
diff --git a/PettingZoo/PettingZoo.csproj b/PettingZoo/PettingZoo.csproj
index 0ad689f..cc761f0 100644
--- a/PettingZoo/PettingZoo.csproj
+++ b/PettingZoo/PettingZoo.csproj
@@ -19,6 +19,7 @@
+
@@ -53,6 +54,7 @@
+
diff --git a/PettingZoo/UI/Main/MainWindow.xaml b/PettingZoo/UI/Main/MainWindow.xaml
index 6a65b2e..a5898da 100644
--- a/PettingZoo/UI/Main/MainWindow.xaml
+++ b/PettingZoo/UI/Main/MainWindow.xaml
@@ -78,7 +78,12 @@
-
+
+
+
+
+
+
diff --git a/PettingZoo/UI/Main/MainWindow.xaml.cs b/PettingZoo/UI/Main/MainWindow.xaml.cs
index d017e71..fda439b 100644
--- a/PettingZoo/UI/Main/MainWindow.xaml.cs
+++ b/PettingZoo/UI/Main/MainWindow.xaml.cs
@@ -9,8 +9,6 @@ using PettingZoo.UI.Connection;
using PettingZoo.UI.Subscribe;
using PettingZoo.UI.Tab;
-// TODO improve readability of the connection status (especially when connecting/disconnected)
-
namespace PettingZoo.UI.Main
{
#pragma warning disable CA1001 // MainWindow can't be IDisposable, handled instead in OnDispatcherShutDownStarted
diff --git a/PettingZoo/UI/Main/MainWindowViewModel.cs b/PettingZoo/UI/Main/MainWindowViewModel.cs
index b16d70e..f8d4470 100644
--- a/PettingZoo/UI/Main/MainWindowViewModel.cs
+++ b/PettingZoo/UI/Main/MainWindowViewModel.cs
@@ -13,6 +13,14 @@ using PettingZoo.UI.Tab.Undocked;
namespace PettingZoo.UI.Main
{
+ public enum ConnectionStatusType
+ {
+ Connecting,
+ Ok,
+ Error
+ }
+
+
public class MainWindowViewModel : BaseViewModel, IAsyncDisposable, ITabHost
{
private readonly IConnectionFactory connectionFactory;
@@ -34,14 +42,27 @@ namespace PettingZoo.UI.Main
private readonly DelegateCommand closeTabCommand;
private readonly DelegateCommand undockTabCommand;
+ private ConnectionStatusType connectionStatusType;
+
public string ConnectionStatus
{
get => connectionStatus;
private set => SetField(ref connectionStatus, value);
}
-
-
+
+
+ public ConnectionStatusType ConnectionStatusType
+ {
+ get => connectionStatusType;
+ set => SetField(ref connectionStatusType, value, otherPropertiesChanged: new [] { nameof(ConnectionStatusOk), nameof(ConnectionStatusError), nameof(ConnectionStatusConnecting) });
+ }
+
+ public Visibility ConnectionStatusOk => ConnectionStatusType == ConnectionStatusType.Ok ? Visibility.Visible : Visibility.Collapsed;
+ public Visibility ConnectionStatusError => ConnectionStatusType == ConnectionStatusType.Error ? Visibility.Visible : Visibility.Collapsed;
+ public Visibility ConnectionStatusConnecting => ConnectionStatusType == ConnectionStatusType.Connecting ? Visibility.Visible : Visibility.Collapsed;
+
+
public ObservableCollection Tabs { get; }
public ITab? ActiveTab
@@ -86,6 +107,7 @@ namespace PettingZoo.UI.Main
this.tabContainer = tabContainer;
connectionStatus = GetConnectionStatus(null);
+ connectionStatusType = ConnectionStatusType.Error;
Tabs = new ObservableCollection();
connectCommand = new DelegateCommand(ConnectExecute);
@@ -119,7 +141,7 @@ namespace PettingZoo.UI.Main
connection = connectionFactory.CreateConnection(new ConnectionParams(
connectionSettings.Host, connectionSettings.VirtualHost, connectionSettings.Port,
- connectionSettings.Username, connectionSettings.Password!));
+ connectionSettings.Username, connectionSettings.Password));
connection.StatusChanged += ConnectionStatusChanged;
if (connectionSettings.Subscribe)
@@ -152,6 +174,7 @@ namespace PettingZoo.UI.Main
}
ConnectionStatus = GetConnectionStatus(null);
+ ConnectionStatusType = ConnectionStatusType.Error;
ConnectionChanged();
}
@@ -271,6 +294,12 @@ namespace PettingZoo.UI.Main
private void ConnectionStatusChanged(object? sender, StatusChangedEventArgs args)
{
ConnectionStatus = GetConnectionStatus(args);
+ ConnectionStatusType = args.Status switch
+ {
+ Core.Connection.ConnectionStatus.Connected => ConnectionStatusType.Ok,
+ Core.Connection.ConnectionStatus.Connecting => ConnectionStatusType.Connecting,
+ _ => ConnectionStatusType.Error
+ };
}