コード例 #1
0
        private static void SendMessageOfType(string title, string message, ChatBase.MessageType messageType, User user)
        {
            switch (messageType)
            {
            case ChatBase.MessageType.Temporary:
            case ChatBase.MessageType.Permanent:
            case ChatBase.MessageType.Popup:
                if (user == null)
                {
                    ChatBase.Send(new ChatBase.Message(message, messageType));
                }
                else
                {
                    ChatBase.Send(new ChatBase.Message(message, user, messageType));
                }
                break;

            case ChatBase.MessageType.Announcement:
                if (user == null)
                {
                    ChatBase.Send(new ChatBase.Message(title, message));
                }
                else
                {
                    ChatBase.Send(new ChatBase.Message(title, message, user));
                }
                break;
            }
        }
コード例 #2
0
ファイル: ChatGrpc.cs プロジェクト: shamaton/StudyGrpcUnity
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(ChatBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Authorize, serviceImpl.Authorize)
            .AddMethod(__Method_Connect, serviceImpl.Connect)
            .AddMethod(__Method_Say, serviceImpl.Say)
            .AddMethod(__Method_Leave, serviceImpl.Leave).Build());
 }
コード例 #3
0
        public ChatWindow(string username)
        {
            InitializeComponent();

            this.username = username;

            ChatBase = new ChatBase();

            try {
                Client = new Client();

                Loaded += (s, ev) => {
                    foreach (Message message in ChatBase.Messages)
                    {
                        AppendMessage(message.Text, message.Date);
                    }
                };

                Client.PeerAdded += new PeerEventHandler(PeerAdded);

                Client.PeerRemoved += new PeerEventHandler(PeerRemoved);

                Client.MessageReceived += new MessageReceivedEventHandler(MessageReceived);

                AddPeerButton.Click += new RoutedEventHandler(AddPeer);

                RemovePeerButton.Click += new RoutedEventHandler(RemovePeer);

                SendButton.Click += new RoutedEventHandler(SendMessage);

                MessageTextBox.KeyDown += (s, ev) => {
                    if (ev.Key == Key.Return)
                    {
                        SendMessage(s, ev);
                    }
                };
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
ファイル: GroupVote.cs プロジェクト: eosvil/AntennaChat
        public static void LeftGroupScrollVote(ChromiumWebBrowser cef, ChatBase msg, List <AntSdkGroupMember> GroupMembers)
        {
            AntSdkGroupMember user = PictureAndTextMixMethod.getGroupMembersUser(GroupMembers, msg);
            //显示内容解析
            MsChatMsgCreateVote_content receive = JsonConvert.DeserializeObject <MsChatMsgCreateVote_content>(msg.sourceContent);
            StringBuilder sbLeft = new StringBuilder();

            sbLeft.AppendLine("function myFunction()");

            sbLeft.AppendLine("{ var nodeFirst=document.createElement('div');");
            sbLeft.AppendLine("nodeFirst.className='leftd';");
            sbLeft.AppendLine("nodeFirst.id='" + msg.messageId + "';");

            //头像显示层
            sbLeft.AppendLine("var second=document.createElement('div');");
            sbLeft.AppendLine("second.className='leftimg';");
            sbLeft.AppendLine("var img = document.createElement('img');");
            sbLeft.AppendLine("img.src='" + PictureAndTextMixMethod.getPathImage(GroupMembers, msg) + "';");
            sbLeft.AppendLine("img.className='divcss5Left';");
            sbLeft.AppendLine("img.id='" + user.userId + "';");
            sbLeft.AppendLine("img.addEventListener('click',clickImgCallUserId);");
            sbLeft.AppendLine("second.appendChild(img);");
            sbLeft.AppendLine("nodeFirst.appendChild(second);");

            //时间显示
            sbLeft.AppendLine("var timeshow = document.createElement('div');");
            sbLeft.AppendLine("timeshow.className='leftTimeText';");
            sbLeft.AppendLine("timeshow.innerHTML ='" + user.userNum + user.userName + "  " + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(timeshow);");

            //投票内容展示层
            sbLeft.AppendLine("var node = document.createElement('div');");
            sbLeft.AppendLine("node.className='speech left';");

            //设置活动Id
            sbLeft.AppendLine("node.id='" + receive.id + "';");
            //事件监听
            sbLeft.AppendLine("node.addEventListener('click',clickVoteShow);");

            //投票默认图片显示层
            sbLeft.AppendLine("var imgVote=document.createElement('img');");
            sbLeft.AppendLine("imgVote.className='baseFloatLeft';");
            sbLeft.AppendLine("imgVote.src='" + PictureAndTextMixMethod.VoteImg + "';");
            sbLeft.AppendLine("node.appendChild(imgVote);");

            //投票title显示层
            sbLeft.AppendLine("var voteTitle = document.createElement('div');");
            sbLeft.AppendLine("voteTitle.className='voteTitle';");
            sbLeft.AppendLine("voteTitle.innerHTML ='" + receive.title + "';");
            sbLeft.AppendLine("node.appendChild(voteTitle);");

            //换行1
            sbLeft.AppendLine("var  newLineOne= document.createElement('br');");
            sbLeft.AppendLine("node.appendChild(newLineOne);");

            //投票第一项
            sbLeft.AppendLine("var voteFirst = document.createElement('div');");
            sbLeft.AppendLine("voteFirst.className='divCircle';");

            sbLeft.AppendLine("var voteInFirst = document.createElement('div');");
            sbLeft.AppendLine("voteInFirst.className='voteContent';");
            sbLeft.AppendLine("voteInFirst.innerHTML ='" + receive.options[0].name + "';");
            sbLeft.AppendLine("voteFirst.appendChild(voteInFirst);");
            sbLeft.AppendLine("node.appendChild(voteFirst);");


            //换行2
            sbLeft.AppendLine("var  newLineTwo= document.createElement('br');");
            sbLeft.AppendLine("node.appendChild(newLineTwo);");

            //投票第二项
            sbLeft.AppendLine("var voteSecond = document.createElement('div');");
            sbLeft.AppendLine("voteSecond.className='divCircle';");

            sbLeft.AppendLine("var voteInSecond = document.createElement('div');");
            sbLeft.AppendLine("voteInSecond.className='voteContent';");
            sbLeft.AppendLine("voteInSecond.innerHTML ='" + receive.options[1].name + "';");
            sbLeft.AppendLine("voteSecond.appendChild(voteInSecond);");
            sbLeft.AppendLine("node.appendChild(voteSecond);");
            if (receive.options.Count > 3)
            {
                //换行3
                sbLeft.AppendLine("var  newLineThree= document.createElement('br');");
                sbLeft.AppendLine("node.appendChild(newLineThree);");

                //投票第三项
                sbLeft.AppendLine("var voteThree = document.createElement('div');");
                sbLeft.AppendLine("voteThree.className='divCircle';");

                sbLeft.AppendLine("var voteInThree = document.createElement('div');");
                sbLeft.AppendLine("voteInThree.className='voteContent';");
                sbLeft.AppendLine("voteInThree.innerHTML ='" + receive.options[2].name + "';");
                sbLeft.AppendLine("voteThree.appendChild(voteInThree);");
                sbLeft.AppendLine("node.appendChild(voteThree);");
            }

            //换行4
            sbLeft.AppendLine("var  newLineFour= document.createElement('br');");
            sbLeft.AppendLine("node.appendChild(newLineFour);");

            sbLeft.AppendLine("nodeFirst.appendChild(node);");

            //获取body层
            sbLeft.AppendLine("var listbody = document.getElementById('bodydiv');");
            sbLeft.AppendLine("listbody.insertBefore(nodeFirst,listbody.childNodes[0]);}");
            //sbLeft.AppendLine("document.body.appendChild(nodeFirst);");
            sbLeft.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbLeft.ToString());
        }
コード例 #5
0
ファイル: GroupVote.cs プロジェクト: eosvil/AntennaChat
        public static void RightGroupSendVote(ChromiumWebBrowser cef, ChatBase msg)
        {
            //显示内容解析
            MsChatMsgCreateVote_content receive = JsonConvert.DeserializeObject <MsChatMsgCreateVote_content>(msg.sourceContent);
            StringBuilder sbRight = new StringBuilder();

            sbRight.AppendLine("function myFunction()");

            sbRight.AppendLine("{ var first=document.createElement('div');");
            sbRight.AppendLine("first.className='rightd';");
            sbRight.AppendLine("first.id='" + msg.messageId + "';");


            //时间显示层
            sbRight.AppendLine("var timeDiv=document.createElement('div');");
            sbRight.AppendLine("timeDiv.className='rightTimeStyle';");
            sbRight.AppendLine("timeDiv.innerHTML='" + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbRight.AppendLine("first.appendChild(timeDiv);");

            //头像显示层
            sbRight.AppendLine("var second=document.createElement('div');");
            sbRight.AppendLine("second.className='rightimg';");
            sbRight.AppendLine("var img = document.createElement('img');");
            sbRight.AppendLine("img.src='" + PictureAndTextMixMethod.HeadImgUrl() + "';");
            sbRight.AppendLine("img.className='divcss5';");
            sbRight.AppendLine("second.appendChild(img);");
            sbRight.AppendLine("first.appendChild(second);");

            //投票内容展示层
            sbRight.AppendLine("var node = document.createElement('div')");
            sbRight.AppendLine("node.className='voteBgColor speech right';");

            //设置活动Id
            sbRight.AppendLine("node.id='" + receive.id + "';");
            //事件监听
            sbRight.AppendLine("node.addEventListener('click',clickVoteShow);");

            //投票默认图片显示层
            sbRight.AppendLine("var imgVote=document.createElement('img');");
            sbRight.AppendLine("imgVote.className='baseFloatLeft';");
            sbRight.AppendLine("imgVote.src='" + PictureAndTextMixMethod.VoteImg + "';");
            sbRight.AppendLine("node.appendChild(imgVote);");

            //投票title显示层
            sbRight.AppendLine("var voteTitle = document.createElement('div');");
            sbRight.AppendLine("voteTitle.className='voteTitle';");
            sbRight.AppendLine("voteTitle.innerHTML ='" + receive.title + "';");
            sbRight.AppendLine("node.appendChild(voteTitle);");


            //换行1
            sbRight.AppendLine("var  newLineOne= document.createElement('br');");
            sbRight.AppendLine("node.appendChild(newLineOne);");

            //投票第一项
            sbRight.AppendLine("var voteFirst = document.createElement('div');");
            sbRight.AppendLine("voteFirst.className='divCircle';");


            sbRight.AppendLine("var voteInFirst = document.createElement('div');");
            sbRight.AppendLine("voteInFirst.className='voteContent';");
            sbRight.AppendLine("voteInFirst.innerHTML ='" + receive.options[0].name + "';");
            sbRight.AppendLine("voteFirst.appendChild(voteInFirst);");
            sbRight.AppendLine("node.appendChild(voteFirst);");


            //换行2
            sbRight.AppendLine("var  newLineTwo= document.createElement('br');");
            sbRight.AppendLine("node.appendChild(newLineTwo);");

            //投票第二项
            sbRight.AppendLine("var voteSecond = document.createElement('div');");
            sbRight.AppendLine("voteSecond.className='divCircle';");

            sbRight.AppendLine("var voteInSecond = document.createElement('div');");
            sbRight.AppendLine("voteInSecond.className='voteContent';");
            sbRight.AppendLine("voteInSecond.innerHTML ='" + receive.options[1].name + "';");
            sbRight.AppendLine("voteSecond.appendChild(voteInSecond);");
            sbRight.AppendLine("node.appendChild(voteSecond);");
            if (receive.options.Count > 3)
            {
                //换行3
                sbRight.AppendLine("var  newLineThree= document.createElement('br');");
                sbRight.AppendLine("node.appendChild(newLineThree);");

                //投票第三项
                sbRight.AppendLine("var voteThree = document.createElement('div');");
                sbRight.AppendLine("voteThree.className='divCircle';");

                sbRight.AppendLine("var voteInThree = document.createElement('div');");
                sbRight.AppendLine("voteInThree.className='voteContent';");
                sbRight.AppendLine("voteInThree.innerHTML ='" + receive.options[2].name + "';");
                sbRight.AppendLine("voteThree.appendChild(voteInThree);");
                sbRight.AppendLine("node.appendChild(voteThree);");
            }
            //换行4
            sbRight.AppendLine("var  newLineFour= document.createElement('br');");
            sbRight.AppendLine("node.appendChild(newLineFour);");

            sbRight.AppendLine("first.appendChild(node);");

            sbRight.AppendLine("document.body.appendChild(first);");
            sbRight.AppendLine("}");
            sbRight.AppendLine("myFunction();");
            Task task = cef.EvaluateScriptAsync(sbRight.ToString());

            task.Wait();
        }
コード例 #6
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(ChatBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_GetMessage, serviceImpl.GetMessage).Build());
 }
コード例 #7
0
ファイル: ChatGrpc.cs プロジェクト: danatunes/grpc
 /// <summary>Register service method with a service binder with or without implementation. Useful when customizing the  service binding logic.
 /// Note: this method is part of an experimental API that can change or be removed without any prior notice.</summary>
 /// <param name="serviceBinder">Service methods will be bound by calling <c>AddMethod</c> on this object.</param>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static void BindService(grpc::ServiceBinderBase serviceBinder, ChatBase serviceImpl)
 {
     serviceBinder.AddMethod(__Method_join, serviceImpl == null ? null : new grpc::DuplexStreamingServerMethod <global::ChatProject.Protos.Message, global::ChatProject.Protos.Message>(serviceImpl.join));
 }
コード例 #8
0
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(ChatBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Introduce, serviceImpl.Introduce)
            .AddMethod(__Method_Connect, serviceImpl.Connect).Build());
 }
コード例 #9
0
        public static void LeftShowPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, AntSdkContact_User user, List <string> imgId)
        {
            //显示内容解析
            List <MixMessage_content> receive = JsonConvert.DeserializeObject <List <MixMessage_content> >(msg.sourceContent);
            string        pathImage           = user.copyPicture;
            StringBuilder sbLeft = new StringBuilder();

            sbLeft.AppendLine("function myFunction()");

            sbLeft.AppendLine("{ var nodeFirst=document.createElement('div');");
            sbLeft.AppendLine("nodeFirst.className='leftd';");
            sbLeft.AppendLine("nodeFirst.id='" + msg.messageId + "';");

            //头像显示层
            sbLeft.AppendLine("var second=document.createElement('div');");
            sbLeft.AppendLine("second.className='leftimg';");
            sbLeft.AppendLine("var img = document.createElement('img');");
            sbLeft.AppendLine("img.src='" + pathImage + "';");
            sbLeft.AppendLine("img.className='divcss5Left';");
            sbLeft.AppendLine("img.id='" + user.userId + "';");
            sbLeft.AppendLine("img.addEventListener('click',clickImgCallUserId);");
            sbLeft.AppendLine("second.appendChild(img);");
            sbLeft.AppendLine("nodeFirst.appendChild(second);");

            //时间显示
            sbLeft.AppendLine("var timeshow = document.createElement('div');");
            sbLeft.AppendLine("timeshow.className='leftTimeText';");
            sbLeft.AppendLine("timeshow.innerHTML ='" + user.userNum + user.userName + "  " + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(timeshow);");

            //图文混合展示层
            //sbLeft.AppendLine("var node = document.createElement('div');");
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");

            sbLeft.AppendLine(PublicTalkMothed.divLeftCopyContent(divid));
            sbLeft.AppendLine("node.id='" + divid + "';");
            sbLeft.AppendLine("node.className='speech left';");
            int i = 0;
            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();

            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    break;

                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content?.ToString());
                    if (msg.IsSetImgLoadComplete)
                    {
                        sbInside.Append("<img id=\"" + imgId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgLeftProportion\" onload=\"scrollToend(event)\" ondblclick=\"myFunctions(event)\"/>");
                    }
                    else
                    {
                        sbInside.Append("<img id=\"" + imgId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgLeftProportion\"  ondblclick=\"myFunctions(event)\"/>");
                    }
                    i++;
                    break;

                case "0000":
                    sbInside.Append("<br/>");
                    break;
                }
            }
            sbLeft.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(node);");
            sbLeft.AppendLine("document.body.appendChild(nodeFirst);");
            sbLeft.AppendLine("}");
            sbLeft.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbLeft.ToString());
        }
コード例 #10
0
ファイル: chat.cs プロジェクト: wncoder/GrpcWpfSample
 /// <summary>Creates service definition that can be registered with a server</summary>
 /// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
 public static grpc::ServerServiceDefinition BindService(ChatBase serviceImpl)
 {
     return(grpc::ServerServiceDefinition.CreateBuilder()
            .AddMethod(__Method_Write, serviceImpl.Write)
            .AddMethod(__Method_Subscribe, serviceImpl.Subscribe).Build());
 }
コード例 #11
0
        public static void RightScrollPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, List <string> imageId)
        {
            #region 右边展示
            StringBuilder sbRight = new StringBuilder();
            sbRight.AppendLine("function myFunction()");
            //显示内容解析
            List <MixMessageObjDto> receive = JsonConvert.DeserializeObject <List <MixMessageObjDto> >(msg.sourceContent);
            sbRight.AppendLine("{ var first=document.createElement('div');");
            sbRight.AppendLine("first.className='rightd';");
            sbRight.AppendLine("first.id='" + msg.messageId + "';");

            //时间显示层
            sbRight.AppendLine("var timeDiv=document.createElement('div');");
            sbRight.AppendLine("timeDiv.className='rightTimeStyle';");
            sbRight.AppendLine("timeDiv.innerHTML='" + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbRight.AppendLine("first.appendChild(timeDiv);");

            //头像显示层
            sbRight.AppendLine("var second=document.createElement('div');");
            sbRight.AppendLine("second.className='rightimg';");
            sbRight.AppendLine("var img = document.createElement('img');");
            sbRight.AppendLine("img.src='" + PictureAndTextMixMethod.HeadImgUrl() + "';");
            sbRight.AppendLine("img.className='divcss5';");
            sbRight.AppendLine("second.appendChild(img);");
            sbRight.AppendLine("first.appendChild(second);");
            int i = 0;
            //图文混合展示层
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");
            sbRight.AppendLine(PublicTalkMothed.divRightCopyContent(divid, msg.messageId));
            sbRight.AppendLine("node.id='" + divid + "';");
            //sbRight.AppendLine("var node = document.createElement('div')");
            sbRight.AppendLine("node.className='speech right';");

            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();
            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    break;

                //图片
                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content?.ToString());
                    sbInside.Append("<img id=\"" + imageId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgRightProportion\"  ondblclick=\"myFunctions(event)\"/>");
                    i++;
                    break;

                //换行
                case "0000":
                    sbInside.Append("<br/>");
                    break;
                }
            }
            sbRight.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbRight.AppendLine("first.appendChild(node);");
            //发送失败判断
            if (msg.sendsucessorfail == 0)
            {
                string guid = Guid.NewGuid().ToString().Replace("-", "");

                sbRight.AppendLine(PictureAndTextMixMethod.OnceSendHistoryPicDiv("sendMixPic", msg.messageId, "", guid, "sending" + guid, "", ""));
            }
            //获取body层
            sbRight.AppendLine("var listbody = document.getElementById('bodydiv');");
            sbRight.AppendLine("listbody.insertBefore(first,listbody.childNodes[0]);}");
            //sbRight.AppendLine("document.body.appendChild(first);");

            sbRight.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbRight.ToString());
            #endregion
        }
コード例 #12
0
        public static void RightGroupScrollActivity(ChromiumWebBrowser cef, ChatBase msg)
        {
            //显示内容解析
            Activity_content receive = JsonConvert.DeserializeObject <Activity_content>(msg.sourceContent);
            StringBuilder    sbRight = new StringBuilder();

            sbRight.AppendLine("function myFunction()");

            sbRight.AppendLine("{ var first=document.createElement('div');");
            sbRight.AppendLine("first.className='rightd';");
            sbRight.AppendLine("first.id='" + msg.messageId + "';");

            //时间显示层
            sbRight.AppendLine("var timeDiv=document.createElement('div');");
            sbRight.AppendLine("timeDiv.className='rightTimeStyle';");
            sbRight.AppendLine("timeDiv.innerHTML='" + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbRight.AppendLine("first.appendChild(timeDiv);");

            //头像显示层
            sbRight.AppendLine("var second=document.createElement('div');");
            sbRight.AppendLine("second.className='rightimg';");
            sbRight.AppendLine("var img = document.createElement('img');");
            sbRight.AppendLine("img.src='" + PictureAndTextMixMethod.HeadImgUrl() + "';");
            sbRight.AppendLine("img.className='divcss5';");
            sbRight.AppendLine("second.appendChild(img);");
            sbRight.AppendLine("first.appendChild(second);");

            //活动内容展示层
            sbRight.AppendLine("var node = document.createElement('div')");
            sbRight.AppendLine("node.className='voteBgColor speech right';");

            //设置活动Id
            sbRight.AppendLine("node.id='" + receive.activityId + "';");
            //事件监听
            sbRight.AppendLine("node.addEventListener('click',clickActivityShow);");

            //活动默认图片显示层
            sbRight.AppendLine("var imgVote=document.createElement('img');");
            sbRight.AppendLine("imgVote.className='activityImg';");
            sbRight.AppendLine("imgVote.src='" + receive.picture + "';");
            sbRight.AppendLine("node.appendChild(imgVote);");

            //活动title显示层
            sbRight.AppendLine("var voteTitle = document.createElement('div');");
            sbRight.AppendLine("voteTitle.className='voteTitle';");
            sbRight.AppendLine("voteTitle.innerHTML ='" + PictureAndTextMixMethod.ImgUrlSplit(receive.picture) + "';");
            sbRight.AppendLine("node.appendChild(voteTitle);");

            //换行1
            sbRight.AppendLine("var  newLineOne= document.createElement('br');");
            sbRight.AppendLine("node.appendChild(newLineOne);");

            //活动时间
            sbRight.AppendLine("var voteInFirst = document.createElement('div');");
            sbRight.AppendLine("voteInFirst.className='activityTP';");
            sbRight.AppendLine("voteInFirst.innerHTML ='时间:" + receive.startTime + "';");
            sbRight.AppendLine("node.appendChild(voteInFirst);");

            //换行2
            sbRight.AppendLine("var  newLineTwo= document.createElement('br');");
            sbRight.AppendLine("node.appendChild(newLineTwo);");

            //活动地点
            sbRight.AppendLine("var voteInSecond = document.createElement('div');");
            sbRight.AppendLine("voteInSecond.className='activityTP';");
            sbRight.AppendLine("voteInSecond.innerHTML ='地点:" + receive.address + "';");
            sbRight.AppendLine("node.appendChild(voteInSecond);");

            //换行4
            sbRight.AppendLine("var  newLineFour= document.createElement('br');");
            sbRight.AppendLine("node.appendChild(newLineFour);");

            sbRight.AppendLine("first.appendChild(node);");

            //获取body层
            sbRight.AppendLine("var listbody = document.getElementById('bodydiv');");
            sbRight.AppendLine("listbody.insertBefore(first,listbody.childNodes[0]);}");
            //sbRight.AppendLine("document.body.appendChild(first);");
            sbRight.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbRight.ToString());
        }
コード例 #13
0
        public static void LeftGroupScrollActivity(ChromiumWebBrowser cef, ChatBase msg, List <AntSdkGroupMember> GroupMembers)
        {
            AntSdkGroupMember user = PictureAndTextMixMethod.getGroupMembersUser(GroupMembers, msg);
            //显示内容解析
            Activity_content receive = JsonConvert.DeserializeObject <Activity_content>(msg.sourceContent);
            StringBuilder    sbLeft  = new StringBuilder();

            sbLeft.AppendLine("function myFunction()");

            sbLeft.AppendLine("{ var nodeFirst=document.createElement('div');");
            sbLeft.AppendLine("nodeFirst.className='leftd';");
            sbLeft.AppendLine("nodeFirst.id='" + msg.messageId + "';");

            //头像显示层
            sbLeft.AppendLine("var second=document.createElement('div');");
            sbLeft.AppendLine("second.className='leftimg';");
            sbLeft.AppendLine("var img = document.createElement('img');");
            sbLeft.AppendLine("img.src='" + PictureAndTextMixMethod.getPathImage(GroupMembers, msg) + "';");
            sbLeft.AppendLine("img.className='divcss5Left';");
            sbLeft.AppendLine("img.id='" + user.userId + "';");
            sbLeft.AppendLine("img.addEventListener('click',clickImgCallUserId);");
            sbLeft.AppendLine("second.appendChild(img);");
            sbLeft.AppendLine("nodeFirst.appendChild(second);");


            //时间显示
            sbLeft.AppendLine("var timeshow = document.createElement('div');");
            sbLeft.AppendLine("timeshow.className='leftTimeText';");
            sbLeft.AppendLine("timeshow.innerHTML ='" + user.userNum + user.userName + "  " + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(timeshow);");

            //活动内容展示层
            sbLeft.AppendLine("var node = document.createElement('div');");
            sbLeft.AppendLine("node.className='speech left';");

            //设置活动Id
            sbLeft.AppendLine("node.id='" + receive.activityId + "';");
            //事件监听
            sbLeft.AppendLine("node.addEventListener('click',clickActivityShow);");

            //活动默认图片显示层
            sbLeft.AppendLine("var imgVote=document.createElement('img');");
            sbLeft.AppendLine("imgVote.className='activityImg';");

            sbLeft.AppendLine("imgVote.src='" + PictureAndTextMixMethod.ImgUrlSplit(receive.picture) + "';");
            sbLeft.AppendLine("node.appendChild(imgVote);");

            //活动title显示层
            sbLeft.AppendLine("var voteTitle = document.createElement('div');");
            sbLeft.AppendLine("voteTitle.className='voteTitle';");
            sbLeft.AppendLine("voteTitle.innerHTML ='" + receive.theme + "';");
            sbLeft.AppendLine("node.appendChild(voteTitle);");

            //换行1
            sbLeft.AppendLine("var  newLineOne= document.createElement('br');");
            sbLeft.AppendLine("node.appendChild(newLineOne);");

            sbLeft.AppendLine("var voteInFirst = document.createElement('div');");
            sbLeft.AppendLine("voteInFirst.className='activityTP';");
            sbLeft.AppendLine("voteInFirst.innerHTML ='时间:" + receive.startTime + "';");;
            sbLeft.AppendLine("node.appendChild(voteInFirst);");

            //换行2
            sbLeft.AppendLine("var  newLineTwo= document.createElement('br');");
            sbLeft.AppendLine("node.appendChild(newLineTwo);");

            //活动地点
            sbLeft.AppendLine("var voteInSecond = document.createElement('div');");
            sbLeft.AppendLine("voteInSecond.className='activityTP';");
            sbLeft.AppendLine("voteInSecond.innerHTML ='地点:" + receive.address + "';");
            sbLeft.AppendLine("node.appendChild(voteInSecond);");

            //换行4
            sbLeft.AppendLine("var  newLineFour= document.createElement('br');");
            sbLeft.AppendLine("node.appendChild(newLineFour);");

            sbLeft.AppendLine("nodeFirst.appendChild(node);");

            //获取body层
            sbLeft.AppendLine("var listbody = document.getElementById('bodydiv');");
            sbLeft.AppendLine("listbody.insertBefore(nodeFirst,listbody.childNodes[0]);}");
            //sbLeft.AppendLine("document.body.appendChild(nodeFirst);");
            sbLeft.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbLeft.ToString());
        }
コード例 #14
0
        public static void LeftGroupScrollPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, List <AntSdkGroupMember> GroupMembers, List <string> imageId)
        {
            AntSdkGroupMember user = PictureAndTextMixMethod.getGroupMembersUser(GroupMembers, msg);
            //显示内容解析
            List <MixMessageObjDto> receive = JsonConvert.DeserializeObject <List <MixMessageObjDto> >(msg.sourceContent);
            StringBuilder           sbLeft  = new StringBuilder();

            sbLeft.AppendLine("function myFunction()");

            sbLeft.AppendLine("{ var nodeFirst=document.createElement('div');");
            sbLeft.AppendLine("nodeFirst.className='leftd';");
            sbLeft.AppendLine("nodeFirst.id='" + msg.messageId + "';");

            //头像显示层
            sbLeft.AppendLine("var second=document.createElement('div');");
            sbLeft.AppendLine("second.className='leftimg';");
            sbLeft.AppendLine("var img = document.createElement('img');");
            sbLeft.AppendLine("img.src='" + PictureAndTextMixMethod.getPathImage(GroupMembers, msg) + "';");
            sbLeft.AppendLine("img.className='divcss5Left';");
            sbLeft.AppendLine("img.id='" + user.userId + "';");
            sbLeft.AppendLine("img.addEventListener('click',clickImgCallUserId);");
            sbLeft.AppendLine("second.appendChild(img);");
            sbLeft.AppendLine("nodeFirst.appendChild(second);");

            //时间显示
            sbLeft.AppendLine("var timeshow = document.createElement('div');");
            sbLeft.AppendLine("timeshow.className='leftTimeText';");
            sbLeft.AppendLine("timeshow.innerHTML ='" + user.userNum + user.userName + "  " + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(timeshow);");
            int i = imageId.Count();
            //图文混合展示层
            //sbLeft.AppendLine("var node = document.createElement('div');");
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");

            sbLeft.AppendLine(PublicTalkMothed.divLeftCopyContent(divid));
            sbLeft.AppendLine("node.id='" + divid + "';");
            sbLeft.AppendLine("node.className='speech left';");

            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();

            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    break;

                //图片
                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content.ToString());
                    sbInside.Append("<img id=\"" + imageId[i - 1] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgLeftProportion\" ondblclick=\"myFunctions(event)\"/>");
                    i--;
                    break;

                //@消息
                case "1008":
                    List <At_content> at    = JsonConvert.DeserializeObject <List <At_content> >(list.content.ToString());
                    string            strAt = "";
                    foreach (var atList in at)
                    {
                        if (atList.type == "1112")
                        {
                            foreach (var atName in atList.names)
                            {
                                strAt += "@" + atName;
                            }
                            sbInside.Append(strAt);
                        }
                        else
                        {
                            #region @全体成员
                            sbInside.Append("@全体成员");
                            #endregion
                        }
                    }
                    break;

                //换行
                case "0000":
                    sbInside.Append("<br/>");
                    break;
                }
            }
            sbLeft.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbLeft.AppendLine("nodeFirst.appendChild(node);");
            //获取body层
            sbLeft.AppendLine("var listbody = document.getElementById('bodydiv');");
            sbLeft.AppendLine("listbody.insertBefore(nodeFirst,listbody.childNodes[0]);}");
            //sbLeft.AppendLine("document.body.appendChild(nodeFirst);");

            sbLeft.AppendLine("myFunction();");
            cef.EvaluateScriptAsync(sbLeft.ToString());;
        }
コード例 #15
0
        public static void RightGroupShowPicAndTextMix(ChromiumWebBrowser cef, ChatBase msg, List <string> imageId)
        {
            #region 右边展示
            StringBuilder sbRight = new StringBuilder();
            sbRight.AppendLine("function myFunction()");
            //显示内容解析
            List <MixMessageObjDto> receive = JsonConvert.DeserializeObject <List <MixMessageObjDto> >(msg.sourceContent);
            sbRight.AppendLine("{ var first=document.createElement('div');");
            sbRight.AppendLine("first.className='rightd';");
            sbRight.AppendLine("first.id='" + msg.messageId + "';");

            //时间显示层
            sbRight.AppendLine("var timeDiv=document.createElement('div');");
            sbRight.AppendLine("timeDiv.className='rightTimeStyle';");
            sbRight.AppendLine("timeDiv.innerHTML='" + PictureAndTextMixMethod.timeComparison(msg.sendTime) + "';");
            sbRight.AppendLine("first.appendChild(timeDiv);");

            //头像显示层
            sbRight.AppendLine("var second=document.createElement('div');");
            sbRight.AppendLine("second.className='rightimg';");
            sbRight.AppendLine("var img = document.createElement('img');");
            sbRight.AppendLine("img.src='" + PictureAndTextMixMethod.HeadImgUrl() + "';");
            sbRight.AppendLine("img.className='divcss5';");
            sbRight.AppendLine("second.appendChild(img);");
            sbRight.AppendLine("first.appendChild(second);");

            //图文混合展示层
            //sbRight.AppendLine("var node = document.createElement('div')");
            string divid = "copy" + Guid.NewGuid().ToString().Replace("-", "");
            sbRight.AppendLine(PublicTalkMothed.divRightCopyContent(divid, msg.messageId));
            sbRight.AppendLine("node.id='" + divid + "';");
            sbRight.AppendLine("node.className='speech right';");
            int i = 0;
            //图文混合内部构造
            StringBuilder sbInside = new StringBuilder();
            foreach (var list in receive)
            {
                switch (list.type)
                {
                //文本
                case "1001":
                    sbInside.Append(PublicTalkMothed.talkContentReplace(list.content?.ToString()));
                    //sbRight.AppendLine("node.innerHTML ='" + list.content.Replace("\r\n", "<br/>").Replace("\n", "<br/>") + "';");
                    break;

                //图片
                case "1002":
                    PictureAndTextMixContentDto pictureAndTextMix = JsonConvert.DeserializeObject <PictureAndTextMixContentDto>(list.content?.ToString());
                    sbInside.Append("<img id=\"" + imageId[i] + "\" src=\"" + pictureAndTextMix.picUrl + "\" class=\"imgRightProportion\" ondblclick=\"myFunctions(event)\"/>");
                    i++;
                    break;

                //换行
                case "0000":
                    sbInside.Append("<br/>");
                    break;

                //@消息
                case "1008":
                    List <At_content> at    = JsonConvert.DeserializeObject <List <At_content> >(list.content.ToString());
                    string            strAt = "";
                    foreach (var atList in at)
                    {
                        if (atList.type == "1112")
                        {
                            foreach (var atName in atList.names)
                            {
                                strAt += "@" + atName;
                            }
                            sbInside.Append(strAt);
                        }
                        else
                        {
                            #region @全体成员
                            sbInside.Append("@全体成员");
                            #endregion
                        }
                    }
                    break;
                }
            }
            sbRight.AppendLine("node.innerHTML ='" + sbInside.ToString() + "';");
            sbRight.AppendLine("first.appendChild(node);");
            //获取body层

            sbRight.AppendLine("document.body.appendChild(first);}");

            sbRight.AppendLine("myFunction();");
            cef.ExecuteScriptAsync(sbRight.ToString());
            #endregion
        }