1258 lines
40 KiB
C#
Raw Permalink Normal View History

2024-06-18 17:35:31 -04:00
using ReCodeIt.AutoMapper;
2024-06-14 19:06:21 -04:00
using ReCodeIt.Models;
using ReCodeIt.ReMapper;
using ReCodeIt.Utils;
2024-06-19 11:01:10 -04:00
using System.Diagnostics;
2024-06-13 20:25:11 -04:00
2024-06-14 19:06:21 -04:00
namespace ReCodeIt.GUI;
2024-06-14 18:07:01 -04:00
2024-06-14 19:06:21 -04:00
public partial class ReCodeItForm : Form
2024-06-13 18:09:31 -04:00
{
2024-06-18 23:45:00 -04:00
private static ReCodeItRemapper Remapper { get; set; } = new();
private static ReCodeItAutoMapper AutoMapper { get; set; } = new();
2024-06-14 18:07:01 -04:00
2024-06-18 23:45:00 -04:00
private static Settings AppSettings => DataProvider.Settings;
2024-06-14 20:52:16 -04:00
2024-06-22 13:57:41 -04:00
private bool _isSearched = false;
public static Dictionary<TreeNode, RemapModel> RemapNodes = [];
2024-06-14 21:29:53 -04:00
private int _selectedRemapTreeIndex = 0;
2024-06-19 10:47:29 -04:00
private int _selectedCCRemapTreeIndex = 0;
2024-06-14 21:29:53 -04:00
private List<string> _cachedNewTypeNames = [];
2024-06-14 19:06:21 -04:00
public ReCodeItForm()
2024-06-13 18:09:31 -04:00
{
2024-06-14 18:07:01 -04:00
InitializeComponent();
2024-06-19 18:15:32 -04:00
SubscribeToEvents();
2024-06-14 18:07:01 -04:00
PopulateDomainUpDowns();
2024-06-15 16:21:12 -04:00
RefreshSettingsPage();
RefreshAutoMapperPage();
2024-06-18 23:45:00 -04:00
LoadMappingFile();
2024-06-20 23:30:17 -04:00
var remaps = DataProvider.Remaps;
2024-06-20 23:30:17 -04:00
ReloadRemapTreeView(remaps);
2024-06-19 18:15:32 -04:00
}
2024-06-14 21:29:53 -04:00
2024-06-19 18:15:32 -04:00
private void SubscribeToEvents()
{
2024-06-19 10:47:29 -04:00
RemapTreeView.NodeMouseDoubleClick += ManualEditSelectedRemap;
2024-06-18 23:45:00 -04:00
Remapper.OnComplete += ReloadTreeAfterMapping;
2024-06-19 18:15:32 -04:00
#region MANUAL_REMAPPER
NewTypeName.GotFocus += (sender, e) =>
{
_cachedNewTypeNames.Add(NewTypeName.Text);
};
2024-06-19 18:15:32 -04:00
IncludeMethodTextBox.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
MethodIncludeAddButton_Click(sender, e);
}
};
ExcludeMethodTextBox.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
MethodExcludeAddButton_Click(sender, e);
}
};
FieldsIncludeTextInput.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
FIeldIncludeAddButton_Click(sender, e);
}
};
FieldsExcludeTextInput.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
FieldExcludeAddButton_Click(sender, e);
}
};
PropertiesIncludeTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
PropertiesIncludeAddButton_Click(sender, e);
}
};
PropertiesExcludeTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
PropertiesExcludeAddButton_Click(sender, e);
}
};
NestedTypesIncludeTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
NestedTypesAddButton_Click(sender, e);
}
};
NestedTypesExcludeTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
NestedTypesExlcudeAddButton_Click(sender, e);
}
};
EventsIncludeTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
EventsAddButton_Click(sender, e);
}
};
EventsExcludeTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
EventsExcludeAddButton_Click(sender, e);
}
};
2024-06-19 18:15:32 -04:00
#endregion MANUAL_REMAPPER
#region AUTOMAPPER
AutoMapperTypesToIgnoreTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
AutoMapperExcludeAddButton_Click(sender, e);
}
};
AutoMapperTokensTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
AutoMapperTokensAddButton_Click(sender, e);
}
};
AutoMapperFPTextField.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
AutoMapperFPAddButton_Click(sender, e);
}
};
AutoMapperMethodTextBox.KeyDown += (sender, e) =>
{
if (e.KeyCode == Keys.Enter)
{
AutoMapperMethodAddButton_Click(sender, e);
}
};
#endregion AUTOMAPPER
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-17 17:29:26 -04:00
#region MANUAL_REMAPPER
2024-06-18 23:45:00 -04:00
private void LoadMappingFile()
{
2024-06-19 15:57:47 -04:00
DataProvider.Remaps = DataProvider.LoadMappingFile(AppSettings.Remapper.MappingPath);
2024-06-18 23:45:00 -04:00
LoadedMappingFilePath.Text = AppSettings.Remapper.MappingPath;
}
private void UseProjectAutoMapping_Clicked(object sender, EventArgs e)
{
var remaps = DataProvider.Remaps;
2024-06-18 23:45:00 -04:00
LoadedMappingFilePath.Text = AppSettings.Remapper?.MappingPath;
2024-06-18 23:45:00 -04:00
2024-06-19 10:47:29 -04:00
ReloadRemapTreeView(remaps!);
2024-06-18 23:45:00 -04:00
}
2024-06-14 18:07:01 -04:00
#region BUTTONS
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
#region MAIN_BUTTONS
2024-06-13 20:25:11 -04:00
2024-06-22 13:57:41 -04:00
private void SearchTreeView(object sender, EventArgs e)
{
if (RemapTreeView.Nodes.Count == 0) { return; }
if (RMSearchBox.Text == string.Empty) { return; }
bool projectMode = AppSettings.Remapper.UseProjectMappings;
var remaps = DataProvider.Remaps;
2024-06-22 13:57:41 -04:00
var matches = remaps
.Where(x => x.NewTypeName == RMSearchBox.Text
|| x.NewTypeName.StartsWith(RMSearchBox.Text));
if (!matches.Any()) { return; }
RemapTreeView.Nodes.Clear();
foreach (var match in matches)
{
RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(match, this));
}
_isSearched = true;
}
private void ResetSearchButton_Click(object sender, EventArgs e)
{
bool projectMode = AppSettings.Remapper.UseProjectMappings;
var remaps = DataProvider.Remaps;
2024-06-22 13:57:41 -04:00
RemapTreeView.Nodes.Clear();
ReloadRemapTreeView(remaps);
RMSearchBox.Clear();
_isSearched = false;
}
2024-06-28 16:17:54 -04:00
private RemapModel? CreateRemapFromGUI()
2024-06-14 18:07:01 -04:00
{
if (NewTypeName.Text == string.Empty)
{
MessageBox.Show("Please enter a new type name", "Invalid data");
2024-06-28 16:17:54 -04:00
return null;
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-14 20:52:16 -04:00
var newRemap = new RemapModel
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
Succeeded = false,
NoMatchReasons = [],
2024-06-14 18:07:01 -04:00
NewTypeName = NewTypeName.Text,
OriginalTypeName = OriginalTypeName.Text == string.Empty ? null : OriginalTypeName.Text,
2024-06-17 17:29:26 -04:00
UseForceRename = RemapperUseForceRename.Checked,
2024-06-14 18:07:01 -04:00
SearchParams = new SearchParams
2024-06-14 11:01:21 -04:00
{
IsPublic = bool.Parse(IsPublicComboBox.GetSelectedItem<string>().AsSpan()),
IsAbstract = IsAbstractComboBox.SelectedItem as string != "Disabled"
? bool.Parse(IsAbstractComboBox.GetSelectedItem<string>().AsSpan())
: null,
IsSealed = IsSealedComboBox.SelectedItem as string != "Disabled"
? bool.Parse(IsSealedComboBox.GetSelectedItem<string>().AsSpan())
: null,
IsInterface = IsInterfaceComboBox.SelectedItem as string != "Disabled"
? bool.Parse(IsInterfaceComboBox.GetSelectedItem<string>().AsSpan())
: null,
IsStruct = IsStructComboBox.SelectedItem as string != "Disabled"
? bool.Parse(IsStructComboBox.GetSelectedItem<string>().AsSpan())
: null,
IsEnum = IsEnumComboBox.SelectedItem as string != "Disabled"
? bool.Parse(IsEnumComboBox.GetSelectedItem<string>().AsSpan())
: null,
HasAttribute = HasAttributeComboBox.SelectedItem as string != "Disabled"
? bool.Parse(HasAttributeComboBox.GetSelectedItem<string>().AsSpan())
: null,
HasGenericParameters = HasGenericParamsComboBox.SelectedItem as string != "Disabled"
? bool.Parse(HasGenericParamsComboBox.GetSelectedItem<string>().AsSpan())
: null,
2024-06-14 18:07:01 -04:00
IsNested = IsNestedUpDown.GetEnabled(),
IsDerived = IsDerivedUpDown.GetEnabled(),
NTParentName = NestedTypeParentName.Text == string.Empty
2024-06-14 18:07:01 -04:00
? null
: NestedTypeParentName.Text,
MatchBaseClass = BaseClassIncludeTextFIeld.Text == string.Empty
? null
: BaseClassIncludeTextFIeld.Text,
IgnoreBaseClass = BaseClassExcludeTextField.Text == string.Empty
? null
: BaseClassExcludeTextField.Text,
// Constructor - TODO
ConstructorParameterCount = ConstructorCountEnabled.GetCount(ConstuctorCountUpDown),
MethodCount = MethodCountEnabled.GetCount(MethodCountUpDown),
FieldCount = FieldCountEnabled.GetCount(FieldCountUpDown),
PropertyCount = PropertyCountEnabled.GetCount(PropertyCountUpDown),
NestedTypeCount = NestedTypeCountEnabled.GetCount(NestedTypeCountUpDown),
2024-06-14 19:06:21 -04:00
IncludeMethods = GUIHelpers.GetAllEntriesFromListBox(MethodIncludeBox),
ExcludeMethods = GUIHelpers.GetAllEntriesFromListBox(MethodExcludeBox),
IncludeFields = GUIHelpers.GetAllEntriesFromListBox(FieldIncludeBox),
ExcludeFields = GUIHelpers.GetAllEntriesFromListBox(FieldExcludeBox),
IncludeProperties = GUIHelpers.GetAllEntriesFromListBox(PropertiesIncludeBox),
ExcludeProperties = GUIHelpers.GetAllEntriesFromListBox(PropertiesExcludeBox),
IncludeNestedTypes = GUIHelpers.GetAllEntriesFromListBox(NestedTypesIncludeBox),
ExcludeNestedTypes = GUIHelpers.GetAllEntriesFromListBox(NestedTypesExcludeBox),
IncludeEvents = GUIHelpers.GetAllEntriesFromListBox(EventsIncludeBox),
ExcludeEvents = GUIHelpers.GetAllEntriesFromListBox(EventsExcludeBox)
2024-06-14 11:01:21 -04:00
}
2024-06-14 18:07:01 -04:00
};
2024-06-13 21:20:48 -04:00
2024-06-28 16:17:54 -04:00
return newRemap;
}
/// <summary>
/// Construct a new remap when the button is pressed
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void AddRemapButton_Click(object sender, EventArgs e)
{
ResetSearchButton_Click(this, e);
var newRemap = CreateRemapFromGUI();
if (newRemap is null) return;
2024-06-18 23:45:00 -04:00
bool projectMode = AppSettings.Remapper.UseProjectMappings;
Logger.Log(projectMode);
var remaps = DataProvider.Remaps;
2024-06-18 23:45:00 -04:00
var existingRemap = remaps
2024-06-21 21:46:10 -04:00
.FirstOrDefault(remap => remap.NewTypeName == newRemap.NewTypeName);
2024-06-14 20:52:16 -04:00
if (existingRemap == null)
{
existingRemap = remaps
2024-06-21 21:46:10 -04:00
.FirstOrDefault(remap => _cachedNewTypeNames.Contains(remap.NewTypeName));
}
2024-06-14 20:52:16 -04:00
// Handle overwriting an existing remap
if (existingRemap != null)
{
2024-06-18 23:45:00 -04:00
var index = remaps.IndexOf(existingRemap);
2024-06-14 20:52:16 -04:00
2024-06-18 23:45:00 -04:00
remaps.Remove(existingRemap);
2024-06-14 20:52:16 -04:00
RemapTreeView.Nodes.RemoveAt(index);
2024-06-18 23:45:00 -04:00
remaps.Insert(index, newRemap);
2024-06-14 20:52:16 -04:00
RemapTreeView.Nodes.Insert(index, GUIHelpers.GenerateTreeNode(newRemap, this));
DataProvider.SaveMapping();
2024-06-14 20:52:16 -04:00
ReloadRemapTreeView(remaps);
2024-06-19 08:59:16 -04:00
ResetAllRemapFields();
2024-06-14 20:52:16 -04:00
return;
}
DataProvider.Remaps.Add(newRemap);
DataProvider.SaveMapping();
2024-06-14 20:52:16 -04:00
2024-06-19 22:33:08 -04:00
var node = GUIHelpers.GenerateTreeNode(newRemap, this);
2024-06-20 13:58:39 -04:00
node.Clone();
//RemapTreeView.Nodes.Remove(node);
2024-06-19 22:33:08 -04:00
RemapTreeView.Nodes.Add(node);
_cachedNewTypeNames.Clear();
ReloadRemapTreeView(remaps);
2024-06-19 08:59:16 -04:00
ResetAllRemapFields();
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void RemoveRemapButton_Click(object sender, EventArgs e)
{
2024-06-22 13:57:41 -04:00
foreach (var node in RemapNodes.ToArray())
2024-06-18 23:54:02 -04:00
{
2024-06-22 13:57:41 -04:00
if (node.Key == RemapTreeView.SelectedNode)
{
bool projectMode = AppSettings.Remapper.UseProjectMappings;
var remaps = DataProvider.Remaps;
2024-06-22 13:57:41 -04:00
remaps.Remove(node.Value);
RemapNodes.Remove(node.Key);
RemapTreeView.Nodes.Remove(node.Key);
}
2024-06-18 23:54:02 -04:00
}
2024-06-22 13:57:41 -04:00
ResetAllRemapFields();
2024-06-18 17:35:31 -04:00
DataProvider.SaveMapping();
2024-06-14 20:52:16 -04:00
}
2024-06-14 18:07:01 -04:00
private void RunRemapButton_Click(object sender, EventArgs e)
{
2024-06-14 19:06:21 -04:00
if (ReCodeItRemapper.IsRunning) { return; }
2024-06-14 14:18:17 -04:00
2024-06-18 23:45:00 -04:00
if (string.IsNullOrEmpty(AppSettings.Remapper.AssemblyPath))
{
MessageBox.Show("Please select an assembly path", "Assembly not loaded");
return;
}
2024-06-14 16:18:43 -04:00
Remapper.InitializeRemap(
DataProvider.LoadMappingFile(AppSettings.Remapper.MappingPath),
AppSettings.Remapper.AssemblyPath,
AppSettings.Remapper.OutputPath);
2024-06-19 10:47:29 -04:00
ReloadRemapTreeView(DataProvider.Remaps);
2024-06-18 23:45:00 -04:00
}
2024-06-18 17:35:31 -04:00
2024-06-28 16:17:54 -04:00
private void ValidateRemapButton_Click(object sender, EventArgs e)
{
List<RemapModel> validation = [];
var remapToValidate = CreateRemapFromGUI();
if (remapToValidate is null) return;
validation.Add(remapToValidate);
Remapper.InitializeRemap(
validation,
AppSettings.Remapper.AssemblyPath,
AppSettings.Remapper.OutputPath,
validate: true);
}
2024-06-18 23:45:00 -04:00
/// <summary>
/// Only used by the manual remap process, not apart of the cross compiler process
/// </summary>
private void ReloadTreeAfterMapping()
{
2024-06-19 10:47:29 -04:00
ReloadRemapTreeView(DataProvider.Remaps);
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
private void SaveMappingFileButton_Click(object sender, EventArgs e)
{
DataProvider.SaveMapping();
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
private void LoadMappingFileButton_Click(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFileDialog("Select a mapping file",
"JSON Files (*.json)|*.json|JSONC Files (*.jsonc)|*.jsonc|All Files (*.*)|*.*");
2024-06-14 13:47:30 -04:00
2024-06-17 18:38:06 -04:00
if (result == string.Empty) { return; }
2024-06-19 15:57:47 -04:00
DataProvider.Remaps = DataProvider.LoadMappingFile(result);
2024-06-18 23:45:00 -04:00
AppSettings.Remapper.MappingPath = result;
2024-06-19 00:02:25 -04:00
AppSettings.Remapper.UseProjectMappings = false;
2024-06-18 17:35:31 -04:00
LoadedMappingFilePath.Text = result;
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
RemapTreeView.Nodes.Clear();
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
foreach (var remap in DataProvider.Remaps)
{
2024-06-14 19:06:21 -04:00
RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(remap, this));
2024-06-14 13:47:30 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-17 17:29:26 -04:00
private void PickAssemblyPathButton_Click_1(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFileDialog("Select a DLL file",
"DLL Files (*.dll)|*.dll|All Files (*.*)|*.*");
2024-06-17 17:29:26 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:29:26 -04:00
{
2024-06-18 23:45:00 -04:00
AppSettings.Remapper.AssemblyPath = result;
2024-06-17 18:38:06 -04:00
TargetAssemblyPath.Text = result;
2024-06-17 17:29:26 -04:00
}
}
private void OutputDirectoryButton_Click_1(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFolderDialog("Select an output directory");
2024-06-17 17:29:26 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:29:26 -04:00
{
2024-06-18 23:45:00 -04:00
AppSettings.Remapper.OutputPath = result;
2024-06-17 18:38:06 -04:00
RemapperOutputDirectoryPath.Text = result;
2024-06-17 17:29:26 -04:00
}
}
2024-06-15 16:21:12 -04:00
private void RunAutoMapButton_Click(object sender, EventArgs e)
{
AutoMapper.InitializeAutoMapping();
}
2024-06-14 18:07:01 -04:00
#endregion MAIN_BUTTONS
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
#region LISTBOX_BUTTONS
2024-06-14 13:47:30 -04:00
2024-06-14 18:07:01 -04:00
private void MethodIncludeAddButton_Click(object sender, EventArgs e)
{
if (IncludeMethodTextBox.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!MethodIncludeBox.Items.Contains(IncludeMethodTextBox.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodIncludeBox.Items.Add(IncludeMethodTextBox.Text);
2024-06-19 22:33:08 -04:00
IncludeMethodTextBox.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void MethodIncludeRemoveButton_Click(object sender, EventArgs e)
{
if (MethodIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodIncludeBox.Items.Remove(MethodIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void MethodExcludeAddButton_Click(object sender, EventArgs e)
{
if (ExcludeMethodTextBox.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!MethodExcludeBox.Items.Contains(ExcludeMethodTextBox.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodExcludeBox.Items.Add(ExcludeMethodTextBox.Text);
2024-06-19 22:33:08 -04:00
ExcludeMethodTextBox.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void MethodExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (MethodExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
MethodExcludeBox.Items.Remove(MethodExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FIeldIncludeAddButton_Click(object sender, EventArgs e)
{
if (FieldsIncludeTextInput.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!FieldIncludeBox.Items.Contains(FieldsIncludeTextInput.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldIncludeBox.Items.Add(FieldsIncludeTextInput.Text);
2024-06-19 22:33:08 -04:00
FieldsIncludeTextInput.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FieldIncludeRemoveButton_Click(object sender, EventArgs e)
{
if (FieldIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldIncludeBox.Items.Remove(FieldIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FieldExcludeAddButton_Click(object sender, EventArgs e)
{
if (FieldsExcludeTextInput.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!FieldExcludeBox.Items.Contains(FieldsExcludeTextInput.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldExcludeBox.Items.Add(FieldsExcludeTextInput.Text);
2024-06-19 22:33:08 -04:00
FieldsExcludeTextInput.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void FieldExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (FieldExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
FieldExcludeBox.Items.Remove(FieldExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesIncludeAddButton_Click(object sender, EventArgs e)
{
if (PropertiesIncludeTextField.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!PropertiesIncludeBox.Items.Contains(PropertiesIncludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesIncludeBox.Items.Add(PropertiesIncludeTextField.Text);
2024-06-19 22:33:08 -04:00
PropertiesIncludeTextField.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesIncludeRemoveButton_Click(object sender, EventArgs e)
{
if (PropertiesIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesIncludeBox.Items.Remove(PropertiesIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesExcludeAddButton_Click(object sender, EventArgs e)
{
if (PropertiesExcludeTextField.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!PropertiesExcludeBox.Items.Contains(PropertiesExcludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesExcludeBox.Items.Add(PropertiesExcludeTextField.Text);
2024-06-19 22:33:08 -04:00
PropertiesExcludeTextField.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void PropertiesExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (PropertiesExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
PropertiesExcludeBox.Items.Remove(PropertiesExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesAddButton_Click(object sender, EventArgs e)
{
if (NestedTypesIncludeTextField.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!NestedTypesIncludeBox.Items.Contains(NestedTypesIncludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesIncludeBox.Items.Add(NestedTypesIncludeTextField.Text);
2024-06-19 22:33:08 -04:00
NestedTypesIncludeTextField.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesRemoveButton_Click(object sender, EventArgs e)
{
if (NestedTypesIncludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesIncludeBox.Items.Remove(NestedTypesIncludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesExlcudeAddButton_Click(object sender, EventArgs e)
{
if (NestedTypesExcludeTextField.Text == string.Empty) return;
2024-06-14 18:07:01 -04:00
if (!NestedTypesExcludeBox.Items.Contains(NestedTypesExcludeTextField.Text))
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesExcludeBox.Items.Add(NestedTypesExcludeTextField.Text);
2024-06-19 22:33:08 -04:00
NestedTypesExcludeTextField.Clear();
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
2024-06-14 18:07:01 -04:00
private void NestedTypesExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (NestedTypesExcludeBox.SelectedItem != null)
2024-06-13 20:25:11 -04:00
{
2024-06-14 18:07:01 -04:00
NestedTypesExcludeBox.Items.Remove(NestedTypesExcludeBox.SelectedItem);
2024-06-13 20:25:11 -04:00
}
2024-06-14 18:07:01 -04:00
}
2024-06-13 20:25:11 -04:00
private void EventsAddButton_Click(object sender, EventArgs e)
{
if (EventsIncludeTextField.Text == string.Empty) return;
if (!EventsIncludeBox.Items.Contains(EventsIncludeTextField.Text))
{
EventsIncludeBox.Items.Add(EventsIncludeTextField.Text);
EventsIncludeTextField.Clear();
}
}
private void EventsRemoveButton_Click(object sender, EventArgs e)
{
if (EventsIncludeBox.SelectedItem != null)
{
EventsIncludeBox.Items.Remove(EventsIncludeBox.SelectedItem);
}
}
private void EventsExcludeAddButton_Click(object sender, EventArgs e)
{
if (EventsExcludeTextField.Text == string.Empty) return;
if (!EventsExcludeBox.Items.Contains(EventsExcludeTextField.Text))
{
EventsExcludeBox.Items.Add(EventsExcludeTextField.Text);
EventsExcludeTextField.Clear();
}
}
private void EventsExcludeRemoveButton_Click(object sender, EventArgs e)
{
if (EventsExcludeBox.SelectedItem != null)
{
EventsExcludeBox.Items.Remove(EventsExcludeBox.SelectedItem);
}
}
2024-06-15 16:21:12 -04:00
private void AutoMapperExcludeAddButton_Click(object sender, EventArgs e)
{
if (AutoMapperTypesToIgnoreTextField.Text == string.Empty) return;
2024-06-16 13:56:55 -04:00
if (!AutoMapperTypesExcludeBox.Items.Contains(AutoMapperTypesToIgnoreTextField.Text))
2024-06-15 16:21:12 -04:00
{
2024-06-16 13:56:55 -04:00
DataProvider.Settings.AutoMapper.TypesToIgnore.Add(AutoMapperTypesToIgnoreTextField.Text);
AutoMapperTypesExcludeBox.Items.Add(AutoMapperTypesToIgnoreTextField.Text);
AutoMapperTypesToIgnoreTextField.Clear();
2024-06-15 16:21:12 -04:00
DataProvider.SaveAppSettings();
}
}
private void AutoMapperExcludeRemoveButton_Click(object sender, EventArgs e)
{
2024-06-16 13:56:55 -04:00
if (AutoMapperTypesExcludeBox.SelectedItem != null)
2024-06-15 16:21:12 -04:00
{
2024-06-16 13:56:55 -04:00
DataProvider.Settings.AutoMapper.TypesToIgnore.RemoveAt(AutoMapperTypesExcludeBox.SelectedIndex);
AutoMapperTypesExcludeBox.Items.Remove(AutoMapperTypesExcludeBox.SelectedItem);
2024-06-15 16:21:12 -04:00
DataProvider.SaveAppSettings();
}
}
private void RunAutoRemapButton_Click(object sender, EventArgs e)
{
2024-06-17 17:29:26 -04:00
if (string.IsNullOrEmpty(DataProvider.Settings.AutoMapper.AssemblyPath))
{
MessageBox.Show("Please go to the settings tab and load an assembly and select and output location", "Assembly not loaded");
return;
}
2024-06-15 16:21:12 -04:00
AutoMapper.InitializeAutoMapping();
}
2024-06-14 18:07:01 -04:00
#endregion LISTBOX_BUTTONS
2024-06-14 13:47:30 -04:00
#region CHECKBOX
private void RemapperUnseal_CheckedChanged(object sender, EventArgs e)
{
AppSettings.Remapper.MappingSettings.Unseal = RemapperUnseal.Checked;
}
private void RemapperPublicicize_CheckedChanged(object sender, EventArgs e)
{
AppSettings.Remapper.MappingSettings.Publicize = RemapperPublicicize.Checked;
}
private void RenameFieldsCheckbox_CheckedChanged(object sender, EventArgs e)
{
AppSettings.Remapper.MappingSettings.RenameFields = RenameFieldsCheckbox.Checked;
}
private void RenamePropertiesCheckbox_CheckedChanged(object sender, EventArgs e)
{
AppSettings.Remapper.MappingSettings.RenameProperties = RenamePropertiesCheckbox.Checked;
}
#endregion CHECKBOX
2024-06-14 18:07:01 -04:00
#endregion BUTTONS
2024-06-14 13:47:30 -04:00
2024-06-17 17:29:26 -04:00
#endregion MANUAL_REMAPPER
2024-06-14 19:06:21 -04:00
#region SETTINGS_TAB
public void RefreshSettingsPage()
{
2024-06-17 17:29:26 -04:00
// Settings page
2024-06-18 23:45:00 -04:00
DebugLoggingCheckbox.Checked = AppSettings.AppSettings.Debug;
SilentModeCheckbox.Checked = AppSettings.AppSettings.SilentMode;
2024-06-17 17:29:26 -04:00
// Remapper page
2024-06-18 23:45:00 -04:00
TargetAssemblyPath.Text = AppSettings.Remapper.AssemblyPath;
RemapperOutputDirectoryPath.Text = AppSettings.Remapper.OutputPath;
RenameFieldsCheckbox.Checked = AppSettings.Remapper.MappingSettings.RenameFields;
RenamePropertiesCheckbox.Checked = AppSettings.Remapper.MappingSettings.RenameProperties;
RemapperPublicicize.Checked = AppSettings.Remapper.MappingSettings.Publicize;
RemapperUnseal.Checked = AppSettings.Remapper.MappingSettings.Unseal;
2024-06-14 19:06:21 -04:00
}
#region CHECKBOXES
private void DebugLoggingCheckbox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AppSettings.Debug = DebugLoggingCheckbox.Checked;
}
private void SilentModeCheckbox_CheckedChanged(object sender, EventArgs e)
{
DataProvider.Settings.AppSettings.SilentMode = SilentModeCheckbox.Checked;
}
#endregion CHECKBOXES
#region UPDOWNS
private void AutoMapperRequiredMatchesUpDown_ValueChanged(object sender, EventArgs e)
{
DataProvider.Settings.AutoMapper.RequiredMatches = (int)AutoMapperRequiredMatchesUpDown.Value;
}
#endregion UPDOWNS
#endregion SETTINGS_TAB
#region AUTOMAPPER
public void RefreshAutoMapperPage()
{
2024-06-16 13:56:55 -04:00
AutoMapperTypesExcludeBox.Items.Clear();
AutoMapperTokensBox.Items.Clear();
AutoMapperFPBox.Items.Clear();
2024-06-18 23:45:00 -04:00
var settings = AppSettings.AutoMapper;
AutoMapperRequiredMatchesUpDown.Value = settings.RequiredMatches;
AutoMapperMinLengthUpDown.Value = settings.MinLengthToMatch;
AutoMapperSearchMethodsCheckBox.Checked = settings.SearchMethods;
AutoMapperRenameFields.Checked = settings.MappingSettings.RenameFields;
AutoMapperRenameProps.Checked = settings.MappingSettings.RenameProperties;
AutoMapperPublicize.Checked = settings.MappingSettings.Publicize;
AutoMapperUnseal.Checked = settings.MappingSettings.Unseal;
2024-06-16 13:56:55 -04:00
2024-06-18 23:45:00 -04:00
foreach (var type in settings.TypesToIgnore)
{
2024-06-16 13:56:55 -04:00
AutoMapperTypesExcludeBox.Items.Add(type);
}
2024-06-18 23:45:00 -04:00
foreach (var token in settings.TokensToMatch)
2024-06-16 13:56:55 -04:00
{
AutoMapperTokensBox.Items.Add(token);
}
2024-06-18 23:45:00 -04:00
foreach (var fp in settings.PropertyFieldBlackList)
2024-06-16 13:56:55 -04:00
{
AutoMapperFPBox.Items.Add(fp);
}
2024-06-16 16:21:42 -04:00
2024-06-18 23:45:00 -04:00
foreach (var mp in settings.MethodParamaterBlackList)
2024-06-16 16:21:42 -04:00
{
AutoMapperMethodBox.Items.Add(mp);
}
}
2024-06-17 17:51:00 -04:00
private void AutoMapperChooseTargetPathButton_Click(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFileDialog("Select a DLL file",
"DLL Files (*.dll)|*.dll|All Files (*.*)|*.*");
2024-06-17 17:51:00 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:51:00 -04:00
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.AssemblyPath = result;
2024-06-26 20:44:22 -04:00
AutoMapperTargetPath.Text = result;
2024-06-17 17:51:00 -04:00
}
}
private void AutoMapperChooseOutpathButton_Click(object sender, EventArgs e)
{
2024-06-17 18:38:06 -04:00
var result = GUIHelpers.OpenFolderDialog("Select an output directory");
2024-06-17 17:51:00 -04:00
2024-06-17 18:38:06 -04:00
if (result != string.Empty)
2024-06-17 17:51:00 -04:00
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.OutputPath = result;
2024-06-26 20:44:22 -04:00
AutoMapperOuputPath.Text = result;
2024-06-17 17:51:00 -04:00
}
}
private void AutoMapperRequiredMatchesUpDown_ValueChanged_1(object sender, EventArgs e)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.RequiredMatches = (int)AutoMapperRequiredMatchesUpDown.Value;
}
private void AutoMapperMinLengthUpDown_ValueChanged(object sender, EventArgs e)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.MinLengthToMatch = (int)AutoMapperMinLengthUpDown.Value;
}
2024-06-16 13:56:55 -04:00
private void AutoMapperTokensAddButton_Click(object sender, EventArgs e)
{
if (!AutoMapperTokensBox.Items.Contains(AutoMapperTokensTextField.Text))
{
AutoMapperTokensBox.Items.Add(AutoMapperTokensTextField.Text);
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.TokensToMatch.Add(AutoMapperTokensTextField.Text);
2024-06-16 13:56:55 -04:00
DataProvider.SaveAppSettings();
AutoMapperTokensTextField.Clear();
2024-06-16 13:56:55 -04:00
}
}
private void AutoMapperTokensRemoveButton_Click(object sender, EventArgs e)
{
if (AutoMapperTokensBox.SelectedItem != null)
{
AppSettings.AutoMapper.TokensToMatch.RemoveAt(AutoMapperTokensBox.SelectedIndex);
2024-06-16 13:56:55 -04:00
AutoMapperTokensBox.Items.Remove(AutoMapperTokensBox.SelectedItem);
DataProvider.SaveAppSettings();
}
}
private void AutoMapperFPAddButton_Click(object sender, EventArgs e)
{
if (!AutoMapperFPBox.Items.Contains(AutoMapperFPTextField.Text))
{
AutoMapperFPBox.Items.Add(AutoMapperFPTextField.Text);
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.PropertyFieldBlackList.Add(AutoMapperFPTextField.Text);
2024-06-16 13:56:55 -04:00
DataProvider.SaveAppSettings();
AutoMapperFPTextField.Clear();
2024-06-16 13:56:55 -04:00
}
}
private void AutoMapperFPRemoveButton_Click(object sender, EventArgs e)
{
if (AutoMapperFPBox.SelectedItem != null)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.PropertyFieldBlackList.RemoveAt(AutoMapperFPBox.SelectedIndex);
AutoMapperFPBox.Items.Remove(AutoMapperFPBox.SelectedItem);
2024-06-16 13:56:55 -04:00
DataProvider.SaveAppSettings();
}
}
2024-06-16 16:21:42 -04:00
private void AutoMapperMethodAddButton_Click(object sender, EventArgs e)
{
if (!AutoMapperMethodBox.Items.Contains(AutoMapperMethodTextBox.Text))
{
AutoMapperMethodBox.Items.Add(AutoMapperMethodTextBox.Text);
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.MethodParamaterBlackList.Add(AutoMapperMethodTextBox.Text);
2024-06-16 16:21:42 -04:00
DataProvider.SaveAppSettings();
AutoMapperMethodTextBox.Clear();
2024-06-16 16:21:42 -04:00
}
}
private void AutoMapperMethodRemoveButton_Click(object sender, EventArgs e)
{
if (AutoMapperMethodBox.SelectedItem != null)
{
AppSettings.AutoMapper.MethodParamaterBlackList
.RemoveAt(AutoMapperMethodBox.SelectedIndex);
AutoMapperMethodBox.Items
.Remove(AutoMapperMethodBox.SelectedItem);
2024-06-16 16:21:42 -04:00
DataProvider.SaveAppSettings();
}
}
private void SearchMethodsCheckBox_CheckedChanged(object sender, EventArgs e)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.SearchMethods = AutoMapperSearchMethodsCheckBox.Checked;
2024-06-16 16:21:42 -04:00
}
2024-06-17 17:51:00 -04:00
private void AutoMapperRenameFields_CheckedChanged(object sender, EventArgs e)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.MappingSettings.RenameFields = AutoMapperRenameFields.Checked;
2024-06-17 17:51:00 -04:00
}
private void AutoMapperRenameProps_CheckedChanged(object sender, EventArgs e)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.MappingSettings.RenameProperties = AutoMapperRenameProps.Checked;
2024-06-17 17:51:00 -04:00
}
private void AutoMapperPublicize_CheckedChanged(object sender, EventArgs e)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.MappingSettings.Publicize = AutoMapperPublicize.Checked;
2024-06-17 17:51:00 -04:00
}
private void AutoMapperUnseal_CheckedChanged(object sender, EventArgs e)
{
2024-06-18 23:45:00 -04:00
AppSettings.AutoMapper.MappingSettings.Unseal = AutoMapperUnseal.Checked;
2024-06-17 17:51:00 -04:00
}
#endregion AUTOMAPPER
2024-06-17 20:25:53 -04:00
2024-06-14 18:07:01 -04:00
// Reset All UI elements to default
2024-06-19 08:59:16 -04:00
private void ResetAllRemapFields()
2024-06-14 18:07:01 -04:00
{
PopulateDomainUpDowns();
// Text fields
NewTypeName.Clear();
OriginalTypeName.Clear();
2024-06-14 18:07:01 -04:00
BaseClassIncludeTextFIeld.Clear();
BaseClassExcludeTextField.Clear();
NestedTypeParentName.Clear();
BaseClassExcludeTextField.Clear();
IncludeMethodTextBox.Clear();
ExcludeMethodTextBox.Clear();
FieldsIncludeTextInput.Clear();
FieldsExcludeTextInput.Clear();
PropertiesIncludeTextField.Clear();
PropertiesExcludeTextField.Clear();
NestedTypesIncludeTextField.Clear();
NestedTypesExcludeTextField.Clear();
EventsIncludeTextField.Clear();
EventsExcludeTextField.Clear();
2024-06-14 18:07:01 -04:00
// Numeric UpDowns
2024-06-14 20:52:16 -04:00
ConstuctorCountUpDown.Value = 0;
2024-06-14 18:07:01 -04:00
MethodCountUpDown.Value = 0;
FieldCountUpDown.Value = 0;
PropertyCountUpDown.Value = 0;
NestedTypeCountUpDown.Value = 0;
// Check boxes
2024-06-17 17:29:26 -04:00
RemapperUseForceRename.Checked = false;
2024-06-14 20:52:16 -04:00
ConstructorCountEnabled.Checked = false;
2024-06-14 18:07:01 -04:00
MethodCountEnabled.Checked = false;
FieldCountEnabled.Checked = false;
PropertyCountEnabled.Checked = false;
NestedTypeCountEnabled.Checked = false;
// List boxes
MethodIncludeBox.Items.Clear();
MethodExcludeBox.Items.Clear();
FieldIncludeBox.Items.Clear();
FieldExcludeBox.Items.Clear();
PropertiesIncludeBox.Items.Clear();
PropertiesExcludeBox.Items.Clear();
NestedTypesIncludeBox.Items.Clear();
NestedTypesExcludeBox.Items.Clear();
EventsIncludeBox.Items.Clear();
EventsExcludeBox.Items.Clear();
2024-06-14 18:07:01 -04:00
}
2024-06-14 13:47:30 -04:00
2024-06-19 10:47:29 -04:00
private void ManualEditSelectedRemap(object? sender, TreeNodeMouseClickEventArgs e)
{
EditSelectedRemap(this, e);
}
private void EditSelectedRemap(
object? sender,
TreeNodeMouseClickEventArgs e,
bool isComingFromOtherTab = false)
2024-06-14 20:52:16 -04:00
{
2024-06-15 16:21:12 -04:00
if (e?.Node.Level != 0 || RemapTreeView?.SelectedNode?.Index < 0 || RemapTreeView?.SelectedNode?.Index == null)
2024-06-14 21:29:53 -04:00
{
return;
}
2024-06-22 13:57:41 -04:00
RemapModel remap = null;
foreach (var node in RemapNodes.ToArray())
{
if (node.Key == RemapTreeView.SelectedNode)
{
bool projectMode = AppSettings.Remapper.UseProjectMappings;
var remaps = DataProvider.Remaps;
2024-06-22 13:57:41 -04:00
remap = remaps.FirstOrDefault(x => x.NewTypeName == node.Value.NewTypeName);
break;
}
}
if (remap == null)
{
return;
}
2024-06-14 21:29:53 -04:00
_selectedRemapTreeIndex = RemapTreeView.SelectedNode.Index;
2024-06-19 08:59:16 -04:00
ResetAllRemapFields();
2024-06-14 21:29:53 -04:00
2024-06-14 20:52:16 -04:00
NewTypeName.Text = remap.NewTypeName;
OriginalTypeName.Text = remap.OriginalTypeName;
2024-06-17 17:29:26 -04:00
RemapperUseForceRename.Checked = remap.UseForceRename;
2024-06-14 20:52:16 -04:00
BaseClassIncludeTextFIeld.Text = remap.SearchParams.MatchBaseClass;
BaseClassExcludeTextField.Text = remap.SearchParams.IgnoreBaseClass;
NestedTypeParentName.Text = remap.SearchParams.NTParentName;
ConstructorCountEnabled.Checked = remap.SearchParams.ConstructorParameterCount is not null
? remap.SearchParams.ConstructorParameterCount > 0
: false;
MethodCountEnabled.Checked = remap.SearchParams.MethodCount is not null
? remap.SearchParams.MethodCount >= 0
: false;
FieldCountEnabled.Checked = remap.SearchParams.FieldCount is not null
? remap.SearchParams.FieldCount >= 0
: false;
PropertyCountEnabled.Checked = remap.SearchParams.PropertyCount is not null
? remap.SearchParams.PropertyCount >= 0
: false;
NestedTypeCountEnabled.Checked = remap.SearchParams.NestedTypeCount is not null
? remap.SearchParams.NestedTypeCount >= 0
: false;
ConstuctorCountUpDown.Value = (decimal)((remap.SearchParams.ConstructorParameterCount != null
? remap.SearchParams.ConstructorParameterCount
: 0));
MethodCountUpDown.Value = (decimal)(remap.SearchParams.MethodCount != null
? remap.SearchParams.MethodCount
: 0);
FieldCountUpDown.Value = (decimal)(remap.SearchParams.FieldCount != null
? remap.SearchParams.FieldCount
: 0);
PropertyCountUpDown.Value = (decimal)(remap.SearchParams.PropertyCount != null
? remap.SearchParams.PropertyCount
: 0);
NestedTypeCountUpDown.Value = (decimal)(remap.SearchParams.NestedTypeCount != null
? remap.SearchParams.NestedTypeCount
: 0);
IsPublicComboBox.SelectedItem = remap.SearchParams.IsPublic.ToString();
IsAbstractComboBox.SelectedItem = remap.SearchParams.IsAbstract is not null
? remap.SearchParams.IsAbstract.ToString()
: "Disabled";
IsSealedComboBox.SelectedItem = remap.SearchParams.IsSealed is not null
? remap.SearchParams.IsSealed.ToString()
: "Disabled";
IsInterfaceComboBox.SelectedItem = remap.SearchParams.IsInterface is not null
? remap.SearchParams.IsInterface.ToString()
: "Disabled";
IsStructComboBox.SelectedItem = remap.SearchParams.IsStruct is not null
? remap.SearchParams.IsStruct.ToString()
: "Disabled";
IsEnumComboBox.SelectedItem = remap.SearchParams.IsEnum is not null
? remap.SearchParams.IsEnum.ToString()
: "Disabled";
HasAttributeComboBox.SelectedItem = remap.SearchParams.HasAttribute is not null
? remap.SearchParams.HasAttribute.ToString()
: "Disabled";
HasGenericParamsComboBox.SelectedItem = remap.SearchParams.HasGenericParameters is not null
? remap.SearchParams.HasGenericParameters.ToString()
: "Disabled";
IsNestedUpDown.BuildStringList("IsNested", false, remap.SearchParams.IsNested);
IsDerivedUpDown.BuildStringList("IsDerived", false, remap.SearchParams.IsDerived);
2024-06-14 20:52:16 -04:00
foreach (var method in remap.SearchParams.IncludeMethods)
{
MethodIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeMethods)
{
MethodExcludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.IncludeFields)
{
FieldIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeFields)
{
FieldExcludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.IncludeProperties)
{
PropertiesIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeProperties)
{
PropertiesExcludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.IncludeNestedTypes)
{
NestedTypesIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeNestedTypes)
{
NestedTypesExcludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.IncludeEvents)
{
EventsIncludeBox.Items.Add(method);
}
foreach (var method in remap.SearchParams.ExcludeEvents)
{
EventsExcludeBox.Items.Add(method);
}
2024-06-14 20:52:16 -04:00
}
2024-06-14 18:07:01 -04:00
private void PopulateDomainUpDowns()
{
// Clear them all first just incase
IsPublicComboBox.AddItemsToComboBox(["True", "False"]);
IsPublicComboBox.SelectedItem = "True";
IsAbstractComboBox.AddItemsToComboBox(["Disabled", "True", "False"]);
IsAbstractComboBox.SelectedItem = "Disabled";
IsSealedComboBox.AddItemsToComboBox(["Disabled", "True", "False"]);
IsSealedComboBox.SelectedItem = "Disabled";
IsInterfaceComboBox.AddItemsToComboBox(["Disabled", "True", "False"]);
IsInterfaceComboBox.SelectedItem = "Disabled";
IsStructComboBox.AddItemsToComboBox(["Disabled", "True", "False"]);
IsStructComboBox.SelectedItem = "Disabled";
IsEnumComboBox.AddItemsToComboBox(["Disabled", "True", "False"]);
IsEnumComboBox.SelectedItem = "Disabled";
HasAttributeComboBox.AddItemsToComboBox(["Disabled", "True", "False"]);
HasAttributeComboBox.SelectedItem = "Disabled";
HasGenericParamsComboBox.AddItemsToComboBox(["Disabled", "True", "False"]);
HasGenericParamsComboBox.SelectedItem = "Disabled";
IsNestedUpDown.BuildStringList("IsNested", false);
IsDerivedUpDown.BuildStringList("IsDerived", false);
2024-06-14 18:07:01 -04:00
}
2024-06-14 18:07:01 -04:00
/// <summary>
/// Subscribes the the remappers OnComplete event
/// </summary>
2024-06-18 23:45:00 -04:00
/// <param name="remaps"></param>
2024-06-23 17:17:27 -04:00
private void ReloadRemapTreeView(List<RemapModel>? remaps)
2024-06-14 18:07:01 -04:00
{
RemapTreeView.Nodes.Clear();
2024-06-22 13:57:41 -04:00
RemapNodes.Clear();
2024-06-23 17:17:27 -04:00
if (remaps is null)
{
return;
}
2024-06-18 23:45:00 -04:00
foreach (var remap in remaps)
2024-06-14 18:07:01 -04:00
{
2024-06-14 19:06:21 -04:00
RemapTreeView.Nodes.Add(GUIHelpers.GenerateTreeNode(remap, this));
}
2024-06-13 18:09:31 -04:00
}
2024-06-19 10:47:29 -04:00
2024-06-19 11:01:10 -04:00
private void GithubLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
Process.Start(new ProcessStartInfo
{
FileName = GithubLinkLabel.Text,
UseShellExecute = true
});
}
2024-06-13 20:25:11 -04:00
}