public void UpdateToList() { bool hasAnythingChanged = false; #region If there is no list watching, then return if (mListOfAttachables == null) { return; } #endregion #region Add nodes to the dictionary if there are any in the list that aren't in the dictionary for (int i = 0; i < mListOfAttachables.Count; i++) { IAttachable iAttachable = (IAttachable)mListOfAttachables[i]; if (iAttachable == null) { throw new Exception(); } if (!IsNodeCreatedForAttachable(iAttachable)) { HierarchyNode hierarchyNode = new HierarchyNode(VisibleRepresentationType.Sprite); hierarchyNode.TextRed = mTextColor.R; hierarchyNode.TextGreen = mTextColor.G; hierarchyNode.TextBlue = mTextColor.B; if (LayerUsing != null) { hierarchyNode.AddToLayer(LayerUsing); } mNodes.Add(iAttachable, hierarchyNode); hierarchyNode.ObjectRepresenting = iAttachable; mNodesAsList.Add(hierarchyNode); hasAnythingChanged = true; } } #endregion #region Remove nodes if necessary if (mListOfAttachables.Count < this.mNodesAsList.Count) { for (int i = 0; i < mNodesAsList.Count; i++) { HierarchyNode node = mNodesAsList[i]; if (!this.mListOfAttachables.Contains(node.ObjectRepresenting)) { // Remove this node mNodes.Remove(node.ObjectRepresenting); node.Destroy(); hasAnythingChanged = true; } } //There are nodes in the dictionary that have to be removed } #endregion #region Update the element visibility of each node foreach (HierarchyNode node in mNodesAsList) { HierarchyNode parentNode = null; IAttachable nodeParent = GetParent(node.ObjectRepresenting); if (nodeParent != null) { parentNode = GetNodeFromAttachable(nodeParent); } hasAnythingChanged |= node.UpdateElementVisibility(parentNode); } #endregion if (hasAnythingChanged) { AutoPosition(); } }
public void UpdateToList() { bool hasAnythingChanged = false; #region If there is no list watching, then return if (mListOfAttachables == null) { return; } #endregion #region Add nodes to the dictionary if there are any in the list that aren't in the dictionary for(int i = 0; i < mListOfAttachables.Count; i++) { IAttachable iAttachable = (IAttachable)mListOfAttachables[i]; if (iAttachable == null) { throw new Exception(); } if (!IsNodeCreatedForAttachable(iAttachable)) { HierarchyNode hierarchyNode = new HierarchyNode(VisibleRepresentationType.Sprite); hierarchyNode.TextRed = mTextColor.R; hierarchyNode.TextGreen = mTextColor.G; hierarchyNode.TextBlue = mTextColor.B; if (LayerUsing != null) { hierarchyNode.AddToLayer(LayerUsing); } mNodes.Add(iAttachable, hierarchyNode); hierarchyNode.ObjectRepresenting = iAttachable; mNodesAsList.Add(hierarchyNode); hasAnythingChanged = true; } } #endregion #region Remove nodes if necessary if (mListOfAttachables.Count < this.mNodesAsList.Count) { for (int i = 0; i < mNodesAsList.Count; i++) { HierarchyNode node = mNodesAsList[i]; if (!this.mListOfAttachables.Contains(node.ObjectRepresenting)) { // Remove this node mNodes.Remove(node.ObjectRepresenting); node.Destroy(); hasAnythingChanged = true; } } //There are nodes in the dictionary that have to be removed } #endregion #region Update the element visibility of each node foreach (HierarchyNode node in mNodesAsList) { HierarchyNode parentNode = null; IAttachable nodeParent = GetParent( node.ObjectRepresenting); if ( nodeParent != null) { parentNode = GetNodeFromAttachable(nodeParent); } hasAnythingChanged |= node.UpdateElementVisibility(parentNode); } #endregion if (hasAnythingChanged) { AutoPosition(); } }