Esempio n. 1
0
        internal XMLList Filter(string selector)
        {
            bool allFit = true;

            _tmpList.Clear();
            foreach (XML xml in _list)
            {
                if (xml.name != selector)
                {
                    allFit = false;
                }
                else
                {
                    _tmpList.Add(xml);
                }
            }

            if (allFit)
            {
                return(this);
            }
            else
            {
                XMLList ret = new XMLList(_tmpList);
                _tmpList = new List <XML>();
                return(ret);
            }
        }
Esempio n. 2
0
 public XMLList Elements(string selector)
 {
     if (_children == null)
     {
         _children = new XMLList();
     }
     return(_children.Filter(selector));
 }
Esempio n. 3
0
 public XMLList Elements()
 {
     if (_children == null)
     {
         _children = new XMLList();
     }
     return(_children);
 }
Esempio n. 4
0
        override public void Setup_AfterAdd(XML cxml)
        {
            base.Setup_AfterAdd(cxml);

            XML xml = cxml.GetNode("ComboBox");

            if (xml == null)
            {
                return;
            }

            string str;

            str = (string)xml.GetAttribute("titleColor");
            if (str != null)
            {
                this.titleColor = UtilsStr.ConvertFromHtmlColor(str);
            }
            str = (string)xml.GetAttribute("visibleItemCount");
            if (str != null)
            {
                _visibleItemCount = int.Parse(str);
            }
            XMLList col = xml.Elements("item");

            _items  = new string[col.Count];
            _values = new string[col.Count];
            int i = 0;

            foreach (XML ix in col)
            {
                _items[i]  = ix.GetAttribute("title");
                _values[i] = ix.GetAttribute("value");
                i++;
            }
            this.text = (string)xml.GetAttribute("title");
            if (str != null && str.Length > 0)
            {
                _selectedIndex = Array.IndexOf(_items, this.text);
            }
            else if (_items.Length > 0)
            {
                _selectedIndex = 0;
            }
            else
            {
                _selectedIndex = -1;
            }
        }
Esempio n. 5
0
        override public void Setup_AfterAdd(XML cxml)
        {
            base.Setup_AfterAdd(cxml);

            XMLList nodes = cxml.GetNode("Slider").Elements();

            if (nodes == null)
            {
                return;
            }

            XML xml = nodes[0];

            _value = int.Parse((string)xml.GetAttribute("value"));
            _max   = int.Parse((string)xml.GetAttribute("max"));
            Update();
        }
Esempio n. 6
0
        public void Setup(XML xml)
        {
            XMLList col = xml.Elements("relation");

            if (col == null)
            {
                return;
            }
            string  targetId;
            GObject target;

            foreach (XML cxml in col)
            {
                targetId = (string)cxml.GetAttribute("target");
                if (_owner.parent != null)
                {
                    if (targetId != null && targetId != "")
                    {
                        target = _owner.parent.GetChildById(targetId);
                    }
                    else
                    {
                        target = _owner.parent;
                    }
                }
                else
                {
                    //call from component construction
                    target = ((GComponent)_owner).GetChildById(targetId);
                }
                if (target != null)
                {
                    AddItems(target, (string)cxml.GetAttribute("sidePair"));
                }
            }
        }
Esempio n. 7
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. 8
0
        private void Create(byte[] desc, byte[] res)           //ByteArray
        {
            _desc = new ZipBuffer(desc);
            _desc.CreateNameIndex();
            if (res != null && res.Length > 0)
            {
                _files = new ZipBuffer(res);
                _files.CreateNameIndex();
            }

            //XML.ignoreWhitespace = true;
            byte[]     buf = _desc.GetEntryData(_desc.GetEntryByName("package.xml"));
            ByteBuffer ba  = new ByteBuffer(buf);
            string     str = ba.ReadString(ba.length);
            XML        xml = new XML(str);

            _id   = (string)xml.GetAttribute("id");
            _name = (string)xml.GetAttribute("name");
            string[] arr = null;

            XML rxml = xml.GetNode("resources");

            if (rxml == null)
            {
                throw new Exception("Invalid package xml");
            }

            XMLList resources = rxml.Elements();

            _itemsById   = new Dictionary <string, PackageItem>();
            _itemsByName = new Dictionary <string, PackageItem>();;
            PackageItem pi;

            foreach (XML cxml in resources)
            {
                pi      = new PackageItem();
                pi.type = cxml.name;
                pi.id   = cxml.GetAttribute("id");
                pi.name = cxml.GetAttribute("name");
                pi.file = cxml.GetAttribute("file");
                str     = cxml.GetAttribute("size");
                if (str != null)
                {
                    arr       = str.Split(new char[] { ',' });
                    pi.width  = int.Parse(arr[0]);
                    pi.height = int.Parse(arr[1]);
                }
                pi.standalone = cxml.GetAttribute("standalone") == "true";
                if (pi.type == "image")
                {
                    pi.scale = cxml.GetAttribute("scale");
                    if (pi.scale == "9grid")
                    {
                        str = cxml.GetAttribute("scale9grid");
                        if (str != null)
                        {
                            pi.scale9Grid        = new Rect();
                            arr                  = str.Split(new char[] { ',' });
                            pi.scale9Grid.x      = int.Parse(arr[0]);
                            pi.scale9Grid.y      = int.Parse(arr[1]);
                            pi.scale9Grid.width  = int.Parse(arr[2]);
                            pi.scale9Grid.height = int.Parse(arr[3]);
                        }
                    }
                }
                else if (pi.type == "jta")
                {
                    str = cxml.GetAttribute("origin");
                    if (str != null)
                    {
                        arr         = str.Split(new char[] { ',' });
                        pi.origin.x = int.Parse(arr[0]);
                        pi.origin.y = int.Parse(arr[1]);
                    }
                }

                pi.owner = this;
                _items.Add(pi);
                _itemsById[pi.id]     = pi;
                _itemsByName[pi.name] = pi;
            }

            appContext.timers.Add(60 + new System.Random().Next(10), 0, Gc);
        }