/// <summary> /// 设置属性 /// </summary> /// <param name="name">属性名称</param> /// <param name="value">属性值</param> public virtual void setProperty(String name, String value) { if (name == "sizetype") { String lowerStr = value.ToLower(); if (value == "absolutesize") { m_sizeType = FCSizeType.AbsoluteSize; } else if (value == "autofill") { m_sizeType = FCSizeType.AutoFill; } else if (value == "percentsize") { m_sizeType = FCSizeType.PercentSize; } } else if (name == "height") { Height = FCStr.convertStrToFloat(value); } }
/// <summary> /// 重置布局 /// </summary> public virtual bool OnResetLayout() { if (Native != null) { if (m_columnsCount > 0 && m_rowsCount > 0 && m_columnStyles.size() > 0 && m_rowStyles.size() > 0) { int width = Width, height = Height; int tabControlsSize = m_tableControls.size(); //获取行列的宽度 int[] columnWidths = new int[m_columnsCount]; int[] rowHeights = new int[m_rowsCount]; //获取列的宽度 int allWidth = 0, allHeight = 0; for (int i = 0; i < m_columnsCount; i++) { FCColumnStyle columnStyle = m_columnStyles.get(i); int cWidth = 0; FCSizeType sizeType = columnStyle.SizeType; float sWidth = columnStyle.Width; if (sizeType == FCSizeType.AbsoluteSize) { cWidth = (int)(sWidth); } else if (sizeType == FCSizeType.AutoFill) { cWidth = width - allWidth; } else if (sizeType == FCSizeType.PercentSize) { cWidth = (int)(width * sWidth); } columnWidths[i] = cWidth; allWidth += cWidth; } for (int i = 0; i < m_rowsCount; i++) { FCRowStyle rowStyle = m_rowStyles.get(i); //获取行的高度 int rHeight = 0; FCSizeType sizeType = rowStyle.SizeType; float sHeight = rowStyle.Height; if (sizeType == FCSizeType.AbsoluteSize) { rHeight = (int)(sHeight); } else if (sizeType == FCSizeType.AutoFill) { rHeight = height - allHeight; } else if (sizeType == FCSizeType.PercentSize) { rHeight = (int)(height * sHeight); } rowHeights[i] = rHeight; allHeight += rHeight; } //控制控件的大小和位置 for (int i = 0; i < tabControlsSize; i++) { FCView control = m_tableControls.get(i); int column = m_columns[i]; int row = m_rows[i]; FCPadding margin = control.Margin; //获取横坐标和纵坐标 int cLeft = 0, cTop = 0; for (int j = 0; j < column; j++) { cLeft += columnWidths[j]; } for (int j = 0; j < row; j++) { cTop += rowHeights[j]; } int cRight = cLeft + columnWidths[column] - margin.right; int cBottom = cTop + rowHeights[row] - margin.bottom; cLeft += margin.left; cTop += margin.top; if (cRight < cLeft) { cRight = cLeft; } if (cBottom < cTop) { cBottom = cTop; } control.Bounds = new FCRect(cLeft, cTop, cRight, cBottom); } } } return(true); }
/// <summary> /// 创建列的样式 /// </summary> /// <param name="sizeType">调整大小的类型</param> /// <param name="width">宽度</param> public FCColumnStyle(FCSizeType sizeType, float width) { m_sizeType = sizeType; m_width = width; }
/// <summary> /// 创建行的样式 /// </summary> /// <param name="sizeType">调整大小的类型</param> /// <param name="height">高度</param> public FCRowStyle(FCSizeType sizeType, float height) { m_sizeType = sizeType; m_height = height; }