CPKreuz 1 年之前
父节点
当前提交
55287387c9

+ 6 - 1
src/PixiEditor.AvaloniaUI/Views/Main/CreateDocumentFallbackView.axaml

@@ -3,6 +3,7 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
              xmlns:viewModels="clr-namespace:PixiEditor.AvaloniaUI.ViewModels"
              xmlns:viewModels="clr-namespace:PixiEditor.AvaloniaUI.ViewModels"
+             xmlns:input="clr-namespace:PixiEditor.AvaloniaUI.Views.Input"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
              x:DataType="viewModels:ViewModelMain"
              x:DataType="viewModels:ViewModelMain"
              x:Class="PixiEditor.AvaloniaUI.Views.Main.CreateDocumentFallbackView">
              x:Class="PixiEditor.AvaloniaUI.Views.Main.CreateDocumentFallbackView">
@@ -12,6 +13,10 @@
 
 
     <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
     <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
         <TextBlock Text="Create new document" HorizontalAlignment="Center" VerticalAlignment="Center"/>
         <TextBlock Text="Create new document" HorizontalAlignment="Center" VerticalAlignment="Center"/>
-        <Button Content="Create" Command="{Binding FileSubViewModel.CreateFromNewFileDialog}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+        
+        <input:SizePicker Name="sizePicker" Margin="0 8" />
+        
+        <Button Content="Create" Click="CreateDocumentClick"
+                HorizontalAlignment="Center" VerticalAlignment="Center"/>
     </StackPanel>
     </StackPanel>
 </UserControl>
 </UserControl>

+ 19 - 0
src/PixiEditor.AvaloniaUI/Views/Main/CreateDocumentFallbackView.axaml.cs

@@ -1,6 +1,11 @@
 using Avalonia;
 using Avalonia;
 using Avalonia.Controls;
 using Avalonia.Controls;
+using Avalonia.Interactivity;
 using Avalonia.Markup.Xaml;
 using Avalonia.Markup.Xaml;
+using ChunkyImageLib;
+using PixiEditor.AvaloniaUI.ViewModels;
+using PixiEditor.DrawingApi.Core.Numerics;
+using PixiEditor.Extensions.Common.Localization;
 
 
 namespace PixiEditor.AvaloniaUI.Views.Main;
 namespace PixiEditor.AvaloniaUI.Views.Main;
 
 
@@ -10,5 +15,19 @@ public partial class CreateDocumentFallbackView : UserControl
     {
     {
         InitializeComponent();
         InitializeComponent();
     }
     }
+
+    private void CreateDocumentClick(object? sender, RoutedEventArgs e)
+    {
+        var fileViewModel = ViewModelMain.Current.FileSubViewModel;
+
+        var width = sizePicker.ChosenWidth;
+        var height = sizePicker.ChosenHeight;
+        
+        fileViewModel.NewDocument(b => b
+            .WithSize(width, height)
+            .WithLayer(l => l
+                .WithName(new LocalizedString("BASE_LAYER_NAME"))
+                .WithSurface(new Surface(new VecI(width, height)))));
+    }
 }
 }
 
 

+ 0 - 8
src/PixiEditor.AvaloniaUI/Views/Main/ViewportControls/Viewport.axaml.cs

@@ -310,7 +310,6 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
             this.AddHandler(PointerMovedEvent, Image_MouseMove, RoutingStrategies.Bubble);
             this.AddHandler(PointerMovedEvent, Image_MouseMove, RoutingStrategies.Bubble);
         }
         }
 
 
-         // TODO: that's not how you're actually supposed to do it I think
         viewportGrid.AddHandler(PointerPressedEvent, Image_MouseDown, RoutingStrategies.Bubble);
         viewportGrid.AddHandler(PointerPressedEvent, Image_MouseDown, RoutingStrategies.Bubble);
     }
     }
 
 
@@ -393,8 +392,6 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
 
 
     private void Image_MouseDown(object? sender, PointerPressedEventArgs e)
     private void Image_MouseDown(object? sender, PointerPressedEventArgs e)
     {
     {
-        Console.WriteLine($"we got some mouse button down movement {e.GetCurrentPoint(this).Properties.PointerUpdateKind}");
-        
         bool isMiddle = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
         bool isMiddle = e.GetCurrentPoint(this).Properties.IsMiddleButtonPressed;
         HandleMiddleMouse(isMiddle);
         HandleMiddleMouse(isMiddle);
 
 
@@ -418,11 +415,8 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
 
 
     private void Image_MouseMove(object? sender, PointerEventArgs e)
     private void Image_MouseMove(object? sender, PointerEventArgs e)
     {
     {
-        Console.WriteLine("we got some mouse movement");
-
         if (MouseMoveCommand is null)
         if (MouseMoveCommand is null)
         {
         {
-            Console.WriteLine("but there isn't a mouse move comment");
             return;
             return;
         }
         }
 
 
@@ -444,8 +438,6 @@ internal partial class Viewport : UserControl, INotifyPropertyChanged
 
 
     private void Image_MouseUp(object? sender, PointerReleasedEventArgs e)
     private void Image_MouseUp(object? sender, PointerReleasedEventArgs e)
     {
     {
-        Console.WriteLine($"we got some mouse button up movement {e.GetCurrentPoint(this).Properties.PointerUpdateKind}");
-        
         if (MouseUpCommand is null)
         if (MouseUpCommand is null)
             return;
             return;
 
 

+ 0 - 2
src/PixiEditor.ChangeableDocument/DocumentChangeTracker.cs

@@ -317,9 +317,7 @@ public class DocumentChangeTracker : IDisposable
         if (running)
         if (running)
             throw new InvalidOperationException("Already currently processing");
             throw new InvalidOperationException("Already currently processing");
         running = true;
         running = true;
-        Console.WriteLine($"Doing {actions.Count} now");
         var result = ProcessActionList(actions);
         var result = ProcessActionList(actions);
-        Console.WriteLine("We're done doing these");
         running = false;
         running = false;
         return result;
         return result;
     }
     }