|
@@ -1,12 +1,13 @@
|
|
|
using PixiEditor.Models.Enums;
|
|
|
using PixiEditor.ViewModels;
|
|
|
-using System.Drawing.Imaging;
|
|
|
+using System;
|
|
|
+using System.ComponentModel;
|
|
|
using System.Windows;
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
namespace PixiEditor.Views
|
|
|
{
|
|
|
- public partial class ExportFilePopup : Window
|
|
|
+ public partial class ExportFilePopup : Window, INotifyPropertyChanged
|
|
|
{
|
|
|
public static readonly DependencyProperty SaveHeightProperty =
|
|
|
DependencyProperty.Register("SaveHeight", typeof(int), typeof(ExportFilePopup), new PropertyMetadata(32));
|
|
@@ -17,6 +18,12 @@ namespace PixiEditor.Views
|
|
|
|
|
|
private readonly SaveFilePopupViewModel dataContext = new SaveFilePopupViewModel();
|
|
|
|
|
|
+ public event PropertyChangedEventHandler PropertyChanged;
|
|
|
+
|
|
|
+ private int imageWidth;
|
|
|
+ private int imageHeight;
|
|
|
+ public string SizeHint => $"If you want to share the image, try {GetBestPercentage()}% for the best clarity";
|
|
|
+
|
|
|
private void CommandBinding_CanExecute(object sender, CanExecuteRoutedEventArgs e)
|
|
|
{
|
|
|
e.CanExecute = true;
|
|
@@ -27,14 +34,30 @@ namespace PixiEditor.Views
|
|
|
SystemCommands.CloseWindow(this);
|
|
|
}
|
|
|
|
|
|
- public ExportFilePopup()
|
|
|
+ public ExportFilePopup(int imageWidth, int imageHeight)
|
|
|
{
|
|
|
+ this.imageWidth = imageWidth;
|
|
|
+ this.imageHeight = imageHeight;
|
|
|
+
|
|
|
InitializeComponent();
|
|
|
Owner = Application.Current.MainWindow;
|
|
|
DataContext = dataContext;
|
|
|
Loaded += (_, _) => sizePicker.FocusWidthPicker();
|
|
|
+
|
|
|
+ SaveWidth = imageWidth;
|
|
|
+ SaveHeight = imageHeight;
|
|
|
}
|
|
|
|
|
|
+ private int GetBestPercentage()
|
|
|
+ {
|
|
|
+ int maxDim = Math.Max(imageWidth, imageWidth);
|
|
|
+ for (int i = 16; i >= 1; i--)
|
|
|
+ {
|
|
|
+ if (maxDim * i <= 1280)
|
|
|
+ return i * 100;
|
|
|
+ }
|
|
|
+ return 100;
|
|
|
+ }
|
|
|
|
|
|
public int SaveWidth
|
|
|
{
|
|
@@ -55,7 +78,7 @@ namespace PixiEditor.Views
|
|
|
set => dataContext.FilePath = value;
|
|
|
}
|
|
|
|
|
|
- public FileType SaveFormat
|
|
|
+ public FileType SaveFormat
|
|
|
{
|
|
|
get => dataContext.ChosenFormat;
|
|
|
set => dataContext.ChosenFormat = value;
|