Beispiel #1
0
        public void SetMainMenu(IMainMenuInstance mainMenu)
        {
            var listener = CreateMainMenuEventListener(mainMenu);

            listener.Subscribe();
            B1EventFilterManager.Include(BoEventTypes.et_MENU_CLICK, @"ALL_FORMS");
        }
Beispiel #2
0
        private void AddEventHandlers(IMainMenuInstance mainMenu)
        {
            var handlerMethods = ClassHelper.FindAnnotatedMethods <MenuEventHandlerAttribute>(mainMenu);

            foreach (var method in handlerMethods)
            {
                var attribute = method.GetAttribute <MenuEventHandlerAttribute>();
                try
                {
                    if (attribute.Before)
                    {
                        before.Add(attribute.MenuId, method.CreateBeforeEventDelegate <MenuEvent>(mainMenu));
                    }
                    else
                    {
                        after.Add(attribute.MenuId, method.CreateAfterEventDelegate <MenuEvent>(mainMenu));
                    }
                }
                catch (ArgumentException e)
                {
                    var exception =
                        new EventHandlerAlreadyExistsException(
                            $"A menu event handler for {attribute.MenuId} already exists. Duplicate method {method.Name}.",
                            e);
                    throw exception;
                }


                HandlerAdded(this, new HandlerAddedEventArgs(BoEventTypes.et_MENU_CLICK, @"ALL_FORMS"));
            }
        }
Beispiel #3
0
        private void AddEventHandlers(IMainMenuInstance mainMenu)
        {
            var handlerMethods = ClassHelper.FindAnnotatedMethods <MenuEventHandlerAttribute>(mainMenu);

            foreach (var method in handlerMethods)
            {
                AddEventHandler(mainMenu, method);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="B1Session" /> class.
        /// </summary>
        /// <param name="application">
        /// The application.
        /// </param>
        /// <param name="applicationEventsHandler">
        /// The instance responsible for application event handling.
        /// </param>
        /// <param name="mainMenu">
        /// The main menu instance.
        /// </param>
        public B1Session(
            Application application,
            IApplicationEventsHandler applicationEventsHandler,
            [CanBeNull] IMainMenuInstance mainMenu)
        {
            this.application = application;
            assembly         = applicationEventsHandler.GetType().Assembly;
            this.applicationEventsHandler = applicationEventsHandler;
            this.mainMenu = mainMenu ?? new NullMainMenuInstance();

            B1ApplicationEventDispatcher = new B1ApplicationEventDispatcher();
            B1FormDataEventDispatcher    = new B1FormDataEventDispatcher();
            B1MenuEventDispatcher        = new B1MenuEventDispatcher();
            B1ItemEventDispatcher        = new B1ItemEventDispatcher();
            B1RightClickEventDispatcher  = new B1RightClickEventDispatcher();
            B1LayoutKeyEventDispatcher   = new B1LayoutKeyEventDispatcher();
        }
Beispiel #5
0
 private static IMainMenuInstance GetMainMenu(IMainMenuInstance mainMenuInstance)
 {
     return(mainMenuInstance ?? new DefaultMainMenu());
 }
Beispiel #6
0
 private IEventListener CreateMainMenuEventListener(IMainMenuInstance mainMenuInstance)
 {
     return(new MainMenuEventListener(mainMenuInstance, B1MenuEventDispatcher));
 }
Beispiel #7
0
        /// <summary>
        /// Set a custom built main menu instance.
        /// </summary>
        /// <param name="instance">
        /// The instance to use.
        /// </param>
        protected void SetMainMenu(IMainMenuInstance instance)
        {
            mainMenu = instance ?? new DefaultMainMenu();

            B1EventsManager.Instance.SetMainMenu(mainMenu);
        }
Beispiel #8
0
 public MainMenuEventListener(IMainMenuInstance main, B1MenuEventDispatcher dispatcher)
 {
     this.main       = main;
     this.dispatcher = dispatcher;
 }