Example #1
0
        /// <summary>
        /// 删除类
        /// </summary>
        public void deleteClass()
        {
            List <FCGridRow> selectedRows = m_tvCollection.SelectedRows;
            int selectedRowsSize          = selectedRows.Count;

            if (selectedRowsSize > 0)
            {
                if (m_collectionName == "TabPages")
                {
                    FCTabControl tabControl = m_target as FCTabControl;
                    FCTabPage    tabPage    = selectedRows[0].Tag as FCTabPage;
                    m_xml.removeControl(tabPage);
                    m_tvCollection.removeRow(selectedRows[0]);
                    m_tvCollection.update();
                    tabControl.update();
                }
                else if (m_collectionName == "Columns")
                {
                    FCGrid       grid   = m_target as FCGrid;
                    FCGridColumn column = selectedRows[0].Tag as FCGridColumn;
                    grid.removeColumn(column);
                    m_xml.m_controls.Remove(column);
                    m_xml.Nodes[column].ParentNode.RemoveChild(m_xml.Nodes[column]);
                    m_xml.Nodes.Remove(column);
                    m_tvCollection.removeRow(selectedRows[0]);
                    m_tvCollection.update();
                    grid.update();
                }
                Native.invalidate();
                m_designerDiv.saveUndo();
            }
        }
Example #2
0
        /// <summary>
        /// 加载表格的模板
        /// </summary>
        /// <param name="node">节点</param>
        public static void GridTemplate(FCGrid grid, UIXmlEx xml, XmlNode node)
        {
            XmlDocument xmlDoc = node.OwnerDocument;

            grid.Size = new FCSize(200, 200);
            FCGridColumn column = new FCGridColumn("Column1");

            grid.addColumn(column);
            FCGridColumn column2 = new FCGridColumn("Column2");

            grid.addColumn(column2);
            grid.update();
            FCGridRow row = new FCGridRow();

            grid.addRow(row);
            FCGridStringCell cell = new FCGridStringCell();

            cell.setString("Cell1");
            row.addCell(0, cell);
            FCGridStringCell cell2 = new FCGridStringCell();

            cell2.setString("Cell2");
            row.addCell(1, cell2);
            grid.update();
            XmlNode columnsNode = xmlDoc.CreateNode(XmlNodeType.Element, "tr", "");

            node.AppendChild(columnsNode);
            XmlNode column1Node = xmlDoc.CreateNode(XmlNodeType.Element, "th", "");

            column1Node.InnerText = "Column1";
            columnsNode.AppendChild(column1Node);
            XmlNode column2Node = xmlDoc.CreateNode(XmlNodeType.Element, "th", "");

            column2Node.InnerText = "Column2";
            columnsNode.AppendChild(column2Node);
            XmlNode rowNode = xmlDoc.CreateNode(XmlNodeType.Element, "tr", "");

            node.AppendChild(rowNode);
            XmlNode cellNode1 = xmlDoc.CreateNode(XmlNodeType.Element, "td", "");

            rowNode.AppendChild(cellNode1);
            cellNode1.InnerText = "Cell1";
            XmlNode cellNode2 = xmlDoc.CreateNode(XmlNodeType.Element, "td", "");

            rowNode.AppendChild(cellNode2);
            cellNode2.InnerText = "Cell2";
        }
Example #3
0
        /// <summary>
        /// 表格选中行改变方法
        /// </summary>
        public void onGridSelectedRowsChanged()
        {
            ArrayList <FCTreeNode> selectedNodes = m_tvTypes.SelectedNodes;
            int selectedNodesSize = selectedNodes.Count;

            if (selectedNodesSize > 0)
            {
                FCTreeNode            node = selectedNodes[0];
                String                name = node.Name.Replace("node_", "");
                ArrayList <FCGridRow> rows = m_gridTemplate.m_rows;
                int rowsSize = rows.Count;
                ArrayList <FCGridRow> selectedRows = new ArrayList <FCGridRow>();
                if (name.IndexOf('_') != -1)
                {
                    String language = name.Substring(0, name.IndexOf('_'));
                    String platform = name.Substring(name.IndexOf('_') + 1);
                    for (int i = 0; i < rowsSize; i++)
                    {
                        FCGridRow row = rows[i];
                        if (row.getCell("COLT2").getString() == language &&
                            row.getCell("COLT3").getString() == platform)
                        {
                            if (selectedRows.Count == 0)
                            {
                                selectedRows.Add(row);
                            }
                            row.Visible = true;
                        }
                        else
                        {
                            row.Visible = false;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < rowsSize; i++)
                    {
                        FCGridRow row = rows[i];
                        if (row.getCell("COLT2").getString() == name)
                        {
                            if (selectedRows.Count == 0)
                            {
                                selectedRows.Add(row);
                            }
                            row.Visible = true;
                        }
                        else
                        {
                            row.Visible = false;
                        }
                    }
                }
                m_gridTemplate.VScrollBar.Pos = 0;
                m_gridTemplate.SelectedRows   = selectedRows;
                m_gridTemplate.update();
                m_gridTemplate.invalidate();
            }
        }
Example #4
0
 /// <summary>
 /// 拖动中方法
 /// </summary>
 public override void onDragging()
 {
     base.onDragging();
     if (m_grid != null)
     {
         ArrayList <FCGridColumn> columns = m_grid.getColumns();
         int columnSize = columns.size();
         for (int i = 0; i < columnSize; i++)
         {
             FCGridColumn column = columns.get(i);
             if (column == this)
             {
                 FCGridColumn lastColumn = null;
                 FCGridColumn nextColumn = null;
                 int          lastIndex  = i - 1;
                 int          nextIndex  = i + 1;
                 while (lastIndex >= 0)
                 {
                     FCGridColumn thatColumn = columns.get(lastIndex);
                     if (thatColumn.Visible)
                     {
                         lastColumn = thatColumn;
                         break;
                     }
                     else
                     {
                         lastIndex--;
                     }
                 }
                 while (nextIndex < columnSize)
                 {
                     FCGridColumn thatColumn = columns.get(nextIndex);
                     if (thatColumn.Visible)
                     {
                         nextColumn = thatColumn;
                         break;
                     }
                     else
                     {
                         nextIndex++;
                     }
                 }
                 //交换列
                 FCNative native  = Native;
                 int      clientX = native.clientX(this);
                 if (lastColumn != null)
                 {
                     int lastClientX = native.clientX(lastColumn);
                     if (clientX < lastClientX + lastColumn.Width / 2)
                     {
                         columns.set(lastIndex, this);
                         columns.set(i, lastColumn);
                         m_grid.update();
                         break;
                     }
                 }
                 if (nextColumn != null)
                 {
                     int nextClientX = native.clientX(nextColumn);
                     if (clientX + column.Width > nextClientX + nextColumn.Width / 2)
                     {
                         columns.set(nextIndex, this);
                         columns.set(i, nextColumn);
                         m_grid.update();
                         break;
                     }
                 }
                 break;
             }
         }
     }
 }
Example #5
0
        /// <summary>
        /// 添加类
        /// </summary>
        public void addClass()
        {
            XmlDocument xmlDoc = m_xml.XmlDoc;

            if (m_collectionName == "TabPages")
            {
                FCTabControl tabControl = m_target as FCTabControl;
                FCTabPage    tabPage    = new FCTabPage();
                tabControl.addControl(tabPage);
                String newControlName = UITemplate.CreateControlName(tabPage, m_xml);
                tabPage.Name = newControlName;
                tabPage.Text = newControlName;
                XmlNode tabControlNode = m_xml.Nodes[tabControl];
                XmlNode tabpageNode    = m_xml.XmlDoc.CreateNode(XmlNodeType.Element, "div", "");
                tabControlNode.AppendChild(tabpageNode);
                XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name");
                xmlAtr1.Value = tabPage.Text;
                tabpageNode.Attributes.Append(xmlAtr1);
                XmlAttribute xmlAtr2 = xmlDoc.CreateAttribute("text");
                xmlAtr2.Value = tabPage.Text;
                tabpageNode.Attributes.Append(xmlAtr2);
                XmlAttribute xmlAtr3 = xmlDoc.CreateAttribute("type");
                xmlAtr3.Value = "tabpage";
                tabpageNode.Attributes.Append(xmlAtr3);
                m_xml.m_controls.Add(tabPage);
                m_xml.Nodes[tabPage] = tabpageNode;
                FCTreeNode node = new FCTreeNode();
                node.setString(tabPage.Name);
                m_tvCollection.appendNode(node);
                node.Row.Tag = tabPage;
                m_tvCollection.update();
                m_tvCollection.selectNextRow();
                tabControl.update();
            }
            else if (m_collectionName == "Columns")
            {
                FCGrid       grid   = m_target as FCGrid;
                FCGridColumn column = new FCGridColumn();
                grid.addColumn(column);
                String newControlName = UITemplate.CreateControlName(column, m_xml);
                column.Name = newControlName;
                column.Text = newControlName;
                XmlNode gridNode    = m_xml.Nodes[grid];
                XmlNode columnsNode = null;
                foreach (XmlNode subNode in gridNode.ChildNodes)
                {
                    if (subNode.Name.ToLower() == "columns" || subNode.Name.ToLower() == "tr")
                    {
                        columnsNode = subNode;
                        break;
                    }
                }
                if (columnsNode == null)
                {
                    columnsNode = xmlDoc.CreateNode(XmlNodeType.Element, "tr", "");
                    gridNode.AppendChild(columnsNode);
                }
                XmlNode columnNode = m_xml.XmlDoc.CreateNode(XmlNodeType.Element, "th", "");
                columnNode.InnerText = column.Text;
                columnsNode.AppendChild(columnNode);
                XmlAttribute xmlAtr1 = xmlDoc.CreateAttribute("name");
                xmlAtr1.Value = column.Text;
                columnNode.Attributes.Append(xmlAtr1);
                m_xml.m_controls.Add(column);
                m_xml.Nodes[column] = columnNode;
                FCTreeNode node = new FCTreeNode();
                node.setString(column.Name);
                m_tvCollection.appendNode(node);
                node.Row.Tag = column;
                grid.update();
            }
            m_tvCollection.update();
            m_tvCollection.selectNextRow();
            Native.invalidate();
            m_designerDiv.saveUndo();
        }