Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Commit 6451f54

Browse files
committed
Workaround for #125
When starting the application and the SSH connection doesn't work, an error page is shown.
1 parent 0510f15 commit 6451f54

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

View/ServerError.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Page x:Class="View.ServerError"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d"
7+
Title="Fout">
8+
9+
<Grid>
10+
<Label Content="Er ging iets mis met de verbinding met de server. Neem contact op met de administrators van Stugether." HorizontalAlignment="Center" VerticalAlignment="Center"/>
11+
</Grid>
12+
</Page>

View/ServerError.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Windows.Controls;
2+
3+
namespace View
4+
{
5+
/// <summary>
6+
/// Interaction logic for ServerError.xaml
7+
/// </summary>
8+
public partial class ServerError : Page
9+
{
10+
public ServerError()
11+
{
12+
InitializeComponent();
13+
}
14+
}
15+
}

ViewModel/MainPageViewModel.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,17 @@ public class MainPageViewModel : ObservableObject
2525
/// </summary>
2626
public MainPageViewModel()
2727
{
28-
SSHService.Initialize(); // Initialize SSH for the database connection and logging in
29-
MainNavigationItems = SetObservableCollection(false); // Initialize the default page list
28+
// Initialize the default page list
29+
MainNavigationItems = SetObservableCollection(false);
30+
31+
try
32+
{
33+
SSHService.Initialize(); // Initialize SSH for the database connection and logging in
34+
}
35+
catch (Exception)
36+
{
37+
MainWindowPage = "ServerError.xaml";
38+
}
3039

3140
// Subscribe a bunch of events to make certain other functions work
3241
ViewModelMediators.AuthenticationStateChanged += OnAuthenticationStateChanged;

0 commit comments

Comments
 (0)