コード例 #1
0
        void AppSAP_MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent)
        {
            try
            {
                if (!pBubbleEvent)
                {
                    BubbleEvent  = false;
                    pBubbleEvent = true;
                    return;
                }

                BubbleEvent = true;


                if (FormSystemModal != null)
                {
                    FormSystemModal.Select();
                    BubbleEvent = false;
                    return;
                }

                ///Tenho sempre de qualquer forma atribuir um valor a esse bloco
                ///Isso é feio demais!!!
                // BubbleEvent = BubbleEvent ? true : false;

                SAPbouiCOM.Form form = null;

                try
                {
                    form = AppSAP.Forms.ActiveForm;
                }
                catch { }

                if (form != null)
                {
                    var formType   = form.Type;
                    var formTypeEx = form.TypeEx;
                    var formcount  = form.TypeCount;
                    var formOpen   = FormOpens.FirstOrDefault(
                        f => ((f.Type == formType || f.TypeEx == formTypeEx) && f.TypeCount == formcount));
                    if (formOpen != null)
                    {
                        try
                        {
                            ItemEvent item = new ItemEvent()
                            {
                                EventType    = BoEventTypes.et_MENU_CLICK,
                                ItemUID      = pVal.MenuUID,
                                BeforeAction = pVal.BeforeAction,
                            };

                            formOpen.DoEvent(item, out BubbleEvent);
                        }
                        catch (Exception ex)
                        {
                            BubbleEvent = false;
                            Application.GetInstance().SetTextOnStatusBar(ex.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                BubbleEvent = false;
                Application.GetInstance().SetTextOnStatusBar(ex.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
            }
        }