Show server address and add disconnect button in Playnite addon settings
parent
14a92bdc3e
commit
37f9027a80
|
@ -15,29 +15,44 @@
|
|||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
<RowDefinition Height="auto" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="75" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" Content="Install Directory" />
|
||||
<TextBox Name="PART_InstallDirectory" Grid.Column="2" Text="{Binding InstallDirectory}" />
|
||||
<Button Grid.Column="4" Content="Browse" Click="SelectInstallDirectory_Click" VerticalAlignment="Center" Grid.ColumnSpan="2" />
|
||||
</Grid>
|
||||
|
||||
<Grid Height="40" Grid.Row="1">
|
||||
<Grid Grid.Row="1" Margin="0,10,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="100" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="10" />
|
||||
<ColumnDefinition Width="75" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Column="0" Content="Server Address" />
|
||||
<TextBox Name="PART_ServerAddress" Grid.Column="2" Text="{Binding ServerAddress}" IsEnabled="false" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="2" Margin="0,10,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button Name="PART_AuthenticationButton" Content="Authenticate" Grid.Column="0" Click="AuthenticateButton_Click" VerticalAlignment="Center" />
|
||||
<Label Name="PART_AuthenticateLabel" Margin="20,0,0,0" VerticalAlignment="Center" Grid.Column="1" />
|
||||
<Button Name="PART_DisconnectButton" Content="Disconnect" Grid.Column="0" Click="DisconnectButton_Click" VerticalAlignment="Center" />
|
||||
<Label Name="PART_AuthenticateLabel" Margin="20,0,0,0" VerticalAlignment="Center" Grid.Column="3" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -39,6 +39,7 @@ namespace LANCommander.PlaynitePlugin
|
|||
PART_AuthenticateLabel.Content = "Checking authentication status...";
|
||||
PART_AuthenticationButton.IsEnabled = false;
|
||||
PART_InstallDirectory.Text = Settings.InstallDirectory;
|
||||
PART_ServerAddress.Text = Settings.ServerAddress;
|
||||
|
||||
var token = new AuthToken()
|
||||
{
|
||||
|
@ -57,11 +58,17 @@ namespace LANCommander.PlaynitePlugin
|
|||
{
|
||||
PART_AuthenticateLabel.Content = "Authentication failed!";
|
||||
PART_AuthenticationButton.IsEnabled = true;
|
||||
PART_AuthenticationButton.Visibility = Visibility.Visible;
|
||||
PART_DisconnectButton.IsEnabled = false;
|
||||
PART_DisconnectButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
else
|
||||
{
|
||||
PART_AuthenticateLabel.Content = "Connection established!";
|
||||
PART_AuthenticationButton.IsEnabled = false;
|
||||
PART_AuthenticationButton.Visibility = Visibility.Hidden;
|
||||
PART_DisconnectButton.IsEnabled = true;
|
||||
PART_DisconnectButton.Visibility = Visibility.Visible;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -79,6 +86,21 @@ namespace LANCommander.PlaynitePlugin
|
|||
authWindow.Closed += AuthWindow_Closed;
|
||||
}
|
||||
|
||||
private void DisconnectButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Plugin.Settings.AccessToken = String.Empty;
|
||||
Plugin.Settings.RefreshToken = String.Empty;
|
||||
Plugin.LANCommander.Token = null;
|
||||
|
||||
Plugin.SavePluginSettings(Plugin.Settings);
|
||||
|
||||
PART_AuthenticateLabel.Content = "Not Authenticated";
|
||||
PART_AuthenticationButton.IsEnabled = true;
|
||||
PART_AuthenticationButton.Visibility = Visibility.Visible;
|
||||
PART_DisconnectButton.IsEnabled = false;
|
||||
PART_DisconnectButton.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
private void AuthWindow_Closed(object sender, EventArgs e)
|
||||
{
|
||||
UpdateAuthenticationButtonVisibility();
|
||||
|
|
Loading…
Reference in New Issue