[ColorPicker] Order colors with up/down buttons. (#10392)

This commit is contained in:
Seraphima Zykova
2021-03-24 19:36:25 +03:00
committed by GitHub
parent 3ae5135f67
commit fd55026fba
5 changed files with 148 additions and 6 deletions

View File

@@ -247,11 +247,28 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
ColorFormats.Add(remainingColorFormat);
}
// Reordering colors with buttons: disable first and last buttons
ColorFormats[0].CanMoveUp = false;
ColorFormats[ColorFormats.Count - 1].CanMoveDown = false;
ColorFormats.CollectionChanged += ColorFormats_CollectionChanged;
}
private void ColorFormats_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
// Reordering colors with buttons: update buttons availability depending on order
if (ColorFormats.Count > 0)
{
foreach (var color in ColorFormats)
{
color.CanMoveUp = true;
color.CanMoveDown = true;
}
ColorFormats[0].CanMoveUp = false;
ColorFormats[ColorFormats.Count - 1].CanMoveDown = false;
}
UpdateColorFormats();
ScheduleSavingOfSettings();
}