Example #1
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y, false))
            {
                return(false);
            }
            Point result;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out result))
            {
                return(false);
            }
            result.Y += 2;
            Ref <int> count = new Ref <int>(0);

            WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count)));
            if (count.Value < 20 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16), 0))
            {
                return(false);
            }
            WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.RadialDither(0.0f, 10f), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort)229, true, true)));
            ShapeData data = new ShapeData();

            WorldUtils.Gen(result, (GenShape) new Shapes.Circle(4, 3), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), (GenAction) new Actions.SetLiquid(2, byte.MaxValue)));
            WorldUtils.Gen(new Point(result.X, result.Y + 1), (GenShape) new ModShapes.InnerOutline(data, true), Actions.Chain((GenAction) new Modifiers.IsEmpty(), (GenAction) new Modifiers.RectangleMask(-6, 6, 1, 3), (GenAction) new Actions.SetTile((ushort)59, true, true)));
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16), 0);
            return(true);
        }
Example #2
0
        private static List <Microsoft.Xna.Framework.Rectangle> CreateRooms(Point origin)
        {
            Point result;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result) || result == origin)
            {
                return(new List <Microsoft.Xna.Framework.Rectangle>());
            }
            Microsoft.Xna.Framework.Rectangle room1 = HouseUtils.FindRoom(result);
            Microsoft.Xna.Framework.Rectangle room2 = HouseUtils.FindRoom(new Point(room1.Center.X, room1.Y + 1));
            Microsoft.Xna.Framework.Rectangle room3 = HouseUtils.FindRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));
            room3.Y = room1.Y + room1.Height - 1;
            float roomSolidPrecentage1 = HouseUtils.GetRoomSolidPrecentage(room2);
            float roomSolidPrecentage2 = HouseUtils.GetRoomSolidPrecentage(room3);

            room1.Y += 3;
            room2.Y += 3;
            room3.Y += 3;
            List <Microsoft.Xna.Framework.Rectangle> rectangleList = new List <Microsoft.Xna.Framework.Rectangle>();

            if ((double)WorldGen.genRand.NextFloat() > (double)roomSolidPrecentage1 + 0.200000002980232)
            {
                rectangleList.Add(room2);
            }
            rectangleList.Add(room1);
            if ((double)WorldGen.genRand.NextFloat() > (double)roomSolidPrecentage2 + 0.200000002980232)
            {
                rectangleList.Add(room3);
            }
            return(rectangleList);
        }
Example #3
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y))
            {
                return(false);
            }
            Point result;

            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new Conditions.IsSolid()), out result))
            {
                return(false);
            }
            result.Y += 2;
            Ref <int> @ref = new Ref <int>(0);

            WorldUtils.Gen(result, new Shapes.Circle(8), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(@ref)));
            if (@ref.Value < 20)
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(result.X - 8, result.Y - 8, 16, 16)))
            {
                return(false);
            }
            WorldUtils.Gen(result, new Shapes.Circle(8), Actions.Chain(new Modifiers.RadialDither(0f, 10f), new Modifiers.IsSolid(), new Actions.SetTile(229, true)));
            ShapeData data = new ShapeData();

            WorldUtils.Gen(result, new Shapes.Circle(4, 3), Actions.Chain(new Modifiers.Blotches(), new Modifiers.IsSolid(), new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), new Actions.SetLiquid(2)));
            WorldUtils.Gen(new Point(result.X, result.Y + 1), new ModShapes.InnerOutline(data), Actions.Chain(new Modifiers.IsEmpty(), new Modifiers.RectangleMask(-6, 6, 1, 3), new Actions.SetTile(59, true)));
            structures.AddStructure(new Rectangle(result.X - 8, result.Y - 8, 16, 16));
            return(true);
        }
Example #4
0
        /// <summary>
        /// 搜索
        /// </summary>
        public ActionResult AjaxSearch()
        {
            //搜索词
            string keyword = WebHelper.GetQueryString("keyword");

            if (keyword.Length == 0)
            {
                return(Content(""));
            }
            if (!SecureHelper.IsSafeSqlString(keyword))
            {
                return(Content(""));
            }

            //分类id
            int cateId = WebHelper.GetQueryInt("cateId");
            //品牌id
            int brandId = WebHelper.GetQueryInt("brandId");
            //筛选价格
            int filterPrice = WebHelper.GetQueryInt("filterPrice");
            //筛选属性
            string filterAttr = WebHelper.GetQueryString("filterAttr");
            //是否只显示有货
            int onlyStock = WebHelper.GetQueryInt("onlyStock");
            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //分类信息
            CategoryInfo categoryInfo = Categories.GetCategoryById(cateId);

            //分类价格范围列表
            string[] catePriceRangeList = StringHelper.SplitString(categoryInfo.PriceRange, "\r\n");
            //筛选属性处理
            List <int> attrValueIdList = new List <int>();

            string[] filterAttrValueIdList = StringHelper.SplitString(filterAttr, "-");
            foreach (string attrValueId in filterAttrValueIdList)
            {
                int temp = TypeHelper.StringToInt(attrValueId);
                if (temp > 0)
                {
                    attrValueIdList.Add(temp);
                }
            }

            //分页对象
            PageModel pageModel = new PageModel(20, page, Searches.GetSearchMallProductCount(keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock));
            //视图对象
            AjaxMallSearchModel model = new AjaxMallSearchModel()
            {
                PageModel   = pageModel,
                ProductList = Searches.SearchMallProducts(pageModel.PageSize, pageModel.PageNumber, keyword, cateId, brandId, filterPrice, catePriceRangeList, attrValueIdList, onlyStock, sortColumn, sortDirection)
            };

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Example #5
0
 private static bool AreRoomsValid(
     IEnumerable <Microsoft.Xna.Framework.Rectangle> rooms,
     StructureMap structures,
     HouseType style)
 {
     foreach (Microsoft.Xna.Framework.Rectangle room in rooms)
     {
         if (style != HouseType.Granite)
         {
             if (WorldUtils.Find(new Point(room.X - 2, room.Y - 2), Searches.Chain(new Searches.Rectangle(room.Width + 4, room.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out Point _))
             {
                 return(false);
             }
         }
         if (WorldGen.notTheBees)
         {
             if (!structures.CanPlace(room, HouseUtils.BeelistedTiles, 5))
             {
                 return(false);
             }
         }
         else if (!structures.CanPlace(room, HouseUtils.BlacklistedTiles, 5))
         {
             return(false);
         }
     }
     return(true);
 }
Example #6
0
        private void CloseTabCommand(object sender, ExecutedRoutedEventArgs e)
        {
            var search = (SearchControl)((FrameworkElement)e.OriginalSource).DataContext;

            Searches.Remove(search);
            CommandManager.InvalidateRequerySuggested();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Ticker,Score,DateSearched")] Searches searches)
        {
            if (id != searches.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(searches);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SearchesExists(searches.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(searches));
        }
        public override bool Place(Point origin, StructureMap structures)
        {
            Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();

            WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 1).Output(dictionary));
            int num = dictionary[0] + dictionary[1];

            if (num < 1250)
            {
                return(false);
            }
            Point result;
            bool  flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result);

            if (WorldUtils.Find(origin, Searches.Chain(new Searches.Up(origin.Y - result.Y), new Conditions.IsTile(53)), out Point _))
            {
                return(false);
            }
            if (!flag)
            {
                return(false);
            }
            result.Y += 50;
            ShapeData shapeData  = new ShapeData();
            ShapeData shapeData2 = new ShapeData();
            Point     point      = new Point(origin.X, origin.Y + 20);
            Point     point2     = new Point(origin.X, origin.Y + 30);
            float     num2       = 0.8f + GenBase._random.NextFloat() * 0.5f;

            if (!structures.CanPlace(new Rectangle(point.X - (int)(20f * num2), point.Y - 20, (int)(40f * num2), 40)))
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), 2))
            {
                return(false);
            }
            WorldUtils.Gen(point, new Shapes.Slime(20, num2, 1f), Actions.Chain(new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(frameNeighbors: true).Output(shapeData)));
            WorldUtils.Gen(point2, new Shapes.Mound(14, 14), Actions.Chain(new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0), new Actions.SetFrames(frameNeighbors: true).Output(shapeData2)));
            shapeData.Subtract(shapeData2, point, point2);
            WorldUtils.Gen(point, new ModShapes.InnerOutline(shapeData), Actions.Chain(new Actions.SetTile(2), new Actions.SetFrames(frameNeighbors: true)));
            WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid()));
            WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceWall(68), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, 1), new ActionVines(3, 5)));
            ShapeData data = new ShapeData();

            WorldUtils.Gen(new Point(origin.X, result.Y + 10), new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(53), new Actions.SetTile(397).Output(data)));
            WorldUtils.Gen(new Point(origin.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true));
            if (GenBase._random.Next(3) == 0)
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, mute: true, forced: false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, mute: true, forced: false, -1, 15);
            }
            WorldUtils.Gen(point2, new ModShapes.All(shapeData2), Actions.Chain(new Modifiers.Offset(0, -1), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, -1), new ActionGrass()));
            structures.AddStructure(new Rectangle(point.X - (int)(20f * num2), point.Y - 20, (int)(40f * num2), 40), 4);
            return(true);
        }
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3)
            {
                return(false);
            }

            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(100), new Conditions.IsSolid()), out origin))
            {
                return(false);
            }

            Point result;

            if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain(new Searches.Down(5), new Conditions.IsTile(new ushort[1] {
                25
            }).AreaAnd(8, 1)), out result))
            {
                return(false);
            }

            ShapeData data1      = new ShapeData();
            ShapeData shapeData1 = new ShapeData();
            ShapeData shapeData2 = new ShapeData();

            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(10, 12) + index), Actions.Chain(new Modifiers.Offset(0, 5 * index + 5), new Modifiers.Blotches(3, 0.3).Output(data1)));
            }
            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(5, 7) + index), Actions.Chain(new Modifiers.Offset(0, 2 * index + 18), new Modifiers.Blotches(3, 0.3).Output(shapeData1)));
            }
            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(4, 6) + index / 2), Actions.Chain(new Modifiers.Offset(0, (int)(7.5 * (double)index) - 10), new Modifiers.Blotches(3, 0.3).Output(shapeData2)));
            }

            ShapeData data2 = new ShapeData(shapeData1);

            shapeData1.Subtract(shapeData2, origin, origin);
            data2.Subtract(shapeData1, origin, origin);
            Microsoft.Xna.Framework.Rectangle bounds = ShapeData.GetBounds(origin, data1, shapeData2);
            if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
            {
                return(false);
            }

            WorldUtils.Gen(origin, new ModShapes.All(data1), Actions.Chain(new Actions.SetTile((ushort)25, true, true), new Actions.PlaceWall(3, true)));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData1), new Actions.SetTile(0, true, true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData2), new Actions.ClearTile(true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData1), Actions.Chain(new Modifiers.IsTouchingAir(true), new Modifiers.NotTouching(0 != 0, new ushort[1] {
                25
            }), new Actions.SetTile(23, true, true)));
            WorldUtils.Gen(origin, new ModShapes.All(data2), new Actions.PlaceWall(69, true));

            structures.AddStructure(bounds, 2);
            return(true);
        }
Example #10
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile((int)origin.X, (int)origin.Y))
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, new ushort[4]
            {
                (ushort)(WorldGen.goldBar == 19 ? 8 : 169),
                (ushort)(WorldGen.silverBar == 21 ? 9 : 168),
                (ushort)(WorldGen.ironBar == 22 ? 6 : 167),
                (ushort)(WorldGen.copperBar == 20 ? 7 : 166)
            });
            double num1 = GenBase._random.NextDouble() * 2.0 - 1.0;

            if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            ShapeData shapeData = new ShapeData();
            Ref <int> count1    = new Ref <int>(0);
            Ref <int> count2    = new Ref <int>(0);

            WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2)));
            if (count2.Value < count1.Value / 2)
            {
                return(false);
            }
            Rectangle area;

            // ISSUE: explicit reference operation
            ((Rectangle)@area).\u002Ector(origin.X - 15, origin.Y - 10, 30, 20);
            if (!structures.CanPlace(area, 0))
            {
                return(false);
            }
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true, true));
            WorldUtils.Gen(new Point(origin.X - (int)(num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.ClearTile(true)));
            Point result1;
            int   num2 = 1 & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0);
            int   num3 = GenBase._random.Next(4) == 0 ? 3 : 7;
            Point result2;
            int   num4 = WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num3 : num3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;

            if ((num2 & num4) == 0)
            {
                return(false);
            }
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            __Null& local1 = @result1.Y;
            // ISSUE: cast to a reference type
            // ISSUE: explicit reference operation
            int num5 = ^ (int&)local1 - 1;
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result;
            bool  flag = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 100).Not()), out result);

            result.Y += 100;
            ShapeData data1     = new ShapeData();
            ShapeData shapeData = new ShapeData();
            Point     point1    = new Point(origin.X, origin.Y + 20);
            Point     point2    = new Point(origin.X, origin.Y + 30);

            bool[] validTiles = new bool[TileID.Sets.GeneralPlacementTiles.Length];
            for (int index = 0; index < validTiles.Length; ++index)
            {
                validTiles[index] = TileID.Sets.GeneralPlacementTiles[index];
            }
            validTiles[21]  = false;
            validTiles[467] = false;
            float xScale = (float)(0.800000011920929 + (double)GenBase._random.NextFloat() * 0.5);

            WorldUtils.Gen(point1, (GenShape) new Shapes.Slime(20, xScale, 1f), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(true).Output(data1)));
            WorldUtils.Gen(point2, (GenShape) new Shapes.Mound(14, 14), Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8), (GenAction) new Actions.SetTile((ushort)0, false, true), new Actions.SetFrames(true).Output(shapeData)));
            data1.Subtract(shapeData, point1, point2);
            WorldUtils.Gen(point1, (GenShape) new ModShapes.InnerOutline(data1, true), Actions.Chain((GenAction) new Actions.SetTile((ushort)2, false, true), (GenAction) new Actions.SetFrames(true)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid(0, byte.MaxValue)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.PlaceWall((ushort)68, true), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5, 382)));
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfEntrance)
            {
                ShapeData data2 = new ShapeData();
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.2), (GenAction) new Modifiers.SkipTiles(new ushort[2]
                {
                    (ushort)191,
                    (ushort)192
                }), new Actions.ClearTile(false).Output(data2), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
                {
                    (ushort)53
                }), new Actions.SetTile((ushort)397, false, true).Output(data2)));
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new ModShapes.All(data2), (GenAction) new Actions.SetFrames(true));
            }
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfRealSword)
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, false, -1, 15);
            }
            WorldUtils.Gen(point2, (GenShape) new ModShapes.All(shapeData), Actions.Chain((GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass()));
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), 10);
            return(true);
        }
Example #12
0
        public async Task <IActionResult> Index()
        {
            Scoring         scoring        = new Scoring();
            Top_Stocks      top_Stocks     = new Top_Stocks();
            List <Searches> unsortedStocks = new List <Searches>();

            //Will need to change once I've implemented time frame, but works for now

            //May be better in the Startup class, but works here for now

            var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);

            if (userId == null)
            {
                for (int i = 0; i < top_Stocks.possibleTopStocks.Count(); i++)
                {
                    Searches search = new Searches();
                    search.Symbol = top_Stocks.possibleTopStocks[i];
                    search.Score  = scoring.GetGoogleScore(search);
                    unsortedStocks.Add(search);
                }

                top_Stocks = SortStocks(unsortedStocks);
                //top_Stocks.UserId = userId;
                _context.Top_Stocks.Add(top_Stocks);
                await _context.SaveChangesAsync();

                List <string[]> peopleToContact = new List <string[]>();

                for (int i = 0; i < _context.User.Count(); i++)
                {
                    string[] person     = new string[2];
                    var      UserList   = _context.User.ToList();
                    var      IdUserList = _context.Users.ToList();
                    for (int j = 0; j < UserList.Count(); j++)
                    {
                        person[0] = UserList[j].FirstName + " " + UserList[j].LastName;
                        person[1] = IdUserList.Where(u => u.Id == UserList[j].UserId).FirstOrDefault().Email;
                        peopleToContact.Add(person);
                        //Not sure if this is disgusting or beautiful.. But it works
                    }
                }

                foreach (string[] person in peopleToContact)
                {
                    SendSimpleMessage(person, top_Stocks);
                    //I think it's running twice on sign in right now. Fix that
                }

                return(Redirect("./Identity/Account/Login"));
            }
            if (User.IsInRole("User"))
            {
                return(RedirectToAction("Index", "Users"));
            }
            return(View());
        }
Example #13
0
        /// <summary>
        /// 店铺搜索
        /// </summary>
        public ActionResult Search()
        {
            //搜索词
            string word = WebHelper.GetQueryString("word");

            if (word.Length == 0)
            {
                return(View("~/mobile/views/shared/prompt.cshtml", new PromptModel(WorkContext.UrlReferrer, "请输入关键词")));
            }

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, word);

            //判断搜索词是否为店铺分类名称,如果是则重定向到店铺分类页面
            int storeCid = Stores.GetStoreCidByStoreIdAndName(WorkContext.StoreId, word);

            if (storeCid > 0)
            {
                return(Redirect(Url.Action("class", new RouteValueDictionary {
                    { "storeId", WorkContext.StoreId }, { "storeCid", storeCid }
                })));
            }

            //排序列
            int sortColumn = WebHelper.GetQueryInt("sortColumn");
            //排序方向
            int sortDirection = WebHelper.GetQueryInt("sortDirection");
            //当前页数
            int page = WebHelper.GetQueryInt("page");

            //检查当前页数
            if (page < 1)
            {
                page = 1;
            }

            //商品总数量
            int totalCount = 0;
            //商品列表
            List <PartProductInfo> productList = null;

            Searches.SearchStoreProducts(20, page, word, WorkContext.StoreId, storeCid, 0, 0, sortColumn, sortDirection, ref totalCount, ref productList);

            //分页对象
            PageModel pageModel = new PageModel(20, page, totalCount);
            //视图对象
            StoreSearchModel model = new StoreSearchModel()
            {
                Word          = word,
                SortColumn    = sortColumn,
                SortDirection = sortDirection,
                PageModel     = pageModel,
                ProductList   = productList
            };

            return(View(model));
        }
Example #14
0
        // Token: 0x06000FB5 RID: 4021 RVA: 0x003F729C File Offset: 0x003F549C
        private Rectangle GetRoom(Point origin)
        {
            Point point;
            bool  flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Left(25), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point);
            Point point2;
            bool  arg_5E_0 = WorldUtils.Find(origin, Searches.Chain(new Searches.Right(25), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point2);

            if (!flag)
            {
                point = new Point(origin.X - 25, origin.Y);
            }
            if (!arg_5E_0)
            {
                point2 = new Point(origin.X + 25, origin.Y);
            }
            Rectangle rectangle = new Rectangle(origin.X, origin.Y, 0, 0);

            if (origin.X - point.X > point2.X - origin.X)
            {
                rectangle.X     = point.X;
                rectangle.Width = Utils.Clamp <int>(point2.X - point.X, 15, 30);
            }
            else
            {
                rectangle.Width = Utils.Clamp <int>(point2.X - point.X, 15, 30);
                rectangle.X     = point2.X - rectangle.Width;
            }
            Point point3;
            bool  flag2 = WorldUtils.Find(point, Searches.Chain(new Searches.Up(10), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point3);
            Point point4;
            bool  arg_164_0 = WorldUtils.Find(point2, Searches.Chain(new Searches.Up(10), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point4);

            if (!flag2)
            {
                point3 = new Point(origin.X, origin.Y - 10);
            }
            if (!arg_164_0)
            {
                point4 = new Point(origin.X, origin.Y - 10);
            }
            rectangle.Height = Utils.Clamp <int>(Math.Max(origin.Y - point3.Y, origin.Y - point4.Y), 8, 12);
            rectangle.Y     -= rectangle.Height;
            return(rectangle);
        }
        private Rectangle GetRoom(Point origin)
        {
            Point origin2;
            bool  flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Left(25), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out origin2);
            Point origin3;
            bool  flag2 = WorldUtils.Find(origin, Searches.Chain(new Searches.Right(25), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out origin3);

            if (!flag)
            {
                origin2 = new Point(origin.X - 25, origin.Y);
            }
            if (!flag2)
            {
                origin3 = new Point(origin.X + 25, origin.Y);
            }
            Rectangle result = new Rectangle(origin.X, origin.Y, 0, 0);

            if (origin.X - origin2.X > origin3.X - origin.X)
            {
                result.X     = origin2.X;
                result.Width = Utils.Clamp <int>(origin3.X - origin2.X, 15, 30);
            }
            else
            {
                result.Width = Utils.Clamp <int>(origin3.X - origin2.X, 15, 30);
                result.X     = origin3.X - result.Width;
            }
            Point point;
            bool  flag3 = WorldUtils.Find(origin2, Searches.Chain(new Searches.Up(10), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point);
            Point point2;
            bool  flag4 = WorldUtils.Find(origin3, Searches.Chain(new Searches.Up(10), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point2);

            if (!flag3)
            {
                point = new Point(origin.X, origin.Y - 10);
            }
            if (!flag4)
            {
                point2 = new Point(origin.X, origin.Y - 10);
            }
            result.Height = Utils.Clamp <int>(Math.Max(origin.Y - point.Y, origin.Y - point2.Y), 8, 12);
            result.Y     -= result.Height;
            return(result);
        }
Example #16
0
        private bool FindVerticalExit(Rectangle wall, bool isUp, out int exitX)
        {
            Point result;
            var   flag = WorldUtils.Find(new Point(wall.X + wall.Width - 3, wall.Y + (isUp ? -5 : 0)),
                                         Searches.Chain(new Searches.Left(wall.Width - 3),
                                                        new Conditions.IsSolid().Not().AreaOr(3, 5)), out result);

            exitX = result.X;
            return(flag);
        }
Example #17
0
        private bool FindSideExit(Rectangle wall, bool isLeft, out int exitY)
        {
            Point result;
            var   flag = WorldUtils.Find(new Point(wall.X + (isLeft ? -4 : 0), wall.Y + wall.Height - 3),
                                         Searches.Chain(new Searches.Up(wall.Height - 3),
                                                        new Conditions.IsSolid().Not().AreaOr(4, 3)), out result);

            exitY = result.Y;
            return(flag);
        }
Example #18
0
        /// <summary>
        /// Create a default settings with one search item and the default cache folder points to:
        /// C:\\ProgramData\\FromThe.Blue\\WallpaperAbyss\\
        /// </summary>
        public Settings()
        {
            CacheDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\FromThe.Blue\\WallpaperAbyss";

            SearchMethods search = new SearchMethods();

            search.Method = LookupMethods.newest;

            Searches.Add(search);
        }
        /// <summary>
        /// Handles the click on the delete search button.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        private void OnDeleteSearchClicked(object sender, RoutedEventArgs e)
        {
            var senderAsFrameworkElement = sender as FrameworkElement;

            if (senderAsFrameworkElement != null)
            {
                var search = senderAsFrameworkElement.DataContext as Search;
                Searches.Remove(search);
            }
        }
Example #20
0
        private void SubscribeSearches()
        {
            Searches.ToList().ForEach(s => s.PropertyChanged += (sender, args) => {
                if (args.PropertyName == "IsSelected")
                {
                    RaisePropertyChanged("AllSelected");
                }
            });

            RaisePropertyChanged("AllSelected");
        }
Example #21
0
        public override void AI()
        {
            Player player = Main.player[npc.target];

            npc.TargetClosest(true);

            if (frameType == attackFrameType)

            {
                attackTime++;
                npc.velocity.X = (0);
                npc.velocity.Y = (0);

                if (attackTime > ReloadTime)
                {
                    if (secondShot)
                    {
                        if (Main.netMode != 1)
                        {
                            Projectile.NewProjectile(npc.Center.X - (17f * npc.direction), npc.Center.Y - 40f, 0f, -10f, mod.ProjectileType("AntiAirRocket"), damage, 3f, Main.myPlayer);
                        }
                        //Projectile.NewProjectile(npc.Center.X-(17f*npc.direction), npc.Center.Y-40f, 0f, 0f, 102, damage, 3f, Main.myPlayer);
                        secondShot = false;
                        attackTime = 0;
                    }
                    else
                    {
                        if (Main.netMode != 1)
                        {
                            Projectile.NewProjectile(npc.Center.X + (23f * npc.direction), npc.Center.Y - 40f, 0f, -10f, mod.ProjectileType("AntiAirRocket"), damage, 3f, Main.myPlayer);
                        }
                        //Projectile.NewProjectile(npc.Center.X+(23f*npc.direction), npc.Center.Y-40f, 0f, 0f, 102, damage, 3f, Main.myPlayer);
                        secondShot = true;
                        attackTime = 0;
                    }
                }
            }

            float playerPositionSummery = player.Center.Y - npc.Center.Y;
            Point origin = player.Center.ToTileCoordinates();
            Point point;

            if (playerPositionSummery < -200f && !WorldUtils.Find(origin, Searches.Chain(new Searches.Down(12), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point))
            {
                frameType = attackFrameType;
            }
            else
            {
                frameType = moveFrameType;
            }
        }
Example #22
0
        private Rectangle GetRoom(Point origin)
        {
            Point result1;
            bool  flag1 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Left(25), (GenCondition) new Conditions.IsSolid()), out result1);
            Point result2;
            bool  flag2 = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Right(25), (GenCondition) new Conditions.IsSolid()), out result2);

            if (!flag1)
            {
                result1 = new Point(origin.X - 25, (int)origin.Y);
            }
            if (!flag2)
            {
                result2 = new Point(origin.X + 25, (int)origin.Y);
            }
            Rectangle rectangle;

            // ISSUE: explicit reference operation
            ((Rectangle)@rectangle).\u002Ector((int)origin.X, (int)origin.Y, 0, 0);
            if (origin.X - result1.X > result2.X - origin.X)
            {
                rectangle.X     = result1.X;
                rectangle.Width = (__Null)Utils.Clamp <int>((int)(result2.X - result1.X), 15, 30);
            }
            else
            {
                rectangle.Width = (__Null)Utils.Clamp <int>((int)(result2.X - result1.X), 15, 30);
                rectangle.X     = result2.X - rectangle.Width;
            }
            Point result3;
            bool  flag3 = WorldUtils.Find(result1, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result3);
            Point result4;
            bool  flag4 = WorldUtils.Find(result2, Searches.Chain((GenSearch) new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result4);

            if (!flag3)
            {
                result3 = new Point((int)origin.X, origin.Y - 10);
            }
            if (!flag4)
            {
                result4 = new Point((int)origin.X, origin.Y - 10);
            }
            rectangle.Height = (__Null)Utils.Clamp <int>(Math.Max((int)(origin.Y - result3.Y), (int)(origin.Y - result4.Y)), 8, 12);
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Rectangle& local1 = @rectangle;
            // ISSUE: explicit reference operation
            // ISSUE: variable of the null type
            __Null local2 = (^ local1).Y - rectangle.Height;

            // ISSUE: explicit reference operation
            (^ local1).Y = local2;
            return(rectangle);
        }
        public async Task <IActionResult> Create([Bind("Id,Ticker,Score,DateSearched")] Searches searches)
        {
            if (ModelState.IsValid)
            {
                _context.Add(searches);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(searches));
        }
Example #24
0
        void Load()
        {
            try
            {
                Servers = _db.Query <Servers>(typeof(Servers))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (Servers == null)
            {
                Servers = new Servers();
                _db.Store(Servers);
            }

            try
            {
                Files = _db.Query <Files>(typeof(Files))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (Files == null)
            {
                Files = new Files();
                _db.Store(Files);
            }

            try
            {
                Searches = _db.Query <Searches>(typeof(Searches))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (Searches == null)
            {
                Searches = new Searches();
                _db.Store(Searches);
            }

            try
            {
                ApiKeys = _db.Query <ApiKeys>(typeof(ApiKeys))[0];
            }
            catch (InvalidOperationException) {}
            catch (Db4oRecoverableException) {}
            if (ApiKeys == null)
            {
                ApiKeys = new ApiKeys();
                _db.Store(ApiKeys);
            }

            TryCommit();
        }
Example #25
0
        private Rectangle GetRoom(Point origin)
        {
            Point result1;
            var   flag1 = WorldUtils.Find(origin,
                                          Searches.Chain(new Searches.Left(25), (GenCondition) new Conditions.IsSolid()),
                                          out result1);
            Point result2;
            var   flag2 = WorldUtils.Find(origin,
                                          Searches.Chain(new Searches.Right(25), (GenCondition) new Conditions.IsSolid()),
                                          out result2);

            if (!flag1)
            {
                result1 = new Point(origin.X - 25, origin.Y);
            }
            if (!flag2)
            {
                result2 = new Point(origin.X + 25, origin.Y);
            }
            var rectangle =
                new Rectangle(origin.X, origin.Y, 0, 0);

            if (origin.X - result1.X > result2.X - origin.X)
            {
                rectangle.X     = result1.X;
                rectangle.Width = Utils.Clamp(result2.X - result1.X, 15, 30);
            }
            else
            {
                rectangle.Width = Utils.Clamp(result2.X - result1.X, 15, 30);
                rectangle.X     = result2.X - rectangle.Width;
            }

            Point result3;
            var   flag3 = WorldUtils.Find(result1,
                                          Searches.Chain(new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result3);
            Point result4;
            var   flag4 = WorldUtils.Find(result2,
                                          Searches.Chain(new Searches.Up(10), (GenCondition) new Conditions.IsSolid()), out result4);

            if (!flag3)
            {
                result3 = new Point(origin.X, origin.Y - 10);
            }
            if (!flag4)
            {
                result4 = new Point(origin.X, origin.Y - 10);
            }
            rectangle.Height = Utils.Clamp(Math.Max(origin.Y - result3.Y, origin.Y - result4.Y), 8, 12);
            rectangle.Y     -= rectangle.Height;
            return(rectangle);
        }
            public override void ModifyHitNPC(Item item, NPC target, ref int damage, ref float knockback, ref bool crit)
            {
                Point origin = player.Bottom.ToTileCoordinates();
                Point point;

                if (effect && !WorldUtils.Find(origin, Searches.Chain(new Searches.Down(3), new GenCondition[]
                {
                    new Conditions.IsSolid()
                }), out point) && player.grappling[0] == -1)
                {
                    damage *= 2;
                }
            }
Example #27
0
        public void RemoveSearch(string queryString)
        {
            int index = Searches.IndexOf(queryString);

            if (index == -1)
            {
                return;
            }

            Searches.RemoveAt(index);

            SearchesChanged.Invoke(this, EventArgs.Empty);
        }
Example #28
0
        protected virtual void OnSearchItemAdded(int galleryId)
        {
            int itemIndex = Searches.IndexOf(galleryId);

            if (itemIndex != -1)
            {
                Searches.RemoveAt(itemIndex);
            }

            Searches.Insert(0, galleryId);

            SearchesChanged.Invoke(this, EventArgs.Empty);
        }
Example #29
0
        public ActionResult KeyWordSearch()
        {
            //搜索词
            string keyword = WebHelper.GetQueryString("keyword");

            WorkContext.SearchWord = WebHelper.HtmlEncode(keyword);
            if (keyword.Length == 0)
            {
                return(PromptView(WorkContext.UrlReferrer, "请输入搜索词"));
            }
            if (!SecureHelper.IsSafeSqlString(keyword))
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            //异步保存搜索历史
            Asyn.UpdateSearchHistory(WorkContext.Uid, keyword);

            //获取当前搜索词匹配缓存结果
            ProductSearchKeyInfo keyInfo = BMACache.Get(keyword) as ProductSearchKeyInfo;

            if (keyInfo != null && string.IsNullOrEmpty(keyInfo.Name)) //无匹配
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            if (keyInfo == null) //未匹配过
            {
                keyInfo = Searches.GetProductSearchKey(keyword);
                if (keyInfo == null || string.IsNullOrEmpty(keyInfo.Name))
                {
                    keyInfo = new ProductSearchKeyInfo()
                    {
                        Name    = "",
                        keyType = -1,
                        ToId    = -1
                    };
                }
                BMACache.Insert(keyword, keyInfo);
            }

            //再次判断搜索词匹配结果
            if (keyInfo != null && string.IsNullOrEmpty(keyInfo.Name)) //无匹配
            {
                return(PromptView(WorkContext.UrlReferrer, "您搜索的商品不存在"));
            }

            return(Redirect(Url.Action("categorysearch", new RouteValueDictionary {
                { "keyword", keyword }, { "searchKeyType", keyInfo.keyType }, { "searchKeyId", keyInfo.ToId }
            })));
        }
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3)
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(100), new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            Point result;

            if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain(new Searches.Down(5), new Conditions.IsTile(25).AreaAnd(8, 1)), out result))
            {
                return(false);
            }
            ShapeData shapeData  = new ShapeData();
            ShapeData shapeData2 = new ShapeData();
            ShapeData shapeData3 = new ShapeData();

            for (int i = 0; i < 6; i++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(10, 12) + i), Actions.Chain(new Modifiers.Offset(0, 5 * i + 5), new Modifiers.Blotches(3).Output(shapeData)));
            }
            for (int j = 0; j < 6; j++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(5, 7) + j), Actions.Chain(new Modifiers.Offset(0, 2 * j + 18), new Modifiers.Blotches(3).Output(shapeData2)));
            }
            for (int k = 0; k < 6; k++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2), Actions.Chain(new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10), new Modifiers.Blotches(3).Output(shapeData3)));
            }
            ShapeData shapeData4 = new ShapeData(shapeData2);

            shapeData2.Subtract(shapeData3, origin, origin);
            shapeData4.Subtract(shapeData2, origin, origin);
            Rectangle bounds = ShapeData.GetBounds(origin, shapeData, shapeData3);

            if (!structures.CanPlace(bounds, ValidTiles, 2))
            {
                return(false);
            }
            WorldUtils.Gen(origin, new ModShapes.All(shapeData), Actions.Chain(new Actions.SetTile(25, true), new Actions.PlaceWall(3)));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData2), new Actions.SetTile(0, true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData3), new Actions.ClearTile(true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData2), Actions.Chain(new Modifiers.IsTouchingAir(true), new Modifiers.NotTouching(false, 25), new Actions.SetTile(23, true)));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData4), new Actions.PlaceWall(69));
            structures.AddStructure(bounds, 2);
            return(true);
        }