diff --git a/easyWSL/App.xaml.cs b/easyWSL/App.xaml.cs index 0a0e63c..dcdff2a 100644 --- a/easyWSL/App.xaml.cs +++ b/easyWSL/App.xaml.cs @@ -18,7 +18,16 @@ public App() protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) { - m_window = new NavigationRoot_Window(); + var isWSLInstalled = WslSdk.CheckIfWSLInstalled(); + if (!isWSLInstalled) + { + m_window = new WelcomeWindow(); + } + else + { + m_window = new NavigationRoot_Window(); + } + m_window.Activate(); m_window.Title = "easyWSL"; m_windowhandle = User32.GetActiveWindow(); diff --git a/easyWSL/DockerDownloader.cs b/easyWSL/DockerDownloader.cs index 22d0f42..286d978 100644 --- a/easyWSL/DockerDownloader.cs +++ b/easyWSL/DockerDownloader.cs @@ -54,7 +54,7 @@ public async Task DownloadImage(string distroImage, Action httpPro string repository = ""; string tag = ""; - string registry = "registry-1.docker.io"; + string registry = "LLL"; string authorizationUrl = "https://auth.docker.io/token"; string registryUrl = "registry.docker.io"; diff --git a/easyWSL/ManageDistrosPage.xaml.cs b/easyWSL/ManageDistrosPage.xaml.cs index 8f8dc6c..d531f9c 100644 --- a/easyWSL/ManageDistrosPage.xaml.cs +++ b/easyWSL/ManageDistrosPage.xaml.cs @@ -32,34 +32,12 @@ public ManageDistrosPage() private async Task RefreshInstalledDistros() { - await wslSdk.GetInstalledDistributions(); + await WslSdk.GetInstalledDistributions(); distrosListView.ItemsSource = null; distrosListView.Items.Clear(); - distrosListView.ItemsSource = wslSdk.InstalledDistros.Values; - if(distrosListView.Items.Count == 0) - { - WelcomeDialog welcomeDialogContent = new(); - ContentDialog welcomeDialog = new ContentDialog(); - welcomeDialog.XamlRoot = distrosListView.XamlRoot; - welcomeDialog.Title = $"Welcome to easyWSL"; - welcomeDialog.Content = welcomeDialogContent; - welcomeDialog.DefaultButton = ContentDialogButton.Primary; - welcomeDialog.PrimaryButtonText = "Install WSL"; - welcomeDialog.CloseButtonText = "WSL is already installed"; - - var result = await welcomeDialog.ShowAsync(); - if(result == ContentDialogResult.Primary) - { - var webPsi = new ProcessStartInfo - { - FileName = "https://docs.microsoft.com/en-us/windows/wsl/install", - UseShellExecute = true - }; - Process.Start(webPsi); - } - } - else - { + distrosListView.ItemsSource = WslSdk.InstalledDistros.Values; + if(distrosListView.Items.Count != 0) + { distrosListView.SelectedIndex = 0; } @@ -91,8 +69,8 @@ private async void removeDistroButton_Click(object sender, RoutedEventArgs e) private async void moreInfoButton_Click(object sender, RoutedEventArgs e) { var name = selectedDistroName; - var version = wslSdk.InstalledDistros[name].version; - var path = wslSdk.InstalledDistros[name].path; + var version = WslSdk.InstalledDistros[name].version; + var path = WslSdk.InstalledDistros[name].path; var dialogContent = new MoreInfoDialog(name, version, path); @@ -126,5 +104,6 @@ private async void stopDistroButton_Click(object sender, RoutedEventArgs e) { await helpers.ExecuteProcessAsynch("wsl.exe", $"-t {selectedDistroName}"); } + } } diff --git a/easyWSL/ManageSnapshotsPage.xaml.cs b/easyWSL/ManageSnapshotsPage.xaml.cs index b1da53e..54b1714 100644 --- a/easyWSL/ManageSnapshotsPage.xaml.cs +++ b/easyWSL/ManageSnapshotsPage.xaml.cs @@ -29,8 +29,8 @@ public ManageSnapshotsPage() public async Task RefreshDistros() { - await wslSdk.GetInstalledDistributions(); - var distrosList = wslSdk.InstalledDistros.Values.Select(o => o.name); + await WslSdk.GetInstalledDistributions(); + var distrosList = WslSdk.InstalledDistros.Values.Select(o => o.name); distrosComboBox.ItemsSource = distrosList; FillSnapshotsListView(); @@ -87,8 +87,8 @@ private void removeSnapshotButton_Click(object sender, RoutedEventArgs e) private async void FillSnapshotsListView() { - await wslSdk.GetInstalledDistributions(); - var distrosList = wslSdk.InstalledDistros.Values.Select(o => o.name); + await WslSdk.GetInstalledDistributions(); + var distrosList = WslSdk.InstalledDistros.Values.Select(o => o.name); var snapshotsStoragePath = Path.Combine(storageDirectory.Path, "snapshots"); try @@ -105,6 +105,10 @@ private async void FillSnapshotsListView() } var distro = distrosComboBox.SelectedValue as string; + if (distro == null) + { + return; + } var snapshotsPath = Path.Combine(storageDirectory.Path, "snapshots", distro); snapshotsList = Directory.EnumerateFiles(snapshotsPath, "*.tar.gz").ToList(); diff --git a/easyWSL/WelcomeDialog.xaml.cs b/easyWSL/WelcomeDialog.xaml.cs deleted file mode 100644 index 55e79d1..0000000 --- a/easyWSL/WelcomeDialog.xaml.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Microsoft.UI.Xaml.Controls; - -namespace easyWSL -{ - public sealed partial class WelcomeDialog : Page - { - public WelcomeDialog() - { - this.InitializeComponent(); - } - } -} diff --git a/easyWSL/WelcomeDialog.xaml b/easyWSL/WelcomeWindow.xaml similarity index 53% rename from easyWSL/WelcomeDialog.xaml rename to easyWSL/WelcomeWindow.xaml index 2efb0d3..c7d3cc3 100644 --- a/easyWSL/WelcomeDialog.xaml +++ b/easyWSL/WelcomeWindow.xaml @@ -1,5 +1,6 @@ - + - + + WSL is not installed on your system This application requires - Windows Subsystem For Linux enabled on your machine. + Windows Subsystem For Linux enabled on your machine. Please install it and relaunch the application. +