private void InitList() { try { if (_list == null) return; _list.Clear(); if (image == null && images == null) { //var resa = _MaplocationRequest.GetDbImages(_MaplocationRequest.GetFilterType(), 0, 21).ToArray(); var resa = new List<Image>(); List<ImageInfo> imageInfos = _MaplocationRequest.GetCurrentLoadedImages(); foreach (ImageInfo imgInfo in imageInfos) { if (imgInfo.Img != null) resa.Add(imgInfo.Img); } int count = resa.Count(); img_cnt = count; // "Add photo" Icon /* if (count < 21) img_cnt = count + 1; else img_cnt = count; */ for (int i = 1; i <= img_cnt; i++) { var imgInfo = new ImageInfo() { Index = i }; if (i <= count) { imgInfo.Img = resa[i - 1]; } _list.Add(imgInfo); } } else { if (images == null) { img_cnt = 6; _list.Add(new ImageInfo(){Index = 1, Img = this.image }); } else { img_cnt = Math.Max(images.Count, 6); for (int i = 0; i < images.Count; i++) { var imgInfo = new ImageInfo() { Index = i + 1, Img = images[i] }; _list.Add(imgInfo); } } } } catch (Exception ex) { Util.LogException("InitList", ex); } }
public override void SearchButtonClicked (string text) { if (string.IsNullOrWhiteSpace(text)) return; if (Root.Count > 0) Root[0].Clear(); FinishSearch(); var lw = new LoadingView(); lw.Show("Searching for " + text); NSTimer.CreateScheduledTimer (TimeSpan.FromSeconds (0.1), delegate { SearchMirror.Text = text; SearchedText = text; LastTime = DateTime.MaxValue; var entries = new Section () { }; var images = SearchImages (); _foundImages = images; int rowCount = 4; for (int i = 0; i < images.Count; i += rowCount) { var imagesInfos = new List<ImageInfo>(); for (int j = 0; j < rowCount; j++) { var imgInfo = new ImageInfo() { Img = (i + j < images.Count) ? images[i + j] : null, }; imagesInfos.Add(imgInfo); } entries.Add(new Images2Element(imagesInfos, i)); } var more = new CustomLoadMoreElement (lme => { // Launch a thread to do some work ThreadPool.QueueUserWorkItem (delegate { SearchMoreKeywords(entries, lme); }); }); more.Height = 60; more.Image = Graphics.GetImgResource("more"); entries.Add(more); Root = new RootElement (Locale.GetText ("Search")){ entries, }; ReloadData(); lw.Hide(); }); }
private void AddImageWithName (ImageInfo imageInfo) { try { int position = imageInfo.Index; var view = new UIView () { ContentMode = UIViewContentMode.Center, Frame = new RectangleF ((position - 1) * w, (h - 75) / 2, w, h), }; Image img = imageInfo.Img; var tilingView = new TilingView (img, new SizeF (75, 75)) { ParentFrame = view.Frame, }; tilingView.ParentHolder = view; tilingView.TouchUpInside += HandleTillingViewTouchUpInside; if (img != null) { string title = img.Name ?? "No title"; var location = new CLLocationCoordinate2D (img.Latitude, img.Longitude); var a = new MyAnnotation (location, title, "Evenement") { TV = tilingView, AssocImage = img, }; a.OnAnnotationClicked += AnnotationClicked; mapView.AddAnnotationObject (a); tilingView.Annotation = a; } view.AddSubview (tilingView); scrollView.AddSubview (view); tillingViews.Add(tilingView); photosViews.Add(view); } catch(Exception ex) { Util.LogException("AddImageWithName", ex); } }
private void SearchMoreKeywords(Section entries, CustomLoadMoreElement lme) { try { var images = SearchImages (); _foundImages.AddRange(images); int rowCount = 4; var newElements = new List<Images2Element>(); for (int i = 0; i < images.Count; i += rowCount) { var imagesInfos = new List<ImageInfo>(); for (int j = 0; j < rowCount; j++) { var imgInfo = new ImageInfo() { Img = (i + j < images.Count) ? images[i + j] : null, }; imagesInfos.Add(imgInfo); } newElements.Add(new Images2Element(imagesInfos, i)); } InvokeOnMainThread(()=> { lme.Animating = false; entries.Insert(entries.Count - 1, UITableViewRowAnimation.None, newElements.ToArray()); }); } catch (Exception ex) { Util.LogException("SearchMoreKeywords", ex); } }
private bool InitList(List<Image> resa) { if (resa == null) return false; hasImage = !(_FilterType == FilterType.Friends && resa.Count == 0); if (!Compare(resa, previousList)) return false; previousList = resa; _list.Clear(); int count = resa.Count(); for (int i = 1; i <= 21; i++) { var imgInfo = new ImageInfo() { Index = i }; if (i <= count) { imgInfo.Img = resa[i - 1]; } _list.Add(imgInfo); } return true; }
private void AddMorePhotoElements(CustomLoadMoreElement more, ManualResetEventSlim wait) { try { pageNumber++; var images = _MapLocationRequest.GetDbImages(_FilterType, (pageNumber - 1) * 21, 21); if (images.Count() == 0) { pageNumber--; this.BeginInvokeOnMainThread(delegate { more.Animating = false; }); return; } Image[] resa = images.ToArray(); int count = resa.Count(); for (int i = 1; i <= 21; i++) { var imgInfo = new ImageInfo() { Index = i }; if (i <= count) { imgInfo.Img = resa[i - 1]; } _list.Add(imgInfo); previousList.Add(imgInfo.Img); } // Now make sure we invoke on the main thread the updates this.BeginInvokeOnMainThread(delegate { more.Animating = false; try { for (int i = (pageNumber - 1) * 7; i < pageNumber * 7; i++) { Root[0].Insert(Root[0].Count - 1, new PhotosElement (this, i)); } } catch (Exception ex) { Util.LogException("AddMorePhotoElements InsertElements", ex); } }); //TableView.ScrollToRow (NSIndexPath.FromRowSection (Root[0].Count - 1, 0), UITableViewScrollPosition.Middle, false); } catch (Exception ex) { Util.LogException("AddMorePhotoElements", ex); pageNumber--; // Now make sure we invoke on the main thread the updates this.BeginInvokeOnMainThread(delegate { more.Animating = false; }); } finally { wait.Set(); } }
public void SetEmptyImages() { hasImage = true; previousList = null; pageNumber = 0; _list.Clear(); for (int i = 1; i <= 21; i++) { var imgInfo = new ImageInfo() { Index = i }; _list.Add(imgInfo); } Root[0].RemoveRange(0, Root[0].Count); for (int i = 0; i < 7; i++) { Root[0].Add (new PhotosElement (this, i)); } }
private void Initialize () { var root = new RootElement("search") { new Section() }; int rowCount = 4; for (int i = 0; i < images.Count; i += rowCount) { var imagesInfos = new List<ImageInfo>(); for (int j = 0; j < rowCount; j++) { var imgInfo = new ImageInfo() { Img = (i + j < images.Count) ? images[i + j] : null, }; imagesInfos.Add(imgInfo); } root[0].Add(new Images2Element(imagesInfos, i)); } var mediaView = new DialogViewController(root, false); mediaView.TableView.BackgroundView = new UIImageView(UIImage.FromBundle("Images/Ver4/fond")); mediaView.View.Frame = new RectangleF(0, 45, 320, this.View.Frame.Height - 45); mediaView.TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None; mediaView.Style = UITableViewStyle.Plain; Add(mediaView.View); var view = new UIView(new RectangleF(0, 40 , 320, 1)); view.Layer.BackgroundColor = UIColor.LightGray.CGColor; this.View.AddSubview(view); }