// 初始visual函数 public override void InitialVisual() { ElementItem item = (ElementItem)this.GetItem(); XmlEditor editor = item.m_document; if (item == null) { return; } if (item.m_childrenExpand == ExpandStyle.Collapse) { this.childrenVisual = null; this.MyText.container = this.container; this.MyText.Name = "content"; this.MyText.Text = "尚未初始化"; // 使用初始item时,赋的值 //this.MyText.Text = item.strInnerXml; // m_strContentXml专门用来传递处于收缩状态的element的下级汇总Xml信息 //把本对象从父亲哪里删除,把m_text加进父亲, //实现了实质的替换,不知道以后这个没人管的content跑到哪里了? ((Box)this.container).AddChildVisual(this.MyText); ((Box)this.container).childrenVisual.Remove(this); item.Flush(); } else if (item.m_childrenExpand == ExpandStyle.Expand) { // 把原初始设好 foreach (Item child in item.children) { if (!(child is ElementItem)) { Debug.Assert(child.GetValue() != null, "准备值不能为null"); child.m_paraValue1 = child.GetValue(); } } if (this.childrenVisual != null) { this.childrenVisual.Clear(); } this.LayoutStyle = LayoutStyle.Vertical; foreach (Item child in item.children) { //设子元素的style样式与父亲相同 child.LayoutStyle = item.LayoutStyle; //把child加到content里作为ChildVisual child.container = this; this.AddChildVisual(child); //实现嵌归 child.InitialVisual(); } } else { Debug.Assert(false, ""); } }
public override void InitialVisual() { ElementItem item = (ElementItem)this.GetItem(); if (item == null) { return; } // 收缩态 if (item.m_attrsExpand == ExpandStyle.Collapse) { this.childrenVisual = null; this.MyText.container = this.container; this.MyText.Name = "attributes"; this.MyText.Text = "尚未初始化"; //item.strAttrsValue; // 把this.MyText加进本对象的父亲中,把this从父亲中删除 ((Box)this.container).AddChildVisual(this.MyText); ((Box)this.container).childrenVisual.Remove(this); item.Flush(); } else if (item.m_attrsExpand == ExpandStyle.Expand) { foreach (AttrItem attr in item.attrs) { Debug.Assert(attr.GetValue() != null, "准备值不能为null"); attr.m_paraValue1 = attr.GetValue(); } if (this.childrenVisual != null) { this.childrenVisual.Clear(); } // 竖向排列 this.LayoutStyle = LayoutStyle.Vertical; foreach (AttrItem attr in item.attrs) { // 设子元素的style样式与父亲相同 attr.LayoutStyle = item.LayoutStyle; // 把child加到content里作为ChildVisual attr.container = this; this.AddChildVisual(attr); // 此处 Debug.Assert(attr.m_paraValue1 != null, "此时不应为null"); // 实现嵌归 attr.InitialVisual(); //elementStyle); } } else { Debug.Assert(false, ""); } }