Improved connection status readability with icons
Fixed default connection not storing "guest" password
This commit is contained in:
parent
28d3548088
commit
75ad22293b
@ -22,7 +22,7 @@ namespace PettingZoo.Settings.LiteDB
|
|||||||
|
|
||||||
var lastUsed = await collection.FindOneAsync(r => true);
|
var lastUsed = await collection.FindOneAsync(r => true);
|
||||||
if (lastUsed == null)
|
if (lastUsed == null)
|
||||||
return new StoredConnectionSettings(Guid.Empty, "", false, ConnectionSettings.Default);
|
return new StoredConnectionSettings(Guid.Empty, "", true, ConnectionSettings.Default);
|
||||||
|
|
||||||
return new StoredConnectionSettings(
|
return new StoredConnectionSettings(
|
||||||
Guid.Empty,
|
Guid.Empty,
|
||||||
|
123
PettingZoo/Images/Connecting.svg
Normal file
123
PettingZoo/Images/Connecting.svg
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
|
||||||
|
<svg
|
||||||
|
version="1.1"
|
||||||
|
id="Capa_1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
viewBox="0 0 22 26"
|
||||||
|
xml:space="preserve"
|
||||||
|
sodipodi:docname="Working.svg"
|
||||||
|
width="22"
|
||||||
|
height="26"
|
||||||
|
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
|
||||||
|
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||||
|
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
||||||
|
id="defs61">
|
||||||
|
|
||||||
|
|
||||||
|
</defs><sodipodi:namedview
|
||||||
|
id="namedview59"
|
||||||
|
pagecolor="#ffffff"
|
||||||
|
bordercolor="#666666"
|
||||||
|
borderopacity="1.0"
|
||||||
|
inkscape:pageshadow="2"
|
||||||
|
inkscape:pageopacity="0.0"
|
||||||
|
inkscape:pagecheckerboard="0"
|
||||||
|
showgrid="false"
|
||||||
|
inkscape:zoom="14.344828"
|
||||||
|
inkscape:cx="-7.0060096"
|
||||||
|
inkscape:cy="1.6382212"
|
||||||
|
inkscape:window-width="1920"
|
||||||
|
inkscape:window-height="1017"
|
||||||
|
inkscape:window-x="1912"
|
||||||
|
inkscape:window-y="-8"
|
||||||
|
inkscape:window-maximized="1"
|
||||||
|
inkscape:current-layer="Capa_1" />
|
||||||
|
<g
|
||||||
|
id="g24"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
<path
|
||||||
|
style="fill:#d0e8f9"
|
||||||
|
d="m 48,43 h -2 v 0 c -3.633,-1.453 -6,-4.861 -6,-8.64 v -3.36 h 14 v 3.36 c 0,3.779 -2.367,7.187 -6,8.64 z"
|
||||||
|
id="path14" />
|
||||||
|
<path
|
||||||
|
style="fill:#d0e8f9"
|
||||||
|
d="m 46,43 h 2 v 0 c 3.633,1.453 6,4.861 6,8.64 v 3.36 h -14 v -3.36 c 0,-3.779 2.367,-7.187 6,-8.64 z"
|
||||||
|
id="path16" />
|
||||||
|
<g
|
||||||
|
id="g22">
|
||||||
|
<path
|
||||||
|
style="fill:#556080"
|
||||||
|
d="m 37,32 h 1 2 17 c 0.553,0 1,-0.448 1,-1 0,-0.552 -0.447,-1 -1,-1 h -17 -2 -1 c -0.553,0 -1,0.448 -1,1 0,0.552 0.447,1 1,1 z"
|
||||||
|
id="path18" />
|
||||||
|
<path
|
||||||
|
style="fill:#556080"
|
||||||
|
d="m 56.999,53.998 h -18 c -0.003,0 -0.006,0.002 -0.01,0.002 h -1.989 c -0.553,0 -1,0.448 -1,1 0,0.552 0.447,1 1,1 h 3 c 0.003,0 0.006,-0.002 0.01,-0.002 h 16.989 c 0.553,0 1,-0.448 1,-1 0,-0.552 -0.447,-1 -1,-1 z"
|
||||||
|
id="path20" />
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g28"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g30"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g32"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g34"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g36"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g38"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g40"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g42"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g44"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g46"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g48"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g50"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g52"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g54"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g56"
|
||||||
|
transform="translate(-36,-30)">
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 2.7 KiB |
@ -19,6 +19,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Remove="Images\Connecting.svg" />
|
||||||
<None Remove="Images\Dock.svg" />
|
<None Remove="Images\Dock.svg" />
|
||||||
<None Remove="Images\Error.svg" />
|
<None Remove="Images\Error.svg" />
|
||||||
<None Remove="Images\Ok.svg" />
|
<None Remove="Images\Ok.svg" />
|
||||||
@ -53,6 +54,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="Images\Undock.svg" />
|
<Resource Include="Images\Undock.svg" />
|
||||||
|
<Resource Include="Images\Connecting.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -78,7 +78,12 @@
|
|||||||
</ToolBar>
|
</ToolBar>
|
||||||
<StatusBar DockPanel.Dock="Bottom">
|
<StatusBar DockPanel.Dock="Bottom">
|
||||||
<StatusBarItem>
|
<StatusBarItem>
|
||||||
<TextBlock Text="{Binding ConnectionStatus}"/>
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Image Source="{svgc:SvgImage Source=/Images/Connecting.svg, AppName=PettingZoo}" Width="16" Height="16" Margin="4" Visibility="{Binding ConnectionStatusConnecting}" />
|
||||||
|
<Image Source="{svgc:SvgImage Source=/Images/Ok.svg, AppName=PettingZoo}" Width="16" Height="16" Margin="4" Visibility="{Binding ConnectionStatusOk}" />
|
||||||
|
<Image Source="{svgc:SvgImage Source=/Images/Error.svg, AppName=PettingZoo}" Width="16" Height="16" Margin="4" Visibility="{Binding ConnectionStatusError}" />
|
||||||
|
<TextBlock Text="{Binding ConnectionStatus}" VerticalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
</StatusBarItem>
|
</StatusBarItem>
|
||||||
</StatusBar>
|
</StatusBar>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
@ -9,8 +9,6 @@ using PettingZoo.UI.Connection;
|
|||||||
using PettingZoo.UI.Subscribe;
|
using PettingZoo.UI.Subscribe;
|
||||||
using PettingZoo.UI.Tab;
|
using PettingZoo.UI.Tab;
|
||||||
|
|
||||||
// TODO improve readability of the connection status (especially when connecting/disconnected)
|
|
||||||
|
|
||||||
namespace PettingZoo.UI.Main
|
namespace PettingZoo.UI.Main
|
||||||
{
|
{
|
||||||
#pragma warning disable CA1001 // MainWindow can't be IDisposable, handled instead in OnDispatcherShutDownStarted
|
#pragma warning disable CA1001 // MainWindow can't be IDisposable, handled instead in OnDispatcherShutDownStarted
|
||||||
|
@ -13,6 +13,14 @@ using PettingZoo.UI.Tab.Undocked;
|
|||||||
|
|
||||||
namespace PettingZoo.UI.Main
|
namespace PettingZoo.UI.Main
|
||||||
{
|
{
|
||||||
|
public enum ConnectionStatusType
|
||||||
|
{
|
||||||
|
Connecting,
|
||||||
|
Ok,
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class MainWindowViewModel : BaseViewModel, IAsyncDisposable, ITabHost
|
public class MainWindowViewModel : BaseViewModel, IAsyncDisposable, ITabHost
|
||||||
{
|
{
|
||||||
private readonly IConnectionFactory connectionFactory;
|
private readonly IConnectionFactory connectionFactory;
|
||||||
@ -34,6 +42,8 @@ namespace PettingZoo.UI.Main
|
|||||||
private readonly DelegateCommand closeTabCommand;
|
private readonly DelegateCommand closeTabCommand;
|
||||||
private readonly DelegateCommand undockTabCommand;
|
private readonly DelegateCommand undockTabCommand;
|
||||||
|
|
||||||
|
private ConnectionStatusType connectionStatusType;
|
||||||
|
|
||||||
|
|
||||||
public string ConnectionStatus
|
public string ConnectionStatus
|
||||||
{
|
{
|
||||||
@ -42,6 +52,17 @@ namespace PettingZoo.UI.Main
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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<ITab> Tabs { get; }
|
public ObservableCollection<ITab> Tabs { get; }
|
||||||
|
|
||||||
public ITab? ActiveTab
|
public ITab? ActiveTab
|
||||||
@ -86,6 +107,7 @@ namespace PettingZoo.UI.Main
|
|||||||
this.tabContainer = tabContainer;
|
this.tabContainer = tabContainer;
|
||||||
|
|
||||||
connectionStatus = GetConnectionStatus(null);
|
connectionStatus = GetConnectionStatus(null);
|
||||||
|
connectionStatusType = ConnectionStatusType.Error;
|
||||||
|
|
||||||
Tabs = new ObservableCollection<ITab>();
|
Tabs = new ObservableCollection<ITab>();
|
||||||
connectCommand = new DelegateCommand(ConnectExecute);
|
connectCommand = new DelegateCommand(ConnectExecute);
|
||||||
@ -119,7 +141,7 @@ namespace PettingZoo.UI.Main
|
|||||||
|
|
||||||
connection = connectionFactory.CreateConnection(new ConnectionParams(
|
connection = connectionFactory.CreateConnection(new ConnectionParams(
|
||||||
connectionSettings.Host, connectionSettings.VirtualHost, connectionSettings.Port,
|
connectionSettings.Host, connectionSettings.VirtualHost, connectionSettings.Port,
|
||||||
connectionSettings.Username, connectionSettings.Password!));
|
connectionSettings.Username, connectionSettings.Password));
|
||||||
connection.StatusChanged += ConnectionStatusChanged;
|
connection.StatusChanged += ConnectionStatusChanged;
|
||||||
|
|
||||||
if (connectionSettings.Subscribe)
|
if (connectionSettings.Subscribe)
|
||||||
@ -152,6 +174,7 @@ namespace PettingZoo.UI.Main
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConnectionStatus = GetConnectionStatus(null);
|
ConnectionStatus = GetConnectionStatus(null);
|
||||||
|
ConnectionStatusType = ConnectionStatusType.Error;
|
||||||
ConnectionChanged();
|
ConnectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,6 +294,12 @@ namespace PettingZoo.UI.Main
|
|||||||
private void ConnectionStatusChanged(object? sender, StatusChangedEventArgs args)
|
private void ConnectionStatusChanged(object? sender, StatusChangedEventArgs args)
|
||||||
{
|
{
|
||||||
ConnectionStatus = GetConnectionStatus(args);
|
ConnectionStatus = GetConnectionStatus(args);
|
||||||
|
ConnectionStatusType = args.Status switch
|
||||||
|
{
|
||||||
|
Core.Connection.ConnectionStatus.Connected => ConnectionStatusType.Ok,
|
||||||
|
Core.Connection.ConnectionStatus.Connecting => ConnectionStatusType.Connecting,
|
||||||
|
_ => ConnectionStatusType.Error
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user