- add: nice error view
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user