/// <summary> Increment or Decrement a given Keys Reference count. </summary> public static void AdjustReferenceCountFor(ScrollableControl inControl, ReferenceMode inMode = ReferenceMode.Increment, bool inOrientHorz = true) { int UpdateReferenceCountFor(int key, ReferenceMode inRefMode = ReferenceMode.Increment) => Controller[key].Count += (int)inRefMode; //ContainsKey() is called before this. int hash = inControl.GetHashCode(); if ((inMode == ReferenceMode.Increment) && !Controller.ContainsKey(hash)) { Controller.Add(hash, new ControllerNode() { Count = 1 }); } else { if (UpdateReferenceCountFor(hash, inMode) < 1) { Controller.Remove(hash); } } }