Skip to content

Commit 0f78202

Browse files
committed
[Presentation] Use vector graphics for message box icon.
1 parent 99fa8fe commit 0f78202

10 files changed

Lines changed: 43 additions & 50 deletions

File tree

sources/presentation/Stride.Core.Presentation.Avalonia/Assets/Images/error-32.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

sources/presentation/Stride.Core.Presentation.Avalonia/Assets/Images/info-32.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

sources/presentation/Stride.Core.Presentation.Avalonia/Assets/Images/question-32.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

sources/presentation/Stride.Core.Presentation.Avalonia/Assets/Images/warning-32.png

Lines changed: 0 additions & 3 deletions
This file was deleted.

sources/presentation/Stride.Core.Presentation.Avalonia/Stride.Core.Presentation.Avalonia.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,5 @@
2828
<ProjectReference Include="..\..\presentation\Stride.Core.Presentation\Stride.Core.Presentation.csproj" />
2929
</ItemGroup>
3030

31-
<ItemGroup>
32-
<AvaloniaResource Include="Assets\**" />
33-
</ItemGroup>
34-
3531
<Import Project="$(StrideSdkTargets)" />
3632
</Project>

sources/presentation/Stride.Core.Presentation.Avalonia/Windows/CheckedMessageBox.axaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
x:Class="Stride.Core.Presentation.Avalonia.Windows.CheckedMessageBox">
1515
<Window.Resources>
1616
<ResourceDictionary>
17-
<ImageBrush x:Key="ImageErrorDialog" Source="/Assets/Images/error-32.png" />
18-
<ImageBrush x:Key="ImageInformationDialog" Source="/Assets/Images/info-32.png" />
19-
<ImageBrush x:Key="ImageQuestionDialog" Source="/Assets/Images/question-32.png" />
20-
<ImageBrush x:Key="ImageWarningDialog" Source="/Assets/Images/warning-32.png" />
17+
<ResourceDictionary.MergedDictionaries>
18+
<ResourceInclude Source="avares://Stride.Core.Presentation.Avalonia/Windows/GeometryResources.axaml"/>
19+
</ResourceDictionary.MergedDictionaries>
2120
</ResourceDictionary>
2221
</Window.Resources>
2322
<Window.ContentTemplate>
@@ -53,11 +52,12 @@
5352
IsChecked="{Binding $parent[windows:CheckedMessageBox].IsChecked}"
5453
HorizontalAlignment="Left" VerticalAlignment="Bottom"
5554
Margin="0,12,0,4" />
56-
<Image DockPanel.Dock="Left"
57-
Source="{Binding $parent[windows:MessageBox].Image}"
58-
HorizontalAlignment="Left" VerticalAlignment="Top"
59-
Height="32" Width="32" Margin="8,4"
60-
IsVisible="{Binding $parent[windows:MessageBox].Image, Converter={cvt:ObjectToBool}}" />
55+
<Path DockPanel.Dock="Left"
56+
HorizontalAlignment="Left" VerticalAlignment="Top"
57+
Height="32" Width="32" Margin="4"
58+
Stretch="Uniform" Fill="{DynamicResource SystemAccentColor}"
59+
Data="{Binding $parent[windows:MessageBox].Geometry}"
60+
IsVisible="{Binding $parent[windows:MessageBox].Geometry, Converter={cvt:ObjectToBool}}" />
6161
<md:MarkdownScrollViewer Markdown="{ReflectionBinding}" VerticalAlignment="Center" />
6262
</DockPanel>
6363
</DataTemplate>

sources/presentation/Stride.Core.Presentation.Avalonia/Windows/CheckedMessageBox.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public static async Task<CheckedMessageBoxResult> ShowAsync(string caption, stri
4444
CheckedMessage = checkedMessage,
4545
IsChecked = isChecked,
4646
};
47-
SetImage(messageBox, image);
47+
SetGeometry(messageBox, image);
4848
SetKeyBindings(messageBox, buttons);
4949
if (owner is not null)
5050
{
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<ResourceDictionary xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
3+
4+
<!-- Fluent Icons for Avalonia (https://avaloniaui.github.io/icons.html) -->
5+
<Geometry x:Key="GeometryError">M12.45 2.15C14.992 4.05652 17.5866 5 20.25 5C20.6642 5 21 5.33579 21 5.75V11C21 16.0012 18.0424 19.6757 12.2749 21.9478C12.0982 22.0174 11.9018 22.0174 11.7251 21.9478C5.95756 19.6757 3 16.0012 3 11V5.75C3 5.33579 3.33579 5 3.75 5C6.41341 5 9.00797 4.05652 11.55 2.15C11.8167 1.95 12.1833 1.95 12.45 2.15ZM12 3.67782C9.58084 5.38829 7.07735 6.32585 4.5 6.47793V11C4.5 15.2556 6.95337 18.3789 12 20.4419C17.0466 18.3789 19.5 15.2556 19.5 11V6.47793C16.9227 6.32585 14.4192 5.38829 12 3.67782ZM12 16C12.4142 16 12.75 16.3358 12.75 16.75C12.75 17.1642 12.4142 17.5 12 17.5C11.5858 17.5 11.25 17.1642 11.25 16.75C11.25 16.3358 11.5858 16 12 16ZM12 7.00356C12.3797 7.00356 12.6935 7.28572 12.7432 7.65179L12.75 7.75356V14.2523C12.75 14.6665 12.4142 15.0023 12 15.0023C11.6203 15.0023 11.3065 14.7201 11.2568 14.3541L11.25 14.2523V7.75356C11.25 7.33935 11.5858 7.00356 12 7.00356Z</Geometry>
6+
<Geometry x:Key="GeometryInformation">M14,2 C20.6274,2 26,7.37258 26,14 C26,20.6274 20.6274,26 14,26 C7.37258,26 2,20.6274 2,14 C2,7.37258 7.37258,2 14,2 Z M14,3.5 C8.20101,3.5 3.5,8.20101 3.5,14 C3.5,19.799 8.20101,24.5 14,24.5 C19.799,24.5 24.5,19.799 24.5,14 C24.5,8.20101 19.799,3.5 14,3.5 Z M14,11 C14.3796833,11 14.6934889,11.2821653 14.7431531,11.6482323 L14.75,11.75 L14.75,19.25 C14.75,19.6642 14.4142,20 14,20 C13.6203167,20 13.3065111,19.7178347 13.2568469,19.3517677 L13.25,19.25 L13.25,11.75 C13.25,11.3358 13.5858,11 14,11 Z M14,7 C14.5523,7 15,7.44772 15,8 C15,8.55228 14.5523,9 14,9 C13.4477,9 13,8.55228 13,8 C13,7.44772 13.4477,7 14,7 Z</Geometry>
7+
<Geometry x:Key="GeometryQuestion">M24 4C35.0457 4 44 12.9543 44 24C44 35.0457 35.0457 44 24 44C12.9543 44 4 35.0457 4 24C4 12.9543 12.9543 4 24 4ZM24 6.5C14.335 6.5 6.5 14.335 6.5 24C6.5 33.665 14.335 41.5 24 41.5C33.665 41.5 41.5 33.665 41.5 24C41.5 14.335 33.665 6.5 24 6.5ZM24.25 32C25.0784 32 25.75 32.6716 25.75 33.5C25.75 34.3284 25.0784 35 24.25 35C23.4216 35 22.75 34.3284 22.75 33.5C22.75 32.6716 23.4216 32 24.25 32ZM24.25 13C27.6147 13 30.5 15.8821 30.5 19.2488C30.502 21.3691 29.7314 22.7192 27.8216 24.7772L26.8066 25.8638C25.7842 27.0028 25.3794 27.7252 25.3409 28.5793L25.3379 28.7411L25.3323 28.8689L25.3143 28.9932C25.2018 29.5636 24.7009 29.9957 24.0968 30.0001C23.4065 30.0049 22.8428 29.4493 22.8379 28.7589C22.8251 26.9703 23.5147 25.7467 25.1461 23.9739L26.1734 22.8762C27.5312 21.3837 28.0012 20.503 28 19.25C28 17.2634 26.2346 15.5 24.25 15.5C22.3307 15.5 20.6142 17.1536 20.5055 19.0587L20.4935 19.3778C20.4295 20.0081 19.8972 20.5 19.25 20.5C18.5596 20.5 18 19.9404 18 19.25C18 15.8846 20.8864 13 24.25 13Z</Geometry>
8+
<Geometry x:Key="GeometryWarning">M10.9093922,2.78216375 C11.9491636,2.20625071 13.2471955,2.54089334 13.8850247,3.52240345 L13.9678229,3.66023048 L21.7267791,17.6684928 C21.9115773,18.0021332 22.0085303,18.3772743 22.0085303,18.7586748 C22.0085303,19.9495388 21.0833687,20.9243197 19.9125791,21.003484 L19.7585303,21.0086748 L4.24277801,21.0086748 C3.86146742,21.0086748 3.48641186,20.9117674 3.15282824,20.7270522 C2.11298886,20.1512618 1.7079483,18.8734454 2.20150311,17.8120352 L2.27440063,17.668725 L10.0311968,3.66046274 C10.2357246,3.291099 10.5400526,2.98673515 10.9093922,2.78216375 Z M20.4146132,18.3952808 L12.6556571,4.3870185 C12.4549601,4.02467391 11.9985248,3.89363262 11.6361802,4.09432959 C11.5438453,4.14547244 11.4637001,4.21532637 11.4006367,4.29899869 L11.3434484,4.38709592 L3.58665221,18.3953582 C3.385998,18.7577265 3.51709315,19.2141464 3.87946142,19.4148006 C3.96285732,19.4609794 4.05402922,19.4906942 4.14802472,19.5026655 L4.24277801,19.5086748 L19.7585303,19.5086748 C20.1727439,19.5086748 20.5085303,19.1728883 20.5085303,18.7586748 C20.5085303,18.6633247 20.4903516,18.5691482 20.455275,18.4811011 L20.4146132,18.3952808 L12.6556571,4.3870185 L20.4146132,18.3952808 Z M12.0004478,16.0017852 C12.5519939,16.0017852 12.9991104,16.4489016 12.9991104,17.0004478 C12.9991104,17.5519939 12.5519939,17.9991104 12.0004478,17.9991104 C11.4489016,17.9991104 11.0017852,17.5519939 11.0017852,17.0004478 C11.0017852,16.4489016 11.4489016,16.0017852 12.0004478,16.0017852 Z M11.9962476,8.49954934 C12.3759432,8.49924613 12.689964,8.78114897 12.7399193,9.14718469 L12.7468472,9.24894974 L12.750448,13.7505438 C12.7507788,14.1647572 12.4152611,14.5008121 12.0010476,14.5011439 C11.621352,14.5014471 11.3073312,14.2195442 11.257376,13.8535085 L11.250448,13.7517435 L11.2468472,9.25014944 C11.2465164,8.83593601 11.5820341,8.49988112 11.9962476,8.49954934 Z</Geometry>
9+
</ResourceDictionary>

sources/presentation/Stride.Core.Presentation.Avalonia/Windows/MessageBox.axaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
x:Class="Stride.Core.Presentation.Avalonia.Windows.MessageBox">
1515
<Window.Resources>
1616
<ResourceDictionary>
17-
<ImageBrush x:Key="ImageErrorDialog" Source="/Assets/Images/error-32.png" />
18-
<ImageBrush x:Key="ImageInformationDialog" Source="/Assets/Images/info-32.png" />
19-
<ImageBrush x:Key="ImageQuestionDialog" Source="/Assets/Images/question-32.png" />
20-
<ImageBrush x:Key="ImageWarningDialog" Source="/Assets/Images/warning-32.png" />
17+
<ResourceDictionary.MergedDictionaries>
18+
<ResourceInclude Source="avares://Stride.Core.Presentation.Avalonia/Windows/GeometryResources.axaml"/>
19+
</ResourceDictionary.MergedDictionaries>
2120
</ResourceDictionary>
2221
</Window.Resources>
2322
<Window.ContentTemplate>
@@ -48,11 +47,12 @@
4847
<ContentPresenter.ContentTemplate>
4948
<DataTemplate>
5049
<DockPanel LastChildFill="True">
51-
<Image DockPanel.Dock="Left"
52-
Source="{Binding $parent[windows:MessageBox].Image}"
53-
HorizontalAlignment="Left" VerticalAlignment="Top"
54-
Height="32" Width="32" Margin="4"
55-
IsVisible="{Binding $parent[windows:MessageBox].Image, Converter={cvt:ObjectToBool}}" />
50+
<Path DockPanel.Dock="Left"
51+
HorizontalAlignment="Left" VerticalAlignment="Top"
52+
Height="32" Width="32" Margin="4"
53+
Stretch="Uniform" Fill="{DynamicResource SystemAccentColor}"
54+
Data="{Binding $parent[windows:MessageBox].Geometry}"
55+
IsVisible="{Binding $parent[windows:MessageBox].Geometry, Converter={cvt:ObjectToBool}}" />
5656
<md:MarkdownScrollViewer Markdown="{ReflectionBinding}" VerticalAlignment="Center" />
5757
</DockPanel>
5858
</DataTemplate>

sources/presentation/Stride.Core.Presentation.Avalonia/Windows/MessageBox.axaml.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ namespace Stride.Core.Presentation.Avalonia.Windows;
1212

1313
public partial class MessageBox : MessageDialogBase
1414
{
15-
public static readonly StyledProperty<IImageBrushSource?> ImageProperty =
16-
AvaloniaProperty.Register<MessageBox, IImageBrushSource?>(nameof(Image));
15+
public static readonly StyledProperty<Geometry?> GeometryProperty =
16+
AvaloniaProperty.Register<MessageBox, Geometry?>(nameof(Geometry));
1717

1818
public MessageBox()
1919
{
2020
InitializeComponent();
2121
}
2222

23-
public IImageBrushSource? Image
23+
public Geometry? Geometry
2424
{
25-
get { return GetValue(ImageProperty); }
26-
set { SetValue(ImageProperty, value); }
25+
get { return GetValue(GeometryProperty); }
26+
set { SetValue(GeometryProperty, value); }
2727
}
2828

2929
public static async Task<int> ShowAsync(string caption, string message, IReadOnlyCollection<DialogButtonInfo> buttons, MessageBoxImage image = MessageBoxImage.None, Window? owner = null)
@@ -34,7 +34,7 @@ public static async Task<int> ShowAsync(string caption, string message, IReadOnl
3434
Content = message,
3535
Title = caption,
3636
};
37-
SetImage(messageBox, image);
37+
SetGeometry(messageBox, image);
3838
SetKeyBindings(messageBox, buttons);
3939
if (owner is not null)
4040
{
@@ -67,21 +67,21 @@ protected static void SetKeyBindings(MessageBox messageBox, IEnumerable<DialogBu
6767
}
6868
}
6969

70-
protected static void SetImage(MessageBox messageBox, MessageBoxImage image)
70+
protected static void SetGeometry(MessageBox messageBox, MessageBoxImage image)
7171
{
72-
var imageKey = image switch
72+
var key = image switch
7373
{
7474
MessageBoxImage.None => null,
75-
MessageBoxImage.Error => "ImageErrorDialog",
76-
MessageBoxImage.Question => "ImageQuestionDialog",
77-
MessageBoxImage.Warning => "ImageWarningDialog",
78-
MessageBoxImage.Information => "ImageInformationDialog",
75+
MessageBoxImage.Error => "GeometryError",
76+
MessageBoxImage.Question => "GeometryQuestion",
77+
MessageBoxImage.Warning => "GeometryWarning",
78+
MessageBoxImage.Information => "GeometryInformation",
7979
_ => throw new ArgumentOutOfRangeException(nameof(image), image, null),
8080
};
81-
if (imageKey is not null)
81+
if (key is not null)
8282
{
83-
messageBox.TryGetResource(imageKey, null, out var bitmap);
84-
messageBox.Image = (bitmap as ImageBrush)?.Source;
83+
messageBox.TryGetResource(key, null, out var geometry);
84+
messageBox.Geometry = geometry as Geometry;
8585
}
8686
}
8787
}

0 commit comments

Comments
 (0)