private void linemessage(MobileServiceCollection<ChatMessage, ChatMessage> items)
 {
     int i;
     for (i = 0; i < items.Count; i++)
     {
         var oldChat = new ChatMessage();
         oldChat.From = items[i].From;
         oldChat.DateTime = items[i].DateTime;
         oldChat.Content = items[i].Content;
         TextBoxChatMessages.Text += Environment.NewLine + oldChat.ToString();
     }
     i = 0;
 }
        async Task loadchat()
        {
            try
            {
                var item = await chatTable.ToCollectionAsync();
                //linemessage(item);
                int i;
                for (i = 0; i < item.Count; i++)
                {
                    var oldChat = new ChatMessage();
                    oldChat.From = item[i].From;
                    oldChat.DateTime = item[i].DateTime;
                    oldChat.Content = item[i].Content;
                    TextBoxChatMessages.Text += oldChat.ToString() + Environment.NewLine;
                }
                i = 0;
            }
            catch
            {

            }
        }
        public async void readMessage()
        {

            try
            {
                //IMobileServiceTable<ChatMessage> todoTable = MobileService.GetTable<ChatMessage>();
                //IMobileServiceTableQuery<ChatMessage> query = todoTable.Skip(50).Take(50);
                //List<ChatMessage> items = await query.ToListAsync();
                //var temp = items;
                //query = query.IncludeTotalCount();

                //var items = await chatTable.ToCollectionAsync();

                //var myTable = MobileService.GetTable<ChatMessage>();
                // var myList = await myTable.Take(500).Where(datetime).ToListAsync();

                var items = await chatTable.ToCollectionAsync();
                var temp = items;


                for (var i = 0; i < items.Count; i++)
                {
                    var oldChat = new ChatMessage();
                    oldChat.Id = items[i].Id;
                    oldChat.created_At = items[i].created_At;
                    oldChat.From = items[i].From;
                    oldChat._Deleted = items[i]._Deleted;
                    //oldChat._deleted = items[i]._deleted;
                    oldChat.DateTime = items[i].DateTime;
                    oldChat.Content = items[i].Content;
                    TextBoxChatMessages.Text += Environment.NewLine + oldChat.ToString();
                    //JObject jo = new JObject();
                    //jo.Add("Id", items[i].Id.ToString());
                    ////var c = items.Count;
                    //await chatTable.DeleteAsync(jo);

                }
            }
            catch
            {

            }
            }
        private async void InsertChatMessage(ChatMessage message)
        {
            try
            {
                TextBoxChatMessages.Text += string.Format("{0}\n", message.ToString());
                //message = output;
                await chatTable.InsertAsync(message);
                ReadyForNextMessage();
            }
            catch
            {

            }
        }
 private void ButtonContent_Click_1(object sender, RoutedEventArgs e)
 {
     string[] badWords = new[] { "f**k", "f u c k","sex", "s e x", "bobo", "b o b o", "f.u.c.k", "s.e.x", "b.o.b.o",
     "puta", "tanga", "p u t a", "t a n g a", "p.u.t.a", "t.a.n.g.a", "tangina", "t.a.n.g.i.n.a", "putangina",
     "p.u.t.a.n.g.i.n.a"};
     string input = TextBoxMessage.Text;
     string output = Filter(input, badWords);
     string date = DateTime.Now.ToString();
     string temp = date;
     if (!string.IsNullOrWhiteSpace(output))
     {
         var chatMessage = new ChatMessage()
         {
             From = name,
             Content = output.Trim(),
             //DateTime = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
             DateTime = DateTime.Now.ToString()
         };
         InsertChatMessage(chatMessage);
     }
     ReadyForNextMessage();
     TextBoxMessage.Text = "";
     //ticktoDisable();
     disable(); 
 }
 private void ButtonContent_Click_1(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(TextBoxMessage.Text))
     {
         var chatMessage = new ChatMessage()
         {
             From = name,
             Content = TextBoxMessage.Text.Trim(),
             DateTime = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"),
             Channel = App.CurrentChannel.Uri
         };
         InsertChatMessage(chatMessage);
     }
     ReadyForNextMessage();
 }