protected override void OnElementChanged(ElementChangedEventArgs <IOSWelcomView> e) { base.OnElementChanged(e); if (Control == null) { if (e.OldElement == null) { screenWidth = UIScreen.MainScreen.Bounds.Width; screenHeight = UIScreen.MainScreen.Bounds.Height; InitImages(); AddScrollView(); AddImageViews(); AddPageControl(); AddGoMainButton(); SetDefaultImage(); } else { scrollView.DecelerationEnded -= ScrollView_DecelerationEnded;; scrollView.DraggingStarted -= ScrollView_DraggingStarted;; scrollView.DraggingEnded -= ScrollView_DraggingEnded; scrollView.Dispose(); pageControl.Dispose(); this.Dispose(); } } }
void CleanUpPageControl() { if (pageControl != null) { pageControl.RemoveFromSuperview(); pageControl.Dispose(); pageControl = null; } }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { if (pageController != null) { pageController.DidFinishAnimating -= PageController_DidFinishAnimating; pageController.GetPreviousViewController = null; pageController.GetNextViewController = null; foreach (var child in pageController.ViewControllers) { child.Dispose(); } pageController.Dispose(); pageController = null; } if (pageControl != null) { pageControl.Dispose(); pageControl = null; } if (Element != null) { Element.SizeChanged -= Element_SizeChanged; if (Element.ItemsSource != null && Element.ItemsSource is INotifyCollectionChanged) { ((INotifyCollectionChanged)Element.ItemsSource).CollectionChanged -= ItemsSource_CollectionChanged; } } Source = null; _disposed = true; } try { base.Dispose(disposing); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { if (pageController != null) { pageController.GetPresentationCount = null; pageController.GetPresentationIndex = null; pageController.DidFinishAnimating -= PageController_DidFinishAnimating; pageController.GetPreviousViewController = null; pageController.GetNextViewController = null; foreach (var child in pageController.ViewControllers) { child.Dispose(); } pageController.Dispose(); pageController = null; } if (pageControl != null) { pageControl.Dispose(); pageControl = null; } if (nativeView != null) { nativeView.Dispose(); nativeView = null; } _disposed = true; } try { base.Dispose(disposing); } catch (Exception ex) { return; } }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { if (pageController != null) { pageController.DidFinishAnimating -= PageController_DidFinishAnimating; pageController.GetPreviousViewController = null; pageController.GetNextViewController = null; foreach (var child in pageController.ViewControllers) { child.Dispose(); } pageController.Dispose(); pageController = null; } if (pageControl != null) { pageControl.Dispose(); pageControl = null; } Source = null; _disposed = true; } try { base.Dispose(disposing); } catch (Exception ex) { Console.WriteLine(ex.Message); return; } }
private void setScroll(float w, float h) { heightscroll = h - 45; //this.View.Bounds.Height; widthscroll = w; //this.View.Bounds.Width;; if (sramdom != null) { foreach (UIView v in sramdom) { v.RemoveFromSuperview(); v.Dispose(); } sramdom.RemoveFromSuperview(); sramdom.Dispose(); sramdom = null; } if (pageControl != null) { pageControl.RemoveFromSuperview(); pageControl.Dispose(); pageControl = null; } sramdom = new UIScrollView(new RectangleF(0, 0, widthscroll, heightscroll)); try { if (dataPos.galerias.Count <= 0) { UIImageView imgViewMainImage = new UIImageView(UIImage.FromFile("images/NOIMG.png")); imgViewMainImage.Frame = this.View.Frame; imgViewMainImage.ContentMode = UIViewContentMode.ScaleAspectFit; imgViewMainImage.UserInteractionEnabled = true; this.View.AddSubview(imgViewMainImage); return; } // UIImage image; var sw = this.View.Bounds.Width; //if (w == 1024) // w = 850; pageControl = new UIPageControl(new RectangleF(0, heightscroll - 100, w, 20)); pageControl.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; // vistaImagenes = new UIView (new RectangleF (0, 0, 320 , 367)); //MyScrollView = new UIScrollView (new RectangleF (0, 0,320 , 367)); //pageControl.BackgroundColor = UIColor.Gray;// .Clear ; RectangleF scrollFrame = sramdom.Frame; //MyScrollView.BackgroundColor =UIColor.Green ; //if (gal.Count <= 5) scrollFrame.Width = scrollFrame.Width * dataPos.galerias.Count; //else // scrollFrame.Width = scrollFrame.Width * 5; sramdom.Scrolled += delegate(object sender, EventArgs e) { try { double page = Math.Floor((sramdom.ContentOffset.X - sramdom.Frame.Width / 2) / sramdom.Frame.Width) + 1; pageControl.CurrentPage = (int)page; positionImg = (int)page; } catch { } }; pageControl.ValueChanged += delegate(object sender, EventArgs e) { var pc = (UIPageControl)sender; double fromPage = Math.Floor((sramdom.ContentOffset.X - sramdom.Frame.Width / 2) / sramdom.Frame.Width) + 1; var toPage = pc.CurrentPage; var pageOffset = sramdom.Frame.Width * toPage; if (fromPage > toPage) { pageOffset = sramdom.ContentOffset.X - sramdom.Frame.Width; } PointF p = new PointF(pageOffset, 0); sramdom.SetContentOffset(p, true); //btnaddItinerary.SetTitle ("+ Bookmark", UIControlState.Normal); }; pageControl.Hidden = false; pageControl.Pages = dataPos.galerias.Count; // else // pageControl.Pages = 5;//maximo 5 imagenes sramdom.BackgroundColor = base.headerColor; sramdom.PagingEnabled = true; sramdom.ContentSize = scrollFrame.Size; sramdom.ShowsHorizontalScrollIndicator = false; //sramdom.AutoresizingMask = UIViewAutoresizing.All; RectangleF frame = sramdom.Frame; frame.X = 0; int i = 0; foreach (galeriaImagenes g in dataPos.galerias) { System.Drawing.RectangleF Fr = new System.Drawing.RectangleF(frame.Width * i, 0, widthscroll, heightscroll); UIImageView imgViewMainImage = new UIImageView(); //(UIImage.FromFile("images/"+namebigPicture)); imgViewMainImage.Frame = Fr; imgViewMainImage.ContentMode = UIViewContentMode.ScaleAspectFill; // .ScaleToFill; imgViewMainImage.UserInteractionEnabled = true; imgViewMainImage.Tag = i; sramdom.InsertSubview(imgViewMainImage, 0); object[] on = new object[2]; on [0] = imgViewMainImage; on [1] = g; System.Threading.ThreadPool.QueueUserWorkItem(RequestImage, on); i++; } this.View.AddSubview(sramdom); this.View.AddSubview(pageControl); } catch { } }