public static string ToDescriptionString(this MainFormPanels val) { DescriptionAttribute[] attributes = (DescriptionAttribute[])val .GetType() .GetField(val.ToString()) .GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }
public void displayMainFormPanel(MainFormPanels mainFormPanel) { hideAllMainFormPanels(); Control control = getMainFormPanelByName(mainFormPanel); control.Visible = true; showMainForm(); }
public Control getMainFormPanelByName(MainFormPanels mainFormPanel) { string panelName = mainFormPanel.ToDescriptionString(); Control control = mainFormPanels.Find(c => c.Name.Equals(panelName)); if (control is null) { throw new Exception("Panel '" + panelName + "' not found"); } return(control); }