Ejemplo n.º 1
0
        /// <summary>
        /// Add a page component to this PageManager.
        /// </summary>
        /// <param name="component">the component that is to be added</param>
        public void AddPageComponent(PageComponent component)
        {
            // If a component with this id has already been added, we throw
            string compId = component.GetId();

            if (_componentIds.ContainsKey(compId) && !CUIUtility.IsNullOrUndefined(_componentIds[compId]))
            {
                throw new ArgumentNullException("A PageComponent with id: " + component.GetId() + " has already been added to the PageManger.");
            }


            // REVIEW(josefl): for performance reasons, we may want to move this into an Init() method
            if (!CUIUtility.IsNullOrUndefined(_components) && !_components.Contains(component))
            {
                _componentIds[component.GetId()] = component;
                component.Init();
                _commandDispatcher.RegisterMultipleCommandHandler((ICommandHandler)component,
                                                                  component.GetGlobalCommands());
                _components.Add(component);
                if (component.IsFocusable())
                {
                    _focusManager.AddPageComponent(component);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Removes a page component from this PageManager.
        /// </summary>
        /// <param name="component">the component that is to be removed</param>
        public void RemovePageComponent(PageComponent component)
        {
            if (CUIUtility.IsNullOrUndefined(_components) || !_components.Contains(component))
            {
                return;
            }

            _commandDispatcher.UnregisterMultipleCommandHandler((ICommandHandler)component,
                                                                component.GetGlobalCommands());
            _components.Remove(component);
            // Add this component to the focus manager if it is focusable
            if (component.IsFocusable())
            {
                _focusManager.RemovePageComponent(component);
            }

            // Remove the component from the hash of their ids
            _componentIds[component.GetId()] = null;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes a page component from this PageManager.
        /// </summary>
        /// <param name="component">the component that is to be removed</param>
        public void RemovePageComponent(PageComponent component)
        {
            if (CUIUtility.IsNullOrUndefined(_components) || !_components.Contains(component))
                return;

            _commandDispatcher.UnregisterMultipleCommandHandler((ICommandHandler)component,
                                                                 component.GetGlobalCommands());
            _components.Remove(component);
            // Add this component to the focus manager if it is focusable
            if (component.IsFocusable())
                _focusManager.RemovePageComponent(component);

            // Remove the component from the hash of their ids
            _componentIds[component.GetId()] = null;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Add a page component to this PageManager.
        /// </summary>
        /// <param name="component">the component that is to be added</param>
        public void AddPageComponent(PageComponent component)
        {
            // If a component with this id has already been added, we throw
            string compId = component.GetId();
            if (_componentIds.ContainsKey(compId) && !CUIUtility.IsNullOrUndefined(_componentIds[compId]))
                throw new ArgumentNullException("A PageComponent with id: " + component.GetId() + " has already been added to the PageManger.");


            // REVIEW(josefl): for performance reasons, we may want to move this into an Init() method
            if (!CUIUtility.IsNullOrUndefined(_components) && !_components.Contains(component))
            {
                _componentIds[component.GetId()] = component;
                component.Init();
                _commandDispatcher.RegisterMultipleCommandHandler((ICommandHandler)component, 
                                                                   component.GetGlobalCommands());
                _components.Add(component);
                if (component.IsFocusable())
                    _focusManager.AddPageComponent(component);
            }
        }