public Boolean setLeftChild(TreeObject leftChild)
 {
     Boolean returned;
     if (!leftChildSet) {
         this.leftChild = leftChild;
         this.leftChildSet = true;
         returned = true;
     } else {
         returned = false;
     }
     return returned;
 }
        private void AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode node = GetRoot(e.Node);
            if (null == node)
                return;

            m_selectedTreeObject = e.Node as TreeObject;
            HighlightSelectedNodes(m_rootNode);

            ChildFormData childFormData = node.Tag as ChildFormData;
            if (m_ownerForm != childFormData.Form)
                return;

            if (m_notifyOnSelection)
            {
                if (m_selectedTreeObject != null)
                {
                    switch ((TreeViewControllerPolicyOriented.NodeType)m_selectedTreeObject.NodeType)
                    {
                        case TreeViewControllerPolicyOriented.NodeType.PolicySet:
                            {
                                ShowPoliciesState state = m_stateMachine.GetState(StateTypeEnum.ShowPolicies) as ShowPoliciesState;
                                state.PolicySet = childFormData.PolicySet as IPolicySet;
                                m_stateMachine.SetState(StateTypeEnum.ShowPolicies);
                            }
                            break;
                        case TreeViewControllerPolicyOriented.NodeType.Policy:
                            {
                                ShowPolicyState state = m_stateMachine.GetState(StateTypeEnum.ShowPolicy) as ShowPolicyState;
                                state.Policy = m_selectedTreeObject.Tag as IPolicy;
                                m_stateMachine.SetState(StateTypeEnum.ShowPolicy);
                            }
                            break;
                        case TreeViewControllerPolicyOriented.NodeType.Conditions:
                            {
                                ShowConditionsState state = m_stateMachine.GetState(StateTypeEnum.ShowConditions) as ShowConditionsState;
                                state.Policy = m_selectedTreeObject.Parent.Tag as IPolicy;
                                m_stateMachine.SetState(StateTypeEnum.ShowConditions);
                            }
                            break;
                        case TreeViewControllerPolicyOriented.NodeType.Channel:
                            {
                                ShowChannelState state = m_stateMachine.GetState(StateTypeEnum.ShowChannel) as ShowChannelState;
                                state.Policy = m_selectedTreeObject.Parent.Tag as IPolicy;
                                state.Channel = m_selectedTreeObject.Tag as IPolicyChannel;
                                m_stateMachine.SetState(StateTypeEnum.ShowChannel);
                            }
                            break;
                    }
                }
            }
        }
 public Boolean setRightChild(TreeObject rightChild)
 {
     Boolean returned;
     if (!rightChildSet) {
         this.rightChild = rightChild;
         this.rightChildSet = true;
         returned = true;
     }
     else {
         returned = false;
     }
     return returned;
 }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var InputFile = "input.txt";

            if (args.Length >= 1)
            {
                InputFile = args[0];
            }

            OpenFile(InputFile);
            StartCompute();

            char[] whitespaces = { ' ' };

            int N = Read <int>();

            for (int n = 1; n <= N; n++)
            {
                Console.WriteLine("Case #{0}:", n);

                int           L  = Read <int>();
                StringBuilder sb = new StringBuilder(L * 10);

                for (int l = 0; l < L; l++)
                {
                    sb.Append(reader.ReadLine());
                }

                int        offset = 0;
                TreeObject tree   = ParseTree(sb.ToString(), ref offset);

                int A = Read <int>();
                for (int a = 0; a < A; a++)
                {
                    var features = new HashSet <String>();

                    string   f  = reader.ReadLine();
                    string[] fs = f.Split(whitespaces, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string feature in fs.Skip(2))
                    {
                        features.Add(feature);
                    }

                    double res = tree.Evaluate(1.0, features);
                    //Console.WriteLine("{0,1.7}", res);
                    Console.WriteLine(res.ToString("0.0000000", System.Globalization.CultureInfo.InvariantCulture.NumberFormat));
                }
            }

            EndCompute();
        }
Esempio n. 5
0
 private TreeItemDTO AsDTO(TreeObject x)
 {
     if (x is TreeGroup group)
     {
         return(new TreeItemDTO(group));
     }
     if (x is TreeItem item)
     {
         return(new TreeItemDTO(item));
     }
     else
     {
         throw new ArgumentException("Tree object not expected");
     }
 }
Esempio n. 6
0
        public TreeObject CreateTreeObject(BlobObject blobObject)
        {
            var treeObject = new TreeObject
            {
                Permissions    = "100644",
                ObjectType     = "blob",
                ObjectFileName = ExampleFileName,
                BlobObject     = blobObject
            };

            treeObject.SetHash();

            TreeObjects.Add(treeObject);

            return(treeObject);
        }
Esempio n. 7
0
        /// <summary>
        /// Adds tree object created to the list holding all trees.
        /// </summary>
        /// <param name="genericTree">
        /// The generic tree.
        /// </param>
        /// <typeparam name="T">
        /// Parameter type string/double.
        /// </typeparam>
        private void AddToList <T>(T genericTree)
        {
            TreeObject genericTreeObject = null;

            if (this.CheckType <T>().Equals("text"))
            {
                genericTreeObject = new TreeObject(this.treeName, this.CheckType <T>(), (ITree <string>)genericTree);
            }

            if (this.CheckType <T>().Equals("numeric"))
            {
                genericTreeObject = new TreeObject(this.treeName, this.CheckType <T>(), (ITree <double>)genericTree);
            }

            this.provider.TreeObjects.Add(genericTreeObject);
        }
    public bool PlantTree(FieldVector coordinates)
    {
        Field field = GetFieldByVector(coordinates);

        if (field._assignment != null)
        {
            return(false);
        }

        TreeObject tree = new TreeObject(TreeObject.TreeLvl.SMALL, _players[_currentPlayerId]);

        field._assignment = tree;
        _players[_currentPlayerId].ChangeNumberOfSmallTrees(-1);
        field._already_used = true;
        SetNeighborhoodToActive(field);
        return(true);
    }
    public bool AddSeed(FieldVector coordinates)
    {
        Field field = GetFieldByVector(coordinates);

        if (field._assignment != null || field._is_active[_currentPlayerId] == false)
        {
            return(false);
        }

        TreeObject seed = new TreeObject(TreeObject.TreeLvl.SEED, _players[_currentPlayerId]);

        field._assignment   = seed;
        field._already_used = true;
        _players[_currentPlayerId].ChangeNumberOfSeeds(-1);
        _players[_currentPlayerId].ChangePointOfLights(-1);
        return(true);
    }
Esempio n. 10
0
        /// <summary>
        /// The add to batch list.
        /// </summary>
        /// <param name="genericTree">
        /// The generic tree.
        /// </param>
        /// <typeparam name="T">
        /// Parameter type string/double.
        /// </typeparam>
        private void AddToBatchList <T>(T genericTree)
        {
            TreeObject genericTreeObject = null;

            if (this.CheckType <T>().Equals("text"))
            {
                genericTreeObject = new TreeObject(this.treeName, this.CheckType <T>(), (ITree <string>)genericTree);
            }

            if (this.CheckType <T>().Equals("numeric"))
            {
                genericTreeObject = new TreeObject(this.treeName, this.CheckType <T>(), (ITree <double>)genericTree);
            }

            this.provider.BatchTreeObject.Add(genericTreeObject);
            this.typeOfTrees = genericTreeObject.Type;
            this.noOfTrees++;
        }
Esempio n. 11
0
    public void Insert(TreeObject obj)
    {
        int i = 0,
            index;

        //if we have subnodes ...
        if (this.nodes[0] != null)
        {
            index = this.getIndex(obj.rect);
            if (index != -1)
            {
                this.nodes[index].Insert(obj);
                return;
            }
        }

        this.objects.Add(obj);

        if (this.objects.Count > MAX_OBJECTS && this.level < MAX_LEVELS)
        {
            if (nodes[0] == null)
            {
                this.split();
            }

            //add all objects to there corresponding subnodes
            while (i < this.objects.Count)
            {
                TreeObject to = objects[i];
                index = this.getIndex(to.rect);

                if (index != -1)
                {
                    this.nodes[index].Insert(to);
                    objects.Remove(to);
                }
                else
                {
                    i = i + 1;
                }
            }
        }
    }
Esempio n. 12
0
    // Update is called once per frame
    void Update()
    {
        float horizontal = Input.GetAxis("Horizontal");
        float vertical   = Input.GetAxis("Vertical");

        Vector2 move = new Vector2(horizontal, vertical);

        // Set look direction
        if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f))
        {
            lookDirection.Set(move.x, move.y);
            lookDirection.Normalize();
        }

        animator.SetFloat("MoveX", lookDirection.x);
        animator.SetFloat("MoveY", lookDirection.y);
        animator.SetFloat("Speed", move.magnitude);

        // Move Player
        Vector2 position = rigidbody2d.position;

        position = position + move * speed * Time.deltaTime;

        Teleport(position, Vector2.zero);

        // Check for input
        if (Input.GetKeyDown(KeyCode.Space))
        {
            animator.SetTrigger("Interact");

            RaycastHit2D hit = Physics2D.Raycast(rigidbody2d.position + Vector2.up * 0.1f, lookDirection, 1.5f, LayerMask.GetMask("Breakable"));

            if (hit.collider != null)
            {
                TreeObject treeObject = hit.collider.GetComponent <TreeObject>();
                if (treeObject != null)
                {
                    treeObject.Break();
                }
            }
        }
    }
Esempio n. 13
0
        public MDIChildForm AddPolicySetWindow(IPolicySet policySet, PolicySetVersionStatus status, string version)
        {
            Guid childFormId = Guid.NewGuid();
            string nodeName;
            if (CultureInfo.CurrentCulture.TwoLetterISOLanguageName == "en")
                nodeName = string.Format(CultureInfo.CurrentCulture, "{0} - v{1} [{2}]", policySet.Name.Value, version, Workshare.Policy.PolicySuites.Instance.GetStatusText(status));
            else
                nodeName = string.Format(CultureInfo.CurrentCulture, "{0} - [{1}]", policySet.Name.Value, Workshare.Policy.PolicySuites.Instance.GetStatusText(status));

            TreeObject treeObject = new TreeObject(childFormId, (int)TreeViewControllerPolicyOriented.NodeType.PolicySet, nodeName, policySet);
            policySetTreeView.Nodes.Add(treeObject);

            MDIChildForm childForm = new MDIChildForm(childFormId, policySet, policySetTreeView, treeObject);
            ChildFormData childFormData = new ChildFormData(childFormId, childForm, status, policySet);
            treeObject.Tag = childFormData;

            policySetTreeView.SelectedNode = treeObject;

            return childForm;
        }
Esempio n. 14
0
        public void createTree(TreeNode root, TreeObject treeObject)
        {
            if (treeObject == null)
            {
                return;
            }
            foreach (NodeObject nodeObject in treeObject.ChildNodes)
            {
                if (nodeObject.NodeTag == NodeTag.Root)
                {
                    root.Tag = nodeObject;
                    foreach (NodeObject no in nodeObject.ChildNodes)
                    {
                        createNode(no, root);
                    }
                }
            }

            ISolutionPlugin.expandTree(root);
        }
Esempio n. 15
0
        public static TreeObject GetTreeObject()
        {
            var tree  = new TreeObject();
            var admin = GetDirectoryObject();

            tree.label = GetProperty(admin, "name");
            var description = GetProperty(admin, "description");

            if (!string.IsNullOrEmpty(description))
            {
                tree.label += "--" + description;
            }
            foreach (DirectoryEntry child in admin.Children)
            {
                var temp = GetTreeObject(child);
                if (temp != null)
                {
                    tree.children.Add(temp);
                }
            }
            return(tree);
        }
Esempio n. 16
0
        public void SimpleCollapseTest()
        {
            TreeRoot unOptimized = new()
            {
                Tree = new TreeObject[]
                {
                    new BrainFck.Instruction {
                        Operation = BrainFck.Operations.Increment
                    },
                    new BrainFck.Instruction {
                        Operation = BrainFck.Operations.Increment
                    },
                    new BrainFck.Instruction {
                        Operation = BrainFck.Operations.Increment
                    },
                    new BrainFck.Instruction {
                        Operation = BrainFck.Operations.Increment
                    },
                    new BrainFck.Instruction {
                        Operation = BrainFck.Operations.Increment
                    }
                }
            };
            TreeRoot expected = new()
            {
                Tree = new TreeObject[]
                {
                    new MoreFck.Instruction {
                        Operation = MoreFck.Operations.Add, OpData = 5
                    }
                }
            };

            var actual = unOptimized.Optimize();

            Assert.AreEqual(expected, actual);
        }

        [Test]
Esempio n. 17
0
    public void ChopTreeOnTile(FloorTile _tile)
    {
        //Would be better to just call use() on the tile's objects, maybe add some more specific item classes later!
        TileObject obj = _tile.TileObject;

        if (obj == null)
        {
            return;
        }

        TreeObject tree = obj as TreeObject;

        if (tree == null)
        {
            return;
        }

        if (tree.Chop())
        {
            _tile.RemoveObject();
        }
    }
Esempio n. 18
0
    void Update()
    {
        if (Map.getChunkX(lastPos.x) != obj.getChunkX() || Map.getChunkZ(lastPos.z) != obj.getChunkZ())
        {
            reloadChunk();
        }

        if (!BPCanvas.pausePanel.isShowing())
        {
            if (Input.GetMouseButtonDown(0))
            {
                //TODO クリックすると目線の先に木を置くテスト用機能
                Vector3 pos = p_camera.ViewportToWorldPoint(Input.mousePosition);

                TreeObject mapobj = new TreeObject(obj.chunk.map, pos, transform.rotation);
                obj.chunk.map.addObject(mapobj);
                mapobj.generate();
            }
        }
        if (transform.position.y < Map.ABYSS_HEIGHT)
        {
            print(DateTime.Now + " プレイヤー\"" + player.name + "\"が奈落に落ちました");
            if (obj == null)
            {
                Destroy(gameObject);
            }
            else
            {
                player.respawn();
            }
        }

        lastPos = transform.position;
        lastRot = transform.rotation;
        obj.SyncFromEntity();
        obj.moved();
    }
Esempio n. 19
0
	/// <summary>
	/// ツリーにあたった
	/// </summary>
	void onHit()
	{
		var effectPos = cacheTransform.localPosition;
		effectPos.y += 2.0f;
		effectPos.z += 3.0f;

		int damage = 0;
		if (isChargeAttackSuccess)
		{
			EffectManager.PlayEffect(EffectManager.EFFECT_ID.HIT_CHARGE, ref effectPos);
			isChargeAttackSuccess = false;
			damage = 10;
		}
		else
		{
			EffectManager.PlayEffect(EffectManager.EFFECT_ID.HIT_ATTACK, ref effectPos);
			damage = 1;
		}

		TreeObject.OnDamage(damage);

		effectPos.y += 1.0f;
		UIBattleController.GetDamageUI().DrawDamageNumber(damage, ref effectPos);
	}
Esempio n. 20
0
 // constructor Root-Object
 public TreeObjectViewModel(TreeObject inObject) : base(null, true)
 {
     _object = inObject;
 }
Esempio n. 21
0
 // constructor Branch-Or-Leaf-Object
 public TreeObjectViewModel(TreeObject inObject, TreeObjectViewModel inParent, bool isLeaf) : base(inParent, !isLeaf)
 {
     _object = inObject;
 }
Esempio n. 22
0
    void SaveTree()
    {
        Node root = null;

        for (int i = 0; i < nodes.Count; i++)                                                                                                                                   //Ensure that root is the first node in the tree!
        {
            if (nodes[i].isRoot && i == 0)
            {
                break;
            }
            if (nodes[i].isRoot)
            {
                root = nodes[i];
                nodes.RemoveAt(i);
                nodes.Insert(0, root);
                break;
            }
        }

        List <Node> rootedNodes = new List <Node>();

        for (int i = 0; i < nodes[0].GetChildren().Count;)                                                                                                      //Delete nodes that aren't connected to the root
        {
            if (!nodes[0].GetChildren()[i].IsConnectedToRoot())
            {
                DeleteNode(nodes[0].GetChildren()[i]);
            }
            else
            {
                i++;
            }
        }

        for (int i = 0; i < nodes.Count;)
        {
            if (nodes[i].IsConnectedToRoot())                                                                                                                                                   //Ensure that the node is connected to the root (otherwise we don't want it in the tree)
            {
                rootedNodes.Add(new Node(nodes[i].GetNodeName(), nodes[i].size, nodes[i].pos, this));
                rootedNodes[i].isRoot    = nodes[i].isRoot;
                rootedNodes[i].listIndex = i;
                rootedNodes[i].SetNodeType(nodes[i].GetNodeType());
                rootedNodes[i].childConnectionPoint  = nodes[i].childConnectionPoint;
                rootedNodes[i].parentConnectionPoint = nodes[i].parentConnectionPoint;
                nodes[i].listIndex = i;
                i++;
            }
            else
            {
                DeleteNode(nodes[i]);
            }
        }

        for (int i = 0; i < rootedNodes.Count; i++)                                                                 //Compare tree object nodes and tree maker nodes to find and set parents and children
        {
            if (nodes[i].GetParent() != null)
            {
                rootedNodes[i].SetParent(rootedNodes[nodes[i].GetParent().listIndex]);
            }

            List <Node> nodeChildren = new List <Node>(nodes[i].GetChildren());
            if (nodeChildren != null && nodeChildren.Count > 0)
            {
                foreach (Node n in nodeChildren)
                {
                    rootedNodes[i].AddChild(rootedNodes[n.listIndex]);
                }
            }
        }

        List <NodeConnection> rootedConnections = new List <NodeConnection>();

        for (int i = 0; i < nodeConnections.Count; i++)                                                             //Create new connections that can be saved
        {
            rootedConnections.Add(new NodeConnection(rootedNodes[nodeConnections[i].GetChild().listIndex], rootedNodes[nodeConnections[i].GetParent().listIndex], this, true, true));
            rootedConnections[i].SetChildPoint(nodeConnections[i].GetChild().childConnectionPoint);
            rootedConnections[i].SetParentPoint(nodeConnections[i].GetParent().parentConnectionPoint);
            rootedConnections[i].SetChildIndex(nodeConnections[i].GetChild().listIndex);
            rootedConnections[i].SetParentIndex(nodeConnections[i].GetParent().listIndex);
        }

        int leafCount = 0;

        foreach (Node n in rootedNodes)                                                                             //Go through all viable nodes and find the number of leaves (leaf nodes)
        {
            if (n.GetNodeType() == NodeTypes.Leaf)
            {
                leafCount++;
            }
        }

        if (isTreeLoaded)
        {
            AssetDatabase.DeleteAsset("Assets/Trees/" + loadedTree.name + ".asset");
        }
        TreeObject behaviorTree = CreateInstance <TreeObject>();                                                    //Create a new instance of the scriptable object TreeObject

        behaviorTree.name            = treeName;                                                                    //Set the object's name
        behaviorTree.nodes           = new List <Node>(rootedNodes);                                                //Add the viable nodes to the object
        behaviorTree.nodeConnections = new List <NodeConnection>(rootedConnections);;
        behaviorTree.leafCount       = leafCount;                                                                   //Add the leafCount to the object
        AssetDatabase.CreateAsset(behaviorTree, "Assets/Trees/" + behaviorTree.name + ".asset");                    //Create a asset in the folder with the user-entered name
        if (isTreeLoaded)
        {
            loadedTree = behaviorTree;
        }

        AssetDatabase.SaveAssets();                                                                                 //Save assets to write the new asset to the disk
        Debug.Log("The tree '" + treeName + "' was saved");
    }
        public override void Display()
        {
            m_treeView.SuspendLayout();

            if (m_treeView == null)
            {
				TreeViewException ex = new TreeViewException("Attempted access to treeview without it being set");
				Logger.LogError(ex.Message);
                throw ex;
            }

            TreeNode tmp = m_treeView.SelectedNode;
            m_rootNode.Nodes.Clear();

            m_selectedTreeObject = tmp as TreeObject;

            PolicySetToTreeModel();

            m_treeView.SelectedNode = tmp;

			if (0 == m_rootNode.Nodes.Count)
			{
				m_treeView.SelectedNode = m_rootNode;
				m_selectedTreeObject = m_rootNode as TreeObject; 
			}
			else if (m_treeView.SelectedNode != null)
			{
				m_treeView.SelectedNode.Expand();
			}
			else
			{
				if (m_rootNode.Nodes.Count > 0)
				{
					m_treeView.SelectedNode = m_rootNode.Nodes[0];
					m_selectedTreeObject = m_rootNode.Nodes[0] as TreeObject;
				}
			}

            m_treeView.ResumeLayout();
        }
 public void setRoot(TreeObject newItem)
 {
     key = newItem;
 }
 public void setRightChild(TreeObject newItem)
 {
     rightchild = newItem;
 }
Esempio n. 26
0
    // Public
    public void SetParam(GameObject currentTarget)
    {
        // Offset Count
        uint offsetCount = 0;

        // Clear Content
        RemoveAllChildren(panelContent);
        if (currentTarget.GetComponent <BaseNPC>() != null)
        {
            BaseNPC baseNPC = currentTarget.GetComponent <BaseNPC>();
            // Create Action Cell
            GameObject loockCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
            loockCell.GetComponent <PanelActionCell>().SetParam("Loock", currentTarget);
            offsetCount++;
            if (baseNPC.NPCParam.agresion >= 0)
            {
                // Talk
                GameObject talkCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
                talkCell.GetComponent <PanelActionCell>().SetParam("Talk", currentTarget);
                offsetCount++;
                // Trade
                GameObject tradeCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
                tradeCell.GetComponent <PanelActionCell>().SetParam("Trade", currentTarget);
                offsetCount++;
            }
            GameObject stealCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
            stealCell.GetComponent <PanelActionCell>().SetParam("Steal", currentTarget);
            offsetCount++;
        }
        if (currentTarget.GetComponent <BaseSceneObject>() != null)
        {
            // Create Action Cell
            GameObject loockCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
            loockCell.GetComponent <PanelActionCell>().SetParam("Loock", currentTarget);
            offsetCount++;
            /// Tree Object
            if (currentTarget.GetComponent <TreeObject>() != null)
            {
                TreeObject treeObject = currentTarget.GetComponent <TreeObject>();
                // Get Hurvest
                GameObject hurvestCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
                hurvestCell.GetComponent <PanelActionCell>().SetParam("Hurvest", currentTarget);
                offsetCount++;
                // Get Sticks
                GameObject stickCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
                stickCell.GetComponent <PanelActionCell>().SetParam("GetStick", currentTarget);
                offsetCount++;
                // Cut
                GameObject cutCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
                cutCell.GetComponent <PanelActionCell>().SetParam("CutTree", currentTarget);
                offsetCount++;
            }
            /// Barrel Object
            if (currentTarget.GetComponent <BarrelObject>() != null)
            {
                // Open
                GameObject cutCell = Instantiate <GameObject>(actionCellPrefab, panelContent.transform);
                cutCell.GetComponent <PanelActionCell>().SetParam("Open", currentTarget);
                offsetCount++;
            }
        }
        // Set Panel Height
        RectTransform rectTransform = gameObject.GetComponent <RectTransform>();

        rectTransform.sizeDelta = new Vector2(rectTransform.rect.width, rectTransform.rect.height + (offsetCount * offSet));
    }
 public TreeObjectViewModel(TreeObject inTopObject)
     : this(inTopObject, null)
 {
 }
        /// <summary>
        /// Returns the IPolicy object associated with a particular treeObject. If the specified TreeObject is
        /// not directly associated with an IPolicy, will search up the TreeObject branch to find the IPolicy.
        /// </summary>
        /// <param name="treeObject">The TreeObject to evaluate</param>
        /// <returns>The IPolicy associated with the TreeObject, or null if no associated IPolicy object</returns>
        private IPolicy GetPolicyFromTreeObject(TreeObject treeObject)
        {
            if (null == treeObject)
            {
                return null;
            }

            if (treeObject.Tag is IPolicy)
            {
                return treeObject.Tag as IPolicy;
            }

            return GetPolicyFromTreeObject((TreeObject)treeObject.Parent);
        }
 private void DeleteNode(TreeObject treeObject)
 {
     if (treeObject != null)
     {
         if (treeObject.Parent != null)
         {
             TreeNode parent = treeObject.Parent;
             m_treeView.SelectedNode = parent;
             parent.Nodes.Remove(treeObject);
         }
         else
         {
             m_treeView.Nodes.Remove(treeObject);
         }
     }
 }
 void MouseUp(object sender, MouseEventArgs e)
 {
     //if right click, get the node at the position we clicked. We need to do this because there is way of
     //telling directly from the context menu which node owns the context menu. that's rubbish, huh?. 
     //Note that we don't try to select the node as we don't want to change the page displayed in the designer.
     //see http://www.dotnet247.com/247reference/msgs/15/75515.aspx for more info about this.
     if (e.Button == MouseButtons.Right)
     {
         m_treeObjectMostRecentlySelectedWithRightClick = m_treeView.GetNodeAt(new Point(e.X, e.Y)) as TreeObject;
     }
 }
        public override void SelectNode(object tag, bool notifyOnSelection)
        {
            TreeObject treeObject = null;
            if (tag is PolicySet && m_rootNode.Tag is ChildFormData)
            {
                if (Object.ReferenceEquals(tag, (m_rootNode.Tag as ChildFormData).PolicySet))
                    treeObject = m_rootNode as TreeObject;
            }

            if (null == treeObject)
            {
                if (Object.ReferenceEquals(tag, m_rootNode.Tag))
                {
                    treeObject = m_rootNode as TreeObject;
                }
                else
                {
                    treeObject = FindNode(tag);
                }
            }

            if (treeObject != null)
            {
                bool oldNotifyOnSelection = m_notifyOnSelection;
                m_notifyOnSelection = notifyOnSelection;
                m_treeView.SelectedNode = treeObject;
				m_selectedTreeObject = treeObject;
                m_notifyOnSelection = oldNotifyOnSelection;

                if ((treeObject.Parent != null) && (!treeObject.Parent.IsExpanded))
                {
                    treeObject.Parent.Expand();
                }
            }
        }
        public override void SelectNode(Guid guid, bool notifyOnSelection)
        {
			TreeObject treeObject = FindChildNode(m_rootNode as TreeObject, guid);
            if (treeObject != null)
            {
                bool oldNotifyOnSelection = m_notifyOnSelection;
                m_notifyOnSelection = notifyOnSelection;
                m_treeView.SelectedNode = treeObject;
				m_selectedTreeObject = treeObject;
                m_notifyOnSelection = oldNotifyOnSelection;

                if ((treeObject.Parent != null) && (!treeObject.Parent.IsExpanded))
                {
                    treeObject.Parent.Expand();
                }
            }
        }
        private TreeObject FindChildNode(TreeObject treeObject, Guid guid)
        {
            if (treeObject.Guid == guid)
            {
                return treeObject;
            }

            foreach (TreeObject childTreeObject in treeObject.Nodes)
            {
                TreeObject locatedTreeObject = FindChildNode(childTreeObject, guid);
                if (locatedTreeObject != null)
                {
                    return locatedTreeObject;
                }
            }

            return null;
        }
Esempio n. 34
0
//render Tree
    public void RenderStuffs()
    {
        for (int i = 0; i < zoneDiv; i++)
        {
            for (int j = 0; j < zoneDiv; j++)
            {
                GameObject tree_parent = new GameObject();
                tree_parent.name = "Trees";
                GameObject item_parent = new GameObject();
                item_parent.name = "Items";
                GameObject mogwaiSpawners = new GameObject();
                mogwaiSpawners.name = "MogwaiSpawners";

                tree_parent.transform.SetParent(mapZones[i, j].transform);
                item_parent.transform.SetParent(mapZones[i, j].transform);
                mogwaiSpawners.transform.SetParent(mapZones[i, j].transform);



                for (int x = 0; x < unitX / zoneDiv; x++)
                {
                    for (int y = 0; y < unitY / zoneDiv; y++)
                    {
                        //Debug.Log("check the units");
                        float rand  = Random.value;
                        int   unitx = unitX * i / zoneDiv + x;
                        int   unity = unitY * j / zoneDiv + y;
                        int   id    = units[unitx, unity].ID;


                        //Render Tree
                        for (int w = 0; w < biomes[id].trees.Count; w++)
                        {
                            float val = Random.value;
                            if (val < biomes[id].trees[w].bornChance && units[unitx, unity].isOccupied == false)
                            {
                                units[unitx, unity].Tree       = biomes[id].trees[w];
                                units[unitx, unity].isOccupied = true;

                                GameObject tree_go = Instantiate(worldPrefabDictionary["Tree"], Vector3.zero, Quaternion.identity);
                                tree_go.name = units[unitx, unity].Tree.name;
                                tree_go.transform.SetParent(tree_parent.transform);
                                tree_go.transform.position = new Vector3(unitx * 4, 0.9f, unity * 4);

                                TreeObject treeObject = tree_go.GetComponent <TreeObject>();

                                treeObject.destroyableObject = units[unitx, unity].Tree;
                                treeObject.Setup();

                                tree_go.GetComponentInChildren <SpriteRenderer>().sprite       = treeObject.sprites[tree_go.name][Random.Range(0, treeObject.sprites[tree_go.name].Count)];
                                tree_go.GetComponentInChildren <SpriteRenderer>().sortingOrder = 1000 - units[unitx, unity].Y * 2;
                            }
                        }
                        //Render Items
                        if (biomes[id].items.Count > 0)
                        {
                            for (int w = 0; w < biomes[id].items.Count; w++)
                            {
                                float val = Random.value;
                                if (val < biomes[id].items[w].dropChance && units[unitx, unity].isOccupied == false)
                                {
                                    units[unitx, unity].Item = biomes[id].items[w];

                                    units[unitx, unity].isOccupied = true;

                                    GameObject item_go = Instantiate(worldItemDictionary["ItemPickup"], Vector3.zero, Quaternion.identity);
                                    item_go.name = units[unitx, unity].Item.name;
                                    item_go.transform.SetParent(item_parent.transform);
                                    item_go.transform.position = new Vector3(unitx * 4, 0f, unity * 4);

                                    ItemPickup itemPickup = item_go.GetComponent <ItemPickup>();
                                    itemPickup.item = units[x * i, y *j].Item;
                                    itemPickup.Setup();

                                    itemPickup.item = units[unitx, unity].Item;

                                    item_go.GetComponentInChildren <SpriteRenderer>().sprite       = itemPickup.sprites[item_go.name][Random.Range(0, itemPickup.sprites[item_go.name].Count)];
                                    item_go.GetComponentInChildren <SpriteRenderer>().sortingOrder = 1000 - units[unitx, unity].Y * 2;
                                }
                            }
                        }

                        //Render mogwaiSpanwers

                        /*if(biomes[id].mogwaispawner.Count > 0){
                         *
                         * } */
                    }
                }
            }
        }
    }
        private TreeObject TreeObjectFactory(object tag)
        {
            TreeObject treeObject = null;
            if (tag != null)
            {
                if (tag is IPolicySet)
                {
                    //Policies
                    treeObject = m_rootNode as TreeObject;
                    IPolicySet policySet = tag as IPolicySet;
                    foreach (IPolicy policy in policySet.Policies)
                    {
                        treeObject.AddChild(TreeObjectFactory(policy));
                    }
                }
                else if (tag is IPolicy)
                {
                    //Policy
                    IPolicy policy = tag as IPolicy;
                    treeObject = new TreeObject(policy.Identifier, (int)NodeType.Policy, policy.Name.Value, tag);

                    TreeObject conditionsNode = TreeObjectFactory(policy.Conditions);
                    treeObject.AddChild(conditionsNode);

                    foreach (IPolicyChannel channel in OrderedChannels(policy.Channels))
                    {
                        if (channel.Type == ChannelType.SMTP || channel.Type == ChannelType.ActiveContent)
                            treeObject.AddChild(TreeObjectFactory(channel));
                    }
                }
                else if (tag is IPolicyObjectCollection<IPolicyObject>)
                {
                    //Conditions
                    treeObject = new TreeObject(Guid.NewGuid(), (int)NodeType.Conditions, Properties.Resources.TREEOBJECT_CONDITION, tag);
                }
                else if (tag is IPolicyChannel)
                {
                    //Actions
                    IPolicyChannel channel = tag as IPolicyChannel;
                    treeObject = new TreeObject(channel.Identifier, (int)NodeType.Channel, Workshare.Policy.UI.DisplayTranslations.ChannelTypeDisplayTranslator.Instance.GetDisplayType(channel.Type), tag);
                }
                else
                {
					ArgumentException ex = new ArgumentException("Unsupported tag type");
					Logger.LogError(ex.Message);
                    throw ex;
                }

                if (treeObject != null)
                {
                    DecorateTreeObject(treeObject);
                }
            }
            return treeObject;
        }
Esempio n. 36
0
    void Update()
    {
        if (temp != null)
        {
            GameObject.Destroy(temp);
        }
        if (sAI_ != null && sAI_.mAIRT != null)
        {
            sAI_.mAIRT.GetComponent <MeshRenderer> ().material.color = mSrc;
            sAI_ = null;
        }
        switch (mEnumType)
        {
        case TESTZOOLOGYMOUSE.NONE:
            break;

        case TESTZOOLOGYMOUSE.DELETECOW:
            SimpleAI sAI = FindAIByRayCast("Cow");
            if (sAI != null)
            {
                sAI_ = sAI;
                mSrc = sAI.mAIRT.GetComponent <MeshRenderer> ().material.color;
                sAI.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f);

                if (Input.GetMouseButton(0))
                {
                    sAI.Destroy();
                }
            }
            break;

        case TESTZOOLOGYMOUSE.DELETEGRASS:
            SimpleAI sAI1 = FindAIByRayCast("Glass");
            if (sAI1 != null)
            {
                sAI_ = sAI1;
                mSrc = sAI1.mAIRT.GetComponent <MeshRenderer> ().material.color;
                sAI1.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f);
                if (Input.GetMouseButton(0))
                {
                    sAI1.Destroy();
                }
            }
            break;

        case TESTZOOLOGYMOUSE.DELETETREE:
            SimpleAI sAI2 = FindAIByRayCast("Tree");
            if (sAI2 != null)
            {
                sAI_ = sAI2;
                mSrc = sAI2.mAIRT.GetComponent <MeshRenderer> ().material.color;
                sAI2.mAIRT.GetComponent <MeshRenderer> ().material.color = new Color(1.0f, 0, 0, 0.4f);
                if (Input.GetMouseButton(0))
                {
                    sAI2.Destroy();
                }
            }
            break;

        case TESTZOOLOGYMOUSE.ADDCOW:
            Vector3 pos = FindPointByRayCast();
            if (pos != Vector3.zero)
            {
                temp = GameObject.Instantiate(Cow, pos, Quaternion.identity) as GameObject;
                temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f);
                if (Input.GetMouseButton(0))
                {
                    CowObject co = new CowObject();
                    co.RandomData();
                    co.Type      = true;
                    co.mPosition = pos;
                    co.Encode();
                    co.InitBreakPoint();
                    SimpleAI scow = RePair(new CowRePairer(), new CowRunner(), new CowJudger(), Cow,
                                           Player, new CowDestroyer(), "Cow", co, GAPopulation.allDic["Cow"].mTempCount);
                    scow.mCharacter = co;
                    GAPopulation.allDic ["Cow"].Add(scow);
                }
                else if (Input.GetMouseButton(1))
                {
                    CowObject co = new CowObject();
                    co.RandomData();
                    co.Type      = false;
                    co.mPosition = pos;
                    co.Encode();
                    co.InitBreakPoint();
                    SimpleAI scow = RePair(new CowRePairer(), new CowRunner(), new CowJudger(), Cow,
                                           Player, new CowDestroyer(), "Cow", co, GAPopulation.allDic["Cow"].mTempCount);
                    scow.mCharacter = co;
                    GAPopulation.allDic ["Cow"].Add(scow);
                }
            }
            break;

        case TESTZOOLOGYMOUSE.ADDGRASS:
            Vector3 pos1 = FindPointByRayCast();
            if (pos1 != Vector3.zero)
            {
                temp = GameObject.Instantiate(Grass, pos1, Quaternion.identity) as GameObject;
                temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f);
                if (Input.GetMouseButton(0))
                {
                    glassObject go = new glassObject();
                    go.RandomData();
                    go.mColor    = 0.9f;
                    go.mPosition = pos1;
                    go.Encode();
                    go.InitBreakPoint();
                    SimpleAI sglass = RePair(new GlassRePairer(), new GlassRunner(), new GlassJudger(), Grass,
                                             Player, new CowDestroyer(), "Glass", go, GAPopulation.allDic["Glass"].mTempCount);
                    sglass.mCharacter = go;
                    //Debug.Log (FreedomAIEncoderAndDecoder.bitbunch2String(FreedomAIEncoderAndDecoder.float2BitBunch(0.2f,0.0f,1.0f,11)));
                    GAPopulation.allDic ["Glass"].Add(sglass);
                }
                else if (Input.GetMouseButton(1))
                {
                    glassObject go = new glassObject();
                    go.RandomData();
                    go.mColor    = Random.Range(0.1f, 0.4f);
                    go.mPosition = pos1;
                    go.Encode();
                    go.InitBreakPoint();
                    SimpleAI sglass = RePair(new GlassRePairer(), new GlassRunner(), new GlassJudger(), Grass,
                                             Player, new CowDestroyer(), "Glass", go, GAPopulation.allDic["Glass"].mTempCount);
                    sglass.mCharacter = go;
                    GAPopulation.allDic ["Glass"].Add(sglass);
                }
            }
            break;

        case TESTZOOLOGYMOUSE.ADDTREE:
            Vector3 pos2 = FindPointByRayCast();
            if (pos2 != Vector3.zero)
            {
                temp = GameObject.Instantiate(Tree, pos2, Quaternion.identity) as GameObject;
                temp.GetComponent <MeshRenderer> ().material.color = new Color(0, 1, 0, 0.5f);
                if (Input.GetMouseButton(0))
                {
                    TreeObject to = new TreeObject();
                    to.RandomData();
                    to.mStrongRate = Random.Range(0.0f, 0.5f);
                    to.mPosition   = pos2;
                    //	go.mHeight = Random.Range (1.0f,1.5f);
                    to.Encode();
                    to.InitBreakPoint();
                    SimpleAI sTree = RePair(new TreeRePairer(), new TreeRunner(), new TreeJudger(), Tree,
                                            Player, new CowDestroyer(), "Tree", to, GAPopulation.allDic["Tree"].mTempCount);
                    sTree.mCharacter = to;
                    GAPopulation.allDic ["Tree"].Add(sTree);
                }
                else if (Input.GetMouseButton(1))
                {
                    TreeObject to = new TreeObject();
                    to.RandomData();
                    to.mStrongRate = Random.Range(0.5f, 1.0f);
                    to.mPosition   = pos2;

                    to.Encode();
                    to.InitBreakPoint();
                    SimpleAI sTree = RePair(new TreeRePairer(), new TreeRunner(), new TreeJudger(), Tree,
                                            Player, new CowDestroyer(), "Tree", to, GAPopulation.allDic["Tree"].mTempCount);
                    sTree.mCharacter = to;
                    GAPopulation.allDic ["Tree"].Add(sTree);
                }
            }
            break;
        }
    }
 public TreeObject(TreeObject newitem)
 {
     key = newitem;
 }
        private ContextMenuStrip GetContextMenuStrip(TreeObject treeObject, bool bPolicySetInProgress)
        {
            ContextMenuStrip contextMenuStrip = null;
			switch (treeObject.NodeType)
            {
                case (int)NodeType.PolicySet:
                    contextMenuStrip = new ContextMenuStrip();
                    contextMenuStrip.Items.Add(Properties.Resources.POLICY_MENU_ADD, null, AddPolicyEventHandler);
                    contextMenuStrip.Items.Add(Properties.Resources.MENU_SEP);
					ToolStripItem publish = new ToolStripButton(Properties.Resources.MENU_PUBLISH, null, PublishPolicySetEventHandler);
					publish.Enabled = PolicyDesigner.CheckLicense();

                    contextMenuStrip.Items.Add(publish);

                    if (IsEnabled(GetRoot(treeObject)) || HasPolicySetBeenPublished(GetRoot(treeObject)))
                    {
                        contextMenuStrip.Items.Add(Properties.Resources.MENU_UNPUBLISH, null, UnpublishPolicySetEventHandler);
                    }
                    
					contextMenuStrip.Items.Add(Properties.Resources.MENU_SEP);
                    contextMenuStrip.Items.Add(Properties.Resources.POLICY_MENU_DELETEALL, null, DeleteAllPoliciesEventHandler);
                    contextMenuStrip.Items.Add(Properties.Resources.POLICY_SET_MENU_DELETE, null, DeletePolicySetEventHandler);
                    contextMenuStrip.Items.Add(Properties.Resources.POLICY_SET_MENU_CLOSE, null, ClosePolicySetEventHandler);
                    break;
                case (int)NodeType.Policy:
                    contextMenuStrip = new ContextMenuStrip();
                    contextMenuStrip.Items.Add(Properties.Resources.POLICY_MENU_DELETE, null, DeletePolicyEventHandler);
                    break;
                case (int)NodeType.Conditions:
                    break;
                case (int)NodeType.Actions:
                    break;
                case (int)NodeType.Channel:
                    break;
                default:
                    {
                        Utilities.ErrorMessage errorMessage = new Utilities.ErrorMessage(
                            "NODETYPE_INVALID",
                            "Workshare.PolicyDesigner.Properties.Resources",
                            System.Reflection.Assembly.GetExecutingAssembly());
						Logger.LogError(errorMessage.LogString);
						throw new ArgumentException(errorMessage.DisplayString);
                    }
            }

            return contextMenuStrip;
        }
 public void setLeftChild(TreeObject newItem)
 {
     leftchild = newItem;
 }
        private TreeObject FindChildNode(TreeObject treeObject, object tag)
        {
            if (Object.ReferenceEquals(tag, treeObject.Tag))
            {
                return treeObject;
            }

            foreach (TreeObject childTreeObject in treeObject.Nodes)
            {
                TreeObject locatedTreeObject = FindChildNode(childTreeObject, tag);
                if (locatedTreeObject != null)
                {
                    return locatedTreeObject;
                }
            }

            return null;
        }
 public TreeObject init(TreeObject newitem)
 {
     return(new TreeObject(newitem));
 }
Esempio n. 42
0
        private void policySetTreeView_ItemDrag(object sender, ItemDragEventArgs e)
        {
            m_draggedTreeObject = null;
            if (e.Button == MouseButtons.Left)
            {
                m_draggedTreeObject = e.Item as TreeObject;
                if (null == m_draggedTreeObject)
                    return;

                if (m_draggedTreeObject.Tag is IPolicy)
                    DoDragDrop(e.Item, DragDropEffects.Copy);
            }
        }
Esempio n. 43
0
    void NodeEditPanel()
    {
        //This region is the basics of the edit panel
        #region
        Rect topRect = new Rect(0, 0, 200, position.height);                                                                                            //Define the rect for this window
        GUILayout.BeginArea(topRect, GUI.skin.GetStyle("Box"));                                                                                         //This is used to make an area that can be drawn by the editor GUI drawer

        if (GUILayout.Button("Reset Root Position"))                                                                                                    //If the button is clicked, reset the root node's position
        {
            nodes[0].pos = new Vector2(position.width / 2, 50);
        }

        if (GUILayout.Button("Add Node"))                                                                           //If the button is clicked, add a new object to the window and the list
        {
            nodes.Add(new Node("Node " + (nodes.Count), rectSize, new Vector2(210, 50), this));
        }

        EditorGUI.BeginChangeCheck();                                                                                                                           //This is used to check for updates in the text fields
        GUILayout.Label("Node name:");
        nodeName = EditorGUILayout.TextField(nodeName);                                                                                                         //Read and set the string during edits
        GUILayout.Label("Node type:");
        nodeType = (NodeTypes)EditorGUILayout.EnumPopup(nodeType);                                                                                              //Make a dropdown based on the NodeTypes enum

        if (EditorGUI.EndChangeCheck())                                                                                                                         //If changes happened, update the information in the currently selected node
        {
            selectedNode.SetName(nodeName);
            selectedNode.SetNodeType(nodeType);
        }

        GUILayout.Label("");
        GUILayout.Label("");

        if (selectedNode != null)                                                                                           //If a node is selected
        {
            if (GUILayout.Button("Delete Current Node"))                                                                    //If button is clicked, delete the selected node and connections to or from it
            {
                DeleteNode();
                Debug.Log("Current node deleted");
            }
        }

        if (GUILayout.Button("Clear Everything"))                                                                                                                               //If button is clicked, clear everything
        {
            ClearWorkSpace();
            Debug.Log("Work space clearded");
        }

        GUILayout.EndArea();                                                                                        //Tell the editor to stop drawing here
        #endregion

        //This region controls the more dynamic functions (delete nodes, clear work space, create or save trees)
        #region
        Rect bottomRect;                                                                                                                                                                        //New rect that is at the bottom of the previous
        if (loadedTree == null)
        {
            bottomRect = new Rect(0, position.height - 120, 200, position.height);
        }
        else
        {
            bottomRect = new Rect(0, position.height - 60, 200, position.height);
        }
        GUILayout.BeginArea(bottomRect, GUI.skin.GetStyle("Box"));
        loadedTree = (TreeObject)EditorGUILayout.ObjectField(loadedTree, typeof(TreeObject), true);                 //Draw an objectfield to pass a ScriptableObject of type TreeObject
        if (loadedTree == null)                                                                                     //If a tree object hasn't been loaded, draw the UI for making one
        {
            if (isTreeLoaded)
            {
                isTreeLoaded = false;
                ClearWorkSpace();
                loadedTree   = null;
                isTreeLoaded = false;
            }
            GUILayout.Label("Tree name:");
            treeName        = EditorGUILayout.TextField(treeName);
            error           = "";
            isTreeNameInUse = false;
            foreach (string guid in AssetDatabase.FindAssets(treeName, new[] { "Assets/Trees" }))                           //Go through all assets at the given location (the string)
            {
                string temp = AssetDatabase.GUIDToAssetPath(guid);                                                          //Translate from GUID to string
                temp = temp.Substring(13, temp.Length - 13);                                                                //Hardcoded substring
                temp = temp.Substring(0, temp.Length - 6);                                                                  //Hardcoded substring
                //The final substring is the asset's name without location and extension

                if (treeName.Equals(temp))                                                                                          //Check if the currently entered name equals the asset's name
                {
                    error           = "Name already in use!";
                    isTreeNameInUse = true;
                    break;
                }
            }
            GUILayout.Label(error);
            if (GUILayout.Button("Create Tree Object"))                                                                     //If the button is clicked, call the method to create a new ScriptableObject asset
            {
                CreateBehaviorTreeObject();
            }
        }
        else                                                                                                                                                                                                    //If a tree object has been loaded, draw the UI for saving and updating it
        {
            if (!isTreeLoaded)
            {
                isTreeLoaded = true;
                treeName     = loadedTree.name;
                ClearWorkSpace();

                foreach (Node n in loadedTree.nodes)                                                                                                                                    //Foreach node in the tree object, create a new node for the tree maker
                {
                    nodes.Add(new Node(n.GetNodeName(), rectSize, n.pos, this));
                }
                treeRoot = nodes[0];

                for (int i = 0; i < loadedTree.nodes.Count; i++)
                {
                    nodes[i].ParseLoadedInformation(loadedTree.nodes[i].GetNodeName(), loadedTree.nodes[i].GetNodeType(),
                                                    loadedTree.nodes[i].size, loadedTree.nodes[i].isRoot, this);                            //Parse information about the tree object node to the new tree maker node
                    List <Node> children = loadedTree.nodes[i].GetChildren();
                    foreach (Node n in children)                                                                                            //Go through the tree object node's children
                    {
                        nodes[i].AddChild(nodes[n.listIndex]);                                                                              //Add child to the new node with the same index as the tree object node
                    }
                    if (loadedTree.nodes[i].GetParent() != null)
                    {
                        nodes[i].SetParent(nodes[loadedTree.nodes[i].GetParent().listIndex]);                                                   //Set parent for the new node to the index of the tree object node's parent
                    }
                }

                for (int i = 0; i < loadedTree.nodeConnections.Count; i++)                                                          //Foreach connection in the tree object, create a new connection for the tree maker
                {
                    new NodeConnection(nodes[loadedTree.nodeConnections[i].childIndex],
                                       nodes[loadedTree.nodeConnections[i].parentIndex], this, true);
                }

                if (nodes[0].GetChildren().Count == 0 && nodeConnections.Count > 0)
                {
                    Debug.LogWarning("So many phantom connections, so little time! BURN IN THE FIRES OF THE GARBAGE COLLECTOR!");
                    for (int i = 0; i < nodeConnections.Count;)
                    {
                        nodeConnections[i].DeleteConnection(false);
                    }
                }

                if (currentConnection != null)
                {
                    currentConnection.DeleteConnection(true);                                                                                                   //Ensure that current connection is purged
                }
            }
            if (GUILayout.Button("Save changes to Tree"))                                                                                                                       //If the button is clicked, call the method to save changes to the tree object
            {
                SaveTree();
            }
        }
        GUILayout.EndArea();
        #endregion
    }
        /// <summary>
        /// Returns the IPolicy object associated with a particular treeObject. If the specified TreeObject is
        /// not directly associated with an IPolicy, will search up the TreeObject branch to find the IPolicy.
        /// </summary>
        /// <param name="treeObject">The TreeObject to evaluate</param>
        /// <returns>The IPolicySet associated with the TreeObject, or null if no associated IPolicySet object</returns>
        private IPolicySet GetPolicySetFromTreeObject(TreeObject treeObject)
        {
            if (null == treeObject)
            {
                return null;
            }

            if (treeObject.Tag is ChildFormData)
            {
                return ((ChildFormData)treeObject.Tag).PolicySet;
            }

            if (treeObject.Tag is IPolicySet)
            {
                return treeObject.Tag as IPolicySet;
            }

            return GetPolicySetFromTreeObject((TreeObject)treeObject.Parent);
        }
Esempio n. 45
0
 public SourceError(TreeObject causer, string message) : base(message)
 {
     Start  = causer.Start;
     Length = causer.Length;
 }
 private void DecorateTreeObject(TreeObject treeObject)
 {
     treeObject.ContextMenuStrip = GetContextMenuStrip(treeObject, false);
     treeObject.ImageIndex = GetImageIndex(treeObject.NodeType);
     treeObject.SelectedImageIndex = GetImageIndex(treeObject.NodeType); 
 }
 // constructor Branch-Object
 public TreeLevel5ViewModel(TreeObject inObject, TreeLevel4ViewModel inParent) : base(inParent, true)
 {
     _object = inObject;
 }
Esempio n. 48
0
		public MDIChildForm(Guid guid, IPolicySet policySet, TreeView treeView, TreeObject treeObject)
		{
			InitializeComponent();

			this.SuspendLayout();

			m_guid = guid;
			m_treeView = treeView;
			m_rootTreeObject = treeObject;
						
			Initialise(policySet);

			this.ResumeLayout();
		}