Browse Source

Converted NoticePopup and OptionPopup

Krzysztof Krysiński 1 year ago
parent
commit
11dc48fce9

+ 1 - 0
src/PixiEditor.AvaloniaUI/Models/Commands/Templates/Providers/Parsers/KeysParser.cs

@@ -19,6 +19,7 @@ public abstract class KeysParser
     
     public KeysParser(string mapFileName)
     {
+        // TODO: Fix this, should use avares:// or custom path for external parsers
         _fullMapFilePath = Path.Combine(Paths.DataFullPath, "ShortcutActionMaps", mapFileName);
         if (!File.Exists(_fullMapFilePath))
         {

+ 3 - 2
src/PixiEditor.AvaloniaUI/PixiEditor.AvaloniaUI.csproj

@@ -10,8 +10,9 @@
 
     <ItemGroup>
       <AvaloniaResource Include="Assets\**" />
-      <AvaloniaResource Include="Data\**" />
-      <AvaloniaResource Include="Data\Languages\**" />
+      <AvaloniaResource Include="Data\**"/>
+      <AvaloniaResource Include="Data\Languages\**"/>
+      <AvaloniaResource Include="Data\ShortcutActionMaps\**"/>
       <None Remove="Images\Create-mask.svg" />
       <AvaloniaResource Include="Images\Create-mask.svg" />
       <None Remove="Images\Lock-alpha.svg" />

+ 7 - 18
src/PixiEditor.AvaloniaUI/Views/Dialogs/NoticePopup.axaml

@@ -1,4 +1,4 @@
-<controls:Window x:Class="PixiEditor.AvaloniaUI.Views.Dialogs.NoticePopup"
+<dialogs:PixiEditorPopup x:Class="PixiEditor.AvaloniaUI.Views.Dialogs.NoticePopup"
         x:ClassModifier="internal"
         xmlns="https://github.com/avaloniaui"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@@ -7,26 +7,15 @@
         xmlns:ui="clr-namespace:PixiEditor.Extensions.UI;assembly=PixiEditor.Extensions"
         xmlns:controls="https://github.com/avaloniaui"
         xmlns:markupExtensions="clr-namespace:PixiEditor.AvaloniaUI.Helpers.MarkupExtensions"
+        xmlns:dialogs="clr-namespace:PixiEditor.AvaloniaUI.Views.Dialogs"
         mc:Ignorable="d"
         d:Title="Notice" Height="180" Width="400" MinHeight="180" MinWidth="400"
-        WindowStartupLocation="CenterScreen"
+        CanResize="False"
+        CanMinimize="False"
         x:Name="popup"
-        ui:Translator.Key="{Binding ElementName=popup, Path=Title, Mode=OneTime}"
-        FlowDirection="{markupExtensions:Localization FlowDirection}">
-
-    <!--<WindowChrome.WindowChrome>
-        <WindowChrome CaptionHeight="32"  GlassFrameThickness="0.1"
-                      ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
-    </WindowChrome.WindowChrome>-->
-
-    <DockPanel Background="{DynamicResource ThemeBackgroundBrush1}" Focusable="True">
-        <Interaction.Behaviors>
-            <!--<behaviours:ClearFocusOnClickBehavior/>-->
-        </Interaction.Behaviors>
-
-        <!--<dial:DialogTitleBar DockPanel.Dock="Top"
-            TitleKey="{Binding ElementName=popup, Path=Title}" CloseCommand="{Binding DataContext.CancelCommand, ElementName=popup}" />-->
+        ui:Translator.Key="{Binding ElementName=popup, Path=Title, Mode=OneTime}">
 
+    <DockPanel>
         <StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,0,15">
             <Button Width="70" IsDefault="True" Click="OkButton_Close" ui:Translator.Key="CLOSE"/>
         </StackPanel>
@@ -36,4 +25,4 @@
             VerticalAlignment="Center" FontSize="15" Foreground="White" Margin="20,0" d:Text="The file does not exist"
             TextWrapping="WrapWithOverflow" TextTrimming="WordEllipsis" />
     </DockPanel>
-</controls:Window>
+</dialogs:PixiEditorPopup>

+ 1 - 1
src/PixiEditor.AvaloniaUI/Views/Dialogs/NoticePopup.axaml.cs

@@ -7,7 +7,7 @@ namespace PixiEditor.AvaloniaUI.Views.Dialogs;
 /// <summary>
 /// Interaction logic for NoticePopup.xaml.
 /// </summary>
-internal partial class NoticePopup : Window
+internal partial class NoticePopup : PixiEditorPopup
 {
     public static readonly StyledProperty<string> BodyProperty =
         AvaloniaProperty.Register<NoticePopup, string>(nameof(Body));

+ 3 - 15
src/PixiEditor.AvaloniaUI/Views/Dialogs/OptionPopup.axaml

@@ -1,4 +1,4 @@
-<Window
+<local:PixiEditorPopup
     xmlns="https://github.com/avaloniaui"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@@ -12,31 +12,19 @@
     d:DesignHeight="450"
     x:Class="PixiEditor.AvaloniaUI.Views.Dialogs.OptionPopup"
     Title="OptionPopup"
-    WindowStartupLocation="CenterScreen"
     SizeToContent="WidthAndHeight"
     Name="popup"
-    Background="{DynamicResource AccentColor}"
-    FlowDirection="{markupExtensions:Localization FlowDirection}"
     ui:Translator.Key="{Binding #popup.Title}">
-    
-    <!--<WindowChrome.WindowChrome>
-        <WindowChrome CaptionHeight="32"  GlassFrameThickness="0.1"
-                      ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
-    </WindowChrome.WindowChrome>-->
-
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="Auto"/>
             <RowDefinition/>
             <RowDefinition Height="Auto"/>
         </Grid.RowDefinitions>
 
-        <local:DialogTitleBar TitleKey="{Binding #popup.Title}" CloseCommand="{Binding #popup.CancelCommand}"/>
-
         <ContentPresenter Content="{Binding #popup.PopupContent}"
                           Grid.Row="1" Margin="15"/>
 
-        <ItemsControl ItemsSource="{Binding #popup.Options}" Grid.Row="2" Margin="15">
+        <ItemsControl ItemsSource="{Binding #popup.Options}" Grid.Row="1" Margin="15">
             <ItemsControl.ItemTemplate>
                 <DataTemplate>
                     <Button Content="{Binding}" MinWidth="70" Margin="5,0"
@@ -50,4 +38,4 @@
             </ItemsControl.ItemsPanel>
         </ItemsControl>
     </Grid>
-</Window>
+</local:PixiEditorPopup>

+ 1 - 1
src/PixiEditor.AvaloniaUI/Views/Dialogs/OptionPopup.axaml.cs

@@ -6,7 +6,7 @@ using CommunityToolkit.Mvvm.Input;
 
 namespace PixiEditor.AvaloniaUI.Views.Dialogs;
 
-public partial class OptionPopup : Window
+public partial class OptionPopup : PixiEditorPopup
 {
     public static readonly StyledProperty<object> PopupContentProperty =
         AvaloniaProperty.Register<OptionPopup, object>(nameof(PopupContent));