/// <summary> /// 单元格双击事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="cell">单元格</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="clicks">点击次数</param> /// <param name="delta">滚轮值</param> private void GridCellClick(object sender, GridCell cell, POINT mp, MouseButtonsA button, int clicks, int delta) { if (clicks == 1) { if (cell.Grid == m_tvAllStockNotices) { TreeNodeA tn = cell as TreeNodeA; if (tn.m_nodes.Count == 0) { String id = tn.Tag.ToString(); BindNotices(id); } } } else if (clicks == 2) { if (cell.Grid == m_gridAllStockNotices) { NoticeListNodeBind notice = cell.Row.Tag as NoticeListNodeBind; String url = notice.url; Process.Start(url); //String text = StockNewsDataHelper.GetRealTimeInfoByCode(cell.Row.GetCell("colN4").GetString()); //MessageBox.Show(text); } } }
/// <summary> /// 添加指标到树控件中 /// </summary> /// <param name="indicators">指标列表</param> public void AddIndicatorsToTree(List <Indicator> indicators) { Dictionary <String, TreeNodeA> nodesMap = GetIndicatorsCategoryNodes(); int indicatorsSize = indicators.Count; int pos = 0; for (int i = 0; i < indicatorsSize; i++) { Indicator indicator = indicators[i]; if (nodesMap.ContainsKey(indicator.m_category)) { TreeNodeA indicatorNode = new TreeNodeA(); indicatorNode.Grid = m_tvList; indicatorNode.Name = indicator.m_indicatorID; indicatorNode.Text = indicator.m_description; TreeNodeA parentNode = nodesMap[indicator.m_category]; parentNode.AppendNode(indicatorNode); if (pos == 0) { m_indicator = indicator; LoadIndicator(indicator); } pos++; } } m_tvList.Update(); }
/// <summary> /// 表格选中行改变方法 /// </summary> public void OnGridSelectedRowsChanged() { List <GridRow> selectedRows = m_tvBlock.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { TreeNodeA node = selectedRows[0].GetCell(0) as TreeNodeA; TreeNodeA parentNode = node.Parent; if (parentNode != null && parentNode.Text == "自选股") { String categoryID = node.Value; UserSecurityCategory category = new UserSecurityCategory(); m_userSecurityService.GetCategory(categoryID, ref category); List <Security> securities = new List <Security>(); m_securityService.GetSecuritiesByCodes(category.m_codes, securities); BindSecuritiesToSelectSecuritiesGrid(securities); } else { if (node.GetChildNodes().Count == 0) { String blockID = node.Value; m_securityService.GetSecuritiesByBlockID(m_securitiesRequestID, blockID); } } } }
/// <summary> /// 获取树类别节点的哈希表 /// </summary> /// <returns>哈希表</returns> public Dictionary <String, TreeNodeA> GetIndicatorsCategoryNodes() { Dictionary <String, TreeNodeA> nodesMap = new Dictionary <String, TreeNodeA>(); List <TreeNodeA> nodes = m_tvList.GetChildNodes(); int nodesSize = nodes.Count; for (int i = 0; i < nodesSize; i++) { TreeNodeA node = nodes[i]; nodesMap[node.Text] = node; } return(nodesMap); }
/// <summary> /// 获取树节点的哈希表 /// </summary> /// <returns>哈希表</returns> public Dictionary <String, TreeNodeA> GetIndicatorsNodes() { Dictionary <String, TreeNodeA> indicatorNodesMap = new Dictionary <String, TreeNodeA>(); Dictionary <String, TreeNodeA> nodesMap = GetIndicatorsCategoryNodes(); foreach (TreeNodeA node in nodesMap.Values) { List <TreeNodeA> childNodes = node.GetChildNodes(); int childNodesSize = childNodes.Count; for (int i = 0; i < childNodesSize; i++) { TreeNodeA childNode = childNodes[i]; indicatorNodesMap[childNode.Name] = childNode; } } return(indicatorNodesMap); }
/// <summary> /// 删除指标 /// </summary> public void Delete() { List <GridRow> selectedRows = m_tvList.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { TreeNodeA node = selectedRows[0].GetCell(0) as TreeNodeA; if (node.GetChildNodes().Count == 0) { String indicatorID = node.Name; Indicator indicator = new Indicator(); m_indicatorService.GetIndicatorByID(indicatorID, ref indicator); m_indicatorService.DeleteIndicator(m_indicatorService.OperatorRequestID, indicator); } } }
/// <summary> /// 创建新闻 /// </summary> public AllStockNotices(MainFrame mainFrame) { m_mainFrame = mainFrame; m_gridAllStockNotices = mainFrame.GetGrid("gridAllStockNotices"); m_gridAllStockNotices.GridLineColor = COLOR.EMPTY; m_gridAllStockNotices.BackColor = COLOR.ARGB(0, 0, 0); m_gridAllStockNotices.RowStyle = new GridRowStyle(); m_gridAllStockNotices.RowStyle.BackColor = COLOR.ARGB(0, 0, 0); m_gridAllStockNotices.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); m_tvAllStockNotices = mainFrame.GetTree("tvAllStockNotices"); m_tvAllStockNotices.BackColor = COLOR.ARGB(0, 0, 0); m_tvAllStockNotices.ForeColor = COLOR.ARGB(255, 255, 255); m_tvAllStockNotices.RowStyle = new GridRowStyle(); m_tvAllStockNotices.RowStyle.BackColor = COLOR.ARGB(0, 0, 0); m_tvAllStockNotices.RegisterEvent(new GridCellMouseEvent(GridCellClick), EVENTID.GRIDCELLCLICK); object data = NoticeDataHelper.GetLeftTree("F004"); NewsTypeRoot newsRoot = JsonConvert.DeserializeObject <NewsTypeRoot>(data.ToString()); foreach (NewsTypeNode node in newsRoot.NodeList) { if (node.NodeList != null && node.NodeList.Count > 0) { TreeNodeA tn = new TreeNodeA(); tn.Text = node.Name; tn.Style = new GridCellStyle(); tn.Style.ForeColor = COLOR.ARGB(255, 255, 255); tn.Style.Font = new FONT("微软雅黑", 14, true, false, false); m_tvAllStockNotices.AppendNode(tn); foreach (NewsTypeNode subNode in node.NodeList) { TreeNodeA subTn = new TreeNodeA(); subTn.Text = subNode.Name; subTn.Style = new GridCellStyle(); subTn.Style.ForeColor = COLOR.ARGB(255, 255, 255); subTn.Style.Font = new FONT("微软雅黑", 14, true, false, false); tn.AppendNode(subTn); subTn.Tag = subNode.Id; } } } m_tvAllStockNotices.Update(); BindNotices("S004002"); }
/// <summary> /// 表格选中行改变方法 /// </summary> public void OnGridSelectedRowsChanged() { if (m_tvList != null) { String indicatorID = ""; List <GridRow> selectedRows = m_tvList.SelectedRows; int selectedRowsSize = selectedRows.Count; if (selectedRowsSize > 0) { TreeNodeA node = selectedRows[0].GetCell(0) as TreeNodeA; indicatorID = node.Name; } Indicator indicator = new Indicator(); m_indicatorService.GetIndicatorByID(indicatorID, ref indicator); m_indicator = indicator; LoadIndicator(m_indicator); m_window.Invalidate(); } }
/// <summary> /// 加载指标 /// </summary> /// <param name="type">类型</param> private void LoadType(BrowserType type) { m_tvIndicatorBrowser.ClearNodes(); m_tvIndicatorBrowser.Update(); //请求所有指标 List <String> list = new List <String>(); IndicatorCategoryDataPacket packet = new IndicatorCategoryDataPacket(type); ConnectManager.CreateInstance().Request(packet); while (packet.ReserveFlag == 0) { Thread.Sleep(100); } List <NodeData> nodes = DataCore.CreateInstance().GetCategoryList(type); Dictionary <String, TreeNodeA> nodesMap = new Dictionary <String, TreeNodeA>(); if (nodes != null) { int nodesSzie = nodes.Count; for (int i = 0; i < nodesSzie; i++) { NodeData node = nodes[i]; TreeNodeA tn = new TreeNodeA(); tn.Text = node.Name; tn.Style = new GridCellStyle(); tn.Style.ForeColor = COLOR.ARGB(255, 255, 255); tn.Style.Font = new FONT("微软雅黑", 14, true, false, false); tn.Name = node.Id; tn.Tag = node; if (nodesMap.ContainsKey(node.ParentId)) { nodesMap[node.ParentId].AppendNode(tn); nodesMap[node.Id] = tn; } else { m_tvIndicatorBrowser.AppendNode(tn); nodesMap[node.Id] = tn; } } } }
/// <summary> /// 加载指标 /// </summary> /// <param name="type">类型</param> private void LoadType(MacroDataType type) { m_tvMacIndustry.ClearNodes(); m_tvMacIndustry.Update(); DataTable treeData = LocalDataRetriver.GetTreeCategoryTableFromFile(type); DataView dv = treeData.DefaultView; dv.Sort = "STR_MACROCODE ASC"; Dictionary <String, TreeNodeA> nodesMap = new Dictionary <String, TreeNodeA>(); foreach (DataRowView dRow in dv) { DataRow row = dRow.Row; String code = row[0].ToString(); String parentCode = row[1].ToString(); String name = row[2].ToString(); if (nodesMap.ContainsKey(parentCode)) { TreeNodeA treeNode = new TreeNodeA(); treeNode.Name = code; treeNode.Style = new GridCellStyle(); treeNode.Style.ForeColor = COLOR.ARGB(255, 255, 255); treeNode.Style.Font = new FONT("微软雅黑", 14, true, false, false); treeNode.Text = name; nodesMap[parentCode].AppendNode(treeNode); nodesMap[code] = treeNode; } else { TreeNodeA treeNode = new TreeNodeA(); treeNode.Name = code; treeNode.Text = name; treeNode.Style = new GridCellStyle(); treeNode.Style.ForeColor = COLOR.ARGB(255, 255, 255); treeNode.Style.Font = new FONT("微软雅黑", 14, true, false, false); m_tvMacIndustry.AppendNode(treeNode); nodesMap[code] = treeNode; } } m_tvMacIndustry.Update(); m_tvMacIndustry.Invalidate(); }
/// <summary> /// 加载自选股类别 /// </summary> /// <param name="categories">自选股列表</param> public void LoadUserSecurityCategories(List <UserSecurityCategory> categories) { int categoriesSize = categories.Count; m_tvBlock.BeginUpdate(); List <TreeNodeA> childNodes = m_tvBlock.GetChildNodes(); int childNodesSize = childNodes.Count; if (childNodesSize > 0) { TreeNodeA userSecurityNode = childNodes[childNodesSize - 1]; for (int i = 0; i < categories.Count; i++) { UserSecurityCategory category = categories[i]; TreeNodeA categoryNode = new TreeNodeA(); userSecurityNode.AppendNode(categoryNode); categoryNode.Text = category.m_name; categoryNode.Value = category.m_categoryID; } } m_tvBlock.EndUpdate(); }
/// <summary> /// 单元格双击事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="cell">单元格</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="clicks">点击次数</param> /// <param name="delta">滚轮值</param> private void GridCellClick(object sender, GridCell cell, POINT mp, MouseButtonsA button, int clicks, int delta) { if (cell.Grid == m_tvIndicatorBrowser) { TreeNodeA tn = cell as TreeNodeA; if (tn.m_nodes.Count == 0) { NodeData nodeData = tn.Tag as NodeData; if (nodeData.IsCatalog) { IndicatorLeafDataPacket leafPacket = new IndicatorLeafDataPacket(nodeData.Id); ConnectManager.CreateInstance().Request(leafPacket); int tick = 0; while (leafPacket.ReserveFlag == 0 && tick < 50) { Thread.Sleep(100); tick++; } if (leafPacket.LeafNodeList.Count > 0) { List <NodeData> nodes = leafPacket.LeafNodeList; Dictionary <String, TreeNodeA> nodesMap = new Dictionary <String, TreeNodeA>(); int nodesSzie = nodes.Count; for (int i = 0; i < nodesSzie; i++) { NodeData node = nodes[i]; TreeNodeA subTn = new TreeNodeA(); subTn.Text = node.Name; subTn.Style = new GridCellStyle(); subTn.Style.ForeColor = COLOR.ARGB(255, 255, 80); subTn.Style.Font = new FONT("微软雅黑", 14, true, false, false); subTn.Name = node.Id; subTn.Tag = node; if (nodesMap.ContainsKey(node.ParentId)) { nodesMap[node.ParentId].AppendNode(subTn); nodesMap[node.Id] = subTn; } else { tn.AppendNode(subTn); nodesMap[node.Id] = subTn; } IndicatorEntityDataPacket entity = new IndicatorEntityDataPacket(node.Id); ConnectManager.CreateInstance().Request(entity); } tn.ExpendAll(); m_tvIndicatorBrowser.Update(); m_tvIndicatorBrowser.Invalidate(); } } else { StringBuilder sb = new StringBuilder(); CList <GSecurity> securities = SecurityService.FilterCode(m_txtIndicatorCode.Text); int codesSize = securities.size(); for (int i = 0; i < codesSize; i++) { sb.Append(securities.get(i).m_code); if (i != codesSize - 1) { sb.Append(","); } } m_gridIndicatorBrowser.ClearRows(); IndicatorRootData data = GetIndicatorData(nodeData.Id, "Stock", sb.ToString()); m_gridIndicatorBrowser.GetColumn("colN3").Text = data.categoryName; foreach (IndicatorItemData indicatorItem in data.items) { GridRow row = new GridRow(); m_gridIndicatorBrowser.AddRow(row); GridStringCell codeCell = new GridStringCell(indicatorItem.code); row.AddCell("colN1", codeCell); GSecurity security = new GSecurity(); SecurityService.GetSecurityByCode(indicatorItem.code, ref security); row.AddCell("colN2", new GridStringCell(security.m_name)); if (indicatorItem.type == 0) { GridStringCell valueCell = new GridStringCell(indicatorItem.text); row.AddCell("colN3", valueCell); } else if (indicatorItem.type == 1) { GridDoubleCell valueCell = new GridDoubleCell(indicatorItem.num); row.AddCell("colN3", valueCell); } row.GetCell("colN1").Style = new GridCellStyle(); row.GetCell("colN1").Style.ForeColor = COLOR.ARGB(255, 255, 80); row.GetCell("colN1").Style.Font = new FONT("微软雅黑", 14, true, false, false); row.GetCell("colN1").Style.Font = new FONT("微软雅黑", 14, true, false, false); row.GetCell("colN2").Style = new GridCellStyle(); row.GetCell("colN2").Style.ForeColor = COLOR.ARGB(255, 80, 80); row.GetCell("colN2").Style.Font = new FONT("微软雅黑", 14, true, false, false); row.GetCell("colN3").Style = new GridCellStyle(); row.GetCell("colN3").Style.ForeColor = COLOR.ARGB(80, 255, 255); row.GetCell("colN3").Style.Font = new FONT("微软雅黑", 14, true, false, false); } m_gridIndicatorBrowser.Update(); m_gridIndicatorBrowser.Invalidate(); } } } else if (cell.Grid == m_gridIndicatorBrowser) { if (clicks == 2) { m_mainFrame.SearchSecurity(cell.Row.GetCell("colN1").GetString()); } } }
/// <summary> /// 单元格双击事件 /// </summary> /// <param name="sender">调用者</param> /// <param name="cell">单元格</param> /// <param name="mp">坐标</param> /// <param name="button">按钮</param> /// <param name="clicks">点击次数</param> /// <param name="delta">滚轮值</param> private void GridCellClick(object sender, GridCell cell, POINT mp, MouseButtonsA button, int clicks, int delta) { TreeNodeA tn = cell as TreeNodeA; if (tn.m_nodes.Count == 0) { if (tn.Tag == null) { try { MacroDataType type = (MacroDataType)Enum.Parse(typeof(MacroDataType), m_cbMacIndustry.Text); DataTable dt = MongoRetriver.GetDescendantDataByService(tn.Name, type); foreach (DataRow row in dt.Rows) { if (row[0].ToString().Length > 0 && row[3].ToString().Length > 0) { TreeNodeA node = new TreeNodeA(); node.Tag = "2"; node.Style = new GridCellStyle(); node.Style.ForeColor = COLOR.ARGB(255, 255, 80); node.Style.Font = new FONT("微软雅黑", 14, true, false, false); node.Text = row["STR_MACRONAME"].ToString(); node.Name = row[0].ToString(); tn.AppendNode(node); } } tn.Tag = "1"; m_tvMacIndustry.Update(); } catch (Exception ex) { } } else if (tn.Tag.ToString() == "2") { m_gridMacIndustry.ClearRows(); m_fundCurve.Clear(); FundCurveData data = new FundCurveData(); XAxisPointData xdata = new XAxisPointData(); Dictionary <String, YAxisCurveData> yDatas = new Dictionary <String, YAxisCurveData>(); YAxisStyle ySyle = new YAxisStyle(); YAxisStyle ySyle1 = new YAxisStyle(); YAxisStyle ySyle2 = new YAxisStyle(); XAxisStyle xStyle = new XAxisStyle(); xStyle.XAxisType = XAxisType.Date; data.ChartTitle = "每日进展"; xStyle.XAxisTitle = "时间"; data.BackgroundColor = Color.Black; DataTable dt = GetMacIndustyData(tn.Name, m_cbMacIndustry.Text); YAxisCurveData yData = new YAxisCurveData(); yData.YPointValues = new List <double>(); yData.LineWidth = 3; yData.Text = xdata.Text; yData.ShowCycle = true; data.LstYAxisPointDatas.Add(yData); foreach (DataRow dr in dt.Rows) { if (dr[0].ToString().Length > 0 && dr[1].ToString().Length > 0) { GridRow row = new GridRow(); m_gridMacIndustry.AddRow(row); DateTime date = Convert.ToDateTime(dr[0]); row.AddCell("colN1", new GridStringCell(date.ToString("yyyy-MM-dd"))); row.AddCell("colN2", new GridStringCell(dr[1].ToString())); row.GetCell("colN1").Style = new GridCellStyle(); row.GetCell("colN1").Style.ForeColor = COLOR.ARGB(255, 255, 80); row.GetCell("colN1").Style.Font = new FONT("微软雅黑", 14, true, false, false); row.GetCell("colN2").Style = new GridCellStyle(); row.GetCell("colN2").Style.ForeColor = COLOR.ARGB(255, 80, 80); row.GetCell("colN2").Style.Font = new FONT("微软雅黑", 14, true, false, false); } } int rowsSize = dt.Rows.Count; for (int i = rowsSize - 1; i >= 0; i--) { DataRow dr = dt.Rows[i]; if (dr[0].ToString().Length > 0 && dr[1].ToString().Length > 0) { GridRow row = new GridRow(); m_gridMacIndustry.AddRow(row); DateTime date = Convert.ToDateTime(dr[0]); xdata.Value = date.Year * 10000 + date.Month * 100 + date.Day; xdata.Text = date.ToString("yyyyMMdd"); data.LstXAxisPointDatas.Add(xdata); yData.YPointValues.Add(CStr.ConvertStrToDouble(dr[1].ToString())); } } data.XAxisStyle = xStyle; ySyle.YAxisTitleAlign = YAxisTitleAlign.Middle; ySyle1.YAxisTitleAlign = YAxisTitleAlign.Middle; ySyle2.YAxisTitleAlign = YAxisTitleAlign.Middle; xStyle.XAxisTitleAlign = XAxisTitleAlign.Center; data.LstYAxisStyle.Add(ySyle); data.LstYAxisStyle.Add(ySyle1); data.LstYAxisStyle.Add(ySyle2); m_fundCurve.FundCurveData = data; m_gridMacIndustry.Update(); m_gridMacIndustry.Invalidate(); } } }