public bool AddLayoutHook(string setUniqueId, ModifyLayout layoutCode) { if (customLayoutHooks.ContainsKey(setUniqueId)) { return(false); } customLayoutHooks.Add(setUniqueId, layoutCode); return(true); }
/// <summary> /// Allows the caller to modify multiple layout-affecting properties without causing invokes of /// multiple PerformLayout() events. /// /// For example, setting Width and Height indivually causes two PerformLayout()s to be invoked. /// Using BulkPerformLayout allows the user to modify multiple properties with only one /// PerformLayout() call, thus saving CPU power. /// </summary> /// <param name="modifyLayoutCode">Code to be executed that modifies layout-essential code.</param> public void BulkPerformLayout(ModifyLayout modifyLayoutCode) { try { suppressPerformLayout = true; modifyLayoutCode?.Invoke(this); } finally { suppressPerformLayout = false; PerformLayout(); } }