mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[GUI] Change how errors are shown in device list window.
This commit is contained in:
@@ -34,6 +34,7 @@ using System;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using Aaru.Devices;
|
using Aaru.Devices;
|
||||||
using Aaru.Devices.Remote;
|
using Aaru.Devices.Remote;
|
||||||
using Aaru.Devices.Windows;
|
using Aaru.Devices.Windows;
|
||||||
@@ -41,6 +42,7 @@ using Aaru.Gui.Models;
|
|||||||
using Aaru.Gui.Views.Windows;
|
using Aaru.Gui.Views.Windows;
|
||||||
using Aaru.Localization;
|
using Aaru.Localization;
|
||||||
using Aaru.Logging;
|
using Aaru.Logging;
|
||||||
|
using Avalonia.Threading;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using MsBox.Avalonia;
|
using MsBox.Avalonia;
|
||||||
@@ -73,7 +75,7 @@ public partial class DeviceListViewModel : ViewModelBase
|
|||||||
if(_remotePath != null)
|
if(_remotePath != null)
|
||||||
#pragma warning restore MVVMTK0034
|
#pragma warning restore MVVMTK0034
|
||||||
{
|
{
|
||||||
LoadRemote();
|
_ = Task.Run(LoadRemote);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -125,12 +127,17 @@ public partial class DeviceListViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
AaruLogging.Error(UI.Invalid_remote_protocol);
|
AaruLogging.Error(UI.Invalid_remote_protocol);
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
||||||
UI.Invalid_remote_protocol,
|
UI.Invalid_remote_protocol,
|
||||||
ButtonEnum.Ok,
|
ButtonEnum.Ok,
|
||||||
Icon.Error);
|
Icon.Error);
|
||||||
|
|
||||||
_ = msbox.ShowWindowDialogAsync(_window);
|
_ = msbox.ShowAsync();
|
||||||
|
|
||||||
|
_window.Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
using var remote = new Remote(aaruUri);
|
using var remote = new Remote(aaruUri);
|
||||||
@@ -155,13 +162,18 @@ public partial class DeviceListViewModel : ViewModelBase
|
|||||||
catch(SocketException ex)
|
catch(SocketException ex)
|
||||||
{
|
{
|
||||||
if(ex.SocketErrorCode == SocketError.HostNotFound)
|
if(ex.SocketErrorCode == SocketError.HostNotFound)
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
||||||
UI.Host_not_found,
|
UI.Host_not_found,
|
||||||
ButtonEnum.Ok,
|
ButtonEnum.Ok,
|
||||||
Icon.Error);
|
Icon.Error);
|
||||||
|
|
||||||
_ = msbox.ShowWindowDialogAsync(_window);
|
_ = msbox.ShowAsync();
|
||||||
|
|
||||||
|
_window.Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -170,33 +182,48 @@ public partial class DeviceListViewModel : ViewModelBase
|
|||||||
AaruLogging.Exception(ex, UI.Error_connecting_to_host);
|
AaruLogging.Exception(ex, UI.Error_connecting_to_host);
|
||||||
AaruLogging.Error(UI.Error_connecting_to_host);
|
AaruLogging.Error(UI.Error_connecting_to_host);
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
||||||
Markup.Remove(UI.Error_connecting_to_host),
|
Markup.Remove(UI.Error_connecting_to_host),
|
||||||
ButtonEnum.Ok,
|
ButtonEnum.Ok,
|
||||||
Icon.Error);
|
Icon.Error);
|
||||||
|
|
||||||
_ = msbox.ShowWindowDialogAsync(_window);
|
_ = msbox.ShowAsync();
|
||||||
|
|
||||||
|
_window.Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReSharper disable once UncatchableException
|
// ReSharper disable once UncatchableException
|
||||||
catch(ArgumentException)
|
catch(ArgumentException)
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
||||||
UI.Server_sent_invalid_data,
|
UI.Server_sent_invalid_data,
|
||||||
ButtonEnum.Ok,
|
ButtonEnum.Ok,
|
||||||
Icon.Error);
|
Icon.Error);
|
||||||
|
|
||||||
_ = msbox.ShowWindowDialogAsync(_window);
|
_ = msbox.ShowAsync();
|
||||||
|
|
||||||
|
_window.Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(IOException)
|
catch(IOException)
|
||||||
|
{
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
{
|
{
|
||||||
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
||||||
UI.Unknown_network_error,
|
UI.Unknown_network_error,
|
||||||
ButtonEnum.Ok,
|
ButtonEnum.Ok,
|
||||||
Icon.Error);
|
Icon.Error);
|
||||||
|
|
||||||
_ = msbox.ShowWindowDialogAsync(_window);
|
_ = msbox.ShowAsync();
|
||||||
|
|
||||||
|
_window.Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
@@ -205,12 +232,17 @@ public partial class DeviceListViewModel : ViewModelBase
|
|||||||
AaruLogging.Exception(ex, UI.Error_connecting_to_host);
|
AaruLogging.Exception(ex, UI.Error_connecting_to_host);
|
||||||
AaruLogging.Error(UI.Error_connecting_to_host);
|
AaruLogging.Error(UI.Error_connecting_to_host);
|
||||||
|
|
||||||
|
Dispatcher.UIThread.Invoke(() =>
|
||||||
|
{
|
||||||
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
IMsBox<ButtonResult> msbox = MessageBoxManager.GetMessageBoxStandard(UI.Title_Error,
|
||||||
Markup.Remove(UI.Error_connecting_to_host),
|
Markup.Remove(UI.Error_connecting_to_host),
|
||||||
ButtonEnum.Ok,
|
ButtonEnum.Ok,
|
||||||
Icon.Error);
|
Icon.Error);
|
||||||
|
|
||||||
_ = msbox.ShowWindowDialogAsync(_window);
|
_ = msbox.ShowAsync();
|
||||||
|
|
||||||
|
_window.Close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user