Ejemplo n.º 1
0
        void connect()
        {
            if (!isConnect)
            {
                client = new ServiceChatClient(new System.ServiceModel.InstanceContext(this));

                UserInLog = client.Connect(provider.GetAllUsers().FirstOrDefault(x => x.Name == tbName.Text));

                if (History.IsChecked == true)
                {
                    var allMsg = provider.GetAllMsg();

                    foreach (var item in allMsg)
                    {
                        try
                        {
                            var a = provider.GetAllUsers().FirstOrDefault(x => x.id == item.UserID);
                            MsgCallback(a, item.Message, TypeMsg.Message);
                            //chat.ItemsSource = provider.GetAllMsg();
                            //chat.SelectedValuePath = "Message";
                            //chat.SelectedValue = "Message";
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
                // MessageBox.Show(client.GetAllOnlineUsers().Length.ToString());
                ////Cписок онлайн юзерів

                listOnlineUsers.AddRange(client.GetAllOnlineUsers());

                listUsers.ItemsSource = listOnlineUsers;
                listUsers.Items.Refresh();
                tbName.IsEnabled = false;
                btnCon.Content   = "Disconnect";
                isConnect        = true;
            }
        }