private void Share_Click(object sender, RoutedEventArgs e) { if (Type.SelectedIndex == 0) { //send plaintext Class.File file = new Class.File(); file.Data = TextBox.Text; file.Datetime = DateTime.Now; file.EmailToUser = SendTo.Text; file.FromUser = ((Class.User)App.Current.Properties["LoggedinUser"]); file.isText = true; string result = Methods.Database.SendData(file); Messager.Show("Result", result); } else if (Type.SelectedIndex == 1) { //send file Class.File file = new Class.File(); file.Data = FileBox.Text; file.Datetime = DateTime.Now; file.EmailToUser = SendTo.Text; file.FromUser = ((Class.User)App.Current.Properties["LoggedinUser"]); file.isText = false; string result = Methods.Database.SendData(file); Messager.Show("Result", result); } }
private void FileViewSelectionChanged(object sender, SelectionChangedEventArgs e) { object selectedValue = FileView.SelectedValue; int value = Convert.ToInt32(selectedValue); Class.File file = files.Where(w => w.ID == value).FirstOrDefault(); Messager.ShowFile(file); }
/// <summary> /// Displays the file details in a messagebox /// </summary> /// <param name="file"></param> public static void ShowFile(Class.File file) { string title = ""; string messageString = ""; if (file.isText) { title = "Text message from " + file.FromUser.Name; messageString = "You got a text message from " + file.FromUser.Email + " on " + file.Datetime.ToString("dd/MM/yy HH:mm") + "\nThe message is:\n\n" + file.Data; } else { title = "File from " + file.FromUser.Name; messageString = "You got a file from " + file.FromUser.Email + " on " + file.Datetime.ToString("dd/MM/yy HH:mm") + "\n Download the file here is:\n\n" + file.Data; } Message message = new Message(title, messageString, 300, 450); message.ShowDialog(); }