/// <summary> /// 按钮点击事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="click">点击次数</param> /// <param name="delta">滚轮滚动值</param> private void clickButton(object sender, FCTouchInfo touchInfo) { if (touchInfo.m_firstTouch && touchInfo.m_clicks == 1) { FCView control = sender as FCView; String name = control.Name; if (name == "btnCancel") { close(); } else if (name == "btnOK") { FCTextBox txtName = getTextBox("txtName"); FCTextBox txtScript = getTextBox("txtScript"); List <IndicatorData> indicatorDatas = m_mainFrame.m_indicators; IndicatorData newIndicatorData = null; //判断是否重复 int indicatorDatasSize = indicatorDatas.Count; for (int i = 0; i < indicatorDatasSize; i++) { IndicatorData indicatorData = indicatorDatas[i]; if (indicatorData.m_name == txtName.Text) { if (m_isEdit) { newIndicatorData = indicatorData; } else { MessageBox.Show("该指标名称已经存在!", "提示"); return; } } } //添加指标 if (!m_isEdit) { newIndicatorData = new IndicatorData(); indicatorDatas.Add(newIndicatorData); } newIndicatorData.m_name = txtName.Text; newIndicatorData.m_script = txtScript.Text; String path = Application.StartupPath + "\\indicators.txt"; String content = JsonConvert.SerializeObject(indicatorDatas); FCFile.write(path, content); if (!m_isEdit) { m_mainFrame.addIndicator(newIndicatorData); } close(); Native.update(); Native.invalidate(); } else if (name == "lblDelete") { m_mainFrame.removeIndicator(m_indicatorData); close(); } } }
/// <summary> /// 显示方法 /// </summary> public override void showDialog() { base.showDialog(); FCButton btnOK = getButton("btnOK"); FCButton btnCancel = getButton("btnCancel"); FCLabel lblDelete = getLabel("lblDelete"); if (m_isEdit) { FCTextBox txtName = getTextBox("txtName"); FCTextBox txtScript = getTextBox("txtScript"); txtName.Text = m_indicatorData.m_name; txtScript.Text = m_indicatorData.m_script; txtName.Enabled = false; lblDelete.Visible = true; btnOK.Text = "修改"; m_window.Text = "修改指标"; } else { lblDelete.Visible = false; btnOK.Text = "新增"; m_window.Height -= 50; } Native.invalidate(); }
/// <summary> /// 创建输入框单元格 /// </summary> public FCGridTextBoxCell() { FCTextBox textBox = new FCTextBox(); textBox.BorderColor = FCColor.None; textBox.DisplayOffset = false; Control = textBox; }
/// <summary> /// 浏览文件夹 /// </summary> public void browserDir() { FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog(); if (DialogResult.OK == folderBrowserDialog.ShowDialog()) { FCTextBox txtPath = getTextBox("txtPath"); txtPath.Text = folderBrowserDialog.SelectedPath; txtPath.invalidate(); } }
/// <summary> /// 创建界面 /// </summary> /// <param name="native">方法库</param> public ProjectWindow(FCNative native) { load(native, "ProjectWindow", "windowProject"); //注册点击事件 registerEvents(m_window); m_tvTypes = getTree("tvTypes"); m_gridTemplate = getGrid("gridTemplate"); FCTextBox txtPath = getTextBox("txtPath"); txtPath.Text = DataCenter.GetUserPath(); onGridSelectedRowsChanged(); }
/// <summary> /// 文本框输入 /// </summary> /// <param name="sender">控件</param> private void textBoxInputChanged(object sender) { FCTextBox control = sender as FCTextBox; SearchTextBox = control; filterSearch(); String text = control.Text; if (text != null && text.Length == 0) { Visible = false; } invalidate(); }
/// <summary> /// 显示窗体 /// </summary> /// <param name="var">变量</param> /// <returns>状态</returns> private double SHOWWINDOW(CVariable var) { String xmlName = m_indicator.getText(var.m_parameters[0]); String windowName = m_indicator.getText(var.m_parameters[1]); WindowXmlEx window = new WindowXmlEx(); window.load(m_xml.Native, xmlName, windowName); window.show(); if (xmlName == "HotKeyWindow") { FCTextBox txtKey = window.getTextBox("txtHotKey"); txtKey.Text = "本软件有如下快捷键:\r1. F1-F3 --> 快速出价100-300元\r2. F4-F10 --> 快速伏击400-1000元\r3. F11 --> 出价 \rHome --> 伏击 \rEnd --> 取消出价 \rEnter --> 提交验证码 \rEsc --> 手动断网重连4. 方向键【↑】及【↓】快速调整价格"; } return(0); }
/// <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> public void clearTargets() { //保存上次编辑的控件属性 FCTextBox editTextBox = EditTextBox; if (editTextBox != null) { if (editTextBox.Tag != null) { FCGridCell editingCell = EditTextBox.Tag as FCGridCell; if (editingCell != null) { FCGridCell nameCell = editingCell.Row.getCell("PROPERTYNAME"); if (nameCell != null) { String cellName = nameCell.Name; String cellValue = editTextBox.Text; String eventName = "on" + cellName.ToLower(); int targetsSize = m_targets.Count; for (int i = 0; i < targetsSize; i++) { FCView target = m_targets[i]; if (cellValue == null || cellValue.Trim().Length == 0) { m_xml.removeProperty(target, eventName); } else { m_xml.setProperty(target, eventName, cellValue); } target.update(); } } } } editTextBox.Visible = false; } m_targets.Clear(); }
/// <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 = FCDraw.FCCOLORS_BACKCOLOR; splitter.Size = new FCSize(5, 5); return(splitter); } } //滚动条 FCScrollBar scrollBar = parent as FCScrollBar; if (scrollBar != null) { scrollBar.BackColor = FCColor.None; if (clsid == "addbutton") { RibbonButton addButton = new RibbonButton(); addButton.Size = new FCSize(15, 15); 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(); return(backButton); } else if (clsid == "scrollbutton") { FCButton scrollButton = new FCButton(); scrollButton.AllowDrag = true; scrollButton.BackColor = FCDraw.FCCOLORS_BACKCOLOR; scrollButton.BorderColor = FCDraw.FCCOLORS_LINECOLOR3; return(scrollButton); } else if (clsid == "reducebutton") { RibbonButton reduceButton = new RibbonButton(); reduceButton.Size = new FCSize(15, 15); 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.ArrowType = 4; downButton.DisplayOffset = false; FCSize size = new FCSize(16, 16); downButton.Size = size; return(downButton); } else if (clsid == "upbutton") { RibbonButton upButton = new RibbonButton(); upButton.ArrowType = 3; upButton.DisplayOffset = false; 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(15, 15); return(hScrollBar); } else if (clsid == "vscrollbar") { FCVScrollBar vScrollBar = new FCVScrollBar(); vScrollBar.Visible = false; vScrollBar.Size = new FCSize(15, 15); return(vScrollBar); } } //表格 FCGrid grid = parent as FCGrid; if (grid != null) { if (clsid == "edittextbox") { FCTextBox textBox = new FCTextBox(); textBox.BackColor = FCDraw.FCCOLORS_BACKCOLOR; return(textBox); } } return(base.createInternalControl(parent, clsid)); }