mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 18:57:19 +02:00
[ImageResizer] Fix issues with blank Width and Height controls (#37373)
* Allow custom preset's dimensions to be blank in the UI while still persisted as 0. * XAML formatting - reorder namespaces. * Add "(auto)" text to zero-value Width/Height in Settings. Ensure Width and Height fields in flyout are formatted to empty when their value is 0.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Controls;
|
||||
|
||||
public partial class ImageResizerDimensionsNumberBox : NumberBox
|
||||
{
|
||||
public ImageResizerDimensionsNumberBox()
|
||||
{
|
||||
this.Loaded += (_, _) => UpdateDisplayText();
|
||||
|
||||
this.ValueChanged += (_, _) => UpdateDisplayText();
|
||||
|
||||
this.GotFocus += (s, e) =>
|
||||
{
|
||||
// Show "0" in the UI when focused on the empty value. This ensures that the spinbutton
|
||||
// controls are usable.
|
||||
if (Value is double.NaN)
|
||||
{
|
||||
Value = 0.0;
|
||||
}
|
||||
};
|
||||
|
||||
this.LostFocus += (_, _) => UpdateDisplayText();
|
||||
}
|
||||
|
||||
private void UpdateDisplayText()
|
||||
{
|
||||
if (FocusState == FocusState.Unfocused && Value == 0)
|
||||
{
|
||||
Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user