Show server address and add disconnect button in Playnite addon settings

save-path-regex
Pat Hartl 2023-11-03 00:07:20 -05:00
parent 14a92bdc3e
commit 37f9027a80
2 changed files with 42 additions and 5 deletions

View File

@ -15,29 +15,44 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
<RowDefinition Height="auto" /> <RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid Grid.Row="0"> <Grid Grid.Row="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="100" />
<ColumnDefinition Width="10" /> <ColumnDefinition Width="10" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="10" /> <ColumnDefinition Width="10" />
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="75" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Install Directory" /> <Label Grid.Column="0" Content="Install Directory" />
<TextBox Name="PART_InstallDirectory" Grid.Column="2" Text="{Binding InstallDirectory}" /> <TextBox Name="PART_InstallDirectory" Grid.Column="2" Text="{Binding InstallDirectory}" />
<Button Grid.Column="4" Content="Browse" Click="SelectInstallDirectory_Click" VerticalAlignment="Center" Grid.ColumnSpan="2" /> <Button Grid.Column="4" Content="Browse" Click="SelectInstallDirectory_Click" VerticalAlignment="Center" Grid.ColumnSpan="2" />
</Grid> </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> <Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" /> <ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Name="PART_AuthenticationButton" Content="Authenticate" Grid.Column="0" Click="AuthenticateButton_Click" VerticalAlignment="Center" /> <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>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@ -39,6 +39,7 @@ namespace LANCommander.PlaynitePlugin
PART_AuthenticateLabel.Content = "Checking authentication status..."; PART_AuthenticateLabel.Content = "Checking authentication status...";
PART_AuthenticationButton.IsEnabled = false; PART_AuthenticationButton.IsEnabled = false;
PART_InstallDirectory.Text = Settings.InstallDirectory; PART_InstallDirectory.Text = Settings.InstallDirectory;
PART_ServerAddress.Text = Settings.ServerAddress;
var token = new AuthToken() var token = new AuthToken()
{ {
@ -57,11 +58,17 @@ namespace LANCommander.PlaynitePlugin
{ {
PART_AuthenticateLabel.Content = "Authentication failed!"; PART_AuthenticateLabel.Content = "Authentication failed!";
PART_AuthenticationButton.IsEnabled = true; PART_AuthenticationButton.IsEnabled = true;
PART_AuthenticationButton.Visibility = Visibility.Visible;
PART_DisconnectButton.IsEnabled = false;
PART_DisconnectButton.Visibility = Visibility.Hidden;
} }
else else
{ {
PART_AuthenticateLabel.Content = "Connection established!"; PART_AuthenticateLabel.Content = "Connection established!";
PART_AuthenticationButton.IsEnabled = false; 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; 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) private void AuthWindow_Closed(object sender, EventArgs e)
{ {
UpdateAuthenticationButtonVisibility(); UpdateAuthenticationButtonVisibility();