NewFileDialog.cs 956 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using PixiEditor.Extensions.Common.UserPreferences;
  2. using PixiEditor.Views;
  3. using PixiEditor.Views.Dialogs;
  4. namespace PixiEditor.Models.Dialogs;
  5. internal class NewFileDialog : CustomDialog
  6. {
  7. private int height = IPreferences.Current.GetPreference("DefaultNewFileHeight", Constants.DefaultCanvasSize);
  8. private int width = IPreferences.Current.GetPreference("DefaultNewFileWidth", Constants.DefaultCanvasSize);
  9. public int Width
  10. {
  11. get => width;
  12. set => SetProperty(ref width, value);
  13. }
  14. public int Height
  15. {
  16. get => height;
  17. set => SetProperty(ref height, value);
  18. }
  19. public override bool ShowDialog()
  20. {
  21. NewFilePopup popup = new()
  22. {
  23. FileWidth = Width,
  24. FileHeight = Height
  25. };
  26. popup.ShowDialog();
  27. Height = popup.FileHeight;
  28. Width = popup.FileWidth;
  29. return popup.DialogResult.GetValueOrDefault();
  30. }
  31. }