- add: nice error view
This commit is contained in:
1
.idea/.idea.Nebula/.idea/avalonia.xml
generated
1
.idea/.idea.Nebula/.idea/avalonia.xml
generated
@@ -45,6 +45,7 @@
|
||||
<entry key="Nebula.Launcher/Views/ServerListView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||
<entry key="Nebula.Launcher/Views/Tabs/AccountInfoTab.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||
<entry key="Nebula.Launcher/Views/Tabs/ServerListTab.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||
<entry key="Nebula.Launcher/Views/VisualErrorView.axaml" value="Nebula.Launcher/Nebula.Launcher.csproj" />
|
||||
<entry key="Nebula.UpdateResolver/App.axaml" value="Nebula.UpdateResolver/Nebula.UpdateResolver.csproj" />
|
||||
<entry key="Nebula.UpdateResolver/MainWindow.axaml" value="Nebula.UpdateResolver/Nebula.UpdateResolver.csproj" />
|
||||
</map>
|
||||
|
||||
@@ -28,14 +28,16 @@ public class App : Application
|
||||
{
|
||||
case IClassicDesktopStyleApplicationLifetime desktop:
|
||||
DisableAvaloniaDataAnnotationValidation();
|
||||
desktop.MainWindow = new MessageWindow(out provider);
|
||||
desktop.MainWindow = (Window)(provider = new MessageWindow());
|
||||
break;
|
||||
case ISingleViewApplicationLifetime singleViewPlatform:
|
||||
singleViewPlatform.MainView = new MessageView(out provider);
|
||||
singleViewPlatform.MainView = (Control)(provider = new MessageView());
|
||||
break;
|
||||
}
|
||||
|
||||
provider?.ShowMessage("Launcher is already running.","hey shithead!");
|
||||
provider?.ShowMessage(
|
||||
"Error: An instance of the application is already running. Please close the existing instance before launching a new one.",
|
||||
"Duplicate instance detected.");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
BIN
Nebula.Launcher/Assets/error_presentation/Cinka.png
Normal file
BIN
Nebula.Launcher/Assets/error_presentation/Cinka.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 150 KiB |
BIN
Nebula.Launcher/Assets/error_presentation/alex.png
Normal file
BIN
Nebula.Launcher/Assets/error_presentation/alex.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 158 KiB |
@@ -1,11 +1,11 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using System;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Platform;
|
||||
|
||||
namespace Nebula.Launcher.Converters;
|
||||
|
||||
public class TypeConverters
|
||||
public static class TypeConverters
|
||||
{
|
||||
public static FuncValueConverter<string, string?> IconConverter { get; } =
|
||||
new(iconKey =>
|
||||
@@ -13,4 +13,11 @@ public class TypeConverters
|
||||
if (iconKey == null) return null;
|
||||
return $"/Assets/svg/{iconKey}.svg";
|
||||
});
|
||||
|
||||
public static FuncValueConverter<string, IImage?> ImageConverter { get; } =
|
||||
new(iconKey =>
|
||||
{
|
||||
if (iconKey == null) return null;
|
||||
return new Avalonia.Media.Imaging.Bitmap(AssetLoader.Open(new Uri($"avares://Nebula.Launcher/Assets/error_presentation/{iconKey}.png")));
|
||||
});
|
||||
}
|
||||
@@ -2,16 +2,9 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:views="clr-namespace:Nebula.Launcher.Views"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
Width="600"
|
||||
Height="400"
|
||||
|
||||
x:Class="Nebula.Launcher.MessageBox.MessageView">
|
||||
<Grid RowDefinitions="50,*" ColumnDefinitions="*">
|
||||
<Border Grid.Column="0" Background="#222222" Padding="10" BorderBrush="#444444" BorderThickness="0,0,0,3">
|
||||
<Label VerticalAlignment="Center" x:Name="Title">Text</Label>
|
||||
</Border>
|
||||
<Panel Margin="5" Grid.Row="1">
|
||||
<Label x:Name="Message">Message</Label>
|
||||
</Panel>
|
||||
</Grid>
|
||||
<views:VisualErrorView x:Name="ErrorView"/>
|
||||
</UserControl>
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Nebula.Launcher.ViewModels;
|
||||
|
||||
namespace Nebula.Launcher.MessageBox;
|
||||
|
||||
public partial class MessageView : UserControl, IMessageContainerProvider
|
||||
{
|
||||
public MessageView(out IMessageContainerProvider provider)
|
||||
private readonly VisualErrorViewModel _context;
|
||||
public MessageView()
|
||||
{
|
||||
InitializeComponent();
|
||||
provider = this;
|
||||
_context = new VisualErrorViewModel();
|
||||
ErrorView.Content = _context;
|
||||
}
|
||||
|
||||
public void ShowMessage(string message, string title)
|
||||
{
|
||||
Title.Content = title;
|
||||
Message.Content = message;
|
||||
_context.Title = title;
|
||||
_context.Description = message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,52 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:messageBox="clr-namespace:Nebula.Launcher.MessageBox"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
SystemDecorations="BorderOnly"
|
||||
mc:Ignorable="d" d:DesignWidth="600" d:DesignHeight="260"
|
||||
Width="600"
|
||||
Height="400"
|
||||
Height="260"
|
||||
CanResize="False"
|
||||
x:Class="Nebula.Launcher.MessageBox.MessageWindow"
|
||||
Title="MessageWindow">
|
||||
<Grid ColumnDefinitions="*" RowDefinitions="30,*">
|
||||
<messageBox:MessageView
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
x:Name="MessageView" />
|
||||
<Border
|
||||
|
||||
BorderThickness="0,0,0,2"
|
||||
CornerRadius="0"
|
||||
Grid.Column="0"
|
||||
Grid.Row="0">
|
||||
<Border.BorderBrush>
|
||||
<LinearGradientBrush EndPoint="100%,50%" StartPoint="0%,50%">
|
||||
<GradientStop Color="#222222" Offset="0.0" />
|
||||
<GradientStop Color="#442222" Offset="1.0" />
|
||||
</LinearGradientBrush>
|
||||
</Border.BorderBrush>
|
||||
<Panel
|
||||
Height="30"
|
||||
PointerPressed="InputElement_OnPointerPressed">
|
||||
<TextBlock
|
||||
FontSize="10"
|
||||
Foreground="White"
|
||||
IsVisible="False"
|
||||
Margin="15,0"
|
||||
Text="Nebula Launcher"
|
||||
VerticalAlignment="Center" />
|
||||
<StackPanel
|
||||
HorizontalAlignment="Right"
|
||||
Margin="5,0,5,0"
|
||||
Orientation="Horizontal"
|
||||
Spacing="8">
|
||||
<Button
|
||||
Click="Close_Click"
|
||||
Content="🗙"
|
||||
Foreground="Azure" />
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</Border>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace Nebula.Launcher.MessageBox;
|
||||
|
||||
public partial class MessageWindow : Window
|
||||
public partial class MessageWindow : Window, IMessageContainerProvider
|
||||
{
|
||||
public MessageWindow(out IMessageContainerProvider provider)
|
||||
public MessageWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Content = new MessageView(out provider);
|
||||
}
|
||||
|
||||
public void ShowMessage(string message, string title)
|
||||
{
|
||||
MessageView.ShowMessage(message, title);
|
||||
}
|
||||
|
||||
private void Close_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
BeginMoveDrag(e);
|
||||
}
|
||||
}
|
||||
22
Nebula.Launcher/ViewModels/VisualErrorViewModel.cs
Normal file
22
Nebula.Launcher/ViewModels/VisualErrorViewModel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using Nebula.Launcher.Views;
|
||||
using Nebula.Shared.ViewHelper;
|
||||
|
||||
namespace Nebula.Launcher.ViewModels;
|
||||
|
||||
|
||||
[ViewModelRegister(typeof(VisualErrorView))]
|
||||
public partial class VisualErrorViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty] private string _imgPath = "cinka";
|
||||
[ObservableProperty] private string _title = "Error";
|
||||
[ObservableProperty] private string _description = "This is an error.";
|
||||
|
||||
protected override void InitialiseInDesignMode()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Initialise()
|
||||
{
|
||||
}
|
||||
}
|
||||
39
Nebula.Launcher/Views/VisualErrorView.axaml
Normal file
39
Nebula.Launcher/Views/VisualErrorView.axaml
Normal file
@@ -0,0 +1,39 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels"
|
||||
xmlns:converters="clr-namespace:Nebula.Launcher.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:DataType="viewModels:VisualErrorViewModel"
|
||||
x:Class="Nebula.Launcher.Views.VisualErrorView">
|
||||
<Design.DataContext>
|
||||
<viewModels:VisualErrorViewModel />
|
||||
</Design.DataContext>
|
||||
<Grid RowDefinitions="30,*" ColumnDefinitions="200,*">
|
||||
<Border Grid.Row="1" Grid.Column="0"
|
||||
CornerRadius="10,0,0,10"
|
||||
BorderThickness="0,0,2,0"
|
||||
BorderBrush="{StaticResource DefaultForeground}">
|
||||
<Image Source="{Binding ImgPath, Converter={x:Static converters:TypeConverters.ImageConverter}}" Width="200" Height="200"/>
|
||||
</Border>
|
||||
<Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" CornerRadius="10,10,0,0">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush EndPoint="100%,50%" StartPoint="10%,20%">
|
||||
<GradientStop Color="#FF6B6B" Offset="0.0" />
|
||||
<GradientStop Color="#FF8E53" Offset="0.3" />
|
||||
<GradientStop Color="#FF5E3A" Offset="0.6" />
|
||||
<GradientStop Color="#FF5e5e" Offset="1.0" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
<Label HorizontalAlignment="Center"><TextBlock Text="{Binding Title}"/></Label>
|
||||
</Border>
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="15"
|
||||
HorizontalAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
Text="{Binding Description}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
11
Nebula.Launcher/Views/VisualErrorView.axaml.cs
Normal file
11
Nebula.Launcher/Views/VisualErrorView.axaml.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Nebula.Launcher.Views;
|
||||
|
||||
public partial class VisualErrorView : UserControl
|
||||
{
|
||||
public VisualErrorView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFileShare_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa6b7f037ba7b44df80b8d3aa7e58eeb2e8e938_003F54_003Fc3f4f140_003FFileShare_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFile_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F3f31e7e8aa33de883c2ccfa62a9c81bfc246c36e825b489476f9472032e512_003FFile_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFrozenDictionary_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F89dff9063ddb01ff8125b579122b88bf4de94526490d77bcbbef7d0ee662a_003FFrozenDictionary_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFuncValueConverter_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fe91c13e7e24d7ba324e0e6eb12a24ea8c7761299d3c4703e55c86dd120835e61_003FFuncValueConverter_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AFuture_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fb3575a2f41d7c2dbfaa36e866b8a361e11dd7223ff82bc574c1d5d4b7522f735_003FFuture_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpClient_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fc439425da351c75ac7d966a1cc8324b51a9c471865af79d2f2f3fcb65e392_003FHttpClient_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpContent_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F9657cc383c70851dc2bdcf91eff27f21196844abfe552fc9c3243ff36974cd_003FHttpContent_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
@@ -32,6 +33,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpResponseMessage_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F4cfeb8b377bc81e1fbb5f7d7a02492cb6ac23e88c8c9d7155944f0716f3d4b_003FHttpResponseMessage_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIDispatcherImpl_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F22d92db124764b1ab49745245c66f01b1e1a00_003F0f_003F01061787_003FIDispatcherImpl_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIDisposable_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa6b7f037ba7b44df80b8d3aa7e58eeb2e8e938_003F98_003Fd1b23281_003FIDisposable_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AImage_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F2b95745d8f2ddf7b8ad6130e01c5b2782e253ff11247a9aeefcef47277b1ab_003FImage_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIndex_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F2a1a813823579c69832f1304f97761e7be433bd6aa928f351d138050b56a38_003FIndex_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInt32_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fa882d183338544fdbcbdfc7b6d3dcb78916630765551644a221b5be9c45a121b_003FInt32_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInterop_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FUsers_003FCinka_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fc4d71b51722245ae8cde97bfd996e68386928_003F3a_003F004a1338_003FInterop_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
Reference in New Issue
Block a user