Exemple #1
0
 public static Control getAscx(string ascxControlName)
 {
     return(O2DockUtils.getAscx(ascxControlName));
 }
Exemple #2
0
 public static bool isAscxLoaded(string ascxControlName)
 {
     return(O2DockUtils.getAscx(ascxControlName) != null);
 }
        private static void o2MessageQueue_onMessages(IO2Message o2Message)
        {
            try
            {
                if (o2Message is IM_GUIAction)
                {
                    var mGuiAction = (IM_GUIAction)o2Message;
                    PublicDI.log.info("O2GuiWithDockPanel received IM_GUIAction of action: {0}", mGuiAction.GuiAction);
                    switch (mGuiAction.GuiAction)
                    {
                    case IM_GUIActions.isAscxGuiAvailable:
                        isAscxGuiAvailable();
                        break;

                    //   case (IM_GUIActions.openControlInGui): // don't handle these here
                    case IM_GUIActions.getGuiAscx:
                        if (mGuiAction.returnDataCallback != null)
                        {
                            mGuiAction.returnDataCallback(O2DockUtils.getAscx(mGuiAction.controlName));
                        }
                        break;

                    case IM_GUIActions.executeOnAscx:
                        if (mGuiAction.controlName == null || mGuiAction.targetMethod == null ||
                            mGuiAction.methodParameters == null)
                        {
                            PublicDI.log.error(
                                "in O2Environment.O2MessagesHandler.o2MessageQueue_onMessages received a O2Message for IM_GUIActions.executeOnAscx, but either the targetMethod or methodParameters are null");
                        }
                        else
                        {
                            var ascxControlToExecute = O2AscxGUI.getAscx(mGuiAction.controlName);
                            if (ascxControlToExecute == null)
                            {
                                PublicDI.log.error(
                                    "in O2MessagesHandler...IM_GUIActions.executeOnAscx, could not get control: {0}",
                                    mGuiAction.controlName);
                            }
                            else
                            {
                                o2Message.returnData = PublicDI.reflection.invoke(ascxControlToExecute,
                                                                                  mGuiAction.targetMethod,
                                                                                  mGuiAction.methodParameters);
                            }
                        }
                        break;

                    case IM_GUIActions.closeAscxParent:
                        O2AscxGUI.closeAscxParent(mGuiAction.controlName);
                        break;

                    case IM_GUIActions.openControlInGui:                // this is a special case since we should only handle this if the main GUI is not loaded
                        if (false == O2AscxGUI.isGuiLoaded())           // this tends to happen on Unit tests where we only have one control loaded
                        {
                            // and if the Gui is not loaded open this control as a stand alone FORM
                            O2AscxGUI.openAscxAsForm(mGuiAction.controlType, mGuiAction.controlName);
                        }
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                PublicDI.log.ex(ex, " in O2MessagesHandler.o2MessageQueue_onMessages");
            }
        }