ExportFileDialog.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using PixiEditor.Models.Enums;
  2. using PixiEditor.Views;
  3. using System.Windows;
  4. namespace PixiEditor.Models.Dialogs
  5. {
  6. public class ExportFileDialog : CustomDialog
  7. {
  8. FileType _chosenFormat;
  9. private int fileHeight;
  10. private string filePath;
  11. private int fileWidth;
  12. public ExportFileDialog(Size fileDimensions)
  13. {
  14. FileHeight = (int)fileDimensions.Height;
  15. FileWidth = (int)fileDimensions.Width;
  16. }
  17. public int FileWidth
  18. {
  19. get => fileWidth;
  20. set
  21. {
  22. if (fileWidth != value)
  23. {
  24. fileWidth = value;
  25. RaisePropertyChanged("Width");
  26. }
  27. }
  28. }
  29. public int FileHeight
  30. {
  31. get => fileHeight;
  32. set
  33. {
  34. if (fileHeight != value)
  35. {
  36. fileHeight = value;
  37. RaisePropertyChanged("FileHeight");
  38. }
  39. }
  40. }
  41. public string FilePath
  42. {
  43. get => filePath;
  44. set
  45. {
  46. if (filePath != value)
  47. {
  48. filePath = value;
  49. RaisePropertyChanged("FilePath");
  50. }
  51. }
  52. }
  53. public FileType ChosenFormat
  54. {
  55. get => _chosenFormat;
  56. set
  57. {
  58. if (_chosenFormat != value)
  59. {
  60. _chosenFormat = value;
  61. RaisePropertyChanged(nameof(ChosenFormat));
  62. }
  63. }
  64. }
  65. public override bool ShowDialog()
  66. {
  67. ExportFilePopup popup = new ExportFilePopup(FileWidth, FileHeight);
  68. popup.ShowDialog();
  69. if (popup.DialogResult == true)
  70. {
  71. FileWidth = popup.SaveWidth;
  72. FileHeight = popup.SaveHeight;
  73. FilePath = popup.SavePath;
  74. ChosenFormat = popup.SaveFormat;
  75. }
  76. return (bool)popup.DialogResult;
  77. }
  78. }
  79. }