public static O2DockContent addAscxControlToO2GuiWithDockPanelWithDockState(Type ascxControlToLoad,
                                                                                    DockState dockState,
                                                                                    String name, bool showControl)
        {
            if (DI.o2GuiWithDockPanel == null)
            {
                DI.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))
                {
                    DI.log.error("Failed to load control {0} in 10 sec", o2DocContent.name);
                }
            }
            return(o2DocContent);
        }
示例#2
0
        public static void launchO2DockContentAsStandAloneForm(Type typeOfControlToLoad, string controlName)
        {
            if (typeOfControlToLoad == null)
            {
                DI.log.error("in launchO2DockContentAsStandAloneForm typeOfControlToLoad was null");
            }
            else
            {
                try
                {
                    var sync = new AutoResetEvent(false);
                    O2Thread.staThread(() =>
                    {
                        try
                        {
                            DI.o2GuiStandAloneFormMode = true;
                            //var controlToLoad = (Control) Activator.CreateInstance(typeOfControlToLoad);
                            // if (typeOfControlToLoad != null)
                            // {
                            var o2DockContent = new O2DockContent(typeOfControlToLoad, DockState.Float, controlName);
                            o2DockContent.dockContent.HandleCreated += (sender, e) => sync.Set();
                            // as soons as the control HandleCreated is created, we can let this function (launchO2DockContentAsStandAloneForm end)
                            if (o2DockContent.createControlFromType())
                            {
                                o2DockContent.dockContent.Width  = o2DockContent.desiredWidth;
                                o2DockContent.dockContent.Height = o2DockContent.desiredHeight;
                                O2DockUtils.addO2DockContentToDIGlobalVar(o2DockContent);
                                o2DockContent.dockContent.Closed += (sender, e) =>
                                {
                                    if (DI.dO2LoadedO2DockContent.Count == 0)                                                                 // if there are no more controls trigger the end of the GUI session
                                    {
                                        O2AscxGUI.guiClosed.Set();
                                    }
                                };

                                o2DockContent.dockContent.ShowDialog();
                            }
                            else
                            {
                                DI.log.error(
                                    "in launchO2DockContentAsStandAloneForm, could not create instance of controlToLoad: {0}",
                                    typeOfControlToLoad.ToString());
                            }
                        }
                        catch (Exception ex)
                        {
                            DI.log.ex(ex, "in launchO2DockContentAsStandAloneForm");
                        }
                        sync.Set();
                    });
                    sync.WaitOne();
                }
                catch (Exception ex)
                {
                    DI.log.ex(ex);
                }
            }
        }
示例#3
0
 public static void addO2DockContentToDIGlobalVar(O2DockContent controlToLoad)
 {
     if (DI.dO2LoadedO2DockContent.ContainsKey(controlToLoad.name))
         DI.dO2LoadedO2DockContent[controlToLoad.name] = controlToLoad;
     else
     {
         DI.dO2LoadedO2DockContent.Add(controlToLoad.name, controlToLoad);
         addControlToLoadedO2ModulesList(controlToLoad);
     }
 }
 public static void addO2DockContentToDIGlobalVar(O2DockContent controlToLoad)
 {
     if (DI.dO2LoadedO2DockContent.ContainsKey(controlToLoad.name))
     {
         DI.dO2LoadedO2DockContent[controlToLoad.name] = controlToLoad;
     }
     else
     {
         DI.dO2LoadedO2DockContent.Add(controlToLoad.name, controlToLoad);
         addControlToLoadedO2ModulesList(controlToLoad);
     }
 }
 private static void addControlToLoadedO2ModulesList(O2DockContent controlToLoad)
 {
     if (DI.o2GuiStandAloneFormMode == false)
     {
         if (DI.o2GuiWithDockPanel == null)
         {
             DI.log.error("in addControlToLoadedO2ModulesList , DI.o2GuiWithDockPanel == null");
         }
         else
         {
             DI.o2GuiWithDockPanel.addControlToLoadedO2ModulesMenu(controlToLoad);
         }
     }
 }
        private static void addLogViewerToControlsToLoad(ICollection <O2DockContent> controlsToLoad)
        {
            // first make sure the ascx_LogViewer is not already in the list of controls to add
            foreach (var controlToLoad in controlsToLoad)
            {
                if (controlToLoad.type == typeof(ascx_LogViewer))
                {
                    return;
                }
            }

            var logViewer = new O2DockContent(typeof(ascx_LogViewer), DockState.DockBottomAutoHide, PublicDI.LogViewerControlName);

            controlsToLoad.Add(logViewer);
        }
 public void addControlToLoadedO2ModulesMenu(O2DockContent controlToLoad)
 {
     DI.o2GuiWithDockPanel.invokeOnThread(
         () =>
             {
                 // Make sure there isn't alread an item with this type
                 foreach (ToolStripItem currentToolStripItem in loadedO2ModuleToolStripMenuItem.DropDownItems)
                     if (currentToolStripItem.Tag != null && currentToolStripItem.Tag is O2DockContent &&
                         ((O2DockContent) currentToolStripItem.Tag).type == controlToLoad.type)
                         return;
                 var toolStripItem = new ToolStripMenuItem(controlToLoad.name, null,
                                                           loadedO2ModuleToolStripMenuItem_Click)
                                         {Tag = controlToLoad};
                 loadedO2ModuleToolStripMenuItem.DropDownItems.Add(toolStripItem);
             });
 }
        private void addControlToO2GuiWithDockPanelSync(O2DockContent controlToAdd)
        {
            var controlAdded       = new AutoResetEvent(false);
            var o2GuiWithDockPanel = getO2GuiWithDockPanel();

            //if (DI.o2GuiWithDockPanel.Handle != null)
            if (DI.o2GuiWithDockPanel.InvokeRequired)
            {
                DI.o2GuiWithDockPanel.Invoke(new EventHandler(delegate { addControlToO2GuiWithDockPanelSync(o2GuiWithDockPanel, controlToAdd, controlAdded); }));
            }
            else
            {
                addControlToO2GuiWithDockPanelSync(o2GuiWithDockPanel, controlToAdd, controlAdded);
            }

            controlAdded.WaitOne();
        }
        public static void showO2DockContentInDockPanel(O2DockContent o2DockContent)
        {
            try
            {
                DI.log.info("on O2DockPanel.showO2DockContentInDockPanel: {0} [{1}]", o2DockContent.name, o2DockContent.type);
                if (DI.o2GuiWithDockPanel.okThread(delegate { showO2DockContentInDockPanel(o2DockContent); }))
                {
                    //  if (o2DocContent.dockContent.okThread(delegate { showO2DockContentInDockPanel(o2DocContent); }))
                    //    if (DI.o2GuiWithDockPanel.getDockPanel().okThread(
                    //        delegate { showO2DockContentInDockPanel(o2DocContent); }))

                    // now that we are on the correct thread the control can be created
                    if (o2DockContent.createControlFromType())
                    {
                        if (o2DockContent.dockContent.TopLevelControl != null)
                        {
                            o2DockContent.dockContent.Show(DI.o2GuiWithDockPanel.getDockPanel(), o2DockContent.dockState);

                            if (o2DockContent.dockState == DockState.Float &&
                                o2DockContent.dockContent.TopLevelControl != null)
                            {
                                o2DockContent.dockContent.TopLevelControl.Width  = o2DockContent.desiredWidth;
                                o2DockContent.dockContent.TopLevelControl.Height = o2DockContent.desiredHeight;
                            }
                        }
                    }
                    else
                    {
                        DI.log.error("in showO2DockContentInDockPanel, could not create instance of controlToLoad: {0}",
                                     o2DockContent.type.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "on O2DockPanel.showO2DockContentInDockPanel");
            }
            o2DockContent.controlLoadedIntoGui.Set();
        }
示例#10
0
 public O2DockPanel(O2DockContent controlToLoad)
 {
     openO2DockContentInNewDockPanel(controlToLoad);
 }
示例#11
0
        public static void showO2DockContentInDockPanel(O2DockContent o2DockContent)
        {
            try
            {
                DI.log.info("on O2DockPanel.showO2DockContentInDockPanel: {0} [{1}]", o2DockContent.name, o2DockContent.type);
                if (DI.o2GuiWithDockPanel.okThread(delegate { showO2DockContentInDockPanel(o2DockContent); }))
                {
                    //  if (o2DocContent.dockContent.okThread(delegate { showO2DockContentInDockPanel(o2DocContent); }))
                    //    if (DI.o2GuiWithDockPanel.getDockPanel().okThread(
                    //        delegate { showO2DockContentInDockPanel(o2DocContent); }))

                    // now that we are on the correct thread the control can be created
                    if (o2DockContent.createControlFromType())
                    {
                        if (o2DockContent.dockContent.TopLevelControl != null)
                        {
                            o2DockContent.dockContent.Show(DI.o2GuiWithDockPanel.getDockPanel(), o2DockContent.dockState);

                            if (o2DockContent.dockState == DockState.Float &&
                                o2DockContent.dockContent.TopLevelControl != null)
                            {
                                o2DockContent.dockContent.TopLevelControl.Width = o2DockContent.desiredWidth;
                                o2DockContent.dockContent.TopLevelControl.Height = o2DockContent.desiredHeight;
                            }
                        }
                    }
                    else
                        DI.log.error("in showO2DockContentInDockPanel, could not create instance of controlToLoad: {0}",
                                                           o2DockContent.type.ToString());
                }
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "on O2DockPanel.showO2DockContentInDockPanel");
            }
            o2DockContent.controlLoadedIntoGui.Set();
        }
        private static void addControlToO2GuiWithDockPanelSync(O2GuiWithDockPanel o2GuiWithDockPanel, O2DockContent controlToAdd, EventWaitHandle controlAdded)
        {
            //if (controlToAdd.dockContent != null && controlToAdd.dockContent.okThread(
            //    delegate { addControlToO2GuiWithDockPanelSync(controlToAdd, controlAdded); }))
            //{

            //var sync = new AutoResetEvent(false);

            // add the control on the o2GuiThread
            //DI.o2GuiWithDockPanel.Invoke(new EventHandler(delegate {
            try
            {
                if (controlToAdd.createControlFromType())
                {
                    controlToAdd.dockContent.Show(o2GuiWithDockPanel.getDockPanel(), controlToAdd.dockState);

                    if (controlToAdd.dockState == DockState.Float && controlToAdd.dockContent.TopLevelControl != null)
                    {
                        controlToAdd.dockContent.TopLevelControl.Width  = controlToAdd.desiredWidth;
                        controlToAdd.dockContent.TopLevelControl.Height = controlToAdd.desiredHeight;
                    }
                    if (controlToAdd.dockState == DockState.Document)
                    {
                        if (DI.o2GuiWithDockPanel.Width < controlToAdd.desiredWidth)
                        {
                            DI.o2GuiWithDockPanel.Width = controlToAdd.desiredWidth + 10;
                        }
                        if (DI.o2GuiWithDockPanel.Height < controlToAdd.desiredHeight + 100)
                        {
                            DI.o2GuiWithDockPanel.Height = controlToAdd.desiredHeight + 100;
                        }
                    }
                    O2DockUtils.addO2DockContentToDIGlobalVar(controlToAdd);
                }
            }
            catch (Exception ex)
            {
                DI.log.ex(ex, "in addControlToO2GuiWithDockPanelSync");
            }

            controlAdded.Set();
            //                                                 }));
            //}
            //controlAdded.WaitOne();
        }
示例#13
0
 public void openO2DockContentInNewDockPanel(O2DockContent o2DockContent)
 {
     openO2DockContentInNewDockPanel(new List<O2DockContent> {o2DockContent});
 }
示例#14
0
        private static void addControlToO2GuiWithDockPanelSync(O2GuiWithDockPanel o2GuiWithDockPanel, O2DockContent controlToAdd, EventWaitHandle controlAdded)
        {
            //if (controlToAdd.dockContent != null && controlToAdd.dockContent.okThread(
            //    delegate { addControlToO2GuiWithDockPanelSync(controlToAdd, controlAdded); }))
            //{

            //var sync = new AutoResetEvent(false);

            // add the control on the o2GuiThread
            //DI.o2GuiWithDockPanel.Invoke(new EventHandler(delegate {
            try
            {
                if (controlToAdd.createControlFromType())
                {
                    controlToAdd.dockContent.Show(o2GuiWithDockPanel.getDockPanel(), controlToAdd.dockState);

                    if (controlToAdd.dockState == DockState.Float && controlToAdd.dockContent.TopLevelControl != null)
                    {
                        controlToAdd.dockContent.TopLevelControl.Width = controlToAdd.desiredWidth;
                        controlToAdd.dockContent.TopLevelControl.Height = controlToAdd.desiredHeight;
                    }
                    if (controlToAdd.dockState == DockState.Document)
                    {
                        if (DI.o2GuiWithDockPanel.Width < controlToAdd.desiredWidth)
                            DI.o2GuiWithDockPanel.Width = controlToAdd.desiredWidth + 10;
                        if (DI.o2GuiWithDockPanel.Height < controlToAdd.desiredHeight + 100)
                            DI.o2GuiWithDockPanel.Height = controlToAdd.desiredHeight + 100;
                    }
                    O2DockUtils.addO2DockContentToDIGlobalVar(controlToAdd);
                }
            }
            catch(Exception ex)
            {
                DI.log.ex(ex, "in addControlToO2GuiWithDockPanelSync");
            }

            controlAdded.Set();
            //                                                 }));
            //}
            //controlAdded.WaitOne();
        }
示例#15
0
        private static void addLogViewerToControlsToLoad(ICollection<O2DockContent> controlsToLoad)
        {
            // first make sure the ascx_LogViewer is not already in the list of controls to add
            foreach(var controlToLoad in controlsToLoad)
                if (controlToLoad.type == typeof(ascx_LogViewer))
                    return;

            var logViewer = new O2DockContent(typeof(ascx_LogViewer), DockState.DockBottomAutoHide, PublicDI.LogViewerControlName);
            controlsToLoad.Add(logViewer);
        }
示例#16
0
        private void addControlToO2GuiWithDockPanelSync(O2DockContent controlToAdd)
        {
            var controlAdded = new AutoResetEvent(false);
            var o2GuiWithDockPanel = getO2GuiWithDockPanel();
            //if (DI.o2GuiWithDockPanel.Handle != null)
            if (DI.o2GuiWithDockPanel.InvokeRequired)
                DI.o2GuiWithDockPanel.Invoke(new EventHandler(delegate { addControlToO2GuiWithDockPanelSync(o2GuiWithDockPanel,controlToAdd, controlAdded); }));
            else
               addControlToO2GuiWithDockPanelSync(o2GuiWithDockPanel,controlToAdd, controlAdded);

            controlAdded.WaitOne();
        }
 public O2DockPanel(O2DockContent controlToLoad)
 {
     openO2DockContentInNewDockPanel(controlToLoad);
 }
示例#18
0
        public static O2DockContent addAscxControlToO2GuiWithDockPanelWithDockState(Type ascxControlToLoad,
            DockState dockState,
            String name, bool showControl)
        {
            if (DI.o2GuiWithDockPanel == null)
            {
                DI.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))
                    DI.log.error("Failed to load control {0} in 10 sec", o2DocContent.name);
            }
            return o2DocContent;
        }
示例#19
0
 private static void addControlToLoadedO2ModulesList(O2DockContent controlToLoad)
 {
     if (DI.o2GuiStandAloneFormMode == false)
         if (DI.o2GuiWithDockPanel == null)
             DI.log.error("in addControlToLoadedO2ModulesList , DI.o2GuiWithDockPanel == null");
         else
             DI.o2GuiWithDockPanel.addControlToLoadedO2ModulesMenu(controlToLoad);
 }
 public void openO2DockContentInNewDockPanel(O2DockContent o2DockContent)
 {
     openO2DockContentInNewDockPanel(new List <O2DockContent> {
         o2DockContent
     });
 }
示例#21
0
        public static void launchO2DockContentAsStandAloneForm(Type typeOfControlToLoad, string controlName)
        {
            if (typeOfControlToLoad == null)
                DI.log.error("in launchO2DockContentAsStandAloneForm typeOfControlToLoad was null");
            else
                try
                {
                    var sync = new AutoResetEvent(false);
                    O2Thread.staThread(() =>
                                           {
                                               try
                                               {
                                                   DI.o2GuiStandAloneFormMode = true;
                                                   //var controlToLoad = (Control) Activator.CreateInstance(typeOfControlToLoad);
                                                  // if (typeOfControlToLoad != null)
                                                  // {
                                                    var o2DockContent = new O2DockContent(typeOfControlToLoad, DockState.Float, controlName);
                                                    o2DockContent.dockContent.HandleCreated += (sender, e) => sync.Set();
                                                    // as soons as the control HandleCreated is created, we can let this function (launchO2DockContentAsStandAloneForm end)
                                                    if (o2DockContent.createControlFromType())
                                                    {
                                                        o2DockContent.dockContent.Width = o2DockContent.desiredWidth;
                                                        o2DockContent.dockContent.Height = o2DockContent.desiredHeight;
                                                        O2DockUtils.addO2DockContentToDIGlobalVar(o2DockContent);
                                                        o2DockContent.dockContent.Closed += (sender, e) =>
                                                                                                {
                                                                                                    if (DI.dO2LoadedO2DockContent.Count == 0) // if there are no more controls trigger the end of the GUI session
                                                                                                        O2AscxGUI.guiClosed.Set();
                                                                                                };

                                                        o2DockContent.dockContent.ShowDialog();
                                                    }
                                                    else
                                                    {
                                                        DI.log.error(
                                                            "in launchO2DockContentAsStandAloneForm, could not create instance of controlToLoad: {0}",
                                                            typeOfControlToLoad.ToString());
                                                    }
                                               }
                                               catch (Exception ex)
                                               {
                                                   DI.log.ex(ex, "in launchO2DockContentAsStandAloneForm");
                                               }
                                               sync.Set();
                                           });
                    sync.WaitOne();
                }
                catch (Exception ex)
                {
                    DI.log.ex(ex);
                }
        }