mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
[Code refactoring] Make code comment and NullOrEmpty check more clear (#13352)
* Clarify code * grammar fix * comment change
This commit is contained in:
@@ -252,12 +252,14 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
|||||||
|
|
||||||
public void AddRow(string sizeNamePrefix)
|
public void AddRow(string sizeNamePrefix)
|
||||||
{
|
{
|
||||||
// Without validation we get warning CA1062 when unsing the parameter variable sizeNamePrefix
|
/// This is a fallback validation to eliminate the warning "CA1062:Validate arguments of public methods" when using the parameter (variable) "sizeNamePrefix" in the code.
|
||||||
string prefixString = string.IsNullOrEmpty(sizeNamePrefix) ? "New Size" : sizeNamePrefix;
|
/// If the parameter is unexpectedly empty or null, we fill the parameter with a non-localized string.
|
||||||
|
/// Normally the parameter "sizeNamePrefix" can't be null or empty because it is filled with a localized string when we call this method from <see cref="UI.Views.ImageResizerPage.AddSizeButton_Click"/>.
|
||||||
|
sizeNamePrefix = string.IsNullOrEmpty(sizeNamePrefix) ? "New Size" : sizeNamePrefix;
|
||||||
|
|
||||||
ObservableCollection<ImageSize> imageSizes = Sizes;
|
ObservableCollection<ImageSize> imageSizes = Sizes;
|
||||||
int maxId = imageSizes.Count > 0 ? imageSizes.OrderBy(x => x.Id).Last().Id : -1;
|
int maxId = imageSizes.Count > 0 ? imageSizes.OrderBy(x => x.Id).Last().Id : -1;
|
||||||
string sizeName = GenerateNameForNewSize(imageSizes, prefixString);
|
string sizeName = GenerateNameForNewSize(imageSizes, sizeNamePrefix);
|
||||||
|
|
||||||
ImageSize newSize = new ImageSize(maxId + 1, sizeName, ResizeFit.Fit, 854, 480, ResizeUnit.Pixel);
|
ImageSize newSize = new ImageSize(maxId + 1, sizeName, ResizeFit.Fit, 854, 480, ResizeUnit.Pixel);
|
||||||
newSize.PropertyChanged += SizePropertyChanged;
|
newSize.PropertyChanged += SizePropertyChanged;
|
||||||
|
|||||||
Reference in New Issue
Block a user