/// <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); } } }
/// <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; }
/// <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; }
/// <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); } }