Пример #1
0
        private LoopListViewItem2 GetItemHandle(LoopListView2 listView, int index)
        {
            if (index < 0 || index >= data.Count)
            {
                return(null);
            }

            AffairInfo info = data[index];

            if (string.IsNullOrEmpty(info.uid))
            {
                return(null);
            }
            LoopListViewItem2 item  = listView.NewListViewItem("TimeParts");
            TimeParts         parts = item.GetComponent <TimeParts>();

            if (item.IsInitHandlerCalled == false)
            {
                item.IsInitHandlerCalled = true;
            }
            //parts.Clear();
            parts.AddClickEvent(ClickItemHandler);
            parts.UpdateInfo(info, index);
            return(item);
        }
Пример #2
0
        private void ImageClickHandle(ImageParts parts)
        {
            if (selectedNode == null)
            {
                return;
            }
            AffairInfo info = selectedNode.entity.GetAffair(parts.identify);

            imageMask.enabled = true;
            ZImageController.Instance.Load(parts.identify, info.images[0], OnImageUpdate);
            bigImage.enabled = true;
        }
Пример #3
0
        private void UpdateAnchorStep(AffairInfo info)
        {
            if (string.IsNullOrEmpty(info.uid) || info.year < 1 || lastAffair == info.uid)
            {
                return;
            }
            lastAffair = info.uid;
            var y = ((info.year - yearRange.x) * 12 + info.month) * step;

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Screen.height)
            {
                y = Screen.height - 30;
            }
            targetStep = new Vector2(anchorX, -y);
            //Debug.LogWarning("UpdateAnchorStep...uid = " +info.year + ";pos = " + targetStep);
        }
Пример #4
0
        public void UpdateInfo(AffairInfo info, int index)
        {
            data           = info;
            this.index     = index;
            identify       = info.uid;
            timeLabel.text = info.time;
            bgImage.sprite = normalSp;
            bool sub = info.description.Length > columnMax ? true : false;

            if (sub)
            {
                descLabel.text = data.description.Substring(0, columnMax - 3) + "...";
            }
            else
            {
                descLabel.text = data.description;
            }
            arrowImage.enabled = sub || data.keywords.Length > 0;
            SwitchLabelButtons(false);
            imageContent.gameObject.SetActive(false);
            mTransform.sizeDelta = new Vector2(mTransform.sizeDelta.x, defaultHeight);
            ////descLabel.text = string.Format("<size=24><b>{0}</b></size>", name) + "\n" + desc;
        }
Пример #5
0
        public static EntityInfo ParseEntityJson(string json, string root)
        {
            ZLog.Log("ParseNodeJson..." + json.Length);
            if (string.IsNullOrEmpty(json))
            {
                return(null);
            }
            try
            {
                var        obj   = JsonMapper.ToObject(json);
                EntityInfo model = new EntityInfo
                {
                    name   = (string)obj["name"],
                    uid    = (string)obj["uid"],
                    type   = (string)obj["type"],
                    remark = (string)obj["remark"],
                };
                model.properties = new List <PropertyInfo>(5);
                var remark = new PropertyInfo
                {
                    key      = "remark",
                    entities = new PairInfo[1]
                };
                remark.entities[0].value = model.remark;
                model.properties.Add(remark);
                var props = obj["props"];
                if (props != null && props.IsArray)
                {
                    foreach (JsonData item in props)
                    {
                        var prop = new PropertyInfo
                        {
                            key = (string)item["key"],
                        };
                        List <PairInfo> list  = new List <PairInfo>();
                        var             array = item["array"];
                        foreach (JsonData t in array)
                        {
                            list.Add(new PairInfo((string)t["key"], (string)t["value"]));
                        }
                        prop.entities = list.ToArray();
                        model.properties.Add(prop);
                    }
                }
                int count = 0;
                model.experiences = new List <AffairInfo>(5);
                var experiences = obj["experiences"];
                if (experiences != null && experiences.IsArray)
                {
                    foreach (JsonData item in experiences)
                    {
                        count += 1;
                        AffairInfo tmp = new AffairInfo
                        {
                            uid         = "affair-" + count,
                            time        = (string)item["time"],
                            year        = (int)item["year"],
                            month       = (int)item["month"],
                            name        = (string)item["name"],
                            description = (string)item["desc"]
                        };
                        if (tmp.month < 1)
                        {
                            tmp.month = 1;
                        }
                        tmp.time = tmp.year + "";


                        var images    = item["images"];
                        var imageList = new List <string>(4);
                        foreach (string image in images)
                        {
                            imageList.Add(string.IsNullOrEmpty(root) ? image : Path.Combine(root, image));
                        }
                        tmp.images = imageList.ToArray();

                        var keywordList = new List <PairInfo>(4);
                        var keywords    = item["keywords"];
                        foreach (JsonData keyword in keywords)
                        {
                            keywordList.Add(new PairInfo((string)keyword["key"], (string)keyword["value"]));
                        }
                        tmp.keywords = keywordList.ToArray();
                        model.experiences.Add(tmp);
                    }
                }

                return(model);
            }
            catch (Exception e)
            {
                ZLog.Warning(json);
                ZLog.Warning(e.Message);
                return(null);
            }
        }