Пример #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);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Adds a component that is capable of having focus to this FocusManager
        /// and registers for the appropriate events using PageComponent.GetFocusedCommands()
        /// </summary>
        /// <param name="component">the component that is to be added</param>
        internal void AddPageComponent(PageComponent component)
        {
            if (_components.Contains(component))
            {
                return;
            }

            RegisterMultipleCommandHandler((ICommandHandler)component,
                                           component.GetFocusedCommands());
            _components.Add(component);
        }
Пример #3
0
        /// <summary>
        /// Requests that the focus be released from the passed in component
        /// </summary>
        /// <param name="component">the component that focus is being requested for</param>
        /// <returns>true if the focus was successfully transferred to the passed in PageComponent</returns>
        public bool ReleaseFocusFromComponent(PageComponent component)
        {
            if (CUIUtility.IsNullOrUndefined(component))
                return false;

            if (!_activeComponents.Contains(component))
                return true;

            _activeComponents.Remove(component);
            HandleQuickLookup();
            component.YieldFocus();
            return true;
        }
Пример #4
0
        /// <summary>
        /// Requests that the focus be put on the passed in component
        /// </summary>
        /// <param name="component">the component that focus is being requested for</param>
        /// <returns>true if the focus was successfully transferred to the passed in PageComponent</returns>
        public bool RequestFocusForComponent(PageComponent component)
        {
            if (CUIUtility.IsNullOrUndefined(component))
                return false;

            if (_activeComponents.Contains(component))
                return true;

            _activeComponents.Add(component);
            HandleQuickLookup();
            component.ReceiveFocus();
            return true;
        }
Пример #5
0
        /// <summary>
        /// Removes a component from the FocusManager and unregisters the commands that it is
        /// registerd for using PageComponent.GetFocusedCommands()
        /// </summary>
        /// <param name="component"></param>
        internal void RemovePageComponent(PageComponent component)
        {
            if (!_components.Contains(component))
            {
                return;
            }

            UnregisterMultipleCommandHandler((ICommandHandler)component,
                                             component.GetFocusedCommands());

            // Release the focus from the component in case it has it
            ReleaseFocusFromComponent(component);
            _components.Remove(component);
        }
Пример #6
0
        private void HandleQuickLookup()
        {
            _focusedComponents = new Dictionary <ICommandHandler, PageComponent>();
            int length = _activeComponents.Count;

            for (int i = 0; i < length; i++)
            {
                PageComponent comp = (PageComponent)_activeComponents[i];

                // We just want to have a normal javascript associated array with the object
                // as the key.  Script# does not have a object keyed Dictionary so we just
                // do it this way and it will compile correctly
                _focusedComponents[comp] = comp;
            }
        }
Пример #7
0
        /// <summary>
        /// Removes the focus so that no PageComponent has the focus
        /// </summary>
        /// <returns>true if the focus was successfully removed</returns>
        public bool ReleaseAllFoci()
        {
            // We need to do this here in case some of the components execute commands in their "Yield()" method.
            // This is equivalent to a call to HandleQuickLookup()
            _focusedComponents = new Dictionary <ICommandHandler, PageComponent>();

            int length = _activeComponents.Count;

            for (int i = length - 1; i >= 0; i--)
            {
                PageComponent comp = (PageComponent)_activeComponents[i];
                _activeComponents.Remove(comp);
                comp.YieldFocus();
            }

            return(true);
        }
Пример #8
0
        /// <summary>
        /// Requests that the focus be released from the passed in component
        /// </summary>
        /// <param name="component">the component that focus is being requested for</param>
        /// <returns>true if the focus was successfully transferred to the passed in PageComponent</returns>
        public bool ReleaseFocusFromComponent(PageComponent component)
        {
            if (CUIUtility.IsNullOrUndefined(component))
            {
                return(false);
            }

            if (!_activeComponents.Contains(component))
            {
                return(true);
            }

            _activeComponents.Remove(component);
            HandleQuickLookup();
            component.YieldFocus();
            return(true);
        }
Пример #9
0
        /// <summary>
        /// Requests that the focus be put on the passed in component
        /// </summary>
        /// <param name="component">the component that focus is being requested for</param>
        /// <returns>true if the focus was successfully transferred to the passed in PageComponent</returns>
        public bool RequestFocusForComponent(PageComponent component)
        {
            if (CUIUtility.IsNullOrUndefined(component))
            {
                return(false);
            }

            if (_activeComponents.Contains(component))
            {
                return(true);
            }

            _activeComponents.Add(component);
            HandleQuickLookup();
            component.ReceiveFocus();
            return(true);
        }
Пример #10
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;
        }
Пример #11
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;
        }
Пример #12
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);
            }
        }
Пример #13
0
        /// <summary>
        /// Removes a component from the FocusManager and unregisters the commands that it is
        /// registerd for using PageComponent.GetFocusedCommands()
        /// </summary>
        /// <param name="component"></param>
        internal void RemovePageComponent(PageComponent component)
        {
            if (!_components.Contains(component))
                return;

            UnregisterMultipleCommandHandler((ICommandHandler)component,
                                             component.GetFocusedCommands());

            // Release the focus from the component in case it has it
            ReleaseFocusFromComponent(component);
            _components.Remove(component);
        }
Пример #14
0
        /// <summary>
        /// Adds a component that is capable of having focus to this FocusManager
        /// and registers for the appropriate events using PageComponent.GetFocusedCommands()
        /// </summary>
        /// <param name="component">the component that is to be added</param>
        internal void AddPageComponent(PageComponent component)
        {
            if (_components.Contains(component))
                return;

            RegisterMultipleCommandHandler((ICommandHandler)component,
                                           component.GetFocusedCommands());
            _components.Add(component);
        }