예제 #1
0
        /// <summary>
        /// Draws the views.
        /// </summary>
        private void DrawViews()
        {
            var availDefs = new List <int> ();

            var rowsToKeep = new IDSGridRowViewCollection();
            int lastIndex  = 0;

            if (mRowStart < 0)
            {
                mRowStart = 0;
            }


            for (int i = mRowStart; i < mParentGrid.Processor.NumberOfRows; i++)
            {
                //var height = (i == 0 && mParentGrid.Theme.HeaderStyle != GridHeaderStyle.None) ? mParentGrid.Theme.HeaderHeight : mParentGrid.Processor.RowHeight;
                //var top = mParentGrid.Processor.TopYForRow (i);

                availDefs.Add(i);
                var aRow = mParentGrid.Processor.Rows.ViewForRowIndex(i);

                if (aRow != null)
                {
                    rowsToKeep.Add(aRow);
                }


                //				if (ShouldShowRow (top, height))
                //				{
                //					availDefs.Add (i);
                //					var aRow = Processor.Rows.ViewForRowIndex (i);
                //
                //					if (aRow != null)
                //						rowsToKeep.Add (aRow);
                //
                //				}
                //				else
                //				{
                //					if (IsAboveScreen (top, height))
                //					{
                //						continue;
                //					}
                //					else if (IsBelowScreen (top, height))
                //					{
                //						lastIndex = i;
                //						break;
                //					}
                //				}
            }

            if (rowsToKeep.Count != 0)
            {
                mRowStart = (lastIndex - rowsToKeep.Count) - 5;
            }

            //find the rows that are no longer need on screen
            var freeRows = (from freeRow in mParentGrid.Processor.Rows
                            where !rowsToKeep.Contains(freeRow)
                            select freeRow).ToList();

            //remove them from the screen and add them to the free rows screen
            foreach (var item in freeRows)
            {
                mContainer.RemoveView(item as DSGridViewContainer);
                mParentGrid.Processor.FreeRows.Add(item);
            }

            mParentGrid.Processor.Rows.Clear();

            mParentGrid.Processor.Rows = rowsToKeep;
            rowsToKeep = null;

            foreach (var index in availDefs)
            {
                //var aRow = Processor.FindViewForRow (index);
                var aRow = mParentGrid.Processor.FindViewForRow(index, (Index) =>
                {
                    return(new DSGridRowView(Index, this.mParentGrid));
                }) as DSGridRowView;

                var height = (index == 0 && mParentGrid.Theme.HeaderStyle != GridHeaderStyle.None) ? mParentGrid.Theme.HeaderHeight : mParentGrid.Processor.RowHeight;
                var top    = mParentGrid.Processor.TopYForRow(index);
                //aRow.Columns = ColDefs;
                //aRow.Frame = new RectangleF (0, top, this.ContentSize.Width, height).Integral ();

                var lp = new DSAbsoluteLayout.DSAbsoluteLayoutParams(LayoutParams.FillParent, Context.ToDevicePixels((int)height), 0, Context.ToDevicePixels((int)top));
                aRow.LayoutParameters = lp;

                if (aRow.Parent == null)
                {
                    aRow.Initialize();

                    mContainer.AddView(aRow, 0);
                }
            }

            //clear unused rows
            availDefs.Clear();
            mParentGrid.Processor.FreeRows.Dispose();
        }
예제 #2
0
		/// <summary>
		/// Draws the views.
		/// </summary>
		private void DrawViews ()
		{
			var availDefs = new List<int> ();

			var rowsToKeep = new IDSGridRowViewCollection ();
			int lastIndex = 0;

			if (mRowStart < 0)
				mRowStart = 0;


			for (int i = mRowStart; i < Processor.NumberOfRows; i++)
			{
				var height = (i == 0 && this.Theme.HeaderStyle != GridHeaderStyle.None) ? this.Theme.HeaderHeight : Processor.RowHeight;
				var top = Processor.TopYForRow (i);

				if (ShouldShowRow (top, height))
				{
					availDefs.Add (i);

					var aRow = Processor.Rows.ViewForRowIndex (i) as DSGridRowView;

					if (aRow != null)
						rowsToKeep.Add (aRow);

				}
				else
				{
					if (IsAboveScreen (top, height))
					{
						continue;
					}
					else if (IsBelowScreen (top, height))
					{
						lastIndex = i;
						break;
					}
				}


			}

			if (rowsToKeep.Count != 0)
				mRowStart = (lastIndex - rowsToKeep.Count) - 5;

			//find the rows that are no longer need on screen
			var freeRows = (from freeRow in Processor.Rows
			                where !rowsToKeep.Contains (freeRow)
			                select freeRow).ToList ();

			//remove them from the screen and add them to the free rows screen
			foreach (var item in freeRows)
			{
				item.DetachView ();
				Processor.FreeRows.Add (item);
			}

			Processor.Rows.Clear ();

			Processor.Rows = rowsToKeep;
			rowsToKeep = null;

			foreach (var index in availDefs)
			{
				var aRow = Processor.FindViewForRow (index, (Index)=>
				{
					return new DSGridRowView (Index, this);
				}) as DSGridRowView;

				var height = (index == 0 && this.Theme.HeaderStyle != GridHeaderStyle.None) ? this.Theme.HeaderHeight : Processor.RowHeight;
				var top = Processor.TopYForRow (index);
				//aRow.Columns = ColDefs;
				aRow.Frame = new CGRect (0, top, this.ContentSize.Width, height).Integral ();

				if (aRow.Superview == null)
				{
					this.InsertSubview (aRow, 0);
				}
			}

			//clear unused rows
			availDefs.Clear ();
			Processor.FreeRows.Dispose ();
		
		}
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DSoft.Datatypes.Grid.Shared.DSGridProcessor"/> class.
 /// </summary>
 public DSGridProcessor()
 {
     Rows     = new IDSGridRowViewCollection();
     FreeRows = new IDSGridRowViewCollection();
 }