Beispiel #1
0
        /// <summary>
        /// Tries the get information about a currently attached component.
        /// </summary>
        private bool TryGetAttachedComponent(
            SceneComponentBase component, ViewInformation?correspondingView,
            out SceneComponentInfo componentInfo, out int componentIndex)
        {
            var attachedComponentCount = _attachedComponents.Count;

            for (var loop = 0; loop < attachedComponentCount; loop++)
            {
                if (component.IsViewSpecific)
                {
                    if (component == _attachedComponents[loop].Component &&
                        correspondingView != null &&
                        correspondingView == _attachedComponents[loop].CorrespondingView)
                    {
                        componentInfo  = _attachedComponents[loop];
                        componentIndex = loop;
                        return(true);
                    }
                }
                else
                {
                    if (component == _attachedComponents[loop].Component)
                    {
                        componentInfo  = _attachedComponents[loop];
                        componentIndex = loop;
                        return(true);
                    }
                }
            }

            componentInfo  = default;
            componentIndex = -1;
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Detaches the given component from this scene.
        /// </summary>
        /// <param name="component">The component to be detached.</param>
        /// <param name="sourceView">The view which attached the component initially.</param>
        internal void DetachComponent(SceneComponentBase component, ViewInformation?sourceView)
        {
            component.EnsureNotNull(nameof(component));
            if (component.IsViewSpecific)
            {
                sourceView.EnsureNotNull(nameof(sourceView));
            }

            _componentRequests.Enqueue(new SceneComponentRequest
            {
                RequestType       = SceneComponentRequestType.Detach,
                Component         = component,
                CorrespondingView = component.IsViewSpecific ? sourceView : null
            });
        }
Beispiel #3
0
 /// <summary>
 /// Detaches the given component from this scene.
 /// </summary>
 /// <param name="component">The component to be detached.</param>
 /// <param name="sourceView">The view which attached the component initially.</param>
 public void DetachComponent(SceneComponentBase component, ViewInformation?sourceView = null)
 {
     _sceneComponents.AttachComponent(component, sourceView);
 }