/// <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> /// <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(); } } }