Пример #1
0
        private Button ParseButton(DWidget d)
        {
            Button button = new Button();

            button.Text = d.Attributes["Text"].StringValue;
            return(button);
        }
Пример #2
0
 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;
 }
Пример #3
0
        private Label ParseLabel(DWidget d)
        {
            Debug.Log("parse label");
            Label label = new Label();

            label.Text = d.Attributes["Text"].StringValue;
            return(label);
        }
Пример #4
0
 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;
     }
 }
Пример #5
0
 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);
     }
 }
Пример #6
0
 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;
 }
Пример #7
0
        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);
        }
Пример #8
0
        private Canvas ParseCanvas(DWidget d)
        {
            Canvas canvas = new Canvas();

            return(canvas);
        }
Пример #9
0
 public DWindow()
 {
     WindowInfo    = new DWindowInfo();
     RootContainer = new DWidget();
 }