示例#1
0
		// 应该在删除前把事件发了
		public void FireTreeRemoveEvents(string strXPath)
		{
			// 发自己的ItemDeleted事件

			ItemDeletedEventArgs args = 
				new ItemDeletedEventArgs();
			args.item = this;
			args.XPath = strXPath;

			// 每次按off算,外面需要时设为on
			//args.RiseAttrsEvents = false;
			//args.RecursiveChildEvents = false;
			args.RiseAttrsEvents = true;
			args.RecursiveChildEvents = true;
			this.m_document.fireItemDeleted(this.m_document,args);


			if (args.RiseAttrsEvents == true)
			{
				for(int i=0;i<this.attrs.Count;i++)
				{
					AttrItem attr = (AttrItem)this.attrs[i];

					ItemDeletedEventArgs argsAttr = 
						new ItemDeletedEventArgs();
					argsAttr.item = attr;
					argsAttr.XPath = strXPath + "/@" + attr.Name + "";

					// 每次按off算,外面需要时设为on
					//argsAttr.RiseAttrsEvents = false;
					//argsAttr.RecursiveChildEvents = false;
					
					argsAttr.RiseAttrsEvents = true;
					argsAttr.RecursiveChildEvents = true;

					this.m_document.fireItemDeleted(this.m_document,argsAttr);
				}
			}
			if (args.RecursiveChildEvents == true)
			{
				for(int i=0;i<this.children.Count;i++)
				{
					Item child = this.children[i];
					if (child is ElementItem)
					{
						ElementItem element = (ElementItem)this.children[i];

						string strPartXpath = ItemUtil.GetPartXpath(this,
							element);

						string strChildXPath = strXPath + "/" + strPartXpath;

						element.FireTreeRemoveEvents(strChildXPath);

					}
					else
					{
						ItemDeletedEventArgs argsChild = 
							new ItemDeletedEventArgs();
						argsChild.item = child;
						argsChild.XPath = strXPath;

						// 每次按off算,外面需要时设为on
						//argsChild.RiseAttrsEvents = false;
						//argsChild.RecursiveChildEvents = false;

						
						argsChild.RiseAttrsEvents = true;
						argsChild.RecursiveChildEvents = true;
						this.m_document.fireItemDeleted(this.m_document,argsChild);
					}

				}

			}



		}
示例#2
0
		// 删属性
		internal void RemoveAttrInternal(AttrItem attr,
			bool bAddObjTimestamp)
		{
			Debug.Assert(attr != null,"RemoveAttr() attr不能为null,调用出错");

			// 当前节点 不属于儿子集合
			int nIndex = this.attrs.IndexOf(attr);
			if (nIndex == -1)
			{
				Debug.Assert(false,"RemoveChild() attr不属于属性集合,调入出错");
				return;
			}

			////////////////////////////////////////////////
			// BeforeItemDelete
			///////////////////////////////////////////////
			string strXPath = attr.GetXPath();  // 先得到Xpath,否则删除后就没有了
			BeforeItemDeleteEventArgs beforeArgs = 
				new BeforeItemDeleteEventArgs();
			beforeArgs.item = attr;
			this.m_document.fireBeforeItemDelete(this.m_document,beforeArgs);


			// 把一些有用的初值设好,例如NamespaceURi
			this.SetNamespaceURI((ElementAttrBase)attr);  
			attr.m_paraValue1 = attr.GetValue();


			// 进行Remove操作
			this.attrs.Remove(attr);


			////////////////////////////////////////////////
			// ItemDeleted
			///////////////////////////////////////////////
			ItemDeletedEventArgs args = 
				new ItemDeletedEventArgs();
			args.item = attr;
			args.XPath = strXPath;

			// 每次按off算,外面需要时设为on
			args.RiseAttrsEvents = false;
			args.RecursiveChildEvents = false;
			this.m_document.fireItemDeleted(this.m_document,args);

			if (bAddObjTimestamp == true)
				this.m_objAttrsTimestamp ++;
		}
示例#3
0
		// 清除属性,里面会调ItemDeleted事件
		public void ClearAttrs()
		{
			foreach(AttrItem attr in this.attrs)
			{
				string strXPath = this.GetXPath();
				////////////////////////////////////////////////
				// ItemDeleted
				///////////////////////////////////////////////
				ItemDeletedEventArgs args = 
					new ItemDeletedEventArgs();
				args.item = attr;
				args.XPath = strXPath;

				// 每次按off算,外面需要时设为on
				args.RiseAttrsEvents = false;
				args.RecursiveChildEvents = false;
				this.m_document.fireItemDeleted(this.m_document,args);
			}

			this.attrs.Clear();
		}
示例#4
0
		// 删儿子 item可以是ElementItem 或 TextItem
		internal void RemoveChildInternal(Item item,
			bool bAddObjTimestamp)
		{
			Debug.Assert(item != null,"RemoveChild() item不能为null,调用出错");

			// 当前节点 不属于儿子集合
			int nIndex = this.children.IndexOf(item);
			if (nIndex == -1)
			{
				Debug.Assert(false,"RemoveChild() item不属于儿子集合,调用出错");
				return;
			}

			////////////////////////////////////////////////
			// BeforeItemDelete
			///////////////////////////////////////////////
			string strXPath = item.GetXPath();  // 先得到Xpath,否则删除后就没有了
			BeforeItemDeleteEventArgs beforeArgs = 
				new BeforeItemDeleteEventArgs();
			beforeArgs.item = item;
			this.m_document.fireBeforeItemDelete(this.m_document,beforeArgs);


			// 把一些有用的初值设好,例如NamespaceURi,Value
			if (item is ElementItem)
			{
				// 注意递归下级
				this.SetNamespaceURI((ElementAttrBase)item);  

				// 递归下级设value???????????
			}
			else
			{
				// 把临时参数设好,目的是在一个元素被删除后,还可以继续使用它的Value属性
				item.m_paraValue1 = item.GetValue();
			}

			if (ItemUtil.IsBelong(item,this.m_document.m_selectedItem))
			{
				this.m_document.SetActiveItem(null);
				this.m_document.SetCurText(null,null);
			}

			// 做Remove()操作
			this.children.Remove(item);

			////////////////////////////////////////////////
			// ItemDeleted
			///////////////////////////////////////////////
			if (item is ElementItem)
			{
				ElementItem element = (ElementItem)item;
				
				element.FireTreeRemoveEvents(strXPath);
			}
			else
			{
				ItemDeletedEventArgs args = 
					new ItemDeletedEventArgs();
				args.item = item;
				args.XPath = strXPath;

				// 每次按off算,外面需要时设为on
				args.RiseAttrsEvents = false;
				args.RecursiveChildEvents = false;
				this.m_document.fireItemDeleted(this.m_document,args);
			}

			if (bAddObjTimestamp == true)
				this.m_objChildrenTimestmap ++;
		}
示例#5
0
		public void fireItemDeleted(object sender,
			ItemDeletedEventArgs args)
		{
			if (ItemDeleted != null)
			{
				ItemDeleted(sender,args);
			}
		}