/// <summary> /// 获取所有的子表格列 /// </summary> /// <returns>列头集合</returns> public ArrayList <FCBandedFCGridColumn> getAllChildColumns() { ArrayList <FCBandedFCGridColumn> columns = new ArrayList <FCBandedFCGridColumn>(); int columnsSize = m_columns.size(); for (int i = 0; i < columnsSize; i++) { FCBandedFCGridColumn column = m_columns.get(i); columns.add(column); } int bandsSize = m_bands.size(); for (int i = 0; i < bandsSize; i++) { FCGridBand band = m_bands.get(i); ArrayList <FCBandedFCGridColumn> childColumns = band.getAllChildColumns(); int childColumnsSize = childColumns.size(); for (int j = 0; j < childColumnsSize; j++) { FCBandedFCGridColumn childColumn = childColumns[j]; columns.add(childColumn); } } return(columns); }
/// <summary> /// 创建FCGridBand /// </summary> /// <param name="node">节点</param> /// <param name="control">控件</param> protected virtual void createBandedGridBands(XmlNode node, FCView control) { FCGridBand gridBand = control as FCGridBand; foreach (XmlNode subNode in node.ChildNodes) { FCView subControl = createControl(subNode, subNode.Name.ToLower()); FCGridBand band = subControl as FCGridBand; if (band != null) { band.Native = m_native; gridBand.AddBand(band); setAttributesBefore(subNode, band); createBandedGridBands(subNode, band); setAttributesAfter(subNode, band); onAddControl(band, subNode); } FCBandedFCGridColumn bandcolumn = subControl as FCBandedFCGridColumn; if (bandcolumn != null) { bandcolumn.Native = m_native; gridBand.AddColumn(bandcolumn); setAttributesBefore(subNode, bandcolumn); setAttributesAfter(subNode, bandcolumn); onAddControl(bandcolumn, subNode); } } }
/// <summary> /// 移除表格列 /// </summary> /// <param name="column">表格列</param> public void removeColumn(FCBandedFCGridColumn column) { if (m_columns.Contains(column)) { m_columns.remove(column); m_grid.removeColumn(column); } }
/// <summary> /// 移除列头 /// </summary> /// <param name="column">列头</param> public override void removeColumn(FCGridColumn column) { FCBandedFCGridColumn bandedColumn = column as FCBandedFCGridColumn; if (bandedColumn != null) { m_columns.remove(column); removeControl(column); } }
/// <summary> /// 重置列头布局 /// </summary> public virtual void resetHeaderLayout() { int bandsSize = m_bands.size(); FCRect bounds = Bounds; int left = bounds.left; int width = Width; if (bandsSize == 0) { int scrollH = 0; FCHScrollBar hScrollBar = Grid.HScrollBar; if (hScrollBar != null && hScrollBar.Visible) { scrollH = -hScrollBar.Pos; } int columnsSize = m_columns.size(); for (int i = 0; i < columnsSize; i++) { FCBandedFCGridColumn column = m_columns.get(i); if (column.Visible) { int columnWidth = column.Width; if (i == columnsSize - 1 || left + columnWidth > width + bounds.left) { columnWidth = width + bounds.left - left; } FCRect cellRect = new FCRect(left, bounds.bottom, left + columnWidth, bounds.bottom + column.Height); column.Bounds = cellRect; cellRect.left -= scrollH; cellRect.right -= scrollH; column.HeaderRect = cellRect; left += columnWidth; } } } else { for (int i = 0; i < bandsSize; i++) { FCGridBand band = m_bands.get(i); if (band.Visible) { int bandWidth = band.Width; if (i == bandsSize - 1 || left + bandWidth > width + bounds.left) { bandWidth = width + bounds.left - left; } FCRect cellRect = new FCRect(left, bounds.bottom, left + bandWidth, bounds.bottom + band.Height); band.Bounds = cellRect; band.resetHeaderLayout(); left += bandWidth; } } } }
/// <summary> /// 添加列 /// </summary> /// <param name="column">列</param> public override void addColumn(FCGridColumn column) { FCBandedFCGridColumn bandedColumn = column as FCBandedFCGridColumn; if (bandedColumn != null) { column.Grid = this; m_columns.add(column); addControl(column); } }
/// <summary> /// 清除列 /// </summary> public void clearColumns() { int columnsSize = m_columns.size(); for (int i = 0; i < columnsSize; i++) { FCBandedFCGridColumn column = m_columns.get(i); m_grid.removeColumn(column); column.delete(); } m_columns.clear(); }
/// <summary> /// 重新布局 /// </summary> public override void update() { if (!m_lockUpdate) { int bandsSize = m_bands.size(); //清除所有的列 int col = 0; for (int i = 0; i < bandsSize; i++) { FCGridBand band = m_bands.get(i); ArrayList <FCBandedFCGridColumn> childColumns = band.getAllChildColumns(); int childColumnsSize = childColumns.size(); for (int j = 0; j < childColumnsSize; j++) { FCBandedFCGridColumn column = childColumns.get(j); column.Index = col; col++; } } } base.update(); }
/// <summary> /// 插入表格列 /// </summary> /// <param name="index">索引</param> /// <param name="column">表格列</param> public void insertColumn(int index, FCBandedFCGridColumn column) { column.Band = this; m_columns.Insert(index, column); m_grid.addColumn(column); }
/// <summary> /// 添加表格列 /// </summary> /// <param name="column">表格列</param> public void AddColumn(FCBandedFCGridColumn column) { column.Band = this; m_columns.add(column); m_grid.addColumn(column); }
/// <summary> /// 触摸移动方法 /// </summary> /// <param name="touchInfo">触摸信息</param> public override void onTouchMove(FCTouchInfo touchInfo) { callTouchEvents(FCEventID.TOUCHMOVE, touchInfo); FCGrid grid = Grid; if (m_band != null && grid != null) { FCPoint mp = touchInfo.m_firstPoint; if (AllowResize) { ArrayList <FCBandedFCGridColumn> bandColumns = m_band.getColumns(); int columnsSize = bandColumns.size(); int index = -1; int width = Width; for (int i = 0; i < columnsSize; i++) { if (this == bandColumns.get(i)) { index = i; break; } } if (m_resizeState > 0) { FCPoint curPoint = Native.TouchPoint; int newWidth = m_beginWidth + (curPoint.x - m_touchDownPoint.x); if (newWidth > 0) { if (m_resizeState == 1) { FCBandedFCGridColumn leftColumn = bandColumns.get(index - 1); int leftWidth = leftColumn.Width; leftColumn.Width = newWidth; width += leftWidth - newWidth; Width = width; } else if (m_resizeState == 2) { Width = newWidth; FCBandedFCGridColumn rightColumn = bandColumns.get(index + 1); int rightWidth = rightColumn.Width; rightWidth += width - newWidth; rightColumn.Width = rightWidth; } } grid.invalidate(); return; } else { FCCursors oldCursor = Cursor; FCCursors newCursor = oldCursor; if ((index > 0 && mp.x < 5) || (index < columnsSize - 1 && mp.x > width - 5)) { newCursor = FCCursors.SizeWE; } else { newCursor = FCCursors.Arrow; } if (oldCursor != newCursor) { Cursor = newCursor; invalidate(); } } if (!IsDragging) { Cursor = FCCursors.Arrow; } } } }