Exemplo n.º 1
0
        /// <summary>
        /// 过滤查找
        /// </summary>
        public void FilterSearch()
        {
            String sText = m_searchTextBox.Text.ToUpper();

            m_grid.BeginUpdate();
            m_grid.ClearRows();
            int row = 0;
            CList <GSecurity> securities = SecurityService.FilterCode(sText);

            if (securities != null)
            {
                int rowCount = securities.size();
                for (int i = 0; i < rowCount; i++)
                {
                    GSecurity security = securities.get(i);
                    GridRow   gridRow  = new GridRow();
                    m_grid.AddRow(gridRow);
                    gridRow.AddCell(0, new GridStringCell(security.m_code));
                    gridRow.AddCell(1, new GridStringCell(security.m_name));
                    row++;
                }
            }
            securities.Dispose();
            m_grid.EndUpdate();
        }
Exemplo n.º 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());
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 查询键盘精灵
        /// </summary>
        /// <param name="key">检索值</param>
        /// <param name="limitSize">最大值</param>
        /// <param name="securities">返回键盘精灵集合</param>
        /// <returns>预留</returns>
        public int Find(String key, int limitSize, CList <Security> securities)
        {
            int order = 0, order1 = 0, order2 = 0, order3 = 0, minOrder = 0;
            int securityListSize = m_securities.size();
            CList <SecurityOrder> securityReturnList = new CList <SecurityOrder>();

            securityReturnList.set_capacity(limitSize);
            //遍历
            for (int i = 0; i < securityListSize; i++)
            {
                CList <Security> securityList = m_securities.get(i);
                int securitySize = securityList.size();
                for (int j = 0; j < securitySize; j++)
                {
                    Security security = securityList.get(j);
                    order1 = IsMatching(security.m_code, security.m_type, key, 0, i);
                    order2 = IsMatching(security.m_name, security.m_type, key, 1, i);
                    order3 = IsMatching(security.m_pingyin, security.m_type, key, 2, i);
                    order  = Math.Max(order1, Math.Max(order2, order3));
                    if (order > 0)
                    {
                        SecurityOrder securityReturn = new SecurityOrder();
                        securityReturn.m_order    = order;
                        securityReturn.m_security = security;
                        if (securityReturnList.size() < limitSize)
                        {
                            securityReturnList.push_back(securityReturn);
                        }
                        else
                        {
                            int index = 0;
                            minOrder = securityReturnList.get(0).m_order;
                            for (int m = 0; m < securityReturnList.size(); m++)
                            {
                                if (securityReturnList.get(m).m_order < minOrder)
                                {
                                    minOrder = securityReturnList.get(m).m_order;
                                    index    = m;
                                }
                            }
                            if (minOrder < order)
                            {
                                securityReturnList.get(index).m_order    = order;
                                securityReturnList.get(index).m_security = security;
                            }
                        }
                    }
                }
            }
            //排序
            int           retListSize = securityReturnList.size();
            SecurityOrder security1   = null;
            SecurityOrder security2   = null;

            for (int i = 0; i < retListSize - 1; i++)
            {
                for (int j = i + 1; j < retListSize; j++)
                {
                    security1 = securityReturnList.get(i);
                    security2 = securityReturnList.get(j);
                    if (security1.m_order < security2.m_order ||
                        (security1.m_order == security2.m_order && String.Compare(security1.m_security.m_code, security2.m_security.m_code) > 0))
                    {
                        securityReturnList.set(i, security2);
                        securityReturnList.set(j, security1);
                    }
                }
            }
            //返回
            for (int i = 0; i < retListSize; i++)
            {
                securities.push_back(securityReturnList.get(i).m_security);
            }
            securityReturnList.clear();
            return(securities.size());
        }