-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMessageBox.axaml.cs
More file actions
40 lines (34 loc) · 1.1 KB
/
MessageBox.axaml.cs
File metadata and controls
40 lines (34 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Runtime.InteropServices;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
namespace Autodraw;
public partial class MessageBox : Window
{
public MessageBox()
{
InitializeComponent();
CloseAppButton.Click += CloseAppButton_Click;
}
public void ShowMessageBox(string title, string description, string icon = "info", string sound = "alert.wav")
{
Bitmap bmp = new(AssetLoader.Open(new Uri($"avares://Autodraw/Assets/Message/{icon}.png")));
MessageIcon.Source = bmp;
MessageTitle.Text = title;
MessageContent.Text = description;
Show();
}
private void OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return;
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed && e.GetPosition(this).Y <= 20)
BeginMoveDrag(e);
}
private void CloseAppButton_Click(object? sender, RoutedEventArgs e)
{
Close();
}
}