Skip to content

Commit

Permalink
fix: avoid expanding chunk list on adding new
Browse files Browse the repository at this point in the history
  • Loading branch information
nikich340 committed Jul 28, 2023
1 parent 60d2b65 commit f8181ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions WolvenKit/Forms/MVVM/frmCR2WDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ private object WorkerLoadFile(object sender, DoWorkEventArgs e)
default:
throw new ArgumentOutOfRangeException();
}
chunkList.UpdateList(true);

//workerCompletedAction = WorkerLoadFileCompleted;
return args;
Expand Down Expand Up @@ -275,7 +276,7 @@ private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e
switch (e.PropertyName)
{
case nameof(vm.File):
chunkList.UpdateList();
chunkList.UpdateList(false);
break;
case nameof(vm.SelectedChunks):
if (propertyWindow == null || propertyWindow.IsDisposed)
Expand Down Expand Up @@ -303,7 +304,7 @@ private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e
}


private void ChunkWindowRequestChunkViewUpdate(object sender, EventArgs e) => chunkList.UpdateList();
private void ChunkWindowRequestChunkViewUpdate(object sender, EventArgs e) => chunkList.UpdateList(true);

private void PropertyWindowOnRequestBytesOpen(object sender, RequestByteArrayFileOpenArgs e)
{
Expand Down
20 changes: 11 additions & 9 deletions WolvenKit/Forms/frmChunkList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void UpdateHelperList()
};
}

public void UpdateList()
public void UpdateList(bool expandAll)
{
if (File == null)
return;
Expand All @@ -133,15 +133,17 @@ public void UpdateList()
var model = File.chunks.Where(_ => _.ParentChunk == null).ToList();
treeListView.Roots = model;

treeListView.ExpandAll();
if (expandAll)
treeListView.ExpandAll();
}
else if (viewModel.chunkDisplayMode == CR2WDocumentViewModel.EChunkDisplayMode.VirtualParent)
{
UpdateHelperList();
var model = File.chunks.Where(_ => _.VirtualParentChunk == null).ToList();
treeListView.Roots = model;

treeListView.ExpandAll();
if (expandAll)
treeListView.ExpandAll();
}

// find selectedchunk index
Expand Down Expand Up @@ -341,23 +343,23 @@ private void ChunkDisplayMenuItemLinear_Click(object sender, EventArgs e)
ChunkDisplayMenuItemParent.Checked = false;
ChunkDisplayMenuItemVirtualParent.Checked = false;
viewModel.chunkDisplayMode = CR2WDocumentViewModel.EChunkDisplayMode.Linear;
UpdateList();
UpdateList(true);
}

private void ChunkDisplayMenuItemParent_Click(object sender, EventArgs e)
{
ChunkDisplayMenuItemLinear.Checked = false;
ChunkDisplayMenuItemVirtualParent.Checked = false;
viewModel.chunkDisplayMode = CR2WDocumentViewModel.EChunkDisplayMode.Parent;
UpdateList();
UpdateList(true);
}

private void ChunkDisplayMenuItemVirtualParent_Click(object sender, EventArgs e)
{
ChunkDisplayMenuItemLinear.Checked = false;
ChunkDisplayMenuItemParent.Checked = false;
viewModel.chunkDisplayMode = CR2WDocumentViewModel.EChunkDisplayMode.VirtualParent;
UpdateList();
UpdateList(true);
}
#endregion

Expand All @@ -373,21 +375,21 @@ private void ChunkDisplayMode_ButtonClick(object sender, EventArgs e)
ChunkDisplayMenuItemLinear.Checked = false;
viewModel.chunkDisplayMode = CR2WDocumentViewModel.EChunkDisplayMode.Parent;
ChunkDisplayMenuItemParent.Checked = true;
UpdateList();
UpdateList(true);
}
else if (viewModel.chunkDisplayMode == CR2WDocumentViewModel.EChunkDisplayMode.Parent)
{
ChunkDisplayMenuItemParent.Checked = false;
viewModel.chunkDisplayMode = CR2WDocumentViewModel.EChunkDisplayMode.VirtualParent;
ChunkDisplayMenuItemVirtualParent.Checked = true;
UpdateList();
UpdateList(true);
}
else if (viewModel.chunkDisplayMode == CR2WDocumentViewModel.EChunkDisplayMode.VirtualParent)
{
ChunkDisplayMenuItemVirtualParent.Checked = false;
viewModel.chunkDisplayMode = CR2WDocumentViewModel.EChunkDisplayMode.Linear;
ChunkDisplayMenuItemLinear.Checked = true;
UpdateList();
UpdateList(true);
}
}

Expand Down

0 comments on commit f8181ca

Please sign in to comment.