Speed up form loading

Suspending and resuming layouts & signaling TreeView updates increases load speed by quite a bit. Switching to the Town Map tab will cause a slight delay in CF/NL.
This commit is contained in:
Cuyler36 2018-11-10 00:59:59 -05:00
parent f12ddf25e9
commit 00e53f3c8e

View file

@ -2120,9 +2120,11 @@ private void Shoe_Color_Changed()
private void SetupAcreEditorTreeView()
{
acreTreeView.Nodes.Clear();
acreTreeView.BeginUpdate();
if (_filedAcreData != null)
{
acreTreeView.Nodes.Clear();
foreach (var acreGroup in _filedAcreData)
{
var acreType = new TreeNode
@ -2145,7 +2147,6 @@ private void SetupAcreEditorTreeView()
}
else if (_uInt16FiledAcreData != null)
{
acreTreeView.Nodes.Clear();
foreach (var acreGroup in _uInt16FiledAcreData)
{
var acreType = new TreeNode
@ -2166,6 +2167,8 @@ private void SetupAcreEditorTreeView()
}
}
}
acreTreeView.EndUpdate();
}
private void SetPossibleNativeFruits(SaveGeneration saveGeneration)
@ -2382,6 +2385,11 @@ private static Image GetAcreImage(ushort id)
private void SetupMapPictureBoxes()
{
acrePanel.SuspendLayout();
townPanel.SuspendLayout();
islandPanel.SuspendLayout();
grassPanel.SuspendLayout();
_lastBoxEntered = null;
if (_acreMap != null)
foreach (var map in _acreMap)
@ -2609,6 +2617,11 @@ private void SetupMapPictureBoxes()
}
}
acrePanel.ResumeLayout();
townPanel.ResumeLayout();
islandPanel.ResumeLayout();
grassPanel.ResumeLayout();
if ((SaveFile.SaveType != SaveType.DoubutsuNoMoriEPlus && SaveFile.SaveType != SaveType.AnimalForestEPlus)
|| _selectedIsland == null) return;
var islandAcreIds = _selectedIsland.GetAcreIds();
@ -3750,7 +3763,10 @@ private void SetupBuildingList()
_buildingNames = Building.WelcomeAmiiboBuildingNames.Values.ToArray();
break;
}
buildingsPanel.SuspendLayout();
_buildingListPanels = new Panel[_buildings.Length];
for (var i = 0; i < _buildings.Length; i++)
{
var buildingPanel = new Panel
@ -3803,6 +3819,7 @@ private void SetupBuildingList()
}
buildingsPanel.Controls.AddRange(_buildingListPanels);
buildingsPanel.ResumeLayout();
}
private void UpdateBuildingCount()