/// <summary> /// 获取模板信息 /// </summary> /// <param name="template">模板信息</param> public void GetTemplate(ref SecurityFilterTemplate template) { TextBoxA txtName = GetTextBox("txtName"); TextBoxA txtIndicator = GetTextBox("txtIndicator"); TextBoxA txtParameters = GetTextBox("txtParameters"); ComboBoxA cbCycle = GetComboBox("cbCycle"); ComboBoxA cbSubscription = GetComboBox("cbSubscription"); TextBoxA txtFilter = GetTextBox("txtFilter"); if (m_template.m_templateID != null && m_template.m_templateID.Length > 0) { template.m_templateID = m_template.m_templateID; } template.m_name = txtName.Text; template.m_indicator = txtIndicator.Text; template.m_parameters = txtParameters.Text; if (cbCycle.SelectedValue != null) { template.m_cycle = CStrA.ConvertStrToInt(cbCycle.SelectedValue); } else { template.m_cycle = 1440; } template.m_subscription = cbSubscription.SelectedIndex; template.m_filter = txtFilter.Text; template.m_codes = m_codes; template.m_userID = DataCenter.UserID; }
/// <summary> /// 加载模板 /// </summary> /// <param name="template">模板信息</param> private void LoadTemplate(SecurityFilterTemplate template) { TextBoxA txtName = GetTextBox("txtName"); TextBoxA txtIndicator = GetTextBox("txtIndicator"); TextBoxA txtParameters = GetTextBox("txtParameters"); ComboBoxA cbCycle = GetComboBox("cbCycle"); ComboBoxA cbSubscription = GetComboBox("cbSubscription"); TextBoxA txtFilter = GetTextBox("txtFilter"); ButtonA btnDelete = GetButton("btnDelete"); ButtonA btnRun = GetButton("btnRun"); ButtonA btnWatch = GetButton("btnWatch"); ButtonA btnSave = GetButton("btnSave"); txtName.Text = template.m_name; txtIndicator.Text = template.m_indicator; txtParameters.Text = template.m_parameters; cbCycle.SelectedValue = template.m_cycle.ToString(); cbSubscription.SelectedIndex = template.m_subscription; txtFilter.Text = template.m_filter; m_codes = template.m_codes; bool btnEnabled = (template.m_templateID != null && template.m_templateID.Length > 0); btnDelete.Enabled = btnEnabled; btnRun.Enabled = btnEnabled; btnWatch.Enabled = btnEnabled; btnSave.Enabled = btnEnabled; }
/// <summary> /// 加载宏 /// </summary> /// <param name="macro">宏信息</param> private void LoadMacro(Macro macro) { TextBoxA txtMacroName = GetTextBox("txtMacroName"); TextBoxA txtMacroDescription = GetTextBox("txtMacroDescription"); TextBoxA txtMacroScript = GetTextBox("txtMacroScript"); SpinA spinInterval = GetSpin("spinInterval"); SpinA spinCD = GetSpin("spinCD"); ButtonA btnDelete = GetButton("btnDelete"); ButtonA btnApply = GetButton("btnApply"); ButtonA btnCreate = GetButton("btnCreate"); ButtonA btnSave = GetButton("btnSave"); ComboBoxA cbType = GetComboBox("cbType"); m_divIcon.BackImage = macro.m_icon; txtMacroName.Text = macro.m_name; txtMacroDescription.Text = macro.m_description; txtMacroScript.Text = macro.m_script; spinInterval.Value = macro.m_interval; spinCD.Value = macro.m_cd; cbType.SelectedIndex = macro.m_type; bool btnEnabled = (macro.m_macroID != null && macro.m_macroID.Length > 0); btnDelete.Enabled = btnEnabled; btnSave.Enabled = btnEnabled; }
/// <summary> /// 加载代理信息 /// </summary> private void LoadProxyInfo() { ComboBoxA cbProxyType = GetComboBox("cbProxyType"); TextBoxA txtProxyIP = GetTextBox("txtProxyIP"); SpinA spinProxyPort = GetSpin("spinProxyPort"); TextBoxA txtProxyUserName = GetTextBox("txtProxyUserName"); TextBoxA txtProxyUserPwd = GetTextBox("txtProxyUserPwd"); TextBoxA txtProxyDomain = GetTextBox("txtProxyDomain"); List <ProxyInfo> proxyInfos = new List <ProxyInfo>(); m_proxyService.GetProxyInfos(proxyInfos); int proxyInfosSize = proxyInfos.Count; for (int i = 0; i < proxyInfosSize; i++) { ProxyInfo proxyInfo = proxyInfos[i]; if (cbProxyType.SelectedIndex == proxyInfo.m_type) { txtProxyIP.Enabled = (proxyInfo.m_type == 1 || proxyInfo.m_type == 2); spinProxyPort.Enabled = (proxyInfo.m_type == 1 || proxyInfo.m_type == 2); txtProxyUserName.Enabled = (proxyInfo.m_type == 1 || proxyInfo.m_type == 2 || proxyInfo.m_type == 3); txtProxyUserPwd.Enabled = (proxyInfo.m_type == 1 || proxyInfo.m_type == 2 || proxyInfo.m_type == 3); txtProxyDomain.Enabled = proxyInfo.m_type == 2; txtProxyIP.Text = proxyInfo.m_ip; spinProxyPort.Value = proxyInfo.m_port; txtProxyUserName.Text = proxyInfo.m_name; txtProxyUserPwd.Text = proxyInfo.m_pwd; txtProxyDomain.Text = proxyInfo.m_domain; break; } } m_window.Invalidate(); proxyInfos.Clear(); }
/// <summary> /// 加载数据 /// </summary> public override void LoadData() { //加载连接信息 List <ConnectInfo> connectInfos = new List <ConnectInfo>(); m_connectServer.GetConnects(connectInfos); int connectInfosSize = connectInfos.Count; for (int i = 0; i < connectInfosSize; i++) { ConnectInfo connectInfo = connectInfos[i]; String type = connectInfo.m_type; if (type == "主服务器") { m_cbMainServerIP.Text = connectInfo.m_ip; m_txtMainServerPort.Value = connectInfo.m_port; } } ComboBoxA cbProxyType = GetComboBox("cbProxyType"); List <ProxyInfo> proxyInfos = new List <ProxyInfo>(); m_proxyService.GetProxyInfos(proxyInfos); int proxyInfosSize = proxyInfos.Count; for (int i = 0; i < proxyInfosSize; i++) { ProxyInfo proxyInfo = proxyInfos[i]; if (proxyInfo.m_use) { cbProxyType.SelectedIndex = proxyInfo.m_type; } } }
/// <summary> /// 获取当前的指标 /// </summary> /// <param name="indicator">指标</param> public void GetIndicator(ref Indicator indicator) { //获取控件 TextBoxA txtName = GetTextBox("txtName"); CheckBoxA cbUsePassword = GetCheckBox("cbUsePassword"); TextBoxA txtPassword = GetTextBox("txtPassword"); TextBoxA txtDescription = GetTextBox("txtDescription"); ComboBoxA cbCategory = GetComboBox("cbCategory"); ComboBoxA cbPaintType = GetComboBox("cbPaintType"); ComboBoxA cbDigit = GetComboBox("cbDigit"); TextBoxA txtVersion = GetTextBox("txtVersion"); TextBoxA txtCoordinate = GetTextBox("txtCoordinate"); TextBoxA txtSpecialCoordinate = GetTextBox("txtSpecialCoordinate"); TextBoxA txtText = GetTextBox("txtText"); String parameters = ""; for (int i = 1; i <= 16; i++) { TextBoxA txtPN = GetTextBox("txtPN" + i.ToString()); if (txtPN.Text != null && txtPN.Text.Length > 0) { TextBoxA txtP = GetTextBox("txtP" + i.ToString()); TextBoxA txtPMin = GetTextBox("txtPMin" + i.ToString()); TextBoxA txtPMax = GetTextBox("txtPMax" + i.ToString()); parameters += txtPN.Text + "," + txtPMin.Text + "," + txtPMax.Text + "," + txtP.Text + ";"; } } if (indicator.m_indicatorID == null || indicator.m_indicatorID.Length == 0) { indicator.m_indicatorID = m_indicator.m_indicatorID; } indicator.m_name = txtName.Text; indicator.m_usePassword = cbUsePassword.Checked ? 1 : 0; if (indicator.m_usePassword == 1) { indicator.m_password = txtPassword.Text; } else { indicator.m_password = ""; } indicator.m_description = txtDescription.Text; indicator.m_category = cbCategory.SelectedText; indicator.m_paintType = cbPaintType.SelectedIndex; indicator.m_digit = cbDigit.SelectedIndex; int version = CStr.ConvertStrToInt(txtVersion.Text); indicator.m_version = version; indicator.m_coordinate = txtCoordinate.Text; indicator.m_specialCoordinate = txtSpecialCoordinate.Text; indicator.m_text = txtText.Text; indicator.m_parameters = parameters; indicator.m_userID = DataCenter.UserID; indicator.m_type = 1; }
/// <summary> /// 保存配置 /// </summary> private void SaveData() { List <ConnectInfo> connectInfos = new List <ConnectInfo>(); m_connectServer.GetConnects(connectInfos); int connectInfosSize = connectInfos.Count; for (int i = 0; i < connectInfosSize; i++) { ConnectInfo connectInfo = connectInfos[i]; String type = connectInfo.m_type; if (type == "主服务器") { connectInfo.m_ip = m_cbMainServerIP.Text; connectInfo.m_port = CStr.ConvertStrToInt(m_txtMainServerPort.Text); } m_connectServer.UpdateConnect(connectInfo); } connectInfos.Clear(); //保存代理信息 ComboBoxA cbProxyType = GetComboBox("cbProxyType"); TextBoxA txtProxyIP = GetTextBox("txtProxyIP"); SpinA spinProxyPort = GetSpin("spinProxyPort"); TextBoxA txtProxyUserName = GetTextBox("txtProxyUserName"); TextBoxA txtProxyUserPwd = GetTextBox("txtProxyUserPwd"); TextBoxA txtProxyDomain = GetTextBox("txtProxyDomain"); ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.m_domain = txtProxyDomain.Text; proxyInfo.m_ip = txtProxyIP.Text; proxyInfo.m_port = (int)spinProxyPort.Value; proxyInfo.m_name = txtProxyUserName.Text; proxyInfo.m_pwd = txtProxyUserPwd.Text; proxyInfo.m_type = cbProxyType.SelectedIndex; proxyInfo.m_use = true; List <ProxyInfo> proxyInfos = new List <ProxyInfo>(); m_proxyService.GetProxyInfos(proxyInfos); int proxyInfosSize = proxyInfos.Count; for (int i = 0; i < proxyInfosSize; i++) { ProxyInfo pInfo = proxyInfos[i]; if (cbProxyType.SelectedIndex == pInfo.m_type) { m_proxyService.UpdateConnect(proxyInfo); } else { pInfo.m_use = false; m_proxyService.UpdateConnect(pInfo); } } }
/// <summary> /// 下拉列表选中索引改变事件 /// </summary> /// <param name="comboBox">下拉列表</param> private void OnComboBoxSelectedIndexChanged(ComboBoxA comboBox) { String name = comboBox.Name; if (name == "cbMainServerIP") { String port = comboBox.SelectedValue; m_txtMainServerPort.Value = CStr.ConvertStrToInt(port); } else if (name == "cbProxyType") { LoadProxyInfo(); } }
/// <summary> /// 注册事件 /// </summary> /// <param name="control">控件</param> private void RegisterEvents(ControlA control) { ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickButton); ControlEvent selectedIndexChangedEvent = new ControlEvent(ComboBoxSelectedIndexChanged); List <ControlA> controls = control.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA subControl = controls[i]; GridColumn column = subControl as GridColumn; ButtonA button = subControl as ButtonA; GridA grid = subControl as GridA; ComboBoxA comboBox = subControl as ComboBoxA; if (column != null) { column.AllowResize = true; column.BackColor = CDraw.PCOLORS_BACKCOLOR; column.BorderColor = COLOR.CONTROLBORDER; column.ForeColor = CDraw.PCOLORS_FORECOLOR; } else if (button != null) { button.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (comboBox != null) { comboBox.RegisterEvent(selectedIndexChangedEvent, EVENTID.SELECTEDINDEXCHANGED); } else if (grid != null) { grid.GridLineColor = COLOR.EMPTY; GridRowStyle rowStyle = new GridRowStyle(); grid.RowStyle = rowStyle; rowStyle.BackColor = COLOR.EMPTY; rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; rowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; } RegisterEvents(subControl); } }
/// <summary> /// 获取宏信息 /// </summary> /// <param name="macro">宏信息</param> public void GetMacro(ref Macro macro) { TextBoxA txtMacroName = GetTextBox("txtMacroName"); TextBoxA txtMacroDescription = GetTextBox("txtMacroDescription"); TextBoxA txtMacroScript = GetTextBox("txtMacroScript"); SpinA spinInterval = GetSpin("spinInterval"); SpinA spinCD = GetSpin("spinCD"); if (m_macro.m_macroID != null && m_macro.m_macroID.Length > 0) { macro.m_macroID = m_macro.m_macroID; } ComboBoxA cbType = GetComboBox("cbType"); macro.m_type = cbType.SelectedIndex; macro.m_name = txtMacroName.Text; macro.m_description = txtMacroDescription.Text; macro.m_script = txtMacroScript.Text; macro.m_interval = (int)spinInterval.Value; macro.m_cd = (int)spinCD.Value; macro.m_icon = m_divIcon.BackImage; macro.m_userID = DataCenter.UserID; }
/// <summary> /// 创建内部控件 /// </summary> /// <param name="parent">父控件</param> /// <param name="clsid">控件标识</param> /// <returns>内部控件</returns> public override ControlA CreateInternalControl(ControlA parent, String clsid) { //日历控件 CalendarA calendar = parent as CalendarA; 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 = DockStyleA.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); } } //分割层 SplitLayoutDivA splitLayoutDiv = parent as SplitLayoutDivA; if (splitLayoutDiv != null) { if (clsid == "splitter") { ButtonA splitter = new ButtonA(); splitter.BackColor = CDraw.PCOLORS_BACKCOLOR; splitter.Size = new SIZE(5, 5); return(splitter); } } //滚动条 ScrollBarA scrollBar = parent as ScrollBarA; if (scrollBar != null) { scrollBar.BackColor = COLOR.EMPTY; if (clsid == "addbutton") { RibbonButton addButton = new RibbonButton(); addButton.Size = new SIZE(15, 15); if (scrollBar is HScrollBarA) { addButton.ArrowType = 2; } else if (scrollBar is VScrollBarA) { addButton.ArrowType = 4; } return(addButton); } else if (clsid == "backbutton") { ButtonA backButton = new ButtonA(); return(backButton); } else if (clsid == "scrollbutton") { ButtonA scrollButton = new ButtonA(); scrollButton.AllowDrag = true; scrollButton.BackColor = CDraw.PCOLORS_BACKCOLOR; scrollButton.BorderColor = CDraw.PCOLORS_LINECOLOR3; return(scrollButton); } else if (clsid == "reducebutton") { RibbonButton reduceButton = new RibbonButton(); reduceButton.Size = new SIZE(15, 15); if (scrollBar is HScrollBarA) { reduceButton.ArrowType = 1; } else if (scrollBar is VScrollBarA) { reduceButton.ArrowType = 3; } return(reduceButton); } } //页夹 TabPageA tabPage = parent as TabPageA; if (tabPage != null) { if (clsid == "headerbutton") { RibbonButton button = new RibbonButton(); button.AllowDrag = true; SIZE size = new SIZE(100, 20); button.Size = size; return(button); } } //下拉列表 ComboBoxA comboBox = parent as ComboBoxA; if (comboBox != null) { if (clsid == "dropdownbutton") { RibbonButton dropDownButton = new RibbonButton(); dropDownButton.ArrowType = 4; dropDownButton.DisplayOffset = false; int width = comboBox.Width; int height = comboBox.Height; POINT location = new POINT(width - 20, 0); dropDownButton.Location = location; SIZE size = new SIZE(20, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { ComboBoxMenu comboBoxMenu = new ComboBoxMenu(); comboBoxMenu.ComboBox = comboBox; comboBoxMenu.Popup = true; SIZE size = new SIZE(100, 200); comboBoxMenu.Size = size; return(comboBoxMenu); } } //日期选择 DatePickerA datePicker = parent as DatePickerA; if (datePicker != null) { if (clsid == "dropdownbutton") { RibbonButton dropDownButton = new RibbonButton(); dropDownButton.ArrowType = 4; dropDownButton.DisplayOffset = false; int width = datePicker.Width; int height = datePicker.Height; POINT location = new POINT(width - 16, 0); dropDownButton.Location = location; SIZE size = new SIZE(16, height); dropDownButton.Size = size; return(dropDownButton); } else if (clsid == "dropdownmenu") { MenuA dropDownMenu = new MenuA(); dropDownMenu.Padding = new PADDING(1); dropDownMenu.Popup = true; SIZE size = new SIZE(200, 200); dropDownMenu.Size = size; return(dropDownMenu); } } //数字选择 SpinA spin = parent as SpinA; if (spin != null) { if (clsid == "downbutton") { RibbonButton downButton = new RibbonButton(); downButton.ArrowType = 4; downButton.DisplayOffset = false; SIZE size = new SIZE(16, 16); downButton.Size = size; return(downButton); } else if (clsid == "upbutton") { RibbonButton upButton = new RibbonButton(); upButton.ArrowType = 3; upButton.DisplayOffset = false; SIZE size = new SIZE(16, 16); upButton.Size = size; return(upButton); } } //容器层 DivA div = parent as DivA; if (div != null) { if (clsid == "hscrollbar") { HScrollBarA hScrollBar = new HScrollBarA(); hScrollBar.Visible = false; hScrollBar.Size = new SIZE(15, 15); return(hScrollBar); } else if (clsid == "vscrollbar") { VScrollBarA vScrollBar = new VScrollBarA(); vScrollBar.Visible = false; vScrollBar.Size = new SIZE(15, 15); return(vScrollBar); } } //表格 GridA grid = parent as GridA; if (grid != null) { if (clsid == "edittextbox") { TextBoxA textBox = new TextBoxA(); textBox.BackColor = CDraw.PCOLORS_BACKCOLOR; return(textBox); } } return(null); }
/// <summary> /// 加载指标到界面 /// </summary> public void LoadIndicator(Indicator indicator) { TextBoxA txtName = GetTextBox("txtName"); CheckBoxA cbUsePassword = GetCheckBox("cbUsePassword"); TextBoxA txtPassword = GetTextBox("txtPassword"); TextBoxA txtDescription = GetTextBox("txtDescription"); ComboBoxA cbCategory = GetComboBox("cbCategory"); ComboBoxA cbPaintType = GetComboBox("cbPaintType"); ComboBoxA cbDigit = GetComboBox("cbDigit"); TextBoxA txtVersion = GetTextBox("txtVersion"); TextBoxA txtCoordinate = GetTextBox("txtCoordinate"); TextBoxA txtSpecialCoordinate = GetTextBox("txtSpecialCoordinate"); TextBoxA txtText = GetTextBox("txtText"); ButtonA btnDelete = GetButton("btnDelete"); ButtonA btnSave = GetButton("btnSave"); bool allowEdit = indicator.m_type == 1; int strSize = 0; String[] strs = null; if (indicator.m_parameters != null && indicator.m_parameters.Length > 0) { strs = indicator.m_parameters.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries); strSize = strs.Length; } for (int i = 1; i <= 16; i++) { TextBoxA txtPN = GetTextBox("txtPN" + i.ToString()); TextBoxA txtP = GetTextBox("txtP" + i.ToString()); TextBoxA txtPMin = GetTextBox("txtPMin" + i.ToString()); TextBoxA txtPMax = GetTextBox("txtPMax" + i.ToString()); txtPN.Enabled = allowEdit; txtP.Enabled = allowEdit; txtPMin.Enabled = allowEdit; txtPMax.Enabled = allowEdit; if (i <= strSize) { if (strs[i - 1].Length > 0) { String[] subStrs = strs[i - 1].Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); txtPN.Text = subStrs[0]; txtPMin.Text = subStrs[1]; txtPMax.Text = subStrs[2]; txtP.Text = subStrs[3]; } } else { txtPN.Text = ""; txtP.Text = ""; txtPMin.Text = ""; txtPMax.Text = ""; } } txtName.Text = indicator.m_name; txtName.ReadOnly = !allowEdit; cbUsePassword.Checked = indicator.m_usePassword == 1; cbUsePassword.Enabled = allowEdit; txtPassword.Enabled = cbUsePassword.Checked; txtPassword.Text = indicator.m_password; txtPassword.ReadOnly = !allowEdit; txtDescription.Text = indicator.m_description; txtDescription.ReadOnly = !allowEdit; cbCategory.SelectedText = indicator.m_category; cbCategory.Enabled = allowEdit; cbPaintType.SelectedIndex = indicator.m_paintType; cbPaintType.Enabled = allowEdit; cbDigit.SelectedIndex = indicator.m_digit; cbDigit.Enabled = allowEdit; txtVersion.Text = indicator.m_version.ToString(); txtVersion.ReadOnly = !allowEdit; txtCoordinate.Text = indicator.m_coordinate; txtCoordinate.ReadOnly = !allowEdit; txtSpecialCoordinate.Text = indicator.m_specialCoordinate; txtSpecialCoordinate.ReadOnly = !allowEdit; txtText.Text = indicator.m_text; txtText.ReadOnly = !allowEdit; btnDelete.Enabled = allowEdit; btnSave.Enabled = allowEdit; }
/// <summary> /// 下拉列表选中索引改变事件 /// </summary> /// <param name="sender">调用者</param> private void ComboBoxSelectedIndexChanged(object sender) { ComboBoxA comboBox = sender as ComboBoxA; OnComboBoxSelectedIndexChanged(comboBox); }