public void AddDescribableTreeNode(TreeNode node) { RemoveDescribableTreeNode(node); // ensure no duplicate var describedTreeNode = new DescribableTreeNode(node); bool inserted = false; foreach (DescribableTreeNode describableTreeNode in DescribableTreeNodes) { if (node.IsBefore(describableTreeNode.TreeNode)) { var i = DescribableTreeNodes.IndexOf(describableTreeNode); if (!m_BackupTreeNodes.Contains(describedTreeNode)) { m_BackupTreeNodes.Insert(i, describedTreeNode); } DescribableTreeNodes.Insert(i, describedTreeNode); inserted = true; break; } } if (!inserted) { if (!m_BackupTreeNodes.Contains(describedTreeNode)) { m_BackupTreeNodes.Add(describedTreeNode); } DescribableTreeNodes.Add(describedTreeNode); } }
public void InitWithBackupTreeNodes(bool showEmptyAlt) { DescribableTreeNodes.Clear(); foreach (DescribableTreeNode describedTreeNode in m_BackupTreeNodes) { if (showEmptyAlt) { DescribableTreeNodes.Add(describedTreeNode); } else { TreeNode treeNode = describedTreeNode.TreeNode; if (treeNode.HasXmlProperty) { string localName = treeNode.GetXmlElementLocalName(); if (localName.Equals("img", StringComparison.OrdinalIgnoreCase) //|| localName.Equals("video", StringComparison.OrdinalIgnoreCase) ) { XmlAttribute xmlAttr = treeNode.GetXmlProperty().GetAttribute("alt"); if (xmlAttr != null && !String.IsNullOrEmpty(xmlAttr.Value)) { DescribableTreeNodes.Add(describedTreeNode); } } } } } }