async private void fence_Tapped(object sender, TappedRoutedEventArgs e) { Windows.UI.Xaml.Shapes.Rectangle fench = (Windows.UI.Xaml.Shapes.Rectangle)sender; String userEmail = fench.Name; User user = await SampleDataSource.GetUserAsync(userEmail); if (user == null) { Debug.WriteLine("bad user: "******"Chat with " + user.FirstName + " " + user.LastName + "?"); myDialog.Commands.Add(new UICommand("Yes", async(x) => { IEnumerable <Message> messages = await SampleDataSource.GetMessageAsync(userEmail); Tuple <String, IEnumerable <Message> > args = new Tuple <string, IEnumerable <Message> >(userEmail, messages); if (!Frame.Navigate(typeof(UserPage), args)) { throw new Exception(this.resourceLoader.GetString("NavigationFailedExceptionMessage")); } })); myDialog.Commands.Add(new UICommand("No", (x) => {})); myDialog.DefaultCommandIndex = 0; myDialog.CancelCommandIndex = 1; await myDialog.ShowAsync(); }
/// <summary> /// Shows the details of an item clicked on in the <see cref="ItemPage"/> /// </summary> /// <param name="sender">The source of the click event.</param> /// <param name="e">Defaults about the click event.</param> async private void ItemView_ItemClick(object sender, ItemClickEventArgs e) { String userEmail = ((User)e.ClickedItem).Email; IEnumerable <Message> messages = await SampleDataSource.GetMessageAsync(userEmail); Tuple <String, IEnumerable <Message> > args = new Tuple <string, IEnumerable <Message> >(userEmail, messages); if (!Frame.Navigate(typeof(UserPage), args)) { throw new Exception(this.resourceLoader.GetString("NavigationFailedExceptionMessage")); } }
async private void Button_Click(object sender, RoutedEventArgs e) { String msg = MessageBox.Text; if (msg.Equals("")) { return; } var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("command", "sendMessage"), new KeyValuePair <string, string>("message", msg), new KeyValuePair <string, string>("to", this.user.Email), }; var response = await API.sendCommand(parameters); if (response == null) { return; } MessageBox.Text = ""; IEnumerable <Message> messages = await SampleDataSource.GetMessageAsync(user.Email); List <Message> msgs = messages.ToList(); msgs.Sort((x, y) => x.Ts.CompareTo(y.Ts)); this.DefaultViewModel["Messages"] = msgs; chathistorylist.UpdateLayout(); if (msgs.Count > 0) { chathistorylist.ScrollIntoView(msgs.Last()); } }