/// <summary> /// Initialize this instance. /// </summary> public void Initialize() { this.SetBackgroundColor(Color.Transparent); this.Orientation = Orientation.Horizontal; foreach (var cel in Processor.Columns) { var cell = Processor.Cells [cel.xPosition] as DSGridCellView; if (cell == null) { cell = new DSGridCellView(GridView, this); Processor.Cells.Add(cell); } cell.Processor.Style = this.Processor.Style; if (Processor.RowIndex != 0) { cell.Processor.IsOdd = (Processor.RowIndex % 2) != 0; } cell.Processor.ColumnIndex = cel.xPosition; cell.Processor.RowIndex = this.Processor.RowIndex; var lp = new LinearLayout.LayoutParams(Context.ToDevicePixels((int)cel.width), LayoutParams.FillParent); lp.Gravity = GravityFlags.DisplayClipHorizontal; cell.LayoutParameters = lp; cell.Processor.IsSelected = Processor.IsSelected; cell.Processor.IsReadOnly = cel.IsReadOnly; //work out the position style cell.Processor.ColumnName = cel.Name; cell.Processor.PositionType = Processor.CalculatePosStyle(cell); cell.Processor.Formatter = cel.Formatter; cell.Processor.SortStyle = cel.SortStyle; cell.Initialize(); if (cell.Parent != null) { if (cell.Parent is ViewGroup) { var par = cell.Parent as ViewGroup; par.RemoveView(cell); } } this.AddView(cell); } }
/// <summary> /// ReDraw the row view /// </summary> private void ReDraw() { foreach (var cel in Processor.Columns) { var cell = Processor.Cells [cel.xPosition] as DSGridCellView; if (cell == null) { cell = new DSGridCellView(GridView, this); Processor.Cells.Add(cell); } cell.Processor.Style = this.Processor.Style; if (Processor.RowIndex != 0) { cell.Processor.IsOdd = (Processor.RowIndex % 2) != 0; } cell.Processor.ColumnIndex = cel.xPosition; cell.Processor.RowIndex = this.Processor.RowIndex; var aRect = cel.Frame.ToRectangleF(); aRect.Height = this.Frame.Height; cell.Frame = aRect.Integral(); cell.Processor.IsSelected = Processor.IsSelected; cell.Processor.ShowSelection = Processor.ShowSelection; cell.Processor.IsReadOnly = cel.IsReadOnly; //work out the position style cell.Processor.ColumnName = cel.Name; cell.Processor.PositionType = Processor.CalculatePosStyle(cell); cell.Processor.Formatter = cel.Formatter; cell.Processor.SortStyle = cel.SortStyle; if (cell.Superview == null) { this.InsertSubview(cell, 0); } } }