I need criticism/suggestions on a suitable way of controlling many states of display in a GUI like method, "GUIMethod", below.
/*
*InterfaceState.cs
*/
public struct UIController {
public static InterfaceState interfaceState;
}
public enum InterfaceState {
ENUMS,
SEEM,
EASY,
TO,
WRITE,
TODAY
}
/*
*EnumsAndWrite.cs
*/
public class EnumsAndWrite {
public void GUIMethod() {
switch (UIController.interfaceState) {
case InterfaceState.ENUMS:
case_ENUMS_func_1();
case_ENUMS_func_2();
case_ENUMS_func_3();
break;
case InterfaceState.WRITE:
case_WRITE_func_1();
case_WRITE_func_2();
case_WRITE_func_3();
break;
}
}
//Methods defined
}
/*
*SeemEasy.cs
*Similarly written; handles SEEM and EASY
*/
public class SeemEasy {
public void GUIMethod() {
switch (UIController.interfaceState) {
case InterfaceState.SEEM:
break;
case InterfaceState.EASY:
break;
}
}
}
/*
*ToToday.cs
*Similarly written; handles TO and TODAY
*/
I use a struct because I just need the static reference to the InterfaceState
type. Whenever I need to change the state of InterfaceState
I simply assign it to the respective needed item in InterfaceState
. It seems easy and very maintainable.