Esempio n. 1
0
        virtual public void ConstructFromXML(XML xml)
        {
            string str;

            string[] arr;

            underConstruct = true;

            arr           = xml.GetAttributeArray("size");
            _sourceWidth  = int.Parse(arr[0]);
            _sourceHeight = int.Parse(arr[1]);
            _initWidth    = _sourceWidth;
            _initHeight   = _sourceHeight;

            SetSize(_sourceWidth, _sourceHeight);

            OverflowType overflow;

            str = (string)xml.GetAttribute("overflow");
            if (str != null)
            {
                overflow = FieldTypes.parseOverflowType(str);
            }
            else
            {
                overflow = OverflowType.Visible;
            }

            str = (string)xml.GetAttribute("margin");
            if (str != null)
            {
                _margin.Parse(str);
            }

            ScrollType scroll;

            str = (string)xml.GetAttribute("scroll");
            if (str != null)
            {
                scroll = FieldTypes.parseScrollType(str);
            }
            else
            {
                scroll = ScrollType.Vertical;
            }

            str = (string)xml.GetAttribute("scrollSpeed");
            int scrollSpeed = 0;

            if (str != null)
            {
                scrollSpeed = int.Parse(str);
            }

            ScrollBarDisplayType scrollBarDisplay;

            str = (string)xml.GetAttribute("scrollBar");
            if (str != null)
            {
                scrollBarDisplay = FieldTypes.parseScrollBarDisplayType(str);
            }
            else
            {
                scrollBarDisplay = ScrollBarDisplayType.Default;
            }



            //_instNextId = uint.Parse( ( string )xml.GetAttribute("idnum"));//旧格式定义


            _buildingDisplayList = true;

            XMLList    col = xml.Elements("controller");
            Controller controller;

            if (col != null)
            {
                foreach (XML cxml in col)
                {
                    controller = new Controller();
                    _controllers.Add(controller);
                    controller._parent = this;
                    controller.Setup(cxml);
                }
            }
            XML listNode = xml.GetNode("displayList");

            col = listNode.Elements();
            GObject   u;
            ArrayList tmp = new ArrayList();

            if (col != null)
            {
                foreach (XML cxml in col)
                {
                    u = ConstructChild(cxml);
                    if (u == null)
                    {
                        continue;
                    }

                    u.Setup_BeforeAdd(cxml);
                    AddChild(u);
                    tmp.Add(u);
                    tmp.Add(cxml);
                }
            }

            this.relations.Setup(xml);

            int cnt = tmp.Count;

            for (int i = 0; i < cnt; i += 2)
            {
                u = ( GObject )tmp[i];
                u.Setup_AfterAdd(( XML )tmp[i + 1]);
            }

            ApplyAllControllers();

            _buildingDisplayList = false;
            underConstruct       = false;

            //build real display list
            foreach (GObject child in _children)
            {
                if (child.displayObject != null && child.finalVisible)
                {
                    container.AddChild(child.displayObject);
                }
            }

            SetupOverflowAndScroll(overflow, _margin, scroll, scrollSpeed, scrollBarDisplay);
        }
Esempio n. 2
0
        override public void Setup_BeforeAdd(XML xml)
        {
            base.Setup_BeforeAdd(xml);

            string str;

            str = (string)xml.GetAttribute("layout");
            if (str != null)
            {
                _layoutObsolete = str;
            }
            else
            {
                _layoutObsolete = SINGLE_COLUMN;
            }

            str = (string)xml.GetAttribute("margin");
            _margin.Parse(str);

            OverflowType overflow;

            str = (string)xml.GetAttribute("overflow");
            if (str != null)
            {
                overflow = FieldTypes.parseOverflowType(str);
            }
            else
            {
                overflow = OverflowType.Visible;
            }

            ScrollType scroll;

            str = (string)xml.GetAttribute("scroll");
            if (str != null)
            {
                scroll = FieldTypes.parseScrollType(str);
            }
            else
            {
                scroll = ScrollType.Vertical;
            }

            str = (string)xml.GetAttribute("scrollSpeed");
            int scrollSpeed = 0;

            if (str != null)
            {
                scrollSpeed = int.Parse(str);
            }

            ScrollBarDisplayType scrollBarDisplay;

            str = (string)xml.GetAttribute("scrollBar");
            if (str != null)
            {
                scrollBarDisplay = FieldTypes.parseScrollBarDisplayType(str);
            }
            else
            {
                scrollBarDisplay = ScrollBarDisplayType.Default;
            }

            str = (string)xml.GetAttribute("lineGap");
            if (str != null)
            {
                _lineGap = int.Parse(str);
            }
            else
            {
                _lineGap = 0;
            }

            str = (string)xml.GetAttribute("colGap");
            if (str != null)
            {
                _columnGap = int.Parse(str);
            }
            else
            {
                _columnGap = 0;
            }

            str = (string)xml.GetAttribute("defaultItem");
            if (str != null)
            {
                _defaultItem = str;
            }

            SetupOverflowAndScroll(overflow, _margin, scroll, scrollSpeed, scrollBarDisplay);

            str = (string)xml.GetAttribute("items");
            if (str != null)
            {
                string[] items = str.Split(new char[] { ',' });
                int      cnt   = items.Length;
                for (int i = 0; i < cnt; i++)
                {
                    string s = items[i];
                    if (s != null)
                    {
                        AddChild(GetFromPool(s));
                    }
                }
            }
        }