Диалог создания окна, фикс актуального документа
This commit is contained in:
@@ -640,6 +640,8 @@ public partial class EditorViewModel : ViewModelBase
|
||||
_animationTimer?.Stop();
|
||||
_animationTimer = null;
|
||||
IsPlaying = false;
|
||||
if (ActiveDocument is not null)
|
||||
SyncLayersAndCanvas(ActiveDocument);
|
||||
}
|
||||
|
||||
private void AdvanceAnimationFrame()
|
||||
|
||||
@@ -50,10 +50,18 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
#region File commands
|
||||
|
||||
[RelayCommand]
|
||||
private void NewFile()
|
||||
private async Task NewFileAsync()
|
||||
{
|
||||
Editor.NewContainer(64, 64);
|
||||
StatusText = "New 64×64 container created.";
|
||||
if (Owner is not Window window) return;
|
||||
|
||||
var dialog = new NewContainerDialog();
|
||||
var result = await dialog.ShowDialog<bool?>(window);
|
||||
if (result != true) return;
|
||||
|
||||
int w = dialog.CanvasWidth;
|
||||
int h = dialog.CanvasHeight;
|
||||
Editor.NewContainer(w, h);
|
||||
StatusText = $"New {w}×{h} container created.";
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
|
||||
31
Minint/Views/NewContainerDialog.axaml
Normal file
31
Minint/Views/NewContainerDialog.axaml
Normal file
@@ -0,0 +1,31 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Minint.Views.NewContainerDialog"
|
||||
Title="New Container"
|
||||
Width="300"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
CanResize="False"
|
||||
SizeToContent="Height">
|
||||
<StackPanel Margin="16" Spacing="12">
|
||||
<TextBlock Text="Canvas size:" FontWeight="SemiBold"/>
|
||||
|
||||
<Grid ColumnDefinitions="Auto,*" RowDefinitions="Auto,Auto" RowSpacing="8" ColumnSpacing="8">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Width:" VerticalAlignment="Center"/>
|
||||
<NumericUpDown Grid.Row="0" Grid.Column="1"
|
||||
x:Name="WidthInput"
|
||||
Value="64" Minimum="1" Maximum="4096" Increment="1"
|
||||
FormatString="0"/>
|
||||
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Text="Height:" VerticalAlignment="Center"/>
|
||||
<NumericUpDown Grid.Row="1" Grid.Column="1"
|
||||
x:Name="HeightInput"
|
||||
Value="64" Minimum="1" Maximum="4096" Increment="1"
|
||||
FormatString="0"/>
|
||||
</Grid>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Spacing="8" Margin="0,8,0,0">
|
||||
<Button Content="Create" x:Name="OkButton" IsDefault="True" Padding="16,6"/>
|
||||
<Button Content="Cancel" x:Name="CancelButton" IsCancel="True" Padding="16,6"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Window>
|
||||
17
Minint/Views/NewContainerDialog.axaml.cs
Normal file
17
Minint/Views/NewContainerDialog.axaml.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Minint.Views;
|
||||
|
||||
public partial class NewContainerDialog : Window
|
||||
{
|
||||
public int CanvasWidth => (int)(WidthInput.Value ?? 64);
|
||||
public int CanvasHeight => (int)(HeightInput.Value ?? 64);
|
||||
|
||||
public NewContainerDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
OkButton.Click += (_, _) => Close(true);
|
||||
CancelButton.Click += (_, _) => Close(false);
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,12 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="Minint.Views.PatternDialog"
|
||||
Title="Generate Pattern"
|
||||
Width="360"
|
||||
Width="640"
|
||||
Height="520"
|
||||
MinWidth="480"
|
||||
MinHeight="400"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
CanResize="False"
|
||||
SizeToContent="Height">
|
||||
CanResize="True">
|
||||
<StackPanel Margin="16" Spacing="8">
|
||||
<Grid ColumnDefinitions="100,*" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto" RowSpacing="6" ColumnSpacing="8">
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Text="Pattern:" VerticalAlignment="Center"/>
|
||||
|
||||
Reference in New Issue
Block a user