コード例 #1
0
ファイル: XmlEditor.cs プロジェクト: renyh1013/dp2
		// 专为供Xml属性设得私有函数
		private void SetXml(string strXml)
		{
			strXml = strXml.Trim();
			if (strXml == "")
			{
				if (this.VirtualRoot != null)
				{
					this.VirtualRoot.FireTreeRemoveEvents(this.VirtualRoot.GetXPath());
				}
				this.VirtualRoot = null;
				this.docRoot = null;
				
				this.SetCurText(null,null);
				this.SetActiveItem(null);

				AfterDocumentChanged(ScrollBarMember.Both);
				this.Invalidate();

				// 文档发生变化
				this.FireTextChanged();
				return;
			}

			if (this.VirtualRoot == null)
			{
				this.VirtualRoot = new VirtualRootItem(this);
				this.VirtualRoot.LayoutStyle = this.m_layoutStyle ;
				this.VirtualRoot.m_bConnected = true;
			}
			else
			{
				this.VirtualRoot.ClearAttrs();
				this.VirtualRoot.ClearChildren();
			}


			XmlDocument dom = new XmlDocument();
            dom.PreserveWhitespace = true;
			dom.LoadXml(strXml); 

			ElementInitialStyle style = new ElementInitialStyle();
			style.attrsExpandStyle = ExpandStyle.Expand;
			style.childrenExpandStyle = ExpandStyle.Expand;
			style.bReinitial = false;

			this.VirtualRoot.Initial(dom,//dom.DocumentElement,
				allocator,
				style,
                true);

			this.docRoot = this.GetDocRoot();
				

			this.VirtualRoot.InitialVisual();

			int nWidth = 0;
			int nHeight = 0;
			this.VirtualRoot.Layout(0,
				0,
				this.ClientSize .Width -1,
				0 ,
				nTimeStampSeed++,
				out nWidth,
				out nHeight,
				LayoutMember.Layout );	

			this.SetCurText(this.VirtualRoot,null);
			this.SetActiveItem(this.VirtualRoot);


			if (this.m_bFocused == true)
				this.curEdit.Focus();


			AfterDocumentChanged(ScrollBarMember.Both);
			this.Invalidate();

			// 文档发生变化
			this.FireTextChanged();
		}
コード例 #2
0
ファイル: XmlEditor.cs プロジェクト: renyh1013/dp2
		// 右 -- 剪切

		public void CutToClipboard(Item item)
		{
			string strXml = item.OuterXml;
			Clipboard.SetDataObject(strXml);

			// ???????虚根
			if (item == this.VirtualRoot)
			{
				this.Xml = "";
				this.VirtualRoot = null;
				this.docRoot = null;
			}
			else
			{
				ElementItem myParent = item.parent;
				// 移走当前节点
				myParent.Remove(item);
			}
		}