intrueder/Control.Draggable

Disposed items remain in Dictionary<Control, bool>

hinds44 opened this issue · 0 comments

Love this project, I spent a whole day trying to do this myself with no success.

On stepping through to see how it worked, I noticed that the Dictionary<Control, bool> draggables continued to add controls with each initialization of the form.

I added a simple method to clear the disposed controls from draggables

    private static void CleanDraggables()
    {
        foreach (var item in _draggables.Where(x => x.Key.IsDisposed))
        {
            _draggables.Remove(item.Key);
        }
    }

I added this within the Draggable() method, which I suggest could be changed to Draggable(Control, [bool = true])