private void GetData() { IsLongPressed = false; IsImageChecked = false; IsImageOverlayVisible = false; GalleryList.Add(new GalleryModel { ImageId = 1, ImageUrl = "icon", IsDeleted = false, IsSelected = false }); GalleryList.Add(new GalleryModel { ImageId = 2, ImageUrl = "icon", IsDeleted = false, IsSelected = false }); GalleryList.Add(new GalleryModel { ImageId = 3, ImageUrl = "icon", IsDeleted = false, IsSelected = false }); GalleryList.Add(new GalleryModel { ImageId = 4, ImageUrl = "icon", IsDeleted = false, IsSelected = false }); GalleryList.Add(new GalleryModel { ImageId = 5, ImageUrl = "icon", IsDeleted = false, IsSelected = false }); GalleryList.Add(new GalleryModel { ImageId = 6, ImageUrl = "icon", IsDeleted = false, IsSelected = false }); GalleryList.Add(new GalleryModel { ImageId = 7, ImageUrl = "icon", IsDeleted = false, IsSelected = false }); }
public List <BE.HostingUnit> GetHostingUnits(Func <BE.HostingUnit, bool> predicate = null) { List <BE.HostingUnit> list = null; if (predicate != null) { list = HostingUnitsList.Where(predicate).ToList(); } else { list = HostingUnitsList; } for (int i = 0; i < list.Count(); i++) { list[i].Images = GalleryList.Where(c => c.HostingUnitId == list[i].stSerialKey).ToList(); } for (int i = 0; i < list.Count(); i++) { list[i].Days = DaysList.Where(c => c.HostingUnitId == list[i].stSerialKey).ToList(); } return(list); }
private void GetBearers() { List <GalleryModel> bearersList = null; Task.Factory.StartNew(() => { ISyncServices syncService = new SyncServices(); bearersList = syncService.GetGallery(); }).ContinueWith((obj) => { Device.BeginInvokeOnMainThread(() => { if (bearersList != null) { foreach (var item in bearersList) { if (string.IsNullOrEmpty(item.galleryPhoto)) { item.galleryPhoto = "demo"; } GalleryList.Add(item); } } }); }); }
public HostingUnit GetHostingUnitById(int stSerialKey) { var hosting = HostingUnitsList.FirstOrDefault(c => c.stSerialKey == stSerialKey); if (hosting != null) { hosting.Images = GalleryList.Where(c => c.HostingUnitId == hosting.stSerialKey).ToList(); } return(hosting); }
public void DeleteHostingUnit(int hostingUnitId) { int index = HostingUnitsList.FindIndex(c => c.stSerialKey == hostingUnitId); if (index > -1) { HostingUnitsList.RemoveAt(index); //delete Prev items GalleryList.RemoveAll(c => c.HostingUnitId == hostingUnitId); } UpdateXml <HostingUnit>(HostingUnitsList); UpdateXml <GalleryImageItem>(GalleryList); }
public void AddHostingUnit(BE.HostingUnit hostingUnit) { hostingUnit.stSerialKey = Configuration.HostingUnitKey; Configuration.HostingUnitKey++; HostingUnitsList.Add(hostingUnit); //save images for (int i = 0; i < hostingUnit.TempImages.Count(); i++) { int key = Configuration.ImageIdentity; Configuration.ImageIdentity++; GalleryImageItem ii = new GalleryImageItem() { HostingUnitId = hostingUnit.stSerialKey, Id = key, Url = hostingUnit.TempImages[i].Url }; GalleryList.Add(ii); } UpdateXml <HostingUnit>(HostingUnitsList); UpdateXml <GalleryImageItem>(GalleryList); }
public void UpdatingHostingUnit(BE.HostingUnit hostingUnit) { var h = GetHostingUnitById(hostingUnit.stSerialKey); if (h != null) { h.HostingUnitName = hostingUnit.HostingUnitName; h.Rooms = hostingUnit.Rooms; h.SubArea = hostingUnit.SubArea; h.OwnerId = hostingUnit.OwnerId; h.Pool = hostingUnit.Pool; h.Adult = hostingUnit.Adult; h.Area = hostingUnit.Area; h.Children = hostingUnit.Children; h.ChildrensAttractions = hostingUnit.ChildrensAttractions; h.Garden = hostingUnit.Garden; //h. h.Status = hostingUnit.Status; //h.DiaryState = hostingUnit.DiaryState; //delete Prev items GalleryList.RemoveAll(c => c.HostingUnitId == hostingUnit.stSerialKey); for (int i = 0; i < hostingUnit.TempImages.Count(); i++) { int key = Configuration.ImageIdentity; Configuration.ImageIdentity++; GalleryImageItem ii = new GalleryImageItem() { HostingUnitId = hostingUnit.stSerialKey, Id = key, Url = hostingUnit.TempImages[i].Url }; GalleryList.Add(ii); } UpdateXml <HostingUnit>(HostingUnitsList); UpdateXml <GalleryImageItem>(GalleryList); } }
public static void OnCameraResult() { // Some versions of Android save to the MediaStore as well as the ExtraOutput. // Not sure why! We don't know what name Android will give either, so we get // to search for this manually and remove it. string[] projection = { MediaStore.Images.ImageColumns.Size, MediaStore.Images.ImageColumns.DisplayName, MediaStore.Images.ImageColumns.Data, BaseColumns.Id }; // intialize the Uri and the Cursor, and the current expected size. ICursor c = null; var u = MediaStore.Images.Media.ExternalContentUri; if (_currentFile == null) { return; } // Query the Uri to get the data path. Only if the Uri is valid, // and we had a valid size to be searching for. if ((u != null) && (_currentFile.Length() > 0)) { c = DroidFactory.MainActivity.ManagedQuery(u, projection, null, null, null); } // If we found the cursor and found a record in it (we also have the size). if ((c != null) && c.MoveToFirst()) { do { // Check each previously-built area in the gallery. if (GalleryList.Any(sGallery => string.Equals(sGallery, c.GetString(1), StringComparison.InvariantCultureIgnoreCase))) { continue; } // This is the NEW image. If the size is bigger, copy it. // Then delete it! var f = new File(c.GetString(2)); // Ensure it's there, check size, and delete! if (f.Exists() && (_currentFile.Length() < c.GetLong(0)) && _currentFile.Delete()) { // Finally we can stop the copy. try { FileInputStream source = null; try { source = new FileInputStream(f); var fileContent = new byte[f.Length()]; source.Read(fileContent); iApp.File.Save(_currentFile.AbsolutePath, fileContent, EncryptionMode.NoEncryption); } finally { source?.Close(); } } catch (IOException) { // Could not copy the file over. Toast.MakeText(DroidFactory.MainActivity, iApp.Factory.GetResourceString("ErrorText") ?? "An error occurred. Please try again.", ToastLength.Short).Show(); } } DroidFactory.MainActivity.ContentResolver.Delete(MediaStore.Images.Media.ExternalContentUri, BaseColumns.Id + "=" + c.GetString(3), null); break; }while (c.MoveToNext()); } var id = _currentFile.Name.Remove(_currentFile.Name.LastIndexOf('.')); DroidFactory.Instance.StoreImage(Uri.FromFile(_currentFile), "jpg", id); iApp.File.Delete(_currentFile.Path); if (_callback == null) { return; } DroidFactory.Navigate(new Link(_callback, new Dictionary <string, string> { { CallbackParam, id }, })); _callback = null; }