2023-01-05 01:07:17 -06:00
|
|
|
|
using LANCommander.SDK.Models;
|
|
|
|
|
using Playnite.SDK;
|
|
|
|
|
using System;
|
2023-01-04 19:23:32 -06:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Documents;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
using System.Windows.Media.Imaging;
|
|
|
|
|
using System.Windows.Navigation;
|
|
|
|
|
using System.Windows.Shapes;
|
|
|
|
|
|
2023-01-08 12:09:57 -06:00
|
|
|
|
namespace LANCommander.PlaynitePlugin
|
2023-01-04 19:23:32 -06:00
|
|
|
|
{
|
|
|
|
|
public partial class PlayniteSettingsView : UserControl
|
|
|
|
|
{
|
2023-01-05 01:07:17 -06:00
|
|
|
|
private PlayniteLibraryPlugin Plugin;
|
|
|
|
|
|
|
|
|
|
public PlayniteSettingsView(PlayniteLibraryPlugin plugin)
|
2023-01-04 19:23:32 -06:00
|
|
|
|
{
|
2023-01-05 01:07:17 -06:00
|
|
|
|
Plugin = plugin;
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2023-01-07 12:34:12 -06:00
|
|
|
|
UpdateAuthenticationButtonVisibility();
|
|
|
|
|
}
|
2023-01-05 01:07:17 -06:00
|
|
|
|
|
2023-01-07 12:34:12 -06:00
|
|
|
|
private void UpdateAuthenticationButtonVisibility()
|
|
|
|
|
{
|
|
|
|
|
try
|
2023-01-05 01:07:17 -06:00
|
|
|
|
{
|
2023-01-07 12:34:12 -06:00
|
|
|
|
if (Plugin.LANCommander.ValidateToken(new AuthToken()
|
|
|
|
|
{
|
|
|
|
|
AccessToken = Plugin.Settings.AccessToken,
|
|
|
|
|
RefreshToken = Plugin.Settings.RefreshToken,
|
|
|
|
|
}))
|
|
|
|
|
{
|
|
|
|
|
var authenticateButton = FindName("AuthenticateButton") as Button;
|
|
|
|
|
|
|
|
|
|
authenticateButton.Visibility = Visibility.Hidden;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
2023-01-05 01:07:17 -06:00
|
|
|
|
{
|
2023-01-04 19:23:32 -06:00
|
|
|
|
|
2023-01-05 01:07:17 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AuthenticateButton_Click(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2023-01-07 12:34:12 -06:00
|
|
|
|
var authWindow = Plugin.ShowAuthenticationWindow();
|
|
|
|
|
|
|
|
|
|
authWindow.Closed += AuthWindow_Closed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AuthWindow_Closed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
UpdateAuthenticationButtonVisibility();
|
2023-01-04 19:23:32 -06:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|