To implement application's GUI I would like to have all the logic to go from one form to another centralized. This GUI manager will behave as a finite state machine. Although I think I have seen this kind of implementation somewhere, I can't find a design pattern that matches with this kind of solution.
A form will look like this:
public class Login : Form
{
...
private void EnterButton_Click()
{
...
string user = loginTextBox.Text;
string password = passwordTextBox.Text;
bool isValid = SecurityManager.CheckUserLogin(user,password);
GUIManager.FormEnd(FormLogin,new LoginData(user, pass, isValid));
}
...
}
And the GUI manager will do something like this:
public class GUIManager
{
...
public void FormEnd(FormType type, FormData data)
{
switch (type)
{
...
case FormLogin:
LoginData ld = (LoginData)data;
if (ld.Valid)
{
m_loginForm.Hide();
m_mainForm.Show();
}
...
}
}
...
}
Reaching this point I have the following questions: is there a desing pattern that formalizes this idea? If there is, does .NET support it somehow? If there isn't, does it sound like a good implementation idea? Thanks!