/// <summary> /// Switches the current Program.App.Panel to the panel provided in IFormProvider 'provider' /// </summary> /// <param name="provider"></param> public override void Switch(IPanelProvider provider) { try { ClosePage(); //close the current page for (int i = 0; i < 100; i++) //100 control limit { if (provider.PanelToSwitch.Controls.Count > 0) { Program.App.Controls.Add(provider.PanelToSwitch.Controls[0]); } else { break; } } #if DEBUG Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("Page.Switch called from " + this + " to " + provider); #endif provider.OnPageLoad(); } catch (Exception er) { MessageBox.Show("There was an error loading this page.\n\n" + er.Message); } }
abstract public void Switch(IPanelProvider provider);