void BindData() { try { using (FileTrackingContainer container = new FileTrackingContainer()) { var data = (from query in container.Status select new { query.StatusId, query.CreatedDate, query.StatusName }).ToList(); if (data.Count > 0) { FCGrid.DataSource = data; FCGrid.DataBind(); } else { FCGrid.DataSource = new List <DAL.Status>(); FCGrid.DataBind(); } } } catch (Exception e) { } }
/// <summary> /// 注册事件 /// </summary> /// <param name="control">控件</param> private void registerEvents(FCView control) { FCTouchEvent clickButtonEvent = new FCTouchEvent(clickButton); List <FCView> controls = control.getControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { FCView subControl = controls[i]; FCButton button = subControl as FCButton; FCGrid grid = subControl as FCGrid; if (button != null) { button.addEvent(clickButtonEvent, FCEventID.CLICK); } else if (grid != null) { FCGridRowStyle rowStyle = new FCGridRowStyle(); grid.RowStyle = rowStyle; rowStyle.BackColor = FCColor.None; rowStyle.SelectedBackColor = FCDraw.FCCOLORS_SELECTEDROWCOLOR; rowStyle.HoveredBackColor = FCDraw.FCCOLORS_HOVEREDROWCOLOR; rowStyle.SelectedTextColor = FCDraw.FCCOLORS_TEXTCOLOR4; } registerEvents(subControl); } }
/// <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(); } }
/// <summary> /// 控件触摸滚轮滚动方法 /// </summary> /// <param name="touchInfo">触摸信息</param> public virtual void onControlTouchWheel(FCTouchInfo touchInfo) { FCGrid grid = Grid; if (m_control != null && grid != null) { FCTouchInfo newTouchInfo = touchInfo.clone(); newTouchInfo.m_firstPoint = grid.pointToControl(m_control.pointToNative(touchInfo.m_firstPoint)); newTouchInfo.m_secondPoint = grid.pointToControl(m_control.pointToNative(touchInfo.m_secondPoint)); grid.onTouchWheel(newTouchInfo); } }
private void Proc_FC() { FCGrid.set_TextMatrix(0, 1, (string)Comm_Obj_FC.GetSingleData(4)); FCGrid.set_TextMatrix(1, 1, (string)Comm_Obj_FC.GetSingleData(6)); FCGrid.set_TextMatrix(2, 1, (string)Comm_Obj_FC.GetSingleData(7)); FCGrid.set_TextMatrix(3, 1, (string)Comm_Obj_FC.GetSingleData(8)); FCGrid.set_TextMatrix(4, 1, (string)Comm_Obj_FC.GetSingleData(11)); FCGrid.set_TextMatrix(5, 1, (string)Comm_Obj_FC.GetSingleData(12)); FCGrid.set_TextMatrix(6, 1, (string)Comm_Obj_FC.GetSingleData(13)); FCGrid.set_TextMatrix(7, 1, (string)Comm_Obj_FC.GetSingleData(14)); Comm_Obj_FC.RequestRTReg("FC", gFCode); }
/// <summary> /// 移除单元格方法 /// </summary> public override void onRemove() { FCGrid grid = Grid; if (m_control != null && grid != null) { m_control.removeEvent(m_touchDownEvent, FCEventID.TOUCHDOWN); m_control.removeEvent(m_touchMoveEvent, FCEventID.TOUCHMOVE); m_control.removeEvent(m_touchUpEvent, FCEventID.TOUCHUP); m_control.removeEvent(m_touchWheelEvent, FCEventID.TOUCHWHEEL); grid.removeControl(m_control); } }
/// <summary> /// 导出到Txt /// </summary> /// <param name="fileName">文件名</param> /// <param name="grid">表格控件</param> public static void exportToTxt(String fileName, FCGrid grid) { StringBuilder sb = new StringBuilder(); List <FCGridColumn> columns = grid.m_columns; int columnsSize = columns.Count; for (int i = 0; i < columnsSize; i++) { sb.Append(columns[i].Text); if (i != columnsSize - 1) { sb.Append(","); } } List <FCGridRow> rows = grid.m_rows; int rowsSize = rows.Count; List <FCGridRow> visibleRows = new List <FCGridRow>(); for (int i = 0; i < rowsSize; i++) { if (rows[i].Visible) { visibleRows.Add(rows[i]); } } int visibleRowsSize = visibleRows.Count; if (visibleRowsSize > 0) { sb.Append("\r\n"); for (int i = 0; i < visibleRowsSize; i++) { for (int j = 0; j < columnsSize; j++) { FCGridCell cell = visibleRows[i].getCell(j); String cellValue = cell.getString(); sb.Append(cellValue); if (j != columnsSize - 1) { sb.Append(","); } } if (i != visibleRowsSize - 1) { sb.Append("\r\n"); } } } DataCenter.ExportService.ExportHtmlToTxt(fileName, sb.ToString()); }
/// <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"; }
public MainWindow() { InitializeComponent(); this.Comm_Obj_FH.ReceiveData += new AxGIEXPERTCONTROLLib._DGiExpertControlEvents_ReceiveDataEventHandler(this.Comm_Obj_FH_ReceiveData); this.Comm_Obj_FH.ReceiveRTData += new AxGIEXPERTCONTROLLib._DGiExpertControlEvents_ReceiveRTDataEventHandler(this.Comm_Obj_FH_ReceiveRTData); this.Comm_Obj_Order.ReceiveData += new AxGIEXPERTCONTROLLib._DGiExpertControlEvents_ReceiveDataEventHandler(this.Comm_Obj_Order_ReceiveData); this.Comm_Obj_FC.ReceiveData += new AxGIEXPERTCONTROLLib._DGiExpertControlEvents_ReceiveDataEventHandler(this.Comm_Obj_FC_ReceiveData); this.Comm_Obj_FC.ReceiveRTData += new AxGIEXPERTCONTROLLib._DGiExpertControlEvents_ReceiveRTDataEventHandler(this.Comm_Obj_FC_ReceiveRTData); FCGrid.set_TextMatrix(0, 0, "현재가"); FCGrid.set_TextMatrix(1, 0, "등 락"); FCGrid.set_TextMatrix(2, 0, "등락율"); FCGrid.set_TextMatrix(3, 0, "거래량"); FCGrid.set_TextMatrix(4, 0, "미결제"); FCGrid.set_TextMatrix(5, 0, "시 가"); FCGrid.set_TextMatrix(6, 0, "고 가"); FCGrid.set_TextMatrix(7, 0, "저 가"); }
/// <summary> /// 显示 /// </summary> public override void showDialog() { if (m_collectionName == "TabPages") { FCTabControl tabControlA = m_target as FCTabControl; List <FCTabPage> tabPages = tabControlA.getTabPages(); int tabPagesSize = tabPages.Count; for (int i = 0; i < tabPagesSize; i++) { FCTabPage tabPage = tabPages[i]; FCTreeNode node = new FCTreeNode(); node.setString(tabPage.Text); m_tvCollection.appendNode(node); node.Row.Tag = tabPage; } } else if (m_collectionName == "Columns") { FCGrid grid = m_target as FCGrid; List <FCGridColumn> columns = grid.getColumns(); int columnsSize = columns.Count; for (int i = 0; i < columnsSize; i++) { FCGridColumn column = columns[i]; FCTreeNode node = new FCTreeNode(); node.setString(column.Text); m_tvCollection.appendNode(node); node.Row.Tag = column; } } m_tvCollection.update(); m_gridSelectedRowsChangedEvent = new FCEvent(gridSelectedRowsChanged); m_gridProperty.Xml = m_xml; m_gridProperty.DesignerDiv = m_designerDiv; m_tvCollection.addEvent(m_gridSelectedRowsChangedEvent, FCEventID.GRIDSELECTEDROWSCHANGED); if (m_tvCollection.getRows().Count > 0) { ArrayList <FCGridRow> selectedRows = new ArrayList <FCGridRow>(); selectedRows.Add(m_tvCollection.getRow(0)); m_tvCollection.SelectedRows = selectedRows; } base.showDialog(); }
/// <summary> /// 添加控件方法 /// </summary> public override void onLoad() { base.onLoad(); if (m_grid == null) { m_grid = new FCGrid(); m_grid.AutoEllipsis = true; m_grid.GridLineColor = FCColor.None; m_grid.Size = new FCSize(240, 200); m_grid.addEvent(m_gridCellClickEvent, FCEventID.GRIDCELLCLICK); m_grid.addEvent(m_gridKeyDownEvent, FCEventID.KEYDOWN); addControl(m_grid); m_grid.beginUpdate(); //添加列 FCGridColumn securityCodeColumn = new FCGridColumn("股票代码"); securityCodeColumn.BackColor = FCDraw.FCCOLORS_BACKCOLOR; securityCodeColumn.BorderColor = FCColor.None; securityCodeColumn.Font = new FCFont("Simsun", 14, true, false, false); securityCodeColumn.TextColor = FCDraw.FCCOLORS_FORECOLOR; securityCodeColumn.TextAlign = FCContentAlignment.MiddleLeft; securityCodeColumn.Width = 120; m_grid.addColumn(securityCodeColumn); FCGridColumn securityNameColumn = new FCGridColumn("股票名称"); securityNameColumn.BackColor = FCDraw.FCCOLORS_BACKCOLOR; securityNameColumn.BorderColor = FCColor.None; securityNameColumn.Font = new FCFont("Simsun", 14, true, false, false); securityNameColumn.TextColor = FCDraw.FCCOLORS_FORECOLOR; securityNameColumn.TextAlign = FCContentAlignment.MiddleLeft; securityNameColumn.Width = 110; m_grid.addColumn(securityNameColumn); m_grid.endUpdate(); } if (m_searchTextBox == null) { m_searchTextBox = new FCTextBox(); m_searchTextBox.Location = new FCPoint(0, 200); m_searchTextBox.Size = new FCSize(240, 20); m_searchTextBox.Font = new FCFont("SimSun", 16, true, false, false); m_searchTextBox.addEvent(m_textBoxInputChangedEvent, FCEventID.TEXTCHANGED); m_searchTextBox.addEvent(m_textBoxKeyDownEvent, FCEventID.KEYDOWN); addControl(m_searchTextBox); } }
/// <summary> /// 绘制节点 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="rect">区域</param> public virtual void onPaintNode(FCPaint paint, FCRect rect) { if (m_expended) { if (m_tree.ExpendedNodeImage != null && m_tree.ExpendedNodeImage.Length > 0) { paint.drawImage(m_tree.ExpendedNodeImage, rect); return; } } else { if (m_tree.CollapsedNodeImage != null && m_tree.CollapsedNodeImage.Length > 0) { paint.drawImage(m_tree.CollapsedNodeImage, rect); return; } } int width = rect.right - rect.left; int height = rect.bottom - rect.top; FCPoint[] points = new FCPoint[3]; //展开 if (m_expended) { points[0] = new FCPoint(rect.left, rect.top); points[1] = new FCPoint(rect.left + width, rect.top); points[2] = new FCPoint(rect.left + width / 2, rect.top + height); } //折叠 else { points[0] = new FCPoint(rect.left, rect.top); points[1] = new FCPoint(rect.left, rect.top + height); points[2] = new FCPoint(rect.left + width, rect.top + height / 2); } FCGrid grid = Grid; paint.fillPolygon(grid.TextColor, points); }
/// <summary> /// 创建表格列 /// </summary> /// <param name="node">节点</param> /// <param name="control">控件</param> protected virtual void createGridColumns(XmlNode node, FCView control) { FCGrid grid = control as FCGrid; foreach (XmlNode subNode in node.ChildNodes) { FCView subControl = createControl(subNode, subNode.Name.ToLower()); FCGridColumn column = subControl as FCGridColumn; if (column != null) { column.Native = m_native; grid.addColumn(column); } setAttributesBefore(subNode, subControl); readChildNodes(subNode, subControl); setAttributesAfter(subNode, subControl); if (subNode.InnerText.Length > 0) { column.Text = subNode.InnerText; } onAddControl(subControl, subNode); } }
/// <summary> /// 导出到Excel /// </summary> /// <param name="path">路径</param> public static void exportToExcel(String fileName, FCGrid grid) { DataTable dataTable = new DataTable(); List <FCGridColumn> columns = grid.m_columns; int columnsSize = columns.Count; for (int i = 0; i < columnsSize; i++) { dataTable.Columns.Add(new DataColumn(columns[i].Text)); } List <FCGridRow> rows = grid.m_rows; int rowsSize = rows.Count; for (int i = 0; i < rowsSize; i++) { if (rows[i].Visible) { DataRow dr = dataTable.NewRow(); for (int j = 0; j < columnsSize; j++) { FCGridCell cell = grid.m_rows[i].getCell(j); if (cell is FCGridStringCell) { dr[j] = cell.getString(); } else { dr[j] = cell.getDouble(); } } dataTable.Rows.Add(dr); } } DataCenter.ExportService.ExportDataTableToExcel(dataTable, fileName); dataTable.Dispose(); }
/// <summary> /// 重绘方法 /// </summary> /// <param name="paint">绘图对象</param> /// <param name="rect">矩形</param> /// <param name="clipRect">裁剪矩形</param> /// <param name="isAlternate">是否交替行</param> public override void onPaint(FCPaint paint, FCRect rect, FCRect clipRect, bool isAlternate) { int clipW = clipRect.right - clipRect.left; int clipH = clipRect.bottom - clipRect.top; FCGrid grid = Grid; FCGridRow row = Row; if (clipW > 0 && clipH > 0 && grid != null && Column != null && row != null && TargetColumn != null) { int width = rect.right - rect.left; int height = rect.bottom - rect.top; int scrollH = 0; FCHScrollBar hscrollBar = grid.HScrollBar; if (hscrollBar != null && hscrollBar.Visible) { scrollH = hscrollBar.Pos; } FCFont font = null; long backColor = FCColor.None; long textColor = FCColor.None; bool autoEllipsis = m_tree.AutoEllipsis; FCGridCellStyle style = Style; if (style != null) { if (style.AutoEllipsis) { autoEllipsis = style.AutoEllipsis; } backColor = style.BackColor; if (style.Font != null) { font = style.Font; } textColor = style.TextColor; } FCGridRowStyle rowStyle = grid.RowStyle; if (isAlternate) { FCGridRowStyle alternateRowStyle = grid.AlternateRowStyle; if (alternateRowStyle != null) { rowStyle = alternateRowStyle; } } if (rowStyle != null) { bool selected = false; ArrayList <FCGridRow> selectedRows = grid.SelectedRows; int selectedRowsSize = selectedRows.size(); for (int i = 0; i < selectedRowsSize; i++) { if (selectedRows[i] == row) { selected = true; break; } } if (backColor == FCColor.None) { //选中 if (selected) { backColor = rowStyle.SelectedBackColor; } //悬停 else if (Row == Grid.HoveredRow) { backColor = rowStyle.HoveredBackColor; } //普通 else { backColor = rowStyle.BackColor; } } if (font == null) { font = rowStyle.Font; } if (textColor == FCColor.None) { //选中 if (selected) { textColor = rowStyle.SelectedTextColor; } //悬停 else if (Row == Grid.HoveredRow) { textColor = rowStyle.HoveredTextColor; } //普通 else { textColor = rowStyle.TextColor; } } } //绘制背景 paint.fillRect(backColor, rect); FCRect headerRect = TargetColumn.Bounds; headerRect.left += Grid.HorizontalOffset - scrollH; headerRect.top += Grid.VerticalOffset - scrollH; int left = headerRect.left; //绘制复选框 if (m_tree.CheckBoxes) { int cw = m_tree.CheckBoxSize.cx; int ch = m_tree.CheckBoxSize.cy; FCRect checkBoxRect = new FCRect(); checkBoxRect.left = left; checkBoxRect.top = rect.top + (height - ch) / 2; checkBoxRect.right = checkBoxRect.left + cw; checkBoxRect.bottom = checkBoxRect.top + ch; onPaintCheckBox(paint, checkBoxRect); left += cw + 10; } //绘制折叠展开的标志 int nw = m_tree.NodeSize.cx; int nh = m_tree.NodeSize.cy; if (m_nodes.size() > 0) { FCRect nodeRect = new FCRect(); nodeRect.left = left; nodeRect.top = rect.top + (height - nh) / 2; nodeRect.right = nodeRect.left + nw; nodeRect.bottom = nodeRect.top + nh; onPaintNode(paint, nodeRect); } left += nw + 10; m_indent = left; String text = getPaintText(); //绘制文字 if (text != null) { FCSize tSize = paint.textSize(text, font); FCRect tRect = new FCRect(); tRect.left = left; tRect.top = rect.top + (row.Height - tSize.cy) / 2; tRect.right = tRect.left + tSize.cx; tRect.bottom = tRect.top + tSize.cy; if (autoEllipsis && (tRect.right < clipRect.right || tRect.bottom < clipRect.bottom)) { if (tRect.right < clipRect.right) { tRect.right = clipRect.right; } if (tRect.bottom < clipRect.bottom) { tRect.bottom = clipRect.bottom; } paint.drawTextAutoEllipsis(text, textColor, font, tRect); } else { paint.drawText(text, textColor, font, tRect); } } } onPaintControl(paint, rect, clipRect); }
/// <summary> /// 创建子属性 /// </summary> /// <param name="node">节点</param> /// <param name="control">控件</param> public virtual void createSubProperty(XmlNode node, FCView control) { String name = node.Name.ToLower(); String controlType = null; if (control != null) { controlType = control.getControlType(); } if (name == "bands") { if (control is FCBandedGrid) { createBandedGridColumns(node, control); } } else if (name == "columns") { if (control is FCGrid) { createGridColumns(node, control); } } //下拉项 else if (name == "item" || name == "option") { //下拉列表 if (control is FCComboBox) { FCComboBox comboBox = control as FCComboBox; if (comboBox != null) { createMenuItem(node, comboBox.DropDownMenu, null); } } //菜单 else if (control is FCMenu) { FCMenu menu = control as FCMenu; if (menu != null) { createMenuItem(node, menu, null); } } } //树节点 else if (name == "nodes") { if (control is FCTree) { createTreeNodes(node, control); } } //行 else if (name == "rows") { if (control is FCGrid) { createGridRows(node, control); } } //多页夹 else if (name == "tabpage") { if (control is FCTabControl) { createTabPage(node, control); } } else if (name == "tr") { if (control is FCGrid) { FCGrid grid = control as FCGrid; if (grid.m_columns.size() == 0) { createGridColumns(node, control); } else { createGridRow(node, control); } } } }
/// <summary> /// 创建表格行 /// </summary> /// <param name="node">节点</param> /// <param name="control">控件</param> protected virtual void createGridRow(XmlNode node, FCView control) { FCGrid grid = control as FCGrid; FCGridRow row = new FCGridRow(); grid.addRow(row); setAttributesBefore(node, row); //单元格 int col = 0; foreach (XmlNode node3 in node.ChildNodes) { String subNodeName = node3.Name.ToLower(); String subNodeValue = node3.InnerText; if (subNodeName == "cell" || subNodeName == "td") { String cellType = "string"; HashMap <String, String> attributes = getAttributes(node3); if (attributes.containsKey("type")) { cellType = attributes.get("type"); } attributes.clear(); FCGridCell cell = null; if (cellType == "bool") { cell = new FCGridBoolCell(); } else if (cellType == "button") { cell = new FCGridButtonCell(); } else if (cellType == "checkbox") { cell = new FCGridCheckBoxCell(); } else if (cellType == "combobox") { cell = new FCGridComboBoxCell(); } else if (cellType == "double") { cell = new FCGridDoubleCell(); } else if (cellType == "float") { cell = new FCGridFloatCell(); } else if (cellType == "string") { cell = new FCGridStringCell(); } else if (cellType == "int") { cell = new FCGridIntCell(); } else if (cellType == "long") { cell = new FCGridLongCell(); } else if (cellType == "textbox") { cell = new FCGridTextBoxCell(); } row.addCell(col, cell); setAttributesBefore(node3, cell); cell.setString(subNodeValue); setAttributesAfter(node3, cell); col++; } } setAttributesAfter(node, row); }
/// <summary> /// 创建内部控件 /// </summary> /// <param name="parent">父控件</param> /// <param name="clsid">控件标识</param> /// <returns>内部控件</returns> public override FCView createInternalControl(FCView parent, String clsid) { //日历控件 FCCalendar calendar = parent as FCCalendar; if (calendar != null) { if (clsid == "datetitle") { return(new DateTitle(calendar)); } else if (clsid == "headdiv") { HeadDiv headDiv = new HeadDiv(calendar); headDiv.Width = parent.Width; headDiv.Dock = FCDockStyle.Top; return(headDiv); } else if (clsid == "lastbutton") { return(new ArrowButton(calendar)); } else if (clsid == "nextbutton") { ArrowButton nextBtn = new ArrowButton(calendar); nextBtn.ToLast = false; return(nextBtn); } } //分割层 FCSplitLayoutDiv splitLayoutDiv = parent as FCSplitLayoutDiv; if (splitLayoutDiv != null) { if (clsid == "splitter") { FCButton splitter = new FCButton(); splitter.BackColor = FCColor.Border; splitter.BorderColor = FCColor.Border; splitter.Size = new FCSize(5, 5); return(splitter); } } //滚动条 FCScrollBar scrollBar = parent as FCScrollBar; if (scrollBar != null) { scrollBar.BorderColor = FCColor.None; scrollBar.BackColor = FCColor.None; if (clsid == "addbutton") { RibbonButton addButton = new RibbonButton(); addButton.Size = new FCSize(10, 10); if (scrollBar is FCHScrollBar) { addButton.ArrowType = 2; } else if (scrollBar is FCVScrollBar) { addButton.ArrowType = 4; } return(addButton); } else if (clsid == "backbutton") { FCButton backButton = new FCButton(); backButton.BorderColor = FCColor.None; backButton.BackColor = FCColor.None; return(backButton); } else if (clsid == "scrollbutton") { RibbonButton scrollButton = new RibbonButton(); scrollButton.AllowDrag = true; if (scrollBar is FCVScrollBar) { scrollButton.Angle = 0; } return(scrollButton); } else if (clsid == "reducebutton") { RibbonButton reduceButton = new RibbonButton(); reduceButton.Size = new FCSize(10, 10); if (scrollBar is FCHScrollBar) { reduceButton.ArrowType = 1; } else if (scrollBar is FCVScrollBar) { reduceButton.ArrowType = 3; } return(reduceButton); } } //页夹 FCTabPage tabPage = parent as FCTabPage; if (tabPage != null) { if (clsid == "headerbutton") { RibbonButton button = new RibbonButton(); button.AllowDrag = true; FCSize size = new FCSize(100, 20); button.Size = size; return(button); } } //下拉列表 FCComboBox comboBox = parent as FCComboBox; if (comboBox != null) { if (clsid == "dropdownbutton") { RibbonButton dropDownButton = new RibbonButton(); dropDownButton.ArrowType = 4; dropDownButton.DisplayOffset = false; int width = comboBox.Width; int height = comboBox.Height; FCPoint location = new FCPoint(width - 20, 0); dropDownButton.Location = location; FCSize size = new FCSize(20, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { FCComboBoxMenu comboBoxMenu = new FCComboBoxMenu(); comboBoxMenu.ComboBox = comboBox; comboBoxMenu.Popup = true; FCSize size = new FCSize(100, 200); comboBoxMenu.Size = size; return(comboBoxMenu); } } //日期选择 FCDateTimePicker datePicker = parent as FCDateTimePicker; if (datePicker != null) { if (clsid == "dropdownbutton") { RibbonButton dropDownButton = new RibbonButton(); dropDownButton.ArrowType = 4; dropDownButton.DisplayOffset = false; int width = datePicker.Width; int height = datePicker.Height; FCPoint location = new FCPoint(width - 16, 0); dropDownButton.Location = location; FCSize size = new FCSize(16, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { FCMenu dropDownMenu = new FCMenu(); dropDownMenu.Padding = new FCPadding(1); dropDownMenu.Popup = true; FCSize size = new FCSize(200, 200); dropDownMenu.Size = size; return(dropDownMenu); } } //数字选择 FCSpin spin = parent as FCSpin; if (spin != null) { if (clsid == "downbutton") { RibbonButton downButton = new RibbonButton(); downButton.DisplayOffset = false; downButton.ArrowType = 4; FCSize size = new FCSize(16, 16); downButton.Size = size; return(downButton); } else if (clsid == "upbutton") { RibbonButton upButton = new RibbonButton(); upButton.DisplayOffset = false; upButton.ArrowType = 3; FCSize size = new FCSize(16, 16); upButton.Size = size; return(upButton); } } //容器层 FCDiv div = parent as FCDiv; if (div != null) { if (clsid == "hscrollbar") { FCHScrollBar hScrollBar = new FCHScrollBar(); hScrollBar.Visible = false; hScrollBar.Size = new FCSize(10, 10); return(hScrollBar); } else if (clsid == "vscrollbar") { FCVScrollBar vScrollBar = new FCVScrollBar(); vScrollBar.Visible = false; vScrollBar.Size = new FCSize(10, 10); return(vScrollBar); } } //表格 FCGrid grid = parent as FCGrid; if (grid != null) { if (clsid == "edittextbox") { return(new FCTextBox()); } } return(base.createInternalControl(parent, clsid)); }
/// <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(); }
/// <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; } } } }