I’ve having an issue splitting my main form/class into smaller parts.
The main reason is because of the control events. I can’t figure how it would be possible to make the class smaller since it consists of 20 controls (at least) with at least 3 events for each control.
Even some methods I actually managed to move to a separate class they require to send the control as a method argument in order for them to be able to work as they were intended in the first place.
A small example would be
public static bool GroupContainsSnippet(TreeView tree, string group, string snippetName)
{
bool result = false;
if (tree.Nodes[group] != null)
{
result = tree.Nodes[group].Nodes.ContainsKey(snippetName);
}
return result;
}
For some reason it just feels odd having to send the control in order to do that kind of things, so I’m hoping there is a more clearer way.
Thanks in advance.
Using your example, I would create my own TreeView derived class, e.g., MyTreeView, and put in there as much of the TreeView code as makes sense. For example,
This is a more o-o approach, as it encapsulates your specific TreeView behaviour into its own class.