示例#1
0
 //Validate isRequired
 public static bool IsRequiredValidate(LookupEdit accountEdit, LookupEdit contactEdit,
                                       MessagePanel messagePanel, UserConnection userConnection)
 {
     if (accountEdit.Value.Equals(Guid.Empty) && contactEdit.Value.Equals(Guid.Empty))
     {
         var sb = new StringBuilder();
         //###, ####### ############# ###### # Workspace CR172891
         var resourceStorage = userConnection.Workspace.ResourceStorage;
         var alertMessage    = new LocalizableString(resourceStorage,
                                                     "MultiLookupHelpers", "LocalizableStrings.AlertMessage.Value");
         var alertMessageCaption = new LocalizableString(resourceStorage,
                                                         "MultiLookupHelpers", "LocalizableStrings.AlertMessageCaption.Value");
         sb.AppendFormat(alertMessage, "{" + accountEdit.ClientID + "}", "{" + contactEdit.ClientID + "}");
         messagePanel.AddMessage(alertMessageCaption, sb.ToString(), MessageType.Warning);
         return(false);
     }
     return(true);
 }
示例#2
0
    public void Inits(ChatInfo info)
    {
        SocialModel.Instance.curChatInfo = info;
        if (exitBtn.onClick == null)
        {
            exitBtn.onClick = delegate { Exit(); }
        }
        ;

        if (yuyinBtn.onClick == null)
        {
            yuyinBtn.onClick = delegate { OpenYuyin(); }
        }
        ;
        if (daziSendBtn.onClick == null)
        {
            daziSendBtn.onClick = delegate { SendDazi(); }
        }
        ;

        if (daziBtn.onClick == null)
        {
            daziBtn.onClick = delegate { OpenDazi(); }
        }
        ;

        if (put_yuyinBtn.onDown == null)
        {
            put_yuyinBtn.onDown = delegate { DownYuyin(); }
        }
        ;
        if (put_yuyinBtn.onUp == null)
        {
            put_yuyinBtn.onUp = delegate { OnUp(); }
        }
        ;

        this.curInfo = info;
        nameLb.text  = info.playerBaseInfo.userNickname;

        OpenDazi();
        LoadChatLog();
    }

    /// <summary>
    /// 在messagePanel里增加一条聊天记录
    /// </summary>
    void AddLogMessagePanel()
    {
        messagePanel.AddMessage(curInfo);
    }

    /// <summary>
    /// 在messagePanel里去掉一条聊天记录
    /// </summary>
    void RemoveLogMessagePanel()
    {
        messagePanel.RemoveMessage(curInfo);
    }

    #region 主聊天界面

    void OnValueChange(int index)
    {
        if (index == 0)
        {
            roleInfoView.SetVisibel(true);
            roleInfoView.Init(curInfo.playerBaseInfo, true);
        }
        else if (index == 1)
        {
            UIUtils.DestroyChildren(parent);
            RemoveLogMessagePanel();
            Exit();
            SocialModel.Instance.ClearChatLog(curInfo.chatWithId.ToString());
        }
        dropDown.value = 2;
    }

    void LoadChatLog()
    {
        UIUtils.DestroyChildren(parent);
        if (File.Exists(ConstantUtils.chatConfigPath))
        {
            JsonData jd     = JsonMapper.ToObject(File.ReadAllText(ConstantUtils.chatConfigPath));
            string   logStr = jd.TryGetString(curInfo.chatWithId.ToString());
            if (!string.IsNullOrEmpty(logStr))
            {
                logStr = jd[curInfo.chatWithId.ToString()].ToJson();
                JsonData chatData    = JsonMapper.ToObject(logStr);
                JsonData historyJson = chatData["history"];
                for (int i = 0; i < historyJson.Count; i++)
                {
                    ChatInfo info = JsonMapper.ToObject <ChatInfo>(JsonMapper.ToJson(historyJson[i]));
                    //JsonData chatInfoJson = historyJson[i]; print(int.Parse(historyJson[i]["sender"].ToJson().ToString()));
                    //ChatInfo info = new ChatInfo();
                    //info.senderId = (int)(float.Parse(historyJson[i]["sender"].ToJson()));
                    //info.text = historyJson[i]["value"].ToJson();
                    //info.timer = (int)(float.Parse(historyJson[i]["time"].ToJson()));
                    //info.type = (int)(float.Parse(historyJson[i]["type"].ToJson()));
                    LoadChatItem(info);
                }
            }
        }
    }

    /// <summary>
    /// 退出聊天
    /// </summary>
    void Exit()
    {
        SetVisible(false);
        messagePanel.gameObject.SetActive(true);
    }

    /// <summary>
    /// 打开语音界面
    /// </summary>
    void OpenYuyin()
    {
        yuyinObj.SetActive(true);
        daziObj.SetActive(false);
    }

    /// <summary>
    /// 打开打字界面
    /// </summary>
    void OpenDazi()
    {
        yuyinObj.SetActive(false);
        daziObj.SetActive(true);
    }