public static void MessageType_InsertFrom_DataBase(string recipientid) { #region Load from Database try { var messages = SQL_Commander.GetMessageList(Settings.User_id, recipientid, "0"); if (messages.Count() > 0) { foreach (var Message in messages) { var isVisible = true; if (Message.text == "") { isVisible = false; } var SS = Functions.Messages.Select(a => a.messageID == Message.message_id.ToString()).FirstOrDefault(); if (SS == false) { if (Message.position == "left") { var ImageProfile = ImageSource.FromFile( DependencyService.Get <IPicture>() .GetPictureFromDisk(Message.avatar, recipientid)); #region left_text if (Message.type == "left_text") { Functions.Messages.Add(new MessageViewModal() { Content = Message.text, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), UserImage = ImageProfile, CommingBackroundBoxColor = Settings.MS_CommingBackroundBox_Color }); } #endregion #region Left Image if (Message.type == "left_image") { var ImageUrl = Message.media; var ImageMediaFile = ImageSource.FromFile( DependencyService.Get <IPicture>().GetPictureFromGalery(ImageUrl)); if (DependencyService.Get <IPicture>().GetPictureFromGalery(ImageUrl) == "File Dont Exists") { ImageMediaFile = new UriImageSource { Uri = new Uri(ImageUrl) }; } Functions.Messages.Add(new MessageViewModal() { UserImage = ImageProfile, Visibilty = isVisible, Content = Message.text, Type = Message.type, Position = Message.position, CreatedAt = Message.time, ImageMedia = ImageMediaFile, messageID = Message.message_id.ToString(), ImageUrl = ImageUrl, DownloadFileUrl = Message.DownloadFileUrl, CommingBackroundBoxColor = Settings.MS_CommingBackroundBox_Color }); } #endregion #region Left Sound if (Message.type == "//left_audio") { Functions.Messages.Add(new MessageViewModal() { UserImage = ImageProfile, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), Media = Message.media, DownloadFileUrl = Message.DownloadFileUrl, ImageMedia = Message.ImageMedia, MediaName = Message.MediaName, SliderSoundValue = "0", SliderMaxDuration = "100", CommingBackroundBoxColor = Settings.MS_CommingBackroundBox_Color }); } #endregion #region Left Video if (Message.type == "left_video") { Functions.Messages.Add(new MessageViewModal() { UserImage = ImageProfile, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), Media = Message.media, DownloadFileUrl = Message.DownloadFileUrl, ImageMedia = Message.ImageMedia, MediaName = Message.MediaName, SliderSoundValue = "0", SliderMaxDuration = "100", CommingBackroundBoxColor = Settings.MS_CommingBackroundBox_Color }); } #endregion #region left_contact if (Message.type == "left_contact") { Functions.Messages.Add(new MessageViewModal() { Content = Message.text, Type = Message.type, UserImage = Message.avatar, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), ImageMedia = "UserContact.png", ContactNumber = Message.contactNumber, ContactName = Message.contactName, CommingBackroundBoxColor = Settings.MS_CommingBackroundBox_Color }); } #endregion if (Message.type == "left_sticker") { Functions.Messages.Add(new MessageViewModal() { Content = Message.text, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), ImageUrl = Message.media, ImageMedia = Message.media, UserImage = ImageProfile, }); } } else { var ImageProfile = ImageSource.FromFile(DependencyService.Get <IPicture>() .GetPictureFromDisk(Message.avatar, Settings.User_id)); #region right_text if (Message.type == "right_text") { Functions.Messages.Add(new MessageViewModal() { Content = Message.text, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), UserImage = ImageProfile, GoingBackroundBoxColor = Settings.MS_GoingBackroundBox_Color }); } #endregion #region Left Image if (Message.type == "right_image") { var ImageUrl = Message.media; var ImageMediaFile = ImageSource.FromFile( DependencyService.Get <IPicture>() .GetPictureFromDisk(ImageUrl, Settings.User_id)); if ( DependencyService.Get <IPicture>() .GetPictureFromDisk(ImageUrl, Settings.User_id) == "File Dont Exists") { DependencyService.Get <IPicture>() .SavePictureToDisk(ImageUrl, Settings.User_id); ImageMediaFile = new UriImageSource { Uri = new Uri(ImageUrl) }; } Functions.Messages.Add(new MessageViewModal() { UserImage = ImageProfile, Visibilty = isVisible, Content = Message.text, Type = Message.type, Position = Message.position, CreatedAt = Message.time, ImageMedia = ImageMediaFile, messageID = Message.message_id.ToString(), ImageUrl = ImageUrl, DownloadFileUrl = Message.DownloadFileUrl, GoingBackroundBoxColor = Settings.MS_GoingBackroundBox_Color }); } #endregion #region right Sound if (Message.type == "//right_audio") { Functions.Messages.Add(new MessageViewModal() { UserImage = ImageProfile, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), Media = Message.MediaName, ImageMedia = Message.ImageMedia, DownloadFileUrl = Message.DownloadFileUrl, MediaName = Message.MediaName, SliderSoundValue = "0", SliderMaxDuration = "100", GoingBackroundBoxColor = Settings.MS_GoingBackroundBox_Color }); } #endregion #region right Video if (Message.type == "right_video") { Functions.Messages.Add(new MessageViewModal() { UserImage = ImageProfile, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), Media = Message.media, ImageMedia = Message.ImageMedia, DownloadFileUrl = Message.DownloadFileUrl, MediaName = Message.MediaName, SliderSoundValue = "0", SliderMaxDuration = "100", GoingBackroundBoxColor = Settings.MS_GoingBackroundBox_Color }); } #endregion #region right contact if (Message.type == "right_contact") { Functions.Messages.Add(new MessageViewModal() { UserImage = ImageProfile, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), Media = Message.media, DownloadFileUrl = Message.DownloadFileUrl, MediaName = Message.MediaName, ImageMedia = "UserContact.png", GoingBackroundBoxColor = Settings.MS_GoingBackroundBox_Color, ContactNumber = Message.contactNumber, Content = Message.contactName, ContactName = Message.contactName, }); } #endregion if (Message.type == "right_sticker") { Functions.Messages.Add(new MessageViewModal() { Content = Message.text, Type = Message.type, Position = Message.position, CreatedAt = Message.time, messageID = Message.message_id.ToString(), ImageUrl = Message.media, ImageMedia = Message.media, UserImage = ImageProfile, }); } } } } } } catch (Exception) { } #endregion }