public static Form openO2Gui(this O2AppDomainFactory o2AppDomainFactory) { var o2Gui = (Form)o2AppDomainFactory.proxyInvokeInstance("O2_CoreLib", "O2GuiWithDockPanel", ""); O2Kernel_O2Thread.staThread(() => o2Gui.ShowDialog()); return(o2Gui); }
public void Test_OpenO2CorLibForm() { Test_CreateAppDomainWithO2CoreLibDll(); // do a quick dynamic invocation to confirm that all is OK //o2AppDomainFactory.proxyInvokeInstance("O2_CoreLib", "Log", "info", new object[] { "test" }); Assert.That( o2AppDomainFactory.appDomain.FriendlyName == (string)o2AppDomainFactory.proxyInvokeInstance("O2_Kernel", "O2Proxy", "nameOfCurrentDomain"), "nameOfCurrentDomain test failed"); // get proxy for o2GuiForm object o2GuiWithDockPanel = o2AppDomainFactory.proxyInvokeInstance("O2_External_WinFormsUI", "O2GuiWithDockPanel", ""); Assert.That(o2GuiWithDockPanel != null, "o2GuiWithDockPanel was null"); Assert.That(o2GuiWithDockPanel.GetType().Name == "O2GuiWithDockPanel", "o2GuiWithDockPanel had the wrong type: " + o2GuiWithDockPanel.GetType()); if (!autoCloseForm) { o2AppDomainFactory.showMessageBox("Ready to start?"); } //start o2GuiWithDockPanel on a separate STAthread O2Thread.staThread(() => ((Form)o2GuiWithDockPanel).ShowDialog()); o2AppDomainFactory.proxyInvokeStatic("O2_External_WinFormsUI", "O2GuiWithDockPanel", "logDebug", new object[] { "Good Morning you have 10 seconds for your tests" }); if (!autoCloseForm) { int maxSleeps = 5; while (maxSleeps-- > 0) { Thread.Sleep(10000); if (DialogResult.No == (DialogResult) o2AppDomainFactory.proxyInvokeStatic("O2_External_WinFormsUI", "O2GuiWithDockPanel", "showMessageBox", new object[] { "your 10 seconds are up, Do you want another 10 Seconds? (you can ask for more " + maxSleeps + " extensions", "Message from O2 AppDomain Central", MessageBoxButtons.YesNo })) { break; } } // show final message (using a simpler call syntax :) (using extension methods) o2AppDomainFactory.showMessageBox("Time's up closing all Forms", "Final Message", MessageBoxButtons.OK); } // close Form Thread.Sleep(1000); ((Form)o2GuiWithDockPanel).Close(); if (autoCloseForm) { Assert.Ignore( "Success: change value of autoCloseForm to see some dynamic intercation between this unit test and the O2GuiWithDockPanel form"); } Assert.Ignore( "Success: remember to put the value of autoCloseForm to false, or you will have those popups all the time "); }