SimpleClassicTheme.Taskbar icon indicating copy to clipboard operation
SimpleClassicTheme.Taskbar copied to clipboard

Improve collection-based UI

Open Craftplacer opened this issue 3 years ago • 0 comments

Currently most SCTT components compare UI against data, this is possible to improve, I'd suggest this:

  1. probably make event/interface/class for item changes
  2. for static updates/fetches/pulls, you compare those two collections and call events accordingly

I imagine sharing one base class/interface for either event-based updates or pulling.

Examples of old code

Most of SCTT's current code is like this.

List<Item> newItems = new();
foreach (var item in SomeItemSource)
{
    newItems.Add(item);
    if (!items.Contains(item))
    {
        /* some init here */
        items.Add(item);
    }
}

foreach (var item in items)
{
    if (!newItems.Contains(item))
    {
        _ = items.Remove(item);
        item.Dispose();
    }
}

/* additional processing here */

Craftplacer avatar Aug 07 '21 20:08 Craftplacer