Ejemplo n.º 1
0
        private CheckState GetCheckState(ILayer layer)
        {
            bool hasUncheckedChild = false;
            bool hasCheckedChild   = false;

            foreach (ILayer subLayer in layer.Layers)
            {
                CheckState subCheckState = GetCheckState(subLayer);
                switch (subCheckState)
                {
                case CheckState.Checked:
                    hasCheckedChild = true;
                    break;

                case CheckState.Unchecked:
                    hasUncheckedChild = true;
                    break;

                case CheckState.Indeterminate:
                    hasCheckedChild   = true;
                    hasUncheckedChild = true;
                    break;
                }
            }

            if (!hasCheckedChild || !hasUncheckedChild)
            {
                foreach (IGameObject gameObject in layer.GetGameObjects())
                {
                    IVisible iVisible = gameObject.As <IVisible>();
                    if (iVisible != null)
                    {
                        if (iVisible.Visible)
                        {
                            hasCheckedChild = true;
                        }
                        else
                        {
                            hasUncheckedChild = true;
                        }
                    }
                }
            }

            if (hasCheckedChild && !hasUncheckedChild)
            {
                return(CheckState.Checked);
            }
            if (hasUncheckedChild && !hasCheckedChild)
            {
                return(CheckState.Unchecked);
            }

            return(CheckState.Indeterminate);
        }
Ejemplo n.º 2
0
        private void PropagateVisible(ILayer layer, bool visible)
        {
            // Recursive call to update all sub-layers
            foreach (ILayer subLayer in layer.Layers)
            {
                PropagateVisible(subLayer, visible);
            }

            // Set visibility for all GameObjects
            foreach (IGameObject gameObject in layer.GetGameObjects())
            {
                IVisible iVisible = gameObject.As <IVisible>();
                if (iVisible != null)
                {
                    iVisible.Visible = visible;
                }
            }
        }
Ejemplo n.º 3
0
        private void PropagateVisible(ILayer layer, bool visible)
        {
            // Recursive call to update all sub-layers
            foreach (ILayer subLayer in layer.Layers)
                PropagateVisible(subLayer, visible);

            // Set visibility for all GameObjects
            foreach (IGameObject gameObject in layer.GetGameObjects())
            {
                IVisible iVisible = gameObject.As<IVisible>();
                if (iVisible != null)
                    iVisible.Visible = visible;
            }
        }
Ejemplo n.º 4
0
        private CheckState GetCheckState(ILayer layer)
        {
            bool hasUncheckedChild = false;
            bool hasCheckedChild = false;

            foreach (ILayer subLayer in layer.Layers)
            {
                CheckState subCheckState = GetCheckState(subLayer);
                switch (subCheckState)
                {
                    case CheckState.Checked:
                        hasCheckedChild = true;
                        break;
                    case CheckState.Unchecked:
                        hasUncheckedChild = true;
                        break;
                    case CheckState.Indeterminate:
                        hasCheckedChild = true;
                        hasUncheckedChild = true;
                        break;
                }
            }

            if (!hasCheckedChild || !hasUncheckedChild)
            {
                foreach (IGameObject gameObject in layer.GetGameObjects())
                {
                    IVisible iVisible = gameObject.As<IVisible>();
                    if (iVisible != null)
                    {
                        if (iVisible.Visible)
                            hasCheckedChild = true;
                        else
                            hasUncheckedChild = true;
                    }
                }
            }

            if (hasCheckedChild && !hasUncheckedChild)
                return CheckState.Checked;
            if (hasUncheckedChild && !hasCheckedChild)
                return CheckState.Unchecked;

            return CheckState.Indeterminate;
        }