More bug fixes, add reloading of the tree

This commit is contained in:
Cj 2024-06-14 14:34:24 -04:00
parent 622df3391a
commit b2d90365b2
3 changed files with 31 additions and 13 deletions

View File

@ -11,6 +11,10 @@ public class Remapper
{ {
public static bool IsRunning { get; private set; } = false; public static bool IsRunning { get; private set; } = false;
public delegate void OnCompleteHandler(object sender, EventArgs e);
public event OnCompleteHandler OnComplete;
private static Stopwatch Stopwatch = new(); private static Stopwatch Stopwatch = new();
/// <summary> /// <summary>
@ -260,6 +264,7 @@ public class Remapper
Reset(); Reset();
IsRunning = false; IsRunning = false;
OnComplete.Invoke(this, EventArgs.Empty);
} }
private void Reset() private void Reset()

View File

@ -15,10 +15,8 @@ namespace AssemblyRemapperGUI
InitializeComponent(); InitializeComponent();
PopulateDomainUpDowns(); PopulateDomainUpDowns();
foreach (var remap in DataProvider.Remaps) Remapper.OnComplete += ReloadTreeView;
{ ReloadTreeView(this, EventArgs.Empty);
RemapTreeView.Nodes.Add(GUI.GenerateTreeNode(remap));
}
} }
#region BUTTONS #region BUTTONS
@ -101,7 +99,7 @@ namespace AssemblyRemapperGUI
{ {
if (Remapper.IsRunning) { return; } if (Remapper.IsRunning) { return; }
Task.Run(() => Remapper.InitializeRemap()); Remapper.InitializeRemap();
} }
private void SaveMappingFileButton_Click(object sender, EventArgs e) private void SaveMappingFileButton_Click(object sender, EventArgs e)
@ -338,5 +336,20 @@ namespace AssemblyRemapperGUI
IsDerivedUpDown.BuildStringList("IsDerived"); IsDerivedUpDown.BuildStringList("IsDerived");
HasGenericParametersUpDown.BuildStringList("HasGenericParams"); HasGenericParametersUpDown.BuildStringList("HasGenericParams");
} }
/// <summary>
/// Subscribes the the remappers OnComplete event
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ReloadTreeView(object sender, EventArgs e)
{
RemapTreeView.Nodes.Clear();
foreach (var remap in DataProvider.Remaps)
{
RemapTreeView.Nodes.Add(GUI.GenerateTreeNode(remap));
}
}
} }
} }

View File

@ -132,7 +132,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(IsDerivedNode); remapTreeItem.Nodes.Add(IsDerivedNode);
remapTreeItem.Nodes.Add(HasGenericsNode); remapTreeItem.Nodes.Add(HasGenericsNode);
if (model.SearchParams.IncludeMethods.Count > 0) if (model.SearchParams.IncludeMethods?.Count > 0)
{ {
var includeMethodsNode = var includeMethodsNode =
GenerateNodeFromList(model.SearchParams.IncludeMethods, "Include Methods"); GenerateNodeFromList(model.SearchParams.IncludeMethods, "Include Methods");
@ -140,7 +140,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(includeMethodsNode); remapTreeItem.Nodes.Add(includeMethodsNode);
} }
if (model.SearchParams.ExcludeMethods.Count > 0) if (model.SearchParams.ExcludeMethods?.Count > 0)
{ {
var excludeMethodsNode = var excludeMethodsNode =
GenerateNodeFromList(model.SearchParams.ExcludeMethods, "Exclude Methods"); GenerateNodeFromList(model.SearchParams.ExcludeMethods, "Exclude Methods");
@ -148,7 +148,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(excludeMethodsNode); remapTreeItem.Nodes.Add(excludeMethodsNode);
} }
if (model.SearchParams.IncludeFields.Count > 0) if (model.SearchParams.IncludeFields?.Count > 0)
{ {
var includeFieldsNode = var includeFieldsNode =
GenerateNodeFromList(model.SearchParams.IncludeFields, "Include Fields"); GenerateNodeFromList(model.SearchParams.IncludeFields, "Include Fields");
@ -156,7 +156,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(includeFieldsNode); remapTreeItem.Nodes.Add(includeFieldsNode);
} }
if (model.SearchParams.ExcludeFields.Count > 0) if (model.SearchParams.ExcludeFields?.Count > 0)
{ {
var excludeFieldsNode = var excludeFieldsNode =
GenerateNodeFromList(model.SearchParams.ExcludeFields, "Exclude Fields"); GenerateNodeFromList(model.SearchParams.ExcludeFields, "Exclude Fields");
@ -164,7 +164,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(excludeFieldsNode); remapTreeItem.Nodes.Add(excludeFieldsNode);
} }
if (model.SearchParams.IncludeProperties.Count > 0) if (model.SearchParams.IncludeProperties?.Count > 0)
{ {
var includeProperties = var includeProperties =
GenerateNodeFromList(model.SearchParams.IncludeProperties, "Include Properties"); GenerateNodeFromList(model.SearchParams.IncludeProperties, "Include Properties");
@ -172,7 +172,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(includeProperties); remapTreeItem.Nodes.Add(includeProperties);
} }
if (model.SearchParams.ExcludeProperties.Count > 0) if (model.SearchParams.ExcludeProperties?.Count > 0)
{ {
var excludeProperties = var excludeProperties =
GenerateNodeFromList(model.SearchParams.ExcludeProperties, "Exclude Properties"); GenerateNodeFromList(model.SearchParams.ExcludeProperties, "Exclude Properties");
@ -180,7 +180,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(excludeProperties); remapTreeItem.Nodes.Add(excludeProperties);
} }
if (model.SearchParams.IncludeNestedTypes.Count > 0) if (model.SearchParams.IncludeNestedTypes?.Count > 0)
{ {
var includeNestedTypes = var includeNestedTypes =
GenerateNodeFromList(model.SearchParams.IncludeNestedTypes, "Include Nested Types"); GenerateNodeFromList(model.SearchParams.IncludeNestedTypes, "Include Nested Types");
@ -188,7 +188,7 @@ internal static class GUI
remapTreeItem.Nodes.Add(includeNestedTypes); remapTreeItem.Nodes.Add(includeNestedTypes);
} }
if (model.SearchParams.IncludeNestedTypes.Count > 0) if (model.SearchParams.IncludeNestedTypes?.Count > 0)
{ {
var excludeNestedTypes = var excludeNestedTypes =
GenerateNodeFromList(model.SearchParams.ExcludeNestedTypes, "Exclude Nested Types"); GenerateNodeFromList(model.SearchParams.ExcludeNestedTypes, "Exclude Nested Types");