private Button ParseButton(DWidget d) { Button button = new Button(); button.Text = d.Attributes["Text"].StringValue; return(button); }
private void SetCommonAttribute(Widget c, DWidget d) { c.Position = d.Position.ToVector2(); //c.RealPosition = d.RealPosition.ToVector2(); c.Width = d.Width; c.Height = d.Height; }
private Label ParseLabel(DWidget d) { Debug.Log("parse label"); Label label = new Label(); label.Text = d.Attributes["Text"].StringValue; return(label); }
private void TranverseRoot(Container currentContainer, DWidget d) { d.Children = new DWidget[currentContainer.Childrens.Length]; int i = 0; foreach (var component in currentContainer.Childrens) { DWidget newD = GenerateFromComponent(component); if (newD.IsContainer) { TranverseRoot(component as Container, newD); } d.Children[i++] = newD; } }
public void TranverseRoot(DWidget d, Container container) { Debug.Log(d.Type); foreach (var dchild in d.Children) { Widget component = ParseFromDescription(dchild); Debug.Log(dchild.Type); //如果是容器 if (dchild.IsContainer) { TranverseRoot(dchild, component as Container); } container.Add(component); } }
private DWidget GenerateFromComponent(Widget component) { DWidget d = new DWidget { Type = component.TypeName, Position = component.Position.ToPoint(), //RealPosition = component.RealPosition.ToPoint(), Width = component.Width, Height = component.Height, IsContainer = false, Attributes = component.GetAttributes() }; if (component is Container) d.IsContainer = true; return d; }
private Widget ParseFromDescription(DWidget d) { Widget c; switch (d.Type) { case "Canvas": c = ParseCanvas(d); break; case "Button": c = ParseButton(d); break; case "Label": c = ParseLabel(d); break; default: throw new Exception("错误的Type:" + d.Type); } SetCommonAttribute(c, d); return(c); }
private Canvas ParseCanvas(DWidget d) { Canvas canvas = new Canvas(); return(canvas); }
public DWindow() { WindowInfo = new DWindowInfo(); RootContainer = new DWidget(); }