コード例 #1
0
        public void SetProjectExtension(XmlElement value)
        {
            AssertCanModify();
            var sr = new StringReader(value.OuterXml);
            var xr = new XmlTextReader(sr);

            xr.MoveToContent();
            var cr = new MSBuildXmlReader {
                XmlReader = xr
            };
            var section = value.LocalName;

            MSBuildXmlElement elem = new MSBuildXmlElement();

            elem.Read(cr);

            int i = ChildNodes.FindIndex(n => (n is MSBuildXmlElement) && ((MSBuildXmlElement)n).Name == section);

            if (i == -1)
            {
                ChildNodes = ChildNodes.Add(elem);
            }
            else
            {
                ChildNodes = ChildNodes.RemoveAt(i);
                ChildNodes = ChildNodes.Insert(i, elem);
            }
            elem.ParentNode = this;
            elem.ResetIndent(false);
            NotifyChanged();
        }
コード例 #2
0
 /// <summary>
 ///   Removes the child at the specified index.
 /// </summary>
 /// <param name="index"> The index. </param>
 public void RemoveAt(int index)
 {
     if ((index > ChildNodes.Count - 1) || (index < 0))
     {
         throw new ArgumentOutOfRangeException();
     }
     ChildNodes[index].Parent = null;
     ChildNodes.RemoveAt(index);
 }
コード例 #3
0
        public void RemoveProjectExtension(string section)
        {
            AssertCanModify();
            int i = ChildNodes.FindIndex(n => (n is MSBuildXmlElement) && ((MSBuildXmlElement)n).Name == section);

            if (i != -1)
            {
                ChildNodes = ChildNodes.RemoveAt(i);
                NotifyChanged();
            }
        }
コード例 #4
0
 /// <summary>
 ///   Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1"></see>.
 /// </summary>
 /// <param name="item"> The object to remove from the <see cref="T:System.Collections.Generic.ICollection`1"></see> . </param>
 /// <returns> true if item was successfully removed from the <see cref="T:System.Collections.Generic.ICollection`1"></see> ; otherwise, false. This method also returns false if item is not found in the original <see
 ///    cref="T:System.Collections.Generic.ICollection`1"></see> . </returns>
 /// <exception cref="T:System.NotSupportedException">The
 ///   <see cref="T:System.Collections.Generic.ICollection`1"></see>
 ///   is read-only.</exception>
 public bool Remove(T item)
 {
     for (var i = 0; i < ChildNodes.Count; i++)
     {
         if (ChildNodes[i].Data.Equals(item))
         {
             ChildNodes[i].Parent = null;
             ChildNodes.RemoveAt(i);
             return(true);
         }
     }
     return(false);
 }
コード例 #5
0
    /// <summary>
    /// 移除指定位置的项,并返回移除的项
    /// 该方法不会删除子节点
    /// </summary>
    /// <param name="index">指定位置</param>
    /// <remarks></remarks>
    public UITreeNode RemoveAt(int index)
    {
        UITreeNode removeTarget = ChildNodes[index];

        ChildNodes.RemoveAt(index);
        removeTarget.Parent = null;
        IsExpand            = _isExpand;
        if (StateChangedHandle != null)
        {
            StateChangedHandle();
        }
        return(removeTarget);
    }