/// <summary> /// 调用控件线程方法 /// </summary> /// <param name="args">参数</param> public override void OnInvoke(object args) { CMessage message = (CMessage)args; if (message.m_serviceID == m_quoteService.ServiceID) { LatestDataInfo dataInfo = new LatestDataInfo(); List <SecurityLatestData> datas = new List <SecurityLatestData>(); QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength); int datasSize = datas.Count; for (int i = 0; i < datasSize; i++) { m_latestDatas[datas[i].m_securityCode] = datas[i]; } datas.Clear(); } else if (message.m_serviceID == m_userSecurityService.ServiceID) { if (message.m_functionID < UserSecurityService.FUNCTIONID_USERSECURITY_GETVISITSCOUNT) { LoadCells(); } } Invalidate(); }
/// <summary> /// 销毁方法 /// </summary> public override void Dispose() { if (!IsDisposed) { QuoteService quoteService = DataCenter.QuoteService; quoteService.StopPushLatestDatas(m_requestID); quoteService.UnRegisterListener(m_requestID); } base.Dispose(); }
/// <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="args">参数</param> public override void OnInvoke(object args) { base.OnInvoke(args); if (args != null) { CMessage message = (CMessage)args; LatestDataInfo dataInfo = new LatestDataInfo(); List <SecurityLatestData> datas = new List <SecurityLatestData>(); QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength); int datasSize = datas.Count; for (int i = 0; i < datasSize; i++) { SecurityLatestData latestData = datas[i]; if (i == 0) { if (latestData.m_securityCode == "000001.SH") { if (!latestData.Equal(m_ssLatestData)) { m_ssLatestData = latestData; } } } else if (i == 1) { if (latestData.m_securityCode == "399001.SZ") { if (!latestData.Equal(m_szLatestData)) { m_szLatestData = latestData; } } } else if (i == 2) { if (latestData.m_securityCode == "399006.SZ") { if (!latestData.Equal(m_cyLatestData)) { m_cyLatestData = latestData; } } } } Invalidate(); } }
/// <summary> /// 最新数据回调方法 /// </summary> /// <param name="message">消息</param> public void OnLatestDataCallBack(CMessage message) { LatestDataInfo dataInfo = new LatestDataInfo(); List <SecurityLatestData> latestDatas = new List <SecurityLatestData>(); QuoteService.GetLatestDatas(ref dataInfo, latestDatas, message.m_body, message.m_bodyLength); int latestDatasSize = latestDatas.Count; for (int i = 0; i < latestDatasSize; i++) { String code = latestDatas[i].m_securityCode; if (m_infos.ContainsKey(code)) { m_infos[code].LatestData = latestDatas[i]; } } }
/// <summary> /// 添加控件方法 /// </summary> public override void OnAdd() { base.OnAdd(); if (m_securityService == null) { //注册服务 m_securityService = DataCenter.SecurityService; m_userSecurityService = DataCenter.UserSecurityService; m_userSecurityDataCallBack = new ListenerMessageCallBack(UserSecurityDataCallBack); m_userSecurityService.RegisterListener(m_userSecurityService.GetListRequestID, m_userSecurityDataCallBack); m_userSecurityService.RegisterListener(m_userSecurityService.OperatorRequestID, m_userSecurityDataCallBack); //注册行情 m_quoteService = DataCenter.QuoteService; m_latestDataCallBack = new ListenerMessageCallBack(LatestDataCallBack); m_quoteService.RegisterListener(m_latestDataRequestID, m_latestDataCallBack); StartTimer(m_timerID, 10); } }
/// <summary> /// 销毁方法 /// </summary> public override void Dispose() { if (!IsDisposed) { if (m_quoteService != null) { m_quoteService.UnRegisterListener(m_latestDataRequestID, m_latestDataCallBack); m_latestDataCallBack = null; m_quoteService = null; } m_latestDatas.Clear(); if (m_userSecurityService != null) { m_userSecurityService.UnRegisterListener(m_userSecurityService.OperatorRequestID, m_userSecurityDataCallBack); m_userSecurityDataCallBack = null; m_userSecurityService = null; } base.Dispose(); } }
/// <summary> /// 调用控件线程方法 /// </summary> /// <param name="args">参数</param> public void OnInvoke(object args) { CMessage message = (CMessage)args; if (message.m_serviceID == m_quoteService.ServiceID) { LatestDataInfo dataInfo = new LatestDataInfo(); List <SecurityLatestData> datas = new List <SecurityLatestData>(); QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength); int datasSize = datas.Count; for (int i = 0; i < datasSize; i++) { m_latestDatas[datas[i].m_securityCode] = datas[i]; } datas.Clear(); } else { List <UserSecurityCategory> categories = new List <UserSecurityCategory>(); UserSecurityService.GetCategories(categories, message.m_body, message.m_bodyLength); UserSecurityCategory category = categories[0]; switch (message.m_functionID) { case UserSecurityService.FUNCTIONID_USERSECURITY_ADDCATEGORIES: AddCategoriesToCategoryGrid(categories); break; case UserSecurityService.FUNCTIONID_USERSECURITY_DELETECATEGORIES: RemoveCategoriesFromCategoryGrid(categories); break; case UserSecurityService.FUNCTIONID_USERSECURITY_UPDATECATEGORIES: UpdateCategoriesToCategoryGrid(categories); break; case UserSecurityService.FUNCTIONID_USERSECURITY_ADDSECURITIES: case UserSecurityService.FUNCTIONID_USERSECURITY_DELETESECURITIES: { String categoryID = ""; List <GridRow> selectedRows = m_gridCategory.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { categoryID = selectedRows[0].GetCell(0).Text; } if (categoryID != null && categoryID == category.m_categoryID) { List <Security> securities = new List <Security>(); m_securityService.GetSecuritiesByCodes(category.m_codes, securities); if (message.m_functionID == UserSecurityService.FUNCTIONID_USERSECURITY_ADDSECURITIES) { AddSecuritiesToSecuritiesGrid(securities); } else if (message.m_functionID == UserSecurityService.FUNCTIONID_USERSECURITY_DELETESECURITIES) { RemoveSecuritiesFromSecuritiesGrid(securities); } } break; } } } m_window.Invalidate(); }
/// <summary> /// 调用控件线程方法 /// </summary> /// <param name="args">参数</param> public override void OnInvoke(object args) { base.OnInvoke(args); if (args != null) { CMessage message = (CMessage)args; if (message.m_requestID == m_requestID) { //分时数据 if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHLATESTDATA) { LatestDataInfo dataInfo = new LatestDataInfo(); List <SecurityLatestData> datas = new List <SecurityLatestData>(); QuoteService.GetLatestDatas(ref dataInfo, datas, message.m_body, message.m_bodyLength); SecurityLatestData latestData = datas[0]; if (latestData != null && latestData.m_securityCode == m_securityCode && !latestData.Equal(m_latestData)) { m_latestData = latestData; //设置保留小数的位数 int digit = 2; if (m_latestData.m_securityCode.StartsWith("1") || m_latestData.m_securityCode.StartsWith("5")) { digit = 3; } m_chart.Digit = digit; m_chart.RefreshData(); } } //LV2分时数据 else if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHLATESTDATALV2) { LatestDataInfoLV2 dataInfo = new LatestDataInfoLV2(); List <SecurityLatestDataLV2> datas = new List <SecurityLatestDataLV2>(); QuoteService.GetLatestDatasLV2(ref dataInfo, datas, message.m_body, message.m_bodyLength); SecurityLatestDataLV2 latestDataLV2 = datas[0]; if (latestDataLV2 != null && latestDataLV2.m_securityCode == m_securityCode && !latestDataLV2.Equal(m_latestDataLV2)) { m_latestDataLV2 = latestDataLV2; } } //成交数据 else if (message.m_functionID == QuoteService.FUNCTIONID_QUOTE_PUSHTRANSACTIONDATA) { String securityCode = ""; List <TransactionData> transactionDatas = new List <TransactionData>(); QuoteService.GetTransactionDatas(ref securityCode, transactionDatas, message.m_body, message.m_bodyLength); int transactionDatasSize = transactionDatas.Count; for (int i = 0; i < transactionDatasSize; i++) { TransactionData transactionData = transactionDatas[i]; DateTime date = CStrA.ConvertNumToDate(transactionData.m_date); GridRow row = new GridRow(); m_gridTransaction.InsertRow(0, row); TransactionDateCell dateCell = new TransactionDateCell(); dateCell.Text = date.ToString("HH:mm:ss"); row.AddCell(0, dateCell); GridCellStyle dateCellStyle = new GridCellStyle(); dateCellStyle.BackColor = COLOR.EMPTY; dateCellStyle.Font = new FONT("SimSun", 14, true, false, false); dateCellStyle.ForeColor = CDraw.PCOLORS_FORECOLOR2; dateCell.Style = dateCellStyle; TransactionDataDoubleCell priceCell = new TransactionDataDoubleCell(); priceCell.Digit = 2; priceCell.SetDouble(transactionData.m_price); row.AddCell(1, priceCell); GridCellStyle priceCellStyle = new GridCellStyle(); priceCellStyle.BackColor = COLOR.EMPTY; priceCellStyle.Font = new FONT("SimSun", 14, true, false, false); priceCellStyle.ForeColor = CDraw.GetPriceColor(transactionData.m_price, m_latestData.m_lastClose); priceCell.Style = priceCellStyle; TransactionDataDoubleCell volumeCell = new TransactionDataDoubleCell(); volumeCell.SetDouble(transactionData.m_volume); row.AddCell(2, volumeCell); GridCellStyle volumeCellStyle = new GridCellStyle(); volumeCellStyle.BackColor = COLOR.EMPTY; volumeCellStyle.Font = new FONT("SimSun", 14, true, false, false); if (transactionData.m_type == 0) { volumeCellStyle.ForeColor = CDraw.PCOLORS_FORECOLOR; } else if (transactionData.m_type == 1) { volumeCellStyle.ForeColor = CDraw.PCOLORS_UPCOLOR; } else { volumeCellStyle.ForeColor = CDraw.PCOLORS_DOWNCOLOR; } volumeCell.Style = volumeCellStyle; } m_gridTransaction.Update(); } } Invalidate(); } }