public static bool closeAscxGui()
        {
            var o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel();
            var result             = o2AppDomainFactory.invoke("O2AscxGUI O2_External_WinFormsUI", "close", null);

            if (result is bool)
            {
                return((bool)result);
            }
            return(false);
        }
        public static bool openAscxGui()
        {
            var o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel();
            var result             = o2AppDomainFactory.invoke("O2AscxGUI O2_External_WinFormsUI", "launch", null);

            if (result is bool)
            {
                return((bool)result);
            }
            return(false);
            //o2WcfProxy = O2WcfUtils.createClientProxy(newO2KernelProcessName);
            //o2WcfProxy.invokeOnAppDomainObject(newAppDomain, "O2AscxGUI O2_External_WinFormsUI","launch",null)
        }
        public static void openControlInGUI(string controlTypeAndAssembly, O2DockState o2DockState, string controlName)
        {
            // lets try to find this control in the current AppDomain
            var  o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel();
            Type proxyObjectType    = o2AppDomainFactory.getProxyType(controlTypeAndAssembly);

            if (proxyObjectType == null)
            {
                DI.log.error("in openControlInGUI, could not find control: {0}", controlTypeAndAssembly);
            }
            else
            {
                openControlInGUI(proxyObjectType, o2DockState, controlName);
            }
        }
 public static bool isGuiLoaded()
 {
     try
     {
         if (DI.reflection.getType("O2AscxGUI") == null) // first see if the assembly O2_External_WinFormsUI is loaded
         {
             return(false);
         }
         var o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel();
         return((bool)o2AppDomainFactory.invoke("O2AscxGUI O2_External_WinFormsUI", "isGuiLoaded"));
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public static bool isDebuggerAvailable()
        {
            // need to find a different way to do this

            try
            {
                if (DI.reflection.getType("O2MDbgUtils") == null) // first see if the assembly O2_External_WinFormsUI is loaded
                {
                    return(false);
                }
                var o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel();
                return((bool)o2AppDomainFactory.invoke("O2MDbgUtils O2_Debugger_Mdbg", "IsDebuggerAvailable"));
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public static void waitForAscxGuiEnd()
        {
            var o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel();

            o2AppDomainFactory.invoke("O2AscxGUI O2_External_WinFormsUI", "waitForAscxGuiClose", null);
        }
        public static void openAscxAsForm(object ascxControlToLoad, string controlName)
        {
            var o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel();

            o2AppDomainFactory.invoke("O2AscxGUI O2_External_WinFormsUI", "openAscxAsForm", new [] { ascxControlToLoad, controlName });
        }