Пример #1
0
        /// <summary>
        /// Посик через делегат
        /// </summary>
        /// <returns></returns>
        public string[] FindAllPositiveNumberByDelegate()
        {
            if (this.Values == null)
            {
                return(null);
            }

            List <string> temp   = new List <string>();
            SearchWay     result = new SearchWay(this.FindAllPositiveNumberStrings);

            return(result());
        }
Пример #2
0
        /// <summary>
        /// Поиск через лямбда - выражение
        /// </summary>
        /// <returns></returns>
        public string[] FindAllPositiveNumberByLymbdaExtensionDelegate()
        {
            if (this.Values == null)
            {
                return(null);
            }

            List <string> temp   = new List <string>();
            SearchWay     result = () => this.FindAllPositiveNumberStrings();

            return(result());
        }
Пример #3
0
        public void SearchBySomeWay()//搜索
        {
            SearchWay input = serviceIo.SearchBySomeWayIO();

            switch (input)
            {
            case SearchWay.ByNum:                                       //通过订单号搜索
                long  OrderNum = serviceIo.SearchByOrderNumIO();        //前端获取订单号输入
                Order order    = Unit.SearchByNum(OrderNum, orderList); //调用算法单元获得结果
                if (order != null)
                {
                    serviceIo.ShowOrderOut(order, ShowWay.Normal);
                }
                else
                {
                    throw new Exception("Invalid OrderNum:" + OrderNum + '\n');
                }
                break;

            case SearchWay.ByName:                                                  //通过客户名搜索
                string CustormerName = serviceIo.SearchByCustomerNameIO();          //前端获取用户名输入
                var    result2       = Unit.SearchByName(CustormerName, orderList); //调用算法单元获得结果
                if (result2.FirstOrDefault() != null)                               //搜索到了则输出
                {
                    int i = 1;
                    foreach (var x in result2)
                    {
                        serviceIo.ShowOrderOut(x, ShowWay.Normal, i);
                        i++;
                    }
                }
                else
                {
                    throw new Exception("No such name.\n");
                }
                break;
            }
        }
Пример #4
0
    Dictionary <GridControl, Direction> ShowNeigbhorColor(SearchWay way, GridControl jumpedGrid = null)
    {
        // 存储找到的方格
        Dictionary <GridControl, Direction> saveGrid = new Dictionary <GridControl, Direction>();

        // 先搜索是否空格 是 存储 并开始计数
        for (int i = 0; i < 6; i++)
        {
            GridControl neighborGird = neighbors[i];
            if (neighborGird)
            {
                // 检测这个方向上格子是否存在棋子
                if (!neighborGird.CheckChess())
                {
                    // 若为空格 存储 并且搜索方式为全搜索
                    if (way == SearchWay.SearchAll)
                    {
                        saveGrid.Add(neighborGird, (Direction)i);
                        //neighborGird.ChangeColor(mark);
                    }


                    // 开始寻找这个方向上是否有跳板
                    Direction direction    = (Direction)i;
                    int       gridSpaceNum = 1; // 记录到有棋子的格子数

                    // 检测出存在棋子的格子
                    var tmpNeighbor = neighborGird.neighbors[i];
                    while (tmpNeighbor)
                    {
                        if (!tmpNeighbor.CheckChess())
                        {
                            gridSpaceNum++;
                        }
                        else
                        {
                            break;
                        }
                        tmpNeighbor = tmpNeighbor.neighbors[i];
                    }

                    // 若存在
                    if (tmpNeighbor)
                    {
                        var chooseGrid = CheckLineGrid(gridSpaceNum, tmpNeighbor, i);
                        if (chooseGrid)
                        {
                            if (way == SearchWay.SearchJump & jumpedGrid != null)
                            {
                                if (jumpedGrid != chooseGrid)
                                {
                                    saveGrid.Add(chooseGrid, (Direction)i);
                                }
                            }
                            else
                            {
                                saveGrid.Add(chooseGrid, (Direction)i);
                            }
                        }
                    }
                }
                else
                {
                    // 若格子上有棋子
                    var outGrid = neighborGird.neighbors[i];
                    if (outGrid)
                    {
                        if (!outGrid.CheckChess())
                        {
                            if (way == SearchWay.SearchJump & jumpedGrid != null)
                            {
                                if (jumpedGrid != outGrid)
                                {
                                    saveGrid.Add(outGrid, (Direction)i);
                                }
                            }
                            else
                            {
                                saveGrid.Add(outGrid, (Direction)i);
                            }
                        }
                    }
                }
            }
        }

        return(saveGrid);
    }