mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[ColorPicker]Fix format name duplicates (#22565)
* ColorPicker fix format name duplicates * ColorPicker: extend settings-loading with security code which skips color formats with empty name or duplicate names * Spell checker fix, typo, sorry
This commit is contained in:
parent
7d53b9a5b5
commit
e5d001e434
@ -234,13 +234,20 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
{
|
||||
foreach (var storedColorFormat in _colorPickerSettings.Properties.VisibleColorFormats)
|
||||
{
|
||||
// skip entries with empty name or duplicated name, it should never occur
|
||||
string storedName = storedColorFormat.Key;
|
||||
if (storedName == string.Empty || ColorFormats.Count(x => x.Name.ToUpperInvariant().Equals(storedName.ToUpperInvariant(), StringComparison.Ordinal)) > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string format = storedColorFormat.Value.Value;
|
||||
if (format == string.Empty)
|
||||
{
|
||||
format = ColorFormatHelper.GetDefaultFormat(storedColorFormat.Key);
|
||||
format = ColorFormatHelper.GetDefaultFormat(storedName);
|
||||
}
|
||||
|
||||
ColorFormatModel customColorFormat = new ColorFormatModel(storedColorFormat.Key, format, storedColorFormat.Value.Key);
|
||||
ColorFormatModel customColorFormat = new ColorFormatModel(storedName, format, storedColorFormat.Value.Key);
|
||||
customColorFormat.PropertyChanged += ColorFormat_PropertyChanged;
|
||||
ColorFormats.Add(customColorFormat);
|
||||
}
|
||||
@ -400,7 +407,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||
}
|
||||
else
|
||||
{
|
||||
colorFormatModel.IsValid = ColorFormats.Count(x => x.Name.ToUpperInvariant().Equals(colorFormatModel.Name.ToUpperInvariant(), StringComparison.Ordinal)) < 2;
|
||||
colorFormatModel.IsValid = ColorFormats.Count(x => x.Name.ToUpperInvariant().Equals(colorFormatModel.Name.ToUpperInvariant(), StringComparison.Ordinal))
|
||||
< (colorFormatModel.IsNew ? 1 : 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user