Esempio n. 1
0
        public static bool launch(string parentFormTitle)
        {
            try
            {
                if (isGuiLoaded())
                {
                    PublicDI.log.error("There is already a GUI loaded and only one can be loaded");
                    return(false);
                }
                parentFormTitle = ClickOnceDeployment.getFormTitle_forClickOnce(parentFormTitle);
                //new O2DockPanel();

                O2Thread.staThread(() => new O2DockPanel());

                var maxTimeToWaitForGuiCreation = 20000;
                if (O2DockPanel.guiLoaded.WaitOne(maxTimeToWaitForGuiCreation))
                {
                    O2AscxGUI.o2GuiWithDockPanel.invokeOnThread(() => O2AscxGUI.o2GuiWithDockPanel.Text = parentFormTitle);
                    return(true);
                }
                if (false == DebugMsg.IsDebuggerAttached())
                {
                    //PublicDI.log.reportCriticalErrorToO2Developers(null, null, "from O2AscxGUI: GUI was not available after 20 seconds");
                    PublicDI.log.error("from O2AscxGUI: GUI was not available after 20 seconds");
                }
                return(false);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public static O2DockContent addAscxControlToO2GuiWithDockPanelWithDockState(Type ascxControlToLoad,
                                                                                    DockState dockState,
                                                                                    String name, bool showControl)
        {
            if (O2AscxGUI.o2GuiWithDockPanel == null)
            {
                PublicDI.log.error(" in addAscxControlToO2GuiWithDockPanelWithDockState o2GuiWithDockPanel was null, so aborting load of {0}", ascxControlToLoad.FullName);
                return(null);
            }
            var o2DocContent = new O2DockContent(ascxControlToLoad, dockState, name);

            // add it as soon as possible to this list (in case there is a request for it from another thread)
            O2DockUtils.addO2DockContentToDIGlobalVar(o2DocContent);

            if (showControl)
            {
                //add content to DockPanel (in a thread safe way)
                showO2DockContentInDockPanel(o2DocContent);


                // wait for control to be loaded
                if (false == DebugMsg.IsDebuggerAttached())
                {
                    o2DocContent.controlLoadedIntoGui.WaitOne();
                }
                else if (false == o2DocContent.controlLoadedIntoGui.WaitOne(10000))
                {
                    PublicDI.log.error("Failed to load control {0} in 10 sec", o2DocContent.name);
                }
            }
            return(o2DocContent);
        }
Esempio n. 3
0
        public static bool close()
        {
            if (isGuiLoaded())
            {
                try
                {
                    if (O2AscxGUI.o2GuiWithDockPanel.okThread(delegate { close(); }))
                    {
                        // before we close this we need to remove all loaded Ascx from the O2AscxGUI.dO2LoadedO2DockContent
                        O2AscxGUI.dO2LoadedO2DockContent.Clear();

                        // now close the GUI
                        O2AscxGUI.o2GuiWithDockPanel.Close();

                        //O2AscxGUI.o2GuiWithDockPanel.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    PublicDI.log.ex(ex, "in O2AscxGUI.close");
                    return(false);
                }
            }
            if (O2AscxGUI.o2GuiWithDockPanel == null)
            {
                return(true);
            }
            if (false == DebugMsg.IsDebuggerAttached())
            {
                waitForAscxGuiClose(5000);
            }
            else
            {
                waitForAscxGuiClose();
            }

            PublicDI.log.info("Gui Closed");
            return(true);
        }