/// <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> 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> public void ClearBands() { int bandsSize = m_bands.size(); for (int i = 0; i < bandsSize; i++) { FCGridBand band = m_bands.get(i); m_grid.removeControl(band); band.delete(); } m_bands.clear(); }
/// <summary> /// 添加表格带 /// </summary> /// <param name="band">表格带</param> public void addBand(FCGridBand band) { band.Grid = this; m_bands.add(band); int bandSize = m_bands.size(); for (int i = 0; i < bandSize; i++) { m_bands.get(i).Index = i; } addControl(band); }
/// <summary> /// 插入表格带 /// </summary> /// <param name="index">索引</param> /// <param name="band">表格带</param> public void insertBand(int index, FCGridBand band) { band.Grid = this; m_bands.Insert(index, band); int bandSize = m_bands.size(); for (int i = 0; i < bandSize; i++) { m_bands.get(i).Index = i; } addControl(band); }
/// <summary> /// 移除表格带 /// </summary> /// <param name="band">表格带</param> public void removeBand(FCGridBand band) { if (m_bands.Contains(band)) { m_bands.remove(band); int bandSize = m_bands.size(); for (int i = 0; i < bandSize; i++) { m_bands.get(i).Index = i; } m_grid.removeControl(band); } }
/// <summary> /// 重置列头布局 /// </summary> public override void resetHeaderLayout() { int left = 0, top = 0, scrollH = 0; FCHScrollBar hScrollBar = HScrollBar; if (hScrollBar != null && hScrollBar.Visible) { scrollH = -hScrollBar.Pos; } int headerHeight = HeaderVisible ? HeaderHeight : 0; int horizontalOffset = HorizontalOffset; int verticalOffset = VerticalOffset; int bandsSize = m_bands.size(); for (int i = 0; i < bandsSize; i++) { FCGridBand band = m_bands.get(i); if (band.Visible) { int bandHeight = headerHeight < band.Height ? headerHeight : band.Height; FCRect bandRect = new FCRect(left + horizontalOffset, top + verticalOffset, left + horizontalOffset + band.Width, top + bandHeight + verticalOffset); bool hasFrozenColumn = false; ArrayList <FCBandedFCGridColumn> childColumns = band.getAllChildColumns(); int childColumnsSize = childColumns.size(); for (int j = 0; j < childColumnsSize; j++) { if (childColumns.get(j).Frozen) { hasFrozenColumn = true; break; } } if (!hasFrozenColumn) { bandRect.left += scrollH; bandRect.right += scrollH; } band.Bounds = bandRect; band.resetHeaderLayout(); left += band.Width; } } }
/// <summary> /// 设置控件不可见方法 /// </summary> public override void onSetEmptyClipRegion() { //隐藏控件 ArrayList <FCView> controls = m_controls; int controlsSize = controls.size(); FCRect emptyClipRect = new FCRect(); for (int i = 0; i < controlsSize; i++) { FCView control = controls.get(i); FCScrollBar scrollBar = control as FCScrollBar; FCGridColumn gridColumn = control as FCGridColumn; FCGridBand gridBand = control as FCGridBand; if (control != EditTextBox && scrollBar == null && gridColumn == null && gridBand == null) { control.Region = emptyClipRect; } } }
/// <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="touchInfo">触摸信息</param> public override void onTouchMove(FCTouchInfo touchInfo) { base.onTouchMove(touchInfo); if (m_allowResize) { ArrayList <FCGridBand> bands = null; if (m_parentBand != null) { bands = m_parentBand.getBands(); } else { bands = m_grid.getBands(); } int bandsSize = bands.size(); int width = Width; if (m_resizeState > 0) { FCPoint curPoint = Native.TouchPoint; int newWidth = m_beginWidth + (curPoint.x - m_touchDownPoint.x); if (newWidth > 0) { if (m_resizeState == 1) { FCGridBand leftBand = bands[m_index - 1]; int leftWidth = leftBand.Width; leftBand.Width = newWidth; width += leftWidth - newWidth; Width = width; } else if (m_resizeState == 2) { Width = newWidth; if (m_index < bandsSize - 1) { FCGridBand rightBand = bands[m_index + 1]; int rightWidth = rightBand.Width; rightWidth += width - newWidth; rightBand.Width = rightWidth; } else { if (m_grid != null) { m_grid.resetHeaderLayout(); m_grid.update(); } } } } if (m_grid != null) { m_grid.invalidate(); } } else { if ((m_index > 0 && touchInfo.m_firstPoint.x < 5) || ((m_parentBand == null || m_index < bandsSize - 1) && touchInfo.m_firstPoint.x > width - 5)) { Cursor = FCCursors.SizeWE; } else { Cursor = FCCursors.Arrow; } } } }