feat: add default template.
This commit is contained in:
@@ -13,6 +13,7 @@ public static class MenuKeys
|
|||||||
public const string MenuKeyIconButton = "IconButton";
|
public const string MenuKeyIconButton = "IconButton";
|
||||||
public const string MenuKeyKeyGestureInput = "KeyGestureInput";
|
public const string MenuKeyKeyGestureInput = "KeyGestureInput";
|
||||||
public const string MenuKeyLoading = "Loading";
|
public const string MenuKeyLoading = "Loading";
|
||||||
|
public const string MenuKeyMessageBox = "MessageBox";
|
||||||
public const string MenuKeyNavigation = "Navigation";
|
public const string MenuKeyNavigation = "Navigation";
|
||||||
public const string MenuKeyPagination = "Pagination";
|
public const string MenuKeyPagination = "Pagination";
|
||||||
public const string MenuKeyTagInput = "TagInput";
|
public const string MenuKeyTagInput = "TagInput";
|
||||||
|
|||||||
13
demo/Ursa.Demo/Pages/MessageBoxDemo.axaml
Normal file
13
demo/Ursa.Demo/Pages/MessageBoxDemo.axaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<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"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
xmlns:vm="using:Ursa.Demo.ViewModels"
|
||||||
|
x:DataType="vm:MessageBoxDemoViewModel"
|
||||||
|
x:CompileBindings="True"
|
||||||
|
x:Class="Ursa.Demo.Pages.MessageBoxDemo">
|
||||||
|
<StackPanel HorizontalAlignment="Left">
|
||||||
|
<Button Content="Default" Command="{Binding DefaultMessageBoxCommand}"></Button>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
15
demo/Ursa.Demo/Pages/MessageBoxDemo.axaml.cs
Normal file
15
demo/Ursa.Demo/Pages/MessageBoxDemo.axaml.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
using Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
|
namespace Ursa.Demo.Pages;
|
||||||
|
|
||||||
|
public partial class MessageBoxDemo : UserControl
|
||||||
|
{
|
||||||
|
public MessageBoxDemo()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.DataContext = new MessageBoxDemoViewModel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,6 +35,7 @@ public class MainViewViewModel : ViewModelBase
|
|||||||
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
|
MenuKeys.MenuKeyIpBox => new IPv4BoxDemoViewModel(),
|
||||||
MenuKeys.MenuKeyKeyGestureInput => new KeyGestureInputDemoViewModel(),
|
MenuKeys.MenuKeyKeyGestureInput => new KeyGestureInputDemoViewModel(),
|
||||||
MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(),
|
MenuKeys.MenuKeyLoading => new LoadingDemoViewModel(),
|
||||||
|
MenuKeys.MenuKeyMessageBox => new MessageBoxDemoViewModel(),
|
||||||
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
|
MenuKeys.MenuKeyNavigation => new NavigationMenuDemoViewModel(),
|
||||||
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
MenuKeys.MenuKeyPagination => new PaginationDemoViewModel(),
|
||||||
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
MenuKeys.MenuKeyTagInput => new TagInputDemoViewModel(),
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public class MenuViewModel: ViewModelBase
|
|||||||
new() { MenuHeader = "IPv4Box", Key = MenuKeys.MenuKeyIpBox },
|
new() { MenuHeader = "IPv4Box", Key = MenuKeys.MenuKeyIpBox },
|
||||||
new() { MenuHeader = "KeyGestureInput", Key = MenuKeys.MenuKeyKeyGestureInput },
|
new() { MenuHeader = "KeyGestureInput", Key = MenuKeys.MenuKeyKeyGestureInput },
|
||||||
new() { MenuHeader = "Loading", Key = MenuKeys.MenuKeyLoading },
|
new() { MenuHeader = "Loading", Key = MenuKeys.MenuKeyLoading },
|
||||||
|
new() { MenuHeader = "Message Box", Key = MenuKeys.MenuKeyMessageBox },
|
||||||
new() { MenuHeader = "Navigation", Key = MenuKeys.MenuKeyNavigation },
|
new() { MenuHeader = "Navigation", Key = MenuKeys.MenuKeyNavigation },
|
||||||
new() { MenuHeader = "Pagination", Key = MenuKeys.MenuKeyPagination },
|
new() { MenuHeader = "Pagination", Key = MenuKeys.MenuKeyPagination },
|
||||||
new() { MenuHeader = "TagInput", Key = MenuKeys.MenuKeyTagInput },
|
new() { MenuHeader = "TagInput", Key = MenuKeys.MenuKeyTagInput },
|
||||||
|
|||||||
22
demo/Ursa.Demo/ViewModels/MessageBoxDemoViewModel.cs
Normal file
22
demo/Ursa.Demo/ViewModels/MessageBoxDemoViewModel.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using Ursa.Controls;
|
||||||
|
|
||||||
|
namespace Ursa.Demo.ViewModels;
|
||||||
|
|
||||||
|
public class MessageBoxDemoViewModel: ObservableObject
|
||||||
|
{
|
||||||
|
public ICommand DefaultMessageBoxCommand { get; set; }
|
||||||
|
|
||||||
|
public MessageBoxDemoViewModel()
|
||||||
|
{
|
||||||
|
DefaultMessageBoxCommand = new AsyncRelayCommand(OnDefaultMessageAsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnDefaultMessageAsync()
|
||||||
|
{
|
||||||
|
await MessageBox.ShowAsync("Hello Message Box");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@
|
|||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
x:CompileBindings="True"
|
x:CompileBindings="True"
|
||||||
|
ExtendClientAreaTitleBarHeightHint="48"
|
||||||
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
x:DataType="viewModels:MainWindowViewModel"
|
x:DataType="viewModels:MainWindowViewModel"
|
||||||
Icon="/Assets/Ursa.ico"
|
Icon="/Assets/Ursa.ico"
|
||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
|
|||||||
41
src/Ursa.Themes.Semi/Controls/MessageBoxWindow.axaml
Normal file
41
src/Ursa.Themes.Semi/Controls/MessageBoxWindow.axaml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:u="https://irihi.tech/ursa">
|
||||||
|
<!-- Add Resources Here -->
|
||||||
|
<ControlTheme TargetType="u:MessageBoxWindow" x:Key="{x:Type u:MessageBoxWindow}">
|
||||||
|
<Setter Property="Background" Value="{DynamicResource WindowDefaultBackground}" />
|
||||||
|
<Setter Property="TransparencyBackgroundFallback" Value="{DynamicResource WindowDefaultBackground}" />
|
||||||
|
<Setter Property="Foreground" Value="{DynamicResource WindowDefaultForeground}" />
|
||||||
|
<Setter Property="FontSize" Value="{DynamicResource DefaultFontSize}" />
|
||||||
|
<Setter Property="FontFamily" Value="{DynamicResource DefaultFontFamily}" />
|
||||||
|
<Setter Property="Padding" Value="48 24"></Setter>
|
||||||
|
<Setter Property="MinHeight" Value="300"></Setter>
|
||||||
|
<Setter Property="SizeToContent" Value="WidthAndHeight"></Setter>
|
||||||
|
<Setter Property="WindowStartupLocation" Value="CenterOwner"></Setter>
|
||||||
|
<Setter Property="ExtendClientAreaTitleBarHeightHint" Value="48"></Setter>
|
||||||
|
<Setter Property="ExtendClientAreaToDecorationsHint" Value="True"></Setter>
|
||||||
|
<Setter Property="SystemDecorations" Value="BorderOnly"></Setter>
|
||||||
|
<Setter Property="CanResize" Value="True"></Setter>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<ControlTemplate TargetType="u:MessageBoxWindow">
|
||||||
|
<Panel>
|
||||||
|
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
|
||||||
|
<Border Background="{TemplateBinding Background}" IsHitTestVisible="False" />
|
||||||
|
<Panel Margin="{TemplateBinding WindowDecorationMargin}" Background="Transparent" />
|
||||||
|
<VisualLayerManager>
|
||||||
|
<VisualLayerManager.ChromeOverlayLayer>
|
||||||
|
<TitleBar />
|
||||||
|
</VisualLayerManager.ChromeOverlayLayer>
|
||||||
|
<ContentPresenter Grid.Row="0"
|
||||||
|
Name="PART_ContentPresenter"
|
||||||
|
Margin="{TemplateBinding Padding}"
|
||||||
|
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||||
|
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||||
|
Content="{TemplateBinding Content}"
|
||||||
|
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||||
|
</VisualLayerManager>
|
||||||
|
</Panel>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter>
|
||||||
|
</ControlTheme>
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
<ResourceInclude Source="IPv4Box.axaml" />
|
<ResourceInclude Source="IPv4Box.axaml" />
|
||||||
<ResourceInclude Source="KeyGestureInput.axaml" />
|
<ResourceInclude Source="KeyGestureInput.axaml" />
|
||||||
<ResourceInclude Source="Loading.axaml" />
|
<ResourceInclude Source="Loading.axaml" />
|
||||||
|
<ResourceInclude Source="MessageBoxWindow.axaml" />
|
||||||
<ResourceInclude Source="Navigation.axaml" />
|
<ResourceInclude Source="Navigation.axaml" />
|
||||||
<ResourceInclude Source="Pagination.axaml" />
|
<ResourceInclude Source="Pagination.axaml" />
|
||||||
<ResourceInclude Source="TagInput.axaml" />
|
<ResourceInclude Source="TagInput.axaml" />
|
||||||
|
|||||||
@@ -1,12 +1,28 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls.ApplicationLifetimes;
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
|
||||||
namespace Ursa.Controls.MessageBox;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
public static class MessageBox
|
public static class MessageBox
|
||||||
{
|
{
|
||||||
public static async Task ShowAsync(string message)
|
public static async Task ShowAsync(string message)
|
||||||
{
|
{
|
||||||
var messageWindow = new MessageBoxWindow();
|
var messageWindow = new MessageBoxWindow()
|
||||||
|
{
|
||||||
|
Content = message
|
||||||
|
};
|
||||||
|
var lifetime = Application.Current?.ApplicationLifetime;
|
||||||
|
if (lifetime is IClassicDesktopStyleApplicationLifetime classLifetime)
|
||||||
|
{
|
||||||
|
var main = classLifetime.MainWindow;
|
||||||
|
if (main is null)
|
||||||
|
{
|
||||||
|
messageWindow.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await messageWindow.ShowDialog(main);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Platform;
|
using Avalonia.Platform;
|
||||||
|
|
||||||
namespace Ursa.Controls.MessageBox;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
public class MessageBoxWindow: Window
|
public class MessageBoxWindow: Window
|
||||||
{
|
{
|
||||||
@@ -9,7 +9,6 @@ public class MessageBoxWindow: Window
|
|||||||
|
|
||||||
static MessageBoxWindow()
|
static MessageBoxWindow()
|
||||||
{
|
{
|
||||||
ExtendClientAreaChromeHintsProperty.OverrideDefaultValue<MessageBoxWindow>(ExtendClientAreaChromeHints
|
|
||||||
.NoChrome);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user