protected override void SerializeToData(DataObject data)
 {
     data.SetComponentRefs(new[] { this.component });
 }
Esempio n. 2
0
        protected void AppendNodesToData(DataObject data, IEnumerable<TreeNodeAdv> nodes, bool guardRequiredComponents)
        {
            if (!guardRequiredComponents)
            {
                data.SetData(nodes.ToArray());
                data.SetComponentRefs(
                    from c in nodes
                    where c.Tag is ComponentNode
                    select (c.Tag as ComponentNode).Component);
                data.SetGameObjectRefs(
                    from c in nodes
                    where c.Tag is GameObjectNode
                    select (c.Tag as GameObjectNode).Obj);
            }
            else
            {
                // Query selected objects and components
                var nodeQuery =
                    from viewNode in this.objectView.SelectedNodes
                    select this.objectModel.FindNode(this.objectView.GetPath(viewNode)) as NodeBase;
                var cmpQuery =
                    from cmpNode in nodeQuery
                    where cmpNode is ComponentNode
                    select (cmpNode as ComponentNode).Component;
                var objQuery =
                    from objNode in nodeQuery
                    where objNode is GameObjectNode
                    select (objNode as GameObjectNode).Obj;
                var cmpList = new List<Component>(cmpQuery);
                var objList = new List<GameObject>(objQuery);

                // Check which Components may be removed and which not
                Component conflictComp = this.CheckComponentsRemovable(cmpList, objList);
                if (conflictComp != null)
                {
                    this.FlashNode(this.FindNode(conflictComp));
                    System.Media.SystemSounds.Beep.Play();
                }

                var viewNodeQuery =
                            cmpList.Select(c => this.objectView.FindNodeByTag(this.FindNode(c))).
                    Concat(	objList.Select(o => this.objectView.FindNodeByTag(this.FindNode(o))));

                this.AppendNodesToData(data, viewNodeQuery.ToArray(), false);
            }
        }