mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 19:57:57 +01:00
[ImageResizer]Use updated images from input when pressing Enter(#26292)
* [Image Resizer] HandleEnterKeyPress event added for image resizer. * [Image Resizer] * Comments are added to Button_KeyDown function * Uncessary spaces are removed. * [Image Resizer] Workaround reasons are added to function summary.
This commit is contained in:
@@ -18,6 +18,19 @@ namespace ImageResizer.ViewModels
|
||||
private readonly MainViewModel _mainViewModel;
|
||||
private readonly IMainView _mainView;
|
||||
|
||||
public enum Dimension
|
||||
{
|
||||
Width,
|
||||
Height,
|
||||
}
|
||||
|
||||
public class KeyPressParams
|
||||
{
|
||||
public double Value { get; set; }
|
||||
|
||||
public Dimension Dimension { get; set; }
|
||||
}
|
||||
|
||||
public InputViewModel(
|
||||
Settings settings,
|
||||
MainViewModel mainViewModel,
|
||||
@@ -37,6 +50,7 @@ namespace ImageResizer.ViewModels
|
||||
ResizeCommand = new RelayCommand(Resize);
|
||||
CancelCommand = new RelayCommand(Cancel);
|
||||
OpenSettingsCommand = new RelayCommand(OpenSettings);
|
||||
EnterKeyPressedCommand = new RelayCommand<KeyPressParams>(HandleEnterKeyPress);
|
||||
}
|
||||
|
||||
public Settings Settings { get; }
|
||||
@@ -47,6 +61,8 @@ namespace ImageResizer.ViewModels
|
||||
|
||||
public ICommand OpenSettingsCommand { get; }
|
||||
|
||||
public ICommand EnterKeyPressedCommand { get; private set; }
|
||||
|
||||
public bool TryingToResizeGifFiles
|
||||
{
|
||||
get
|
||||
@@ -67,6 +83,19 @@ namespace ImageResizer.ViewModels
|
||||
SettingsDeepLink.OpenSettings(SettingsDeepLink.SettingsWindow.ImageResizer);
|
||||
}
|
||||
|
||||
private void HandleEnterKeyPress(KeyPressParams parameters)
|
||||
{
|
||||
switch (parameters.Dimension)
|
||||
{
|
||||
case Dimension.Width:
|
||||
Settings.CustomSize.Width = parameters.Value;
|
||||
break;
|
||||
case Dimension.Height:
|
||||
Settings.CustomSize.Height = parameters.Value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
=> _mainView.Close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user