예제 #1
0
 void BindSystemMessageList()
 {
     Message_Service.ListByTargetID(MessageType.System, 0, t =>
     {
         SystemMessageView.BindData <EMessage>("MessageItem", t.GetData() as List <EMessage>, (i, e) =>
         {
             i.name = "MessageItem_" + e.ID.ToString();
             i.transform.Find("Text (1)").GetComponent <Text>().text = e.CreateTime.ToString("yyyy-MM-dd hh:mm:ss");
             i.transform.Find("Text").GetComponent <Text>().text     = "系统";
             Transform bg = i.transform.Find("Image (1)");
             Text content = bg.Find("Text").GetComponent <Text>();
             content.text = e.Content;
             float textH  = content.preferredHeight + 20;
             if (e.SenderID == Session.UserID)
             {
                 i.transform.Find("Image (2)").GetComponent <Image>().color = new Color(178 / 255.0f, 255 / 255.0f, 195 / 255.0f);
                 bg.GetComponent <Image>().color = new Color(178 / 255.0f, 255 / 255.0f, 195 / 255.0f);
             }
             else
             {
                 bg.GetComponent <Image>().color = Color.white;
                 i.transform.Find("Image (2)").GetComponent <Image>().color = Color.white;
             }
             i.GetComponent <LayoutElement>().preferredHeight = textH + 32;
         }, true);
     });
 }
예제 #2
0
    void BindMessageList()
    {
        Message_Service.ListByTargetID(MessageType, TargetId, t =>
        {
            List <EMessage> mlist = t.GetData() as List <EMessage>;
            mlist = mlist.OrderBy(c => c.ID).ToList();
            MessageListView.BindData <EMessage>("MessageItem", mlist, (i, e) =>
            {
                i.name = "MessageItem_" + e.ID.ToString();
                i.transform.Find("Text (1)").GetComponent <Text>().text = e.CreateTime.ToString("yyyy-MM-dd hh:mm:ss");
                i.transform.Find("Text").GetComponent <Text>().text     = e.SenderName;
                Transform bg = i.transform.Find("Image (1)");
                Text content = bg.Find("Text").GetComponent <Text>();
                content.text = e.Content;
                float textH  = content.preferredHeight + 20;
                if (e.SenderID == Session.UserID)
                {
                    i.transform.Find("Image (2)").GetComponent <Image>().color = new Color(178 / 255.0f, 223 / 255.0f, 255 / 255.0f);
                    bg.GetComponent <Image>().color = new Color(178 / 255.0f, 223 / 255.0f, 255 / 255.0f);
                }
                else
                {
                    bg.GetComponent <Image>().color = Color.white;
                    i.transform.Find("Image (2)").GetComponent <Image>().color = Color.white;
                }
                i.GetComponent <LayoutElement>().preferredHeight = textH + 32;

                App.Instance.ShowImage(i.transform.Find("Image").GetComponent <RawImage>(), e.SenderFace, 11);
            }, true);
        });
    }