public static void Reload(this Element element, UITableViewRowAnimation animation = UITableViewRowAnimation.None)
 {
     if (element.GetContainerTableView() == null)
         return;
     var root = element.GetImmediateRootElement();
     if (root != null)
         root.Reload(element, animation);
 }
        public static void Reload(this Element element, UITableViewRowAnimation animation = UITableViewRowAnimation.None)
        {
            if (element.GetContainerTableView() == null)
            {
                return;
            }
            var root = element.GetImmediateRootElement();

            if (root != null)
            {
                root.Reload(element, animation);
            }
        }
Beispiel #3
0
 public void Reset(IEnumerable <Element> elements, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade)
 {
     _elements.Clear();
     _elements.AddRange(elements);
     foreach (var e in _elements)
     {
         e.Section = this;
     }
     if (Root != null && Root.TableView != null)
     {
         Root.TableView.ReloadData();
     }
 }
        private void RemoveRow(Section section, object item, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade)
        {
            RemovePropertyChangedHandler(item);

            var row = section.DataContext.IndexOf(item);

            section.DataContext.Remove(item);

            if (Controller == MonoMobileApplication.CurrentViewController)
            {
                var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) };
                Controller.TableView.DeleteRows(indexPaths, animation);
            }
        }
        public void Remove(Section s, UITableViewRowAnimation anim)
        {
            if (s == null)
            {
                return;
            }
            int idx = Sections.IndexOf(s);

            if (idx == -1)
            {
                return;
            }
            RemoveAt(idx, anim);
        }
        private void ReplaceRow(Section section, object oldItem, object newItem, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade)
        {
            RemovePropertyChangedHandler(oldItem);
            AddPropertyChangedHandler(newItem);

            var row = section.DataContext.IndexOf(oldItem);

            section.DataContext[row] = newItem;

            if (Controller == MonoMobileApplication.CurrentViewController)
            {
                var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) };
                Controller.TableView.ReloadRows(indexPaths, animation);
            }
        }
        /// <summary>
        /// Removes a section at a specified location using the specified animation
        /// </summary>
        /// <param name="idx">
        /// A <see cref="System.Int32"/>
        /// </param>
        /// <param name="anim">
        /// A <see cref="UITableViewRowAnimation"/>
        /// </param>
        public void RemoveAt(int idx, UITableViewRowAnimation anim)
        {
            if (idx < 0 || idx >= Sections.Count)
            {
                return;
            }

            Sections.RemoveAt(idx);

            if (TableView == null)
            {
                return;
            }

            TableView.DeleteSections(NSIndexSet.FromIndex(idx), anim);
        }
Beispiel #8
0
        void InsertVisual(int idx, UITableViewRowAnimation anim, int count)
        {
            if (Root == null || Root.TableView == null)
            {
                return;
            }

            int sidx  = Root.IndexOf(this);
            var paths = new NSIndexPath [count];

            for (int i = 0; i < count; i++)
            {
                paths [i] = NSIndexPath.FromRowSection(idx + i, sidx);
            }
            Root.TableView.InsertRows(paths, anim);
        }
        public override void DeleteRows(NSIndexPath[] atIndexPaths, UITableViewRowAnimation withRowAnimation)
        {
            base.DeleteRows(atIndexPaths, withRowAnimation);

            if (Comparables.Count == 0)
            {
                InsertRows(atIndexPaths, withRowAnimation);
                SetScrollAndSelection();
            }

            OnComparableDeleted.Fire(this, EventArgs.Empty);

            if (atIndexPaths[0].Row == 0)
            {
                UpdateCheapestComparable(Comparables.Count == 0 ? null : Comparables[0]);
            }
        }
Beispiel #10
0
        public void Remove(Element e, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade)
        {
            if (e == null)
            {
                return;
            }

            for (int i = _elements.Count; i > 0;)
            {
                i--;
                if (_elements [i] == e)
                {
                    RemoveRange(i, 1, animation);
                    e.Section = null;
                    return;
                }
            }
        }
Beispiel #11
0
        private void InsertVisual(int idx, UITableViewRowAnimation anim, int count)
        {
            var root = Parent as RootElement;

            if (root?.TableView == null)
            {
                return;
            }

            int sidx  = root.IndexOf(this);
            var paths = new NSIndexPath[count];

            for (int i = 0; i < count; i++)
            {
                paths[i] = NSIndexPath.FromRowSection(idx + i, sidx);
            }

            root.TableView.InsertRows(paths, anim);
        }
Beispiel #12
0
        /// <summary>
        /// Remove a range of elements from the section with the given animation
        /// </summary>
        /// <param name="start">
        /// Starting position
        /// </param>
        /// <param name="count">
        /// Number of elements to remove form the section
        /// </param>
        /// <param name="anim">
        /// The animation to use while removing the elements
        /// </param>
        public void RemoveRange(int start, int count, UITableViewRowAnimation anim)
        {
            if (start < 0 || start >= Elements.Count)
            {
                return;
            }
            if (count == 0)
            {
                return;
            }

            if (start + count > Elements.Count)
            {
                count = Elements.Count - start;
            }

            Elements.RemoveRange(start, count);

            if (Root == null || Root.TableView == null)
            {
                return;
            }

            int sidx  = Root.IndexOf(this as ISection);
            var paths = new NSIndexPath[count];

            for (int i = 0; i < count; i++)
            {
                paths[i] = NSIndexPath.FromRowSection(start + i, sidx);
            }
            Root.TableView.DeleteRows(paths, anim);

            foreach (var element in Elements)
            {
                if (element.Cell != null)
                {
                    element.Cell.SetNeedsDisplay();
                }
            }
        }
        public void Reload(Section section, UITableViewRowAnimation animation)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            if (section.Parent == null || section.Parent != this)
            {
                throw new ArgumentException("Section is not attached to this root");
            }

            int idx = 0;

            foreach (var sect in Sections)
            {
                if (sect == section)
                {
                    TableView.ReloadSections(new NSIndexSet((uint)idx), animation);
                    return;
                }
                idx++;
            }
        }
Beispiel #14
0
        public void Insert(int idx, UITableViewRowAnimation anim, params Section [] newSections)
        {
            if (idx < 0 || idx > _sections.Count)
            {
                return;
            }
            if (newSections == null)
            {
                return;
            }

            _tableView.Get()?.BeginUpdates();

            int pos = idx;

            foreach (var s in newSections)
            {
                s.Root = this;
                _sections.Insert(pos++, s);
            }

            _tableView.Get()?.InsertSections(MakeIndexSet(idx, newSections.Length), anim);
            _tableView.Get()?.EndUpdates();
        }
        protected virtual void ReloadSection(
            nint section,
            [NotNull] NotifyCollectionChangedEventArgs args,
            UITableViewRowAnimation withRowAnimation = UITableViewRowAnimation.Automatic)
        {
            if (args == null)
            {
                throw new ArgumentNullException(nameof(args));
            }

            if (TableViewWeakReference.TryGetTarget(out var tableView))
            {
                switch (args.Action)
                {
                case NotifyCollectionChangedAction.Add:
                    tableView.SupportPerformBatchUpdates(() => tableView.InsertRows(args.ToNewIndexPaths(section), withRowAnimation));
                    break;

                case NotifyCollectionChangedAction.Move:
                    tableView.MoveRow(args.ToOldIndexPath(section), args.ToNewIndexPath(section));
                    break;

                case NotifyCollectionChangedAction.Replace:
                    tableView.SupportPerformBatchUpdates(() => tableView.ReloadRows(args.ToNewIndexPaths(section), withRowAnimation));
                    break;

                case NotifyCollectionChangedAction.Remove:
                    tableView.SupportPerformBatchUpdates(() => tableView.DeleteRows(args.ToOldIndexPaths(section), withRowAnimation));
                    break;

                default:
                    tableView.ReloadSections(NSIndexSet.FromIndex(section), withRowAnimation);
                    break;
                }
            }
        }
Beispiel #16
0
        /// <summary>
        /// Inserts a series of elements into the Section using the specified animation
        /// </summary>
        /// <param name="idx">
        /// The index where the elements are inserted
        /// </param>
        /// <param name="anim">
        /// The animation to use
        /// </param>
        /// <param name="newElements">
        /// A series of elements.
        /// </param>
        public void Insert(int idx, UITableViewRowAnimation anim, params Element [] newElements)
        {
            if (newElements == null)
            {
                return;
            }

            var elements = newElements.Except(_elements);

            int pos     = idx;
            int inserts = 0;

            foreach (var e in elements)
            {
                inserts++;
                _elements.Insert(pos++, e);
                e.SetSection(this);
            }

            if (inserts == 0)
            {
                return;
            }

            if (Root != null && Root.TableView != null)
            {
                if (anim == UITableViewRowAnimation.None)
                {
                    Root.TableView.ReloadData();
                }
                else
                {
                    InsertVisual(idx, anim, inserts);
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Remove a range of elements from the section with the given animation
        /// </summary>
        /// <param name="start">
        /// Starting position
        /// </param>
        /// <param name="count">
        /// Number of elements to remove form the section
        /// </param>
        /// <param name="anim">
        /// The animation to use while removing the elements
        /// </param>
        public void RemoveRange(int start, int count, UITableViewRowAnimation anim)
        {
            if (start < 0 || start >= Elements.Count)
                return;
            if (count == 0)
                return;

            var root = Parent as RootElement;

            if (start + count > Elements.Count)
                count = Elements.Count - start;

            Elements.RemoveRange(start, count);

            if (root == null || root.TableView == null)
                return;

            int sidx = root.IndexOf(this);
            var paths = new NSIndexPath[count];
            for (int i = 0; i < count; i++)
                paths[i] = NSIndexPath.FromRowSection(start + i, sidx);
            root.TableView.DeleteRows(paths, anim);
        }
		/// <summary>
		/// Inserts a single RootElement into the Section using the specified animation
		/// </summary>
		/// <param name="idx">
		/// The index where the elements are inserted
		/// </param>
		/// <param name="anim">
		/// The animation to use
		/// </param>
		/// <param name="newElements">
		/// A series of elements.
		/// </param>
		public void Insert (int idx, UITableViewRowAnimation anim, RootElement newElement)
		{
			Insert (idx, anim, (Element) newElement);
		}
        protected override void ReloadSection(nint section, NotifyCollectionChangedEventArgs args, UITableViewRowAnimation withRowAnimation = UITableViewRowAnimation.Automatic)
        {
            base.ReloadSection(section, args, withRowAnimation);

            if (TableViewWeakReference.TryGetTarget(out var tableView))
            {
                var totalItemsCount = RowsInSection(tableView, DefaultSection);

                foreach (var cell in tableView.VisibleCells)
                {
                    var indexPath = tableView.IndexPathForCell(cell);

                    UpdateCellDevider(cell, indexPath, totalItemsCount);
                }
            }
        }
Beispiel #20
0
        private void InsertVisual(int idx, UITableViewRowAnimation anim, int count)
        {
            var root = Parent as RootElement;

            if (root == null || root.TableView == null)
                return;

            int sidx = root.IndexOf(this);
            var paths = new NSIndexPath[count];
            for (int i = 0; i < count; i++)
                paths[i] = NSIndexPath.FromRowSection(idx + i, sidx);

            root.TableView.InsertRows(paths, anim);
        }
Beispiel #21
0
        /// <summary>
        /// Removes a section at a specified location using the specified animation
        /// </summary>
        /// <param name="idx">
        /// A <see cref="System.Int32"/>
        /// </param>
        /// <param name="anim">
        /// A <see cref="UITableViewRowAnimation"/>
        /// </param>
        public void RemoveAt(int idx, UITableViewRowAnimation anim)
        {
            if (idx < 0 || idx >= Sections.Count)
                return;

            Sections.RemoveAt (idx);

            if (TableView == null)
                return;

            TableView.DeleteSections (NSIndexSet.FromIndex (idx), anim);
        }
Beispiel #22
0
 public virtual void ReloadRowsAtIndexPaths(AnyObject[] indexPaths, UITableViewRowAnimation withRowAnimation)
 {
 }
Beispiel #23
0
 public void Reload(Element element, UITableViewRowAnimation animation)
 {
     if (element == null)
         throw new ArgumentNullException ("element");
     var section = element.Parent as Section;
     if (section == null)
         throw new ArgumentException ("Element is not attached to this root");
     var root = section.Parent as RootElement;
     if (root == null)
         throw new ArgumentException ("Element is not attached to this root");
     var path = element.IndexPath;
     if (path == null)
         return;
     TableView.ReloadRows (new NSIndexPath [] { path }, animation);
 }
Beispiel #24
0
		void InsertVisual(int idx, UITableViewRowAnimation anim, int count)
		{
			if (Root == null || Root.TableView == null)
				return;
			
			int sidx = Root.IndexOf(this as ISection);
			var paths = new NSIndexPath[count];
			for (int i = 0; i < count; i++)
				paths[i] = NSIndexPath.FromRowSection(idx + i, sidx);
			
			Root.TableView.InsertRows(paths, anim);
		}
Beispiel #25
0
//
//		/// <summary>
//		/// Use to add a UIView to a section, it makes the section opaque, to
//		/// get a transparent one, you must manually call UIViewElement
//		public void Add(UIView view)
//		{
//			if (view == null)
//				return;
//			Add(new UIViewElement(null, view, false));
//		}
//
//		/// <summary>
//		///   Adds the UIViews to the section.
//		/// </summary>fparent
//		/// <param name="views">
//		/// An enumarable list that can be produced by something like:
//		///    from x in ... select (UIView) new UIFoo ();
//		/// </param>
//		public void Add(IEnumerable<UIView> views)
//		{
//			foreach (var v in views)
//				Add(v);
//		}

		/// <summary>
		/// Inserts a series of elements into the Section using the specified animation
		/// </summary>
		/// <param name="idx">
		/// The index where the elements are inserted
		/// </param>
		/// <param name="anim">
		/// The animation to use
		/// </param>
		/// <param name="newElements">
		/// A series of elements.
		/// </param>
		public void Insert(int idx, UITableViewRowAnimation anim, params IElement[] newElements)
		{
			if (newElements == null)
				return;
			
			int pos = idx;
			foreach (var e in newElements)
			{
				Elements.Insert(pos++, e);
				e.Parent = this;
			}
			
			if (Root != null && Root.TableView != null)
			{
				if (anim == UITableViewRowAnimation.None)
					Root.TableView.ReloadData();
				else
					InsertVisual(idx, anim, newElements.Length);
			}
		}
Beispiel #26
0
 public virtual void ReloadSections(NSIndexSet sections, UITableViewRowAnimation withRowAnimation)
 {
 }
 public override void InsertRows(NSIndexPath[] atIndexPaths, UITableViewRowAnimation withRowAnimation)
 {
     base.InsertRows(atIndexPaths, withRowAnimation);
 }
 protected abstract void ReloadSections(
     [NotNull] NotifyCollectionChangedEventArgs args,
     UITableViewRowAnimation withRowAnimation = UITableViewRowAnimation.Automatic);
		private void InsertRow(Section section, int row, object item, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade)
		{
			AddPropertyChangedHandler(item);

			section.DataContext.Insert(row, item); 
			
			if (Controller == MonoMobileApplication.CurrentViewController)
			{		
				var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) };
				InvokeOnMainThread(()=> Controller.TableView.InsertRows(indexPaths, animation));
			}
		}
		private void ReplaceRow(Section section, object oldItem, object newItem, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade)
		{
			RemovePropertyChangedHandler(oldItem);
			AddPropertyChangedHandler(newItem);

			var row = section.DataContext.IndexOf(oldItem);

			section.DataContext[row] = newItem;
					
			if (Controller == MonoMobileApplication.CurrentViewController)
			{
				var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) };
				InvokeOnMainThread(()=> Controller.TableView.ReloadRows(indexPaths, animation));
			}
		}
Beispiel #31
0
 public void Remove(Section s, UITableViewRowAnimation anim)
 {
     if (s == null)
         return;
     int idx = Sections.IndexOf (s);
     if (idx == -1)
         return;
     RemoveAt (idx, anim);
 }
Beispiel #32
0
        /// <summary>
        /// Inserts a new section into the RootElement
        /// </summary>
        /// <param name="idx">
        /// The index where the section is added <see cref="System.Int32"/>
        /// </param>
        /// <param name="anim">
        /// The <see cref="UITableViewRowAnimation"/> type.
        /// </param>
        /// <param name="newSections">
        /// A <see cref="Section[]"/> list of sections to insert
        /// </param>
        /// <remarks>
        ///    This inserts the specified list of sections (a params argument) into the
        ///    root using the specified animation.
        /// </remarks>
        public void Insert(int idx, UITableViewRowAnimation anim, params Section [] newSections)
        {
            if (idx < 0 || idx > Sections.Count)
                return;
            if (newSections == null)
                return;

            if (TableView != null)
                TableView.BeginUpdates ();

            int pos = idx;
            foreach (var s in newSections){
                s.Parent = this;
                Sections.Insert (pos++, s);
            }

            if (TableView == null)
                return;

            TableView.InsertSections (MakeIndexSet (idx, newSections.Length), anim);
            TableView.EndUpdates ();
        }
		/// <summary>
		/// Inserts a series of elements into the Section using the specified animation
		/// </summary>
		/// <param name="idx">
		/// The index where the elements are inserted
		/// </param>
		/// <param name="anim">
		/// The animation to use
		/// </param>
		/// <param name="newElements">
		/// A series of elements.
		/// </param>
		public void Insert (int idx, UITableViewRowAnimation anim, params Element [] newElements)
		{
			if (newElements == null)
				return;
			
			int pos = idx;
			foreach (var e in newElements){
				Elements.Insert (pos++, e);
				e.Parent = this;
			}
			
			if (Parent != null)
				InsertVisual (idx, anim, newElements.Length);
		}
Beispiel #34
0
		public int Insert(int idx, UITableViewRowAnimation anim, IEnumerable<IElement> newElements)
		{
			if (newElements == null)
				return 0;
			
			int pos = idx;
			int count = 0;
			foreach (var e in newElements)
			{
				Elements.Insert(pos++, e);
				e.Parent = this;
				count++;
			}

			if (Root != null && Root.TableView != null)
			{
				if (anim == UITableViewRowAnimation.None)
					Root.TableView.ReloadData();
				else
					InsertVisual(idx, anim, pos - idx);
			}
			return count;
		}
Beispiel #35
0
        public void Reload(Section section, UITableViewRowAnimation animation)
        {
            if (section == null)
                throw new ArgumentNullException ("section");
            if (section.Parent == null || section.Parent != this)
                throw new ArgumentException ("Section is not attached to this root");

            int idx = 0;
            foreach (var sect in Sections){
                if (sect == section){
                    TableView.ReloadSections (new NSIndexSet ((uint) idx), animation);
                    return;
                }
                idx++;
            }
        }
Beispiel #36
0
		/// <summary>
		/// Remove a range of elements from the section with the given animation
		/// </summary>
		/// <param name="start">
		/// Starting position
		/// </param>
		/// <param name="count">
		/// Number of elements to remove form the section
		/// </param>
		/// <param name="anim">
		/// The animation to use while removing the elements
		/// </param>
		public void RemoveRange(int start, int count, UITableViewRowAnimation anim)
		{
			if (start < 0 || start >= Elements.Count)
				return;
			if (count == 0)
				return;
			
			if (start + count > Elements.Count)
				count = Elements.Count - start;
			
	//		Elements.RemoveRange(start, count);
			
			if (Root == null || Root.TableView == null)
				return;
			
			int sidx = Root.IndexOf(this as ISection);
			var paths = new NSIndexPath[count];
			for (int i = 0; i < count; i++)
				paths[i] = NSIndexPath.FromRowSection(start + i, sidx);
			Root.TableView.DeleteRows(paths, anim);

			foreach(var element in Elements)
			{
				if (element.Cell != null)
					element.Cell.SetNeedsDisplay();
			}
		}
		private void RemoveRow(Section section, object item, UITableViewRowAnimation animation = UITableViewRowAnimation.Fade)
		{
			RemovePropertyChangedHandler(item);

			var row = section.DataContext.IndexOf(item);
			section.DataContext.Remove(item);
					
			if (Controller == MonoMobileApplication.CurrentViewController)
			{
				var indexPaths = new NSIndexPath[] { NSIndexPath.FromRowSection(row, section.Index) };
				Controller.TableView.DeleteRows(indexPaths, animation);
			}
		}