/// <summary> /// 是否使用密码 /// </summary> public void ChangeUsePassword() { CheckBoxA cbUsePassword = GetCheckBox("cbUsePassword"); TextBoxA txtPassword = GetTextBox("txtPassword"); txtPassword.Enabled = !cbUsePassword.Checked; txtPassword.Invalidate(); }
/// <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> /// <param name="control">控件</param> private void RegisterEvents(ControlA control) { ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickEvent); List <ControlA> controls = control.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA subControl = controls[i]; ButtonA button = subControl as ButtonA; GridColumn column = subControl as GridColumn; GridA grid = subControl as GridA; CheckBoxA checkBox = subControl as CheckBoxA; if (column != null) { column.AllowResize = true; column.BackColor = CDraw.PCOLORS_BACKCOLOR; column.BorderColor = CDraw.PCOLORS_LINECOLOR2; column.ForeColor = CDraw.PCOLORS_FORECOLOR; } else if (checkBox != null) { checkBox.ButtonBackColor = CDraw.PCOLORS_BACKCOLOR; } else if (button != null) { button.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (grid != null) { grid.BackColor = COLOR.EMPTY; grid.GridLineColor = CDraw.PCOLORS_LINECOLOR2; GridRowStyle rowStyle = new GridRowStyle(); grid.RowStyle = rowStyle; rowStyle.BackColor = COLOR.EMPTY; rowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; rowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; grid.HorizontalOffset = grid.Width; grid.UseAnimation = true; } else { if (subControl.GetControlType() == "Div" || subControl.GetControlType() == "TabControl" || subControl.GetControlType() == "TabPage" || subControl.GetControlType() == "SplitLayoutDiv") { subControl.BackColor = COLOR.EMPTY; } } RegisterEvents(controls[i]); } }
/// 注册事件 /// </summary> /// <param name="control">控件</param> private void RegisterEvents(ControlA control) { ControlMouseEvent clickButtonEvent = new ControlMouseEvent(ClickButton); List <ControlA> controls = control.GetControls(); int controlsSize = controls.Count; for (int i = 0; i < controlsSize; i++) { ControlA subControl = controls[i]; ButtonA button = controls[i] as ButtonA; LinkLabelA linkLabel = subControl as LinkLabelA; GridColumn column = subControl as GridColumn; GridA grid = subControl as GridA; CheckBoxA checkBox = subControl as CheckBoxA; if (column != null) { column.AllowDrag = true; column.AllowResize = true; column.BackColor = CDraw.PCOLORS_BACKCOLOR; column.Font = new FONT("微软雅黑", 12, false, false, false); column.ForeColor = CDraw.PCOLORS_FORECOLOR; } else if (button != null) { button.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (linkLabel != null) { linkLabel.RegisterEvent(clickButtonEvent, EVENTID.CLICK); } else if (grid != null) { grid.GridLineColor = COLOR.CONTROLBORDER; grid.RowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; grid.RowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; grid.RowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; grid.RowStyle.Font = new FONT("微软雅黑", 12, false, false, false); GridRowStyle alternateRowStyle = new GridRowStyle(); alternateRowStyle.BackColor = CDraw.PCOLORS_ALTERNATEROWCOLOR; alternateRowStyle.HoveredBackColor = CDraw.PCOLORS_HOVEREDROWCOLOR; alternateRowStyle.SelectedBackColor = CDraw.PCOLORS_SELECTEDROWCOLOR; alternateRowStyle.SelectedForeColor = CDraw.PCOLORS_FORECOLOR4; alternateRowStyle.Font = new FONT("微软雅黑", 12, false, false, false); grid.AlternateRowStyle = alternateRowStyle; grid.UseAnimation = true; } RegisterEvents(controls[i]); } }
/// <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; }