public static void ShowOrActivate(string tab = "general") { var open = Application.OpenForms.Cast<Form>().Where(f => f is Options).FirstOrDefault() as Options; if (open != null) { open.BeginInvoke(new MethodInvoker(() => { open.Activate(); open.SwitchToTab(tab); })); } else { open = new Options(); open.Show(); open.SwitchToTab(tab); } }
public static void ShowOrActivate(string tab = "general") { var open = Application.OpenForms.Cast<Form>().Where(f => f is Options).FirstOrDefault() as Options; if (open != null) { open.BeginInvoke(new MethodInvoker(() => { open.Activate(); var TabButton = open.TabButtons.FirstOrDefault(bt => string.Equals(bt.Tag as string, tab, StringComparison.InvariantCultureIgnoreCase)); if (TabButton != null) TabButton.PerformClick(); })); } else { open = new Options(); open.Show(); var TabButton = open.TabButtons.FirstOrDefault(bt => string.Equals(bt.Tag as string, tab, StringComparison.InvariantCultureIgnoreCase)); if (TabButton != null) TabButton.PerformClick(); } }