-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #194 from AuroraZiling/main
[Refactor/Clean] MessageBox & Toast & WaveProgress
- Loading branch information
Showing
18 changed files
with
322 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
197 changes: 98 additions & 99 deletions
197
SukiUI/MessageBox/MessageBox.axaml → SukiUI/Controls/MessageBox.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,99 @@ | ||
<Window x:Class="SukiUI.MessageBox.MessageBox" | ||
xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:content="clr-namespace:SukiUI.Content" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:suki="clr-namespace:SukiUI.Controls;assembly=SukiUI" | ||
Width="500" | ||
Height="150" | ||
MaxWidth="500" | ||
MaxHeight="150" | ||
d:DesignHeight="200" | ||
d:DesignWidth="500" | ||
Background="{DynamicResource SukiBackground}" | ||
Classes="NakedWindow" | ||
ExtendClientAreaToDecorationsHint="True" | ||
mc:Ignorable="d"> | ||
<Panel> | ||
<Panel.Styles> | ||
<Style Selector="Grid.AnimatedGrid"> | ||
<Style.Animations> | ||
<Animation Duration="0:0:4"> | ||
<KeyFrame Cue="0%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="80%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="84%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="0.99" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="0.99" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="88%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="94%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="0.99" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="0.99" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="100%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
</Animation> | ||
</Style.Animations> | ||
</Style> | ||
</Panel.Styles> | ||
<Panel Background="{DynamicResource SukiBackground}" IsHitTestVisible="False" /> | ||
<Button Width="23" | ||
Height="23" | ||
Margin="12" | ||
Padding="0" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Top" | ||
Background="Transparent" | ||
BorderThickness="0" | ||
Classes="ZoomOnHover" | ||
Click="Close"> | ||
<PathIcon Data="{x:Static content:Icons.CircleOutlineClose}" Foreground="DarkRed" /> | ||
</Button> | ||
|
||
<Grid Classes="AnimatedGrid"> | ||
<PathIcon Name="InfoIcon" | ||
Width="50" | ||
Height="50" | ||
Margin="25,35,0,0" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Data="{x:Static content:Icons.CircleInformation}" | ||
DockPanel.Dock="Left" | ||
Foreground="{DynamicResource SukiPrimaryColor}" /> | ||
</Grid> | ||
|
||
<TextBlock Name="Title" | ||
Margin="100,45,0,-45" | ||
HorizontalAlignment="Left" | ||
Classes="h3" | ||
DockPanel.Dock="Top" /> | ||
<ScrollViewer Margin="102,45,14,10" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center"> | ||
<TextBlock Name="Message" | ||
FontWeight="Light" | ||
TextWrapping="Wrap" /> | ||
</ScrollViewer> | ||
|
||
<Button Width="80" | ||
Margin="0,0,0,7" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Bottom" | ||
Classes="Basic" | ||
Click="Close" | ||
DockPanel.Dock="Bottom"> | ||
<TextBlock /> | ||
</Button> | ||
</Panel> | ||
<Window x:Class="SukiUI.Controls.MessageBox" | ||
xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:content="clr-namespace:SukiUI.Content" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Width="500" | ||
Height="150" | ||
MaxWidth="500" | ||
MaxHeight="150" | ||
d:DesignHeight="200" | ||
d:DesignWidth="500" | ||
Background="{DynamicResource SukiBackground}" | ||
Classes="NakedWindow" | ||
ExtendClientAreaToDecorationsHint="True" | ||
mc:Ignorable="d"> | ||
<Panel> | ||
<Panel.Styles> | ||
<Style Selector="Grid.AnimatedGrid"> | ||
<Style.Animations> | ||
<Animation Duration="0:0:4"> | ||
<KeyFrame Cue="0%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="80%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="84%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="0.99" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="0.99" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="88%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="94%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="0.99" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="0.99" /> | ||
</KeyFrame> | ||
<KeyFrame Cue="100%"> | ||
<Setter Property="ScaleTransform.ScaleX" Value="1" /> | ||
<Setter Property="ScaleTransform.ScaleY" Value="1" /> | ||
</KeyFrame> | ||
</Animation> | ||
</Style.Animations> | ||
</Style> | ||
</Panel.Styles> | ||
<Panel Background="{DynamicResource SukiBackground}" IsHitTestVisible="False" /> | ||
<Button Width="23" | ||
Height="23" | ||
Margin="12" | ||
Padding="0" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Top" | ||
Background="Transparent" | ||
BorderThickness="0" | ||
Classes="ZoomOnHover" | ||
Click="Close"> | ||
<PathIcon Data="{x:Static content:Icons.CircleOutlineClose}" Foreground="DarkRed" /> | ||
</Button> | ||
|
||
<Grid Classes="AnimatedGrid"> | ||
<PathIcon Name="InfoIcon" | ||
Width="50" | ||
Height="50" | ||
Margin="25,35,0,0" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Data="{x:Static content:Icons.CircleInformation}" | ||
DockPanel.Dock="Left" | ||
Foreground="{DynamicResource SukiPrimaryColor}" /> | ||
</Grid> | ||
|
||
<TextBlock Name="Title" | ||
Margin="100,45,0,-45" | ||
HorizontalAlignment="Left" | ||
Classes="h3" | ||
DockPanel.Dock="Top" /> | ||
<ScrollViewer Margin="102,45,14,10" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Center"> | ||
<TextBlock Name="Message" | ||
FontWeight="Light" | ||
TextWrapping="Wrap" /> | ||
</ScrollViewer> | ||
|
||
<Button Width="80" | ||
Margin="0,0,0,7" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Bottom" | ||
Classes="Basic" | ||
Click="Close" | ||
DockPanel.Dock="Bottom"> | ||
<TextBlock /> | ||
</Button> | ||
</Panel> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.Interactivity; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Media; | ||
using SukiUI.Content; | ||
using SukiUI.Extensions; | ||
|
||
namespace SukiUI.Controls; | ||
|
||
public partial class MessageBox : Window | ||
{ | ||
private static readonly SolidColorBrush InfoBrush = new(Color.FromRgb(47, 84, 235)); | ||
|
||
public MessageBox() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public MessageBox(string title, string message) | ||
{ | ||
InitializeComponent(); | ||
this.FindRequiredControl<TextBlock>("Title").Text = title; | ||
this.FindRequiredControl<TextBlock>("Message").Text = message; | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
CanResize = false; | ||
} | ||
|
||
public static void Info(Window owner, string title, string message, WindowStartupLocation startupLocation = WindowStartupLocation.CenterScreen) | ||
{ | ||
var mbox = new MessageBox(title, message); | ||
if (mbox.FindControl<PathIcon>("InfoIcon") is not { } icon) return; | ||
icon.Data = Icons.CircleInformation; | ||
icon.Foreground = InfoBrush; | ||
mbox.WindowStartupLocation = startupLocation; | ||
mbox.ShowDialog(owner); | ||
} | ||
|
||
public static void Success(Window owner, string title, string message, WindowStartupLocation startupLocation = WindowStartupLocation.CenterScreen) | ||
{ | ||
var mbox = new MessageBox(title, message); | ||
if (mbox.FindControl<PathIcon>("InfoIcon") is not { } icon) return; | ||
icon.Data = Icons.CircleCheck; | ||
icon.Foreground = Brushes.DarkGreen; | ||
mbox.WindowStartupLocation = startupLocation; | ||
mbox.ShowDialog(owner); | ||
} | ||
|
||
public static void Error(Window owner, string title, string message, WindowStartupLocation startupLocation = WindowStartupLocation.CenterScreen) | ||
{ | ||
var mbox = new MessageBox(title, message); | ||
if (mbox.FindControl<PathIcon>("InfoIcon") is not { } icon) return; | ||
icon.Data = Icons.CircleClose; | ||
icon.Foreground = Brushes.DarkRed; | ||
mbox.WindowStartupLocation = startupLocation; | ||
mbox.ShowDialog(owner); | ||
} | ||
|
||
private void Close(object sender, RoutedEventArgs e) | ||
{ | ||
Close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.