Beispiel #1
0
        /// <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();
        }
Beispiel #2
0
 /// <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());
         }
     }
 }