Exemple #1
0
 /// <summary>
 /// 创建控件
 /// </summary>
 /// <param name="node">节点</param>
 /// <param name="control">控件</param>
 protected virtual void createTableLayoutSubProperty(XmlNode node, FCTableLayoutDiv tableLayoutDiv)
 {
     setAttributesBefore(node, tableLayoutDiv);
     foreach (XmlNode node2 in node.ChildNodes)
     {
         String nodeName2 = node2.Name.ToLower();
         if (nodeName2 == "columnstyles")
         {
             foreach (XmlNode node3 in node2.ChildNodes)
             {
                 String nodeName3 = node3.Name.ToLower();
                 if (nodeName3 == "columnstyle")
                 {
                     FCColumnStyle column = new FCColumnStyle(FCSizeType.PercentSize, 0.0f);
                     tableLayoutDiv.ColumnStyles.add(column);
                     HashMap <String, String> dic = getAttributes(node3);
                     foreach (String str in dic.Keys)
                     {
                         column.setProperty(str, dic.get(str));
                     }
                 }
             }
         }
         else if (nodeName2 == "rowstyles")
         {
             foreach (XmlNode node3 in node2.ChildNodes)
             {
                 String nodeName3 = node3.Name.ToLower();
                 if (nodeName3 == "rowstyle")
                 {
                     FCRowStyle row = new FCRowStyle(FCSizeType.PercentSize, 0.0f);
                     tableLayoutDiv.RowStyles.add(row);
                     HashMap <String, String> dic = getAttributes(node3);
                     foreach (String str in dic.Keys)
                     {
                         row.setProperty(str, dic.get(str));
                     }
                 }
             }
         }
         else if (nodeName2 == "childs")
         {
             //读取子节点
             readChildNodes(node2, tableLayoutDiv);
         }
     }
     setAttributesAfter(node, tableLayoutDiv);
     tableLayoutDiv.update();
     onAddControl(tableLayoutDiv, node);
 }
Exemple #2
0
 /// <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);
 }