diff --git a/Desktop.Linux/Controls/HostNamePrompt.xaml b/Desktop.Linux/Controls/HostNamePrompt.xaml index 588db61b..00875c3d 100644 --- a/Desktop.Linux/Controls/HostNamePrompt.xaml +++ b/Desktop.Linux/Controls/HostNamePrompt.xaml @@ -5,7 +5,7 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Remotely.Desktop.Linux.Controls.HostNamePrompt" xmlns:ViewModels="clr-namespace:Remotely.Desktop.Linux.ViewModels;assembly=Remotely_Desktop" - Title="Remotely Host Name" Height="150" Width="350" WindowStartupLocation="CenterOwner"> + Title="Remotely Host Name" Height="150" Width="350" WindowStartupLocation="CenterScreen"> diff --git a/Desktop.Linux/ViewModels/MainWindowViewModel.cs b/Desktop.Linux/ViewModels/MainWindowViewModel.cs index c1125516..b7e949a9 100644 --- a/Desktop.Linux/ViewModels/MainWindowViewModel.cs +++ b/Desktop.Linux/ViewModels/MainWindowViewModel.cs @@ -139,18 +139,20 @@ namespace Remotely.Desktop.Linux.ViewModels public async Task Init() { - SessionID = "Retrieving..."; - Host = Config.GetConfig().Host; - while (string.IsNullOrWhiteSpace(Host)) - { - Host = "https://"; - await PromptForHostName(); - } - Host = Host; - Conductor.ProcessArgs(new string[] { "-mode", "Normal", "-host", Host }); try { + SessionID = "Retrieving..."; + Host = Config.GetConfig().Host; + while (string.IsNullOrWhiteSpace(Host)) + { + Host = "https://"; + await PromptForHostName(); + } + Conductor.ProcessArgs(new string[] { "-mode", "Normal", "-host", Host }); await Conductor.Connect(); + + await Conductor.CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID); + await Conductor.CasterSocket.GetSessionID(); } catch (Exception ex) { @@ -158,9 +160,6 @@ namespace Remotely.Desktop.Linux.ViewModels await MessageBox.Show("Failed to connect to server.", "Connection Failed", MessageBoxType.OK); return; } - - await Conductor.CasterSocket.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName, Conductor.DeviceID); - await Conductor.CasterSocket.GetSessionID(); } public async Task PromptForHostName() diff --git a/Desktop.Linux/Views/MainWindow.xaml.cs b/Desktop.Linux/Views/MainWindow.xaml.cs index d0cbd653..0f557a15 100644 --- a/Desktop.Linux/Views/MainWindow.xaml.cs +++ b/Desktop.Linux/Views/MainWindow.xaml.cs @@ -33,7 +33,12 @@ namespace Remotely.Desktop.Linux.Views this.FindControl("TitleBanner").PointerPressed += TitleBanner_PointerPressed; - _ = (this.DataContext as MainWindowViewModel).Init(); + this.Opened += MainWindow_Opened; + } + + private async void MainWindow_Opened(object sender, System.EventArgs e) + { + await (this.DataContext as MainWindowViewModel).Init(); } } }