// 当命令送达目标后,此方法被调用 private void CbOnExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) { TextBoxA.Clear(); // 避免继续向上传而降低性能 executedRoutedEventArgs.Handled = true; }
/// <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(); }
public void HabilitarCampos(String distribucion) { DesHabilitarCampos(); TextBoxValores.Enabled = true; TextBoxIntervalos.Enabled = true; if (distribucion == "Normal") { Media.Text = "Media"; Desviacion.Text = "Desviacion"; TextBoxMedia.Show(); TextBoxDesviacion.Show(); } else if (distribucion == "Uniforme") { A.Text = "A"; B.Text = "B"; TextBoxA.Show(); TextBoxB.Show(); } else if (distribucion == "Exponencial") { Media.Text = "Media"; TextBoxMedia.Show(); } else if (distribucion == "Poisson") { Lambda.Text = "Lambda"; TextBoxLambda.Show(); } else { } }
/// <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="indicatorList">指标列表窗体</param> /// <param name="cancel">是否取消</param> public void OnIndicatorListWindowClosed(IndicatorList indicatorList, ref bool cancel) { if (indicatorList.IsSubmit) { Indicator indicator = new Indicator(); indicatorList.GetIndicator(ref indicator); TextBoxA txtIndicator = GetTextBox("txtIndicator"); TextBoxA txtParameters = GetTextBox("txtParameters"); txtIndicator.Text = indicator.m_text; if (indicator.m_parameters != null && indicator.m_parameters.Length > 0) { String[] strs = indicator.m_parameters.Split(new String[] { ";" }, StringSplitOptions.RemoveEmptyEntries); int strsSize = strs.Length; String parameters = ""; for (int i = 0; i < strsSize; i++) { if (strs[i].IndexOf(",") != -1) { String[] subStrs = strs[i].Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries); parameters += subStrs[0] + ":" + subStrs[3] + ";"; } } txtParameters.Text = parameters; } else { txtParameters.Text = ""; } } m_window.StartTimer(m_timerID, 100); m_window.Invalidate(); }
/// <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> public void ChangeUsePassword() { CheckBoxA cbUsePassword = GetCheckBox("cbUsePassword"); TextBoxA txtPassword = GetTextBox("txtPassword"); txtPassword.Enabled = !cbUsePassword.Checked; txtPassword.Invalidate(); }
/// <summary> /// 发送聊天内容 /// </summary> public void Send() { TextBoxA txtData = GetTextBox("txtData"); ChatData data = new ChatData(); data.m_text = txtData.Text; data.m_type = 0; data.m_userID = DataCenter.UserID; m_chatService.Send(m_chatService.RequestID, data); }
/// <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); } } }
private void TextBoxA_TextChanged(object sender, EventArgs e) { try { int.Parse(TextBoxA.Text); } catch (Exception exp) { MessageBox.Show(exp.Message); TextBoxA.Clear(); } }
/// <summary> /// 获取布局信息 /// </summary> /// <param name="template">布局信息</param> public void GetLayout(ref IndicatorLayout layout) { TextBoxA txtLayoutName = GetTextBox("txtLayoutName"); LayoutScaleDiv layoutScaleDiv = FindControl("divLayoutScale") as LayoutScaleDiv; if (m_layout.m_layoutID != null && m_layout.m_layoutID.Length > 0) { layout.m_layoutID = m_layout.m_layoutID; } layout.m_name = txtLayoutName.Text; layout.m_text = layoutScaleDiv.LayoutStr; layout.m_userID = DataCenter.UserID; }
/// <summary> /// 销毁方法 /// </summary> public override void Dispose() { if (!IsDisposed) { if (m_gridCategory != null) { m_gridCategory.UnRegisterEvent(m_gridSelectedRowsChangedEvent, EVENTID.GRIDSELECTEDROWSCHANGED); m_gridSelectedRowsChangedEvent = null; m_gridCategory.UnRegisterEvent(m_gridCellEditEndEvent, EVENTID.GRIDCELLEDITEND); m_gridCellEditEndEvent = null; m_gridCategory = null; } if (m_gridSecurities != null) { m_gridSecurities.UnRegisterEvent(m_gridCellClick, EVENTID.GRIDCELLCLICK); m_gridCellClick = null; m_gridSecurities = null; } if (m_quoteService != null) { m_quoteService.UnRegisterListener(m_latestDataRequestID, m_latestDataCallBack); m_latestDataCallBack = null; m_quoteService = null; } m_latestDatas.Clear(); if (m_txtSearch != null) { m_txtSearch.UnRegisterEvent(m_searchTextBoxGotFocus, EVENTID.GOTFOCUS); m_searchTextBoxGotFocus = null; m_txtSearch = null; } if (m_userSecurityService != null) { m_userSecurityService.UnRegisterListener(m_userSecurityService.OperatorRequestID, m_userSecurityDataCallBack); m_userSecurityDataCallBack = null; m_userSecurityService = null; } if (m_window != null) { m_window.UnRegisterEvent(m_invokeEvent, EVENTID.INVOKE); m_invokeEvent = null; m_window.UnRegisterEvent(m_timerEvent, EVENTID.TIMER); m_timerEvent = null; m_window.Close(); m_window.Dispose(); m_window = null; } base.Dispose(); } }
/// <summary> /// 文本框输入 /// </summary> /// <param name="sender">控件</param> private void TextBoxInputChanged(object sender) { TextBoxA control = sender as TextBoxA; 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") { TextBoxA 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); }
public void DesHabilitarCampos() { TextBoxMedia.Hide(); TextBoxA.Hide(); TextBoxB.Hide(); // TextBoxValores.Hide(); //TextBoxIntervalos.Hide(); TextBoxMedia.Hide(); TextBoxDesviacion.Hide(); TextBoxLambda.Hide(); A.Text = ""; B.Text = ""; Lambda.Text = ""; Media.Text = ""; Desviacion.Text = ""; }
/// <summary> /// 登录 /// </summary> public void Login() { DataCenter.LoadData(1); Close(); return; int state = DataCenter.Connect(); if (state == -1) { m_mainFrame.ShowMessageBox("无法连接服务器!", "提示", 0); return; } TabControlA tabLogin = GetTabControl("tabLogin"); TabPageA selectedTabpage = tabLogin.SelectedTabPage; TextBoxA txtUserName = GetTextBox("txtUserName"); TextBoxA txtPassword = GetTextBox("txtPassword"); String userName = txtUserName.Text; String passWord = txtPassword.Text; if (userName.Length == 0) { m_mainFrame.ShowMessageBox("请输入邮箱!", "提示", 0); return; } if (userName.IndexOf("@") == -1) { m_mainFrame.ShowMessageBox("邮箱格式不符合要求!", "提示", 0); return; } if (passWord.Length == 0) { m_mainFrame.ShowMessageBox("请输入密码!", "提示", 0); return; } int ret = m_loginService.Login(userName, passWord, m_loginRequestID); if (ret != -1) { UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); cookie.m_key = "LOGININFO"; cookie.m_value = userName + "," + passWord; cookieService.AddCookie(cookie); m_window.Enabled = false; } }
/// <summary> /// 加载布局 /// </summary> /// <param name="layout">布局信息</param> private void LoadLayout(IndicatorLayout layout) { TextBoxA txtLayoutName = GetTextBox("txtLayoutName"); LayoutScaleDiv layoutScaleDiv = FindControl("divLayoutScale") as LayoutScaleDiv; ButtonA btnDelete = GetButton("btnDelete"); ButtonA btnApply = GetButton("btnApply"); ButtonA btnCreate = GetButton("btnCreate"); ButtonA btnSave = GetButton("btnSave"); txtLayoutName.Text = layout.m_name; layoutScaleDiv.LayoutStr = layout.m_text; bool btnEnabled = (layout.m_layoutID != null && layout.m_layoutID.Length > 0); btnDelete.Enabled = btnEnabled; btnApply.Enabled = btnEnabled; btnSave.Enabled = btnEnabled; }
/// <summary> /// 显示 /// </summary> public override void Show() { UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); if (cookieService.GetCookie("LOGININFO", ref cookie) > 0) { String[] strs = cookie.m_value.Split(','); if (strs.Length >= 2) { TextBoxA txtUserName = GetTextBox("txtUserName"); TextBoxA txtPassword = GetTextBox("txtPassword"); txtUserName.Text = strs[0]; txtPassword.Text = strs[1]; } } base.Show(); }
/// <summary> /// 添加控件方法 /// </summary> public override void OnLoad() { base.OnLoad(); if (m_grid == null) { m_grid = new GridA(); m_grid.AutoEllipsis = true; m_grid.GridLineColor = COLOR.EMPTY; m_grid.Size = new SIZE(240, 200); m_grid.RegisterEvent(m_gridCellClickEvent, EVENTID.GRIDCELLCLICK); m_grid.RegisterEvent(m_gridKeyDownEvent, EVENTID.KEYDOWN); AddControl(m_grid); m_grid.BeginUpdate(); //添加列 GridColumn securityCodeColumn = new GridColumn("股票代码"); securityCodeColumn.BackColor = CDraw.PCOLORS_BACKCOLOR; securityCodeColumn.BorderColor = COLOR.EMPTY; securityCodeColumn.Font = new FONT("Simsun", 14, true, false, false); securityCodeColumn.ForeColor = CDraw.PCOLORS_FORECOLOR; securityCodeColumn.TextAlign = ContentAlignmentA.MiddleLeft; securityCodeColumn.Width = 120; m_grid.AddColumn(securityCodeColumn); GridColumn securityNameColumn = new GridColumn("股票名称"); securityNameColumn.BackColor = CDraw.PCOLORS_BACKCOLOR; securityNameColumn.BorderColor = COLOR.EMPTY; securityNameColumn.Font = new FONT("Simsun", 14, true, false, false); securityNameColumn.ForeColor = CDraw.PCOLORS_FORECOLOR; securityNameColumn.TextAlign = ContentAlignmentA.MiddleLeft; securityNameColumn.Width = 110; m_grid.AddColumn(securityNameColumn); m_grid.EndUpdate(); } if (m_searchTextBox == null) { m_searchTextBox = new TextBoxA(); m_searchTextBox.Location = new POINT(0, 200); m_searchTextBox.Size = new SIZE(240, 20); m_searchTextBox.Font = new FONT("SimSun", 16, true, false, false); m_searchTextBox.RegisterEvent(m_textBoxInputChangedEvent, EVENTID.TEXTCHANGED); m_searchTextBox.RegisterEvent(m_textBoxKeyDownEvent, EVENTID.KEYDOWN); AddControl(m_searchTextBox); } }
/// <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> public override void Show() { UserCookieService cookieService = DataCenter.UserCookieService; UserCookie cookie = new UserCookie(); if (cookieService.GetCookie("LOGININFO", ref cookie) > 0) { String[] strs = cookie.m_value.Split(','); if (strs.Length >= 2) { TextBoxA txtUserName = GetTextBox("txtUserName"); TextBoxA txtPassword = GetTextBox("txtPassword"); txtUserName.Text = strs[0]; txtPassword.Text = strs[1]; } } m_window.Location = new POINT(-m_window.Width, -m_window.Height); m_window.AnimateShow(true); m_window.Invalidate(); m_sky = new Sky(); m_sky.Size = new SIZE(m_window.Width, 200); m_window.Frame.AddControl(m_sky); m_window.RegisterEvent(new ControlEvent(WindowLocationChanged), EVENTID.LOCATIONCHANGED); }
/// <summary> /// 发送全体消息 /// </summary> private void SendAll() { byte[] fileBytes = null; RadioButtonA rbBarrage = GetRadioButton("rbBarrage"); RadioButtonA rbText = GetRadioButton("rbText"); RadioButtonA rbFile = GetRadioButton("rbFile"); RadioButtonA rbAttention = GetRadioButton("rbAttention"); String text = GetTextBox("txtSend").Text; String sayText = text; if (rbFile.Checked) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { text = "sendfile('" + new FileInfo(openFileDialog.FileName).Name + "');"; fileBytes = File.ReadAllBytes(openFileDialog.FileName); sayText = text; } else { return; } } else { if (text == null || text.Trim().Length == 0) { MessageBox.Show("请输入你想说的内容!", "提示"); } } if (rbBarrage.Checked) { text = "addbarrage('" + text + "');"; } else if (rbText.Checked) { text = "addtext('" + text + "');"; } else if (rbAttention.Checked) { text = "how('" + GetTextBox("txtUserName").Text + "喊:" + text + "');"; } ChatData chatData = new ChatData(); chatData.m_content = text; if (fileBytes != null) { chatData.m_body = fileBytes; chatData.m_bodyLength = fileBytes.Length; } chatData.m_from = DataCenter.UserName; DataCenter.SendAll(chatData); if (rbBarrage.Checked) { CIndicator indicator = CFunctionEx.CreateIndicator("", text, this); indicator.Clear(); indicator.Dispose(); } TextBoxA txtReceive = GetTextBox("txtReceive"); txtReceive.Text += "我说:\r\n" + sayText + "\r\n"; txtReceive.Invalidate(); if (txtReceive.VScrollBar != null && txtReceive.VScrollBar.Visible) { txtReceive.VScrollBar.ScrollToEnd(); txtReceive.Update(); txtReceive.Invalidate(); } }
/// <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> /// <param name="args">参数</param> public void Invoke(object sender, object args) { CMessage message = args as CMessage; if (message != null) { if (message.m_serviceID == ChatService.SERVICEID_CHAT) { if (message.m_functionID == ChatService.FUNCTIONID_SENDALL) { ChatData chatData = new ChatData(); ChatService.GetChatData(chatData, message.m_body, message.m_bodyLength); CIndicator indicator = CFunctionEx.CreateIndicator2("", chatData, this); indicator.Clear(); indicator.Dispose(); } else if (message.m_functionID == ChatService.FUNCTIONID_GETHOSTS) { List <ChatHostInfo> datas = new List <ChatHostInfo>(); int type = 0; ChatService.GetHostInfos(datas, ref type, message.m_body, message.m_bodyLength); if (type != 2) { int datasSize = datas.Count; for (int i = 0; i < datasSize; i++) { ChatHostInfo hostInfo = datas[i]; List <GridRow> rows = m_gridHosts.m_rows; int rowsSize = rows.Count; bool containsRow = false; for (int j = 0; j < rowsSize; j++) { GridRow oldRow = rows[j]; if (oldRow.GetCell("colP1").GetString() == hostInfo.m_ip && oldRow.GetCell("colP2").GetInt() == hostInfo.m_serverPort) { containsRow = true; } } if (!containsRow) { if (hostInfo.m_type == 1) { String key = hostInfo.m_ip + ":" + hostInfo.m_serverPort; ChatService newServerService = DataCenter.GetClientChatService(key); if (newServerService == null) { newServerService = new ChatService(); newServerService.ServerIP = hostInfo.m_ip; newServerService.ServerPort = hostInfo.m_serverPort; newServerService.ToServer = true; BaseService.AddService(newServerService); DataCenter.AddClientChatService(key, newServerService); } } else { GridRow row = new GridRow(); m_gridHosts.AddRow(row); row.AddCell("colP1", new GridStringCell(hostInfo.m_ip)); row.AddCell("colP2", new GridIntCell(hostInfo.m_serverPort)); if (hostInfo.m_type == 1) { row.AddCell("colP3", new GridStringCell("--")); row.AddCell("colP4", new GridStringCell("--")); } else { row.AddCell("colP3", new GridStringCell(hostInfo.m_userID)); row.AddCell("colP4", new GridStringCell(hostInfo.m_userName)); } row.AddCell("colP5", new GridStringCell(hostInfo.m_type == 1 ? "服务器" : "客户端")); } } } } else { Dictionary <String, String> removeHosts = new Dictionary <String, String>(); foreach (ChatHostInfo hostInfo in datas) { removeHosts[hostInfo.ToString()] = ""; } List <GridRow> rows = m_gridHosts.m_rows; int rowsSize = rows.Count; if (rowsSize > 0) { for (int i = 0; i < rowsSize; i++) { GridRow row = rows[i]; String key = row.GetCell("colP1").GetString() + ":" + row.GetCell("colP2").GetString(); if (removeHosts.ContainsKey(key)) { m_gridHosts.RemoveRow(row); i--; rowsSize--; } } } } SetHostGridRowVisible(); } else if (message.m_functionID == ChatService.FUNCTIONID_SEND) { ChatData chatData = new ChatData(); ChatService.GetChatData(chatData, message.m_body, message.m_bodyLength); CIndicator indicator = CFunctionEx.CreateIndicator2("", chatData, this); indicator.Clear(); indicator.Dispose(); } } } String newStr = args as String; if (newStr != null) { if (newStr == "showchat") { FlashWindow(m_mainForm.Handle, true); SetForegroundWindow(m_mainForm.Handle); } else if (newStr == "shake") { m_mainForm.Play(); } else if (newStr.StartsWith("how:")) { String text = newStr.Substring(4); Barrage barrage = new Barrage(); barrage.Text = text; barrage.Mode = 1; m_barrageForm.BarrageDiv.AddBarrage(barrage); } else { TextBoxA txtReceive = GetTextBox("txtReceive"); txtReceive.Text += newStr; txtReceive.Invalidate(); if (txtReceive.VScrollBar != null && txtReceive.VScrollBar.Visible) { txtReceive.VScrollBar.ScrollToEnd(); txtReceive.Update(); txtReceive.Invalidate(); } } } }
/// <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> private void Send(List <GridRow> rows) { byte[] fileBytes = null; String text = GetTextBox("txtSend").Text; RadioButtonA rbBarrage = GetRadioButton("rbBarrage"); RadioButtonA rbText = GetRadioButton("rbText"); RadioButtonA rbFile = GetRadioButton("rbFile"); RadioButtonA rbAttention = GetRadioButton("rbAttention"); String sayText = text; if (rbFile.Checked) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { text = "sendfile('" + new FileInfo(openFileDialog.FileName).Name + "');"; fileBytes = File.ReadAllBytes(openFileDialog.FileName); sayText = text; } else { return; } } else { if (text == null || text.Trim().Length == 0) { MessageBox.Show("请输入你想说的内容!", "提示"); } } if (rbBarrage.Checked) { text = "addbarrage('" + text + "');"; } else if (rbText.Checked) { text = "addtext('" + text + "');"; } else if (rbAttention.Checked) { text = "how('" + GetTextBox("txtUserName").Text + "喊:" + text + "');"; } int rowsSize = rows.Count; bool sendAll = false; if (rowsSize > 0) { for (int i = 0; i < rowsSize; i++) { GridRow thisRow = rows[i]; String ip = thisRow.GetCell("colP1").GetString(); int port = thisRow.GetCell("colP2").GetInt(); String userID = thisRow.GetCell("colP3").GetString(); ChatService chatService = null; String key = ip + ":" + CStr.ConvertIntToStr(port); chatService = DataCenter.GetClientChatService(key); if (chatService != null) { if (!chatService.Connected) { int socketID = OwLib.BaseService.Connect(ip, port); if (socketID != -1) { chatService.Connected = true; chatService.SocketID = socketID; chatService.Enter(); } else { sendAll = true; } } } else { int type = thisRow.GetCell("colP5").GetInt(); if (type == 1) { continue; } else { int socketID = OwLib.BaseService.Connect(ip, port); if (socketID != -1) { chatService = new ChatService(); chatService.SocketID = socketID; chatService.ServerIP = ip; chatService.ServerPort = port; chatService.ToServer = false; DataCenter.AddClientChatService(key, chatService); BaseService.AddService(chatService); } else { sendAll = true; } } } ChatData chatData = new ChatData(); chatData.m_content = text; if (fileBytes != null) { chatData.m_body = fileBytes; chatData.m_bodyLength = fileBytes.Length; } chatData.m_from = DataCenter.UserName; if (sendAll) { chatData.m_to = userID; DataCenter.SendAll(chatData); } else { chatService.Send(chatData); } if (rbBarrage.Checked) { CIndicator indicator = CFunctionEx.CreateIndicator("", text, this); indicator.Clear(); indicator.Dispose(); } TextBoxA txtReceive = GetTextBox("txtReceive"); txtReceive.Text += "我说:\r\n" + sayText + "\r\n"; txtReceive.Invalidate(); if (txtReceive.VScrollBar != null && txtReceive.VScrollBar.Visible) { txtReceive.VScrollBar.ScrollToEnd(); txtReceive.Update(); txtReceive.Invalidate(); } } } }