Changed Linux GUI viewmodel init.

This commit is contained in:
Jared Goodwin 2020-03-08 14:13:39 -07:00
parent 7fe7659579
commit bf5ae5d205
3 changed files with 18 additions and 14 deletions

View File

@ -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">
<Window.DataContext>
<ViewModels:HostNamePromptViewModel/>
</Window.DataContext>

View File

@ -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()

View File

@ -33,7 +33,12 @@ namespace Remotely.Desktop.Linux.Views
this.FindControl<Border>("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();
}
}
}