public void UpdateOutliner(CHierarchyEntry root)
        {
            void AddOutlinerEntity(CHierarchyEntry entity, COutlinerEntityViewModel parent)
            {
                COutlinerEntityViewModel viewModel = new COutlinerEntityViewModel(this, new SEntityId(entity.EntityId), entity.Label, parent, -1);

                parent.Children.Add(viewModel);

                foreach (var child in entity.Children)
                {
                    AddOutlinerEntity(child, viewModel);
                }
            }

            m_entities.Clear();

            for (int i = 0, count = root.Children.Count; i < count; i++)
            {
                CHierarchyEntry child = root.Children[i];

                COutlinerEntityViewModel rootEntity = new COutlinerEntityViewModel(this, new SEntityId(child.EntityId), child.Label, null, i);
                foreach (var hierarchyChild in child.Children)
                {
                    AddOutlinerEntity(hierarchyChild, rootEntity);
                }
                m_entities.Add(rootEntity);
            }

            CWorkspace.Instance.SetSelectedObject(CWorkspace.Instance.SelectedEditableObject, true);
        }
        public void SetSelectedEntity(SEntityId entityId)
        {
            bool CheckEntity(COutlinerEntityViewModel vm)
            {
                if (vm.EntityId == entityId)
                {
                    vm.IsSelected = true;
                    return(true);
                }

                for (int i = 0, count = vm.Children.Count; i < count; i++)
                {
                    if (CheckEntity(vm.Children[i]))
                    {
                        vm.IsExpanded = true;
                        return(true);
                    }
                }

                return(false);
            }

            for (int i = 0, count = m_entities.Count; i < count; i++)
            {
                COutlinerEntityViewModel entry = m_entities[i];
                if (CheckEntity(entry))
                {
                    if (entry.Children.Count > 0)
                    {
                        entry.IsExpanded = true;
                    }
                    return;
                }
            }
        }
        public COutlinerEntityViewModel(CWorldOutlinerViewModel vm, SEntityId entityId, string name, COutlinerEntityViewModel parent, int index)
        {
            EntityId    = entityId;
            m_viewModel = vm;
            m_name      = name;
            Parent      = parent;
            Index       = index;

            InitCommands();
        }
        private void OnDrop(object e)
        {
            DragEventArgs args = (DragEventArgs)e;

            if (args.Data.GetDataPresent("entity") && args.Data.GetData("entity") != this)
            {
                COutlinerEntityViewModel otherEntity = args.Data.GetData("entity") as COutlinerEntityViewModel;
                if (otherEntity != null && otherEntity != this)
                {
                    m_viewModel.AttachEntities(otherEntity.EntityId, EntityId);
                }
            }
        }