public async Task <IActionResult> AddCategory(Category category, IFormFile pathImage) { if (ModelState.IsValid) { await _context.Categories.AddAsync(category); await _context.SaveChangesAsync(); PathImage image = new PathImage { NameImage = pathImage.FileName, ProductId = null, CategoryId = category.Id, SubCategoryId = null, Slider = false, TypeImage = pathImage.ContentType }; await _context.PathImages.AddAsync(image); await SaveFile(category, pathImage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> AddProduct(Product product, IFormFile pathImage) { if (ModelState.IsValid) { await _context.Products.AddAsync(product); await _context.SaveChangesAsync(); PathImage nameImage = new PathImage { NameImage = pathImage.FileName, ProductId = product.Id, Slider = false, CategoryId = null, SubCategoryId = null, TypeImage = pathImage.ContentType }; await _context.PathImages.AddAsync(nameImage); await SaveFile(product, pathImage); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <VirtualFileResult> GetImage(int?id) { if (id.HasValue) { PathImage image = await _context.PathImages.FindAsync(id); string currentDirectory = "/Content/Slider/" + image.Id; if (CheckFile(_appEnvironment.WebRootPath + currentDirectory, image.NameImage)) { return(File(Path.Combine("~" + currentDirectory, image.NameImage), image.TypeImage, image.NameImage)); } else { currentDirectory = "~/Content/"; image = new PathImage { NameImage = "image-aborted.jpg", TypeImage = "image/jpeg" }; return(File(Path.Combine(currentDirectory, image.NameImage), image.TypeImage, image.NameImage)); } } else { string currentDirectory = "~/Content/"; PathImage image = new PathImage { NameImage = "plus.png", TypeImage = "image/png" }; return(File(Path.Combine(currentDirectory, image.NameImage), image.TypeImage, image.NameImage)); } }
public void TestPathImageKalimdor() { System.Collections.Generic.List <Hop> path; var bas = new Vector3(1825.286f, -4395.726f, 103.5342f); var haut = new Vector3(1845.853f, -4396.072f, 135.2314f); string ipath = iBaseMeshesPath + "Kalimdor"; Pather = new Pather(@ipath, MockConnectionHandler); Pather.Filter.SetAreaCost((int)PolyArea.Water, 4); Pather.Filter.SetAreaCost((int)PolyArea.Terrain, 1); Pather.Filter.SetAreaCost((int)PolyArea.Road, 1); Pather.Filter.SetAreaCost((int)PolyArea.Danger, 20); double l; PathImage image; System.Console.WriteLine("Test Orgrimar..."); l = TryHugePath(bas, haut, out path); image = new PathImage(Pather.Continent, 128 * 1, 128 * 1, path); image.Generate(); image.Result.Save("TestOrgrimmar.png", ImageFormat.Png); System.Console.WriteLine("Test Orgrimmar Length : " + l); System.Console.WriteLine("--------------------------------------------"); }
public void TestPathImageDraenor() { System.Collections.Generic.List <Hop> path; var pt1 = new Vector3(4069.933f, -2376.877f, 94.60396f); // porte de tenebres var pt2 = new Vector3(1845.853f, -4396.072f, 135.2314f); var pop = new Vector3(1583.356f, 106.8728f, 65.87754f); var TelaariNagran = new Vector3(2563.416f, 5700.69f, 102.2419f); string ipath = iBaseMeshesPath + "Draenor"; Pather = new Pather(@ipath, MockConnectionHandler); Pather.Filter.SetAreaCost((int)PolyArea.Water, 4); Pather.Filter.SetAreaCost((int)PolyArea.Terrain, 1); Pather.Filter.SetAreaCost((int)PolyArea.Road, 1); Pather.Filter.SetAreaCost((int)PolyArea.Danger, 20); double l; PathImage image; System.Console.WriteLine("Test Draenor..."); l = TryHugePath(pop, TelaariNagran, out path); image = new PathImage(Pather.Continent, 128 * 11, 128 * 4, path); image.Generate(); image.Result.Save("TestDraenor.png", ImageFormat.Png); System.Console.WriteLine("Test Draenor Length : " + l); System.Console.WriteLine("--------------------------------------------"); }
private void PathOsu_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { IsTruePath(); PathImage.Focus(); } }
public async Task <VirtualFileResult> GetImage(int id, string typeObject) { string currentDirectory = ""; PathImage image = null; if (!String.IsNullOrEmpty(typeObject)) { if (typeObject.Equals("product")) { image = await _context.PathImages.FirstOrDefaultAsync(i => i.ProductId == id); currentDirectory += "/Content/Product/" + id; } else if (typeObject.Equals("subCategory")) { image = await _context.PathImages.FirstOrDefaultAsync(i => i.SubCategoryId == id); currentDirectory += "/Content/SubCategory/" + id; } else if (typeObject.Equals("category")) { image = await _context.PathImages.FirstOrDefaultAsync(i => i.CategoryId == id); currentDirectory += "/Content/Category/" + id; } else if (typeObject.Equals("slider")) { image = await _context.PathImages.FindAsync(id); currentDirectory += "/Content/Slider/" + image.Id; } else if (typeObject.Equals("maps")) { image = new PathImage { NameImage = "maps.png", TypeImage = "image/png" }; currentDirectory = "/Content/"; } } if (CheckFile(_appEnvironment.WebRootPath + currentDirectory, image.NameImage)) { return(File(Path.Combine("~" + currentDirectory, image.NameImage), image.TypeImage, image.NameImage)); } else { currentDirectory = "~/Content/"; image = new PathImage { NameImage = "image-aborted.jpg" }; return(File(Path.Combine(currentDirectory, image.NameImage), "image/jpg", image.NameImage)); } }
public void TestPathImage() { System.Collections.Generic.List <Hop> path; //TryPath(new Vector3(-8949.918f, -133.572f, 83.589f), new Vector3(-8957.4f, 517.3f, 96.3f), out path, true); //TryPath(new Vector3(-8020f, 1515f, -1.5f), new Vector3(-8015f, 1515f, -1.5f), out path, true); //TryPath(new Vector3(-8957.4f, 517.3f, 96.3f), new Vector3(-8476.375f, 1257.56f, 5.238828f), out path, true); TryPath(new Vector3(1209.394f, -3645.967f, 97.30154f), new Vector3(-448.6f, -2641.4f, 95.5f), out path, true); Assert.NotNull(path); var image = new PathImage(Pather.Continent, 256 * 3, 256 * 4, path); image.Generate(); image.Result.Save("S:\\meshReader\\PathImageTest.png", ImageFormat.Png); }
public async Task <IActionResult> DeleteImage(int id) { PathImage image = await _context.PathImages.FindAsync(id); string currentDirectory = "/Content/Slider/" + image.Id; if (CheckFile(_appEnvironment.WebRootPath + currentDirectory, image.NameImage)) { FileInfo file = new FileInfo(_appEnvironment.WebRootPath + currentDirectory); file.Delete(); } _context.PathImages.Remove(image); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
protected void Button1_Click(object sender, EventArgs e) { if (PathImage.HasFile == true) { LabelImage.Text = "file is selected"; string virtual_path = "~/img/"; string physical_path = Server.MapPath(virtual_path); PathImage.SaveAs(physical_path + PathImage.FileName); LabelImage.Text = "file saved"; Image1.ImageUrl = virtual_path + PathImage.FileName; } else { LabelImage.Text = "please select a file"; } }
// установка новой цели движения public void OnSetTarget(TargetPoint point) { if (targetPoint != null) { targetPoint.DeleteLink(); } if (!TerrainNavGrid.IsPositionCorrect(point.Position)) { return; } StopMove(); targetPoint = point; targetPoint.AddLink(); PathImage = new PathImage(GameParams.Width, GameParams.Length); SetMovePosition(targetPoint.Position); }
private async Task <bool> SaveFile(PathImage pathImage, IFormFile formFile) { bool result = false; string pathSaveFile = _appEnvironment.WebRootPath + "/Content/Slider/" + pathImage.Id; if (!Directory.Exists(pathSaveFile)) { Directory.CreateDirectory(pathSaveFile); } pathSaveFile += "/" + formFile.FileName; using (var fileStream = new FileStream(pathSaveFile, FileMode.Create)) { await formFile.CopyToAsync(fileStream); result = true; } return(result); }
public async Task <IActionResult> AddImage(IFormFile pathImage) { PathImage image = new PathImage { NameImage = pathImage.FileName, TypeImage = pathImage.ContentType, Slider = true, CategoryId = null, ProductId = null, SubCategoryId = null }; await _context.PathImages.AddAsync(image); await _context.SaveChangesAsync(); SaveFile(image, pathImage); return(RedirectToAction(nameof(Index))); }
/// <summary> /// Used to save path to bitmap /// </summary> public void SavePathToBitmap(string filename, PathImage pathImage) { // Genrates bitmap BMP24Bit bitmap = new BMP24Bit(mWidth, mHeight); // Sets bitmap data to the specified path image switch (pathImage) { case PathImage.ColorImage: bitmap.BitmapArray = mColorArray; break; case PathImage.WaveImage: bitmap.BitmapArray = mDistanceArray; break; } // Saves bitmap bitmap.Export(filename); }
public async Task <IActionResult> EditCategory(Category category, IFormFile pathImage) { if (ModelState.IsValid) { PathImage image = await _context.PathImages.FirstOrDefaultAsync(c => c.CategoryId == category.Id); if (pathImage != null) { image.NameImage = pathImage.FileName; await SaveFile(category, pathImage); _context.PathImages.Update(image); } _context.Categories.Update(category); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> EditProduct(Product product, IFormFile pathImage) { if (ModelState.IsValid) { PathImage image = await _context.PathImages.FirstOrDefaultAsync(p => p.ProductId == product.Id); if (pathImage != null) { image.NameImage = pathImage.FileName; await SaveFile(product, pathImage); _context.PathImages.Update(image); } _context.Products.Update(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
private void Draw(bool erase, bool autoZoom) { if (erase) { pictureBox1.Image = new System.Drawing.Bitmap(519, 411); toolStripStatusLabel1.Text = "Please open a file"; textBox1.Visible = true; textBox1.Text = "Invalid profile"; } else { if (Hops != null) // it's null during initialize { try { textBox1.Text = "Please Wait..."; textBox1.Visible = true; this.Refresh(); var image = new PathImage(continent, Hops, NpcDB, autoZoom, zoom, ignorewater); image.Generate(GetScreen().Width, GetScreen().Height, out zoom); textBox1.Visible = false; this.Controls.Remove(pictureBox1); pictureBox1.Image = image.Result; this.Controls.Add(pictureBox1); toolStripStatusLabel1.Text = Hops.Count + " nodes in the path"; } catch { pictureBox1.Image = new System.Drawing.Bitmap(519, 411); toolStripStatusLabel1.Text = "Please open a file"; textBox1.Visible = true; textBox1.Text = "An error occured, be sure to use the proper map"; } } } }
public void TestPathImageWestern() { System.Collections.Generic.List <Hop> path; // Azeroth var IronForgeFly = new Vector3(-4821.13f, -1152.4f, 502.295f); var LocModanCityFly = new Vector3(-5424.85f, -2929.87f, 347.645f); var BootyTunnel = new Vector3(-14247.34f, 328.0565f, 24.18314f); var MalTerreEstNord = new Vector3(3362.56f, -4446.57f, 127.746f); var BootyBay = new Vector3(-14374.42f, 382.3631f, 22.77349f); var Goldshire = new Vector3(-9465.505f, 73.8429f, 56.57315f); var AgentKearnenInWestFall = new Vector3(-11042.13f, 625.1042f, 36.90501f); var TopOfTowerInWestfall = new Vector3(-11132.36f, 555.1247f, 70.38676f); // Kalimdor string ipath = iBaseMeshesPath + "Azeroth"; Pather = new Pather(@ipath, MockConnectionHandler); Pather.Filter.SetAreaCost((int)PolyArea.Water, 4); Pather.Filter.SetAreaCost((int)PolyArea.Terrain, 1); Pather.Filter.SetAreaCost((int)PolyArea.Road, 1); Pather.Filter.SetAreaCost((int)PolyArea.Danger, 20); double l; PathImage image; /*TryPath(IronForgeFly, LocModanCityFly, out path, true); * * Assert.NotNull(path); * * image = new PathImage(Pather.Continent, 128*5, 128*2, path); // 5 * 2 * image.Generate(); * image.Result.Save("IronForgeLocModan.png", ImageFormat.Png); */ System.Console.WriteLine("AgentKearnen-Tower..."); l = TryHugePath(AgentKearnenInWestFall, TopOfTowerInWestfall, out path); image = new PathImage(Pather.Continent, 128 * 1, 128 * 1, path); image.Generate(); image.Result.Save("AgentKearnenToTower.png", ImageFormat.Png); System.Console.WriteLine("AgentKearnen-Tower Length : " + l); System.Console.WriteLine("--------------------------------------------"); /*System.Console.WriteLine("BootyTunnel-BootyBay..."); * l = TryHugePath(BootyTunnel, BootyBay, out path); * image = new PathImage(Pather.Continent, 128 * 5, 128 * 2, path); * image.Generate(); * image.Result.Save("BootyTunnelBootyBay.png", ImageFormat.Png); * System.Console.WriteLine("BootyTunnel-BootyBay Length : " + l); * System.Console.WriteLine("--------------------------------------------");*/ System.Console.WriteLine("IronForge-LocModanCity..."); l = TryPath(IronForgeFly, LocModanCityFly, out path, true); image = new PathImage(Pather.Continent, 128 * 5, 128 * 2, path); image.Generate(); image.Result.Save("IronForgeLocModanCity.png", ImageFormat.Png); System.Console.WriteLine("IronForge-LocModanCity Length : " + l); System.Console.WriteLine("--------------------------------------------"); System.Console.WriteLine("Goldshire-IronForge..."); l = TryHugePath(Goldshire, IronForgeFly, out path); image = new PathImage(Pather.Continent, 128 * 6, 128 * 10, path); image.Generate(); image.Result.Save("GoldshireIronForge.png", ImageFormat.Png); System.Console.WriteLine("Goldshire-IronForge Length : " + l); System.Console.WriteLine("--------------------------------------------"); System.Console.WriteLine("IronForge-Goldshire..."); l = TryHugePath(IronForgeFly, Goldshire, out path); image = new PathImage(Pather.Continent, 128 * 6, 128 * 10, path); image.Generate(); image.Result.Save("IronForgeGoldshire.png", ImageFormat.Png); System.Console.WriteLine("IronForge-Goldshire Length : " + l); System.Console.WriteLine("--------------------------------------------"); /*System.Console.WriteLine("Goldshire-BootyTunnel..."); * l = TryHugePath(Goldshire, BootyTunnel, out path); * image = new PathImage(Pather.Continent, 128 * 2, 128 * 10, path); * image.Generate(); * image.Result.Save("GoldshireBootyTunnel.png", ImageFormat.Png); * System.Console.WriteLine("Goldshire-BootyTunnel Length : " + l); * System.Console.WriteLine("--------------------------------------------");*/ System.Console.WriteLine("Goldshire-BootyTown..."); l = TryHugePath(Goldshire, BootyBay, out path); image = new PathImage(Pather.Continent, 128 * 2, 128 * 10, path); image.Generate(); image.Result.Save("GoldshireBootyTown.png", ImageFormat.Png); System.Console.WriteLine("Goldshire-BootyTown Length : " + l); System.Console.WriteLine("--------------------------------------------"); System.Console.WriteLine("IronForge-Booty..."); l = TryHugePath(IronForgeFly, BootyBay, out path); image = new PathImage(Pather.Continent, 128 * 6, 128 * 18, path); image.Generate(); image.Result.Save("IronForgeBooty.png", ImageFormat.Png); System.Console.WriteLine("IronForge-Booty Length : " + l); System.Console.WriteLine("--------------------------------------------"); System.Console.WriteLine("IronForge-MalTerre..."); l = TryHugePath(IronForgeFly, MalTerreEstNord, out path); image = new PathImage(Pather.Continent, 128 * 8, 128 * 18, path); image.Generate(); image.Result.Save("IronForgeMalTerre.png", ImageFormat.Png); System.Console.WriteLine("IronForge-MalTerre Length : " + l); System.Console.WriteLine("--------------------------------------------"); // And the final one, the biggest, the best, the .... I am the best ^^ System.Console.WriteLine("Booty-MalTerre..."); l = TryHugePath(BootyBay, MalTerreEstNord, out path); image = new PathImage(Pather.Continent, 128 * 10, 128 * 34, path); image.Generate(); image.Result.Save("BootyMalTerre.png", ImageFormat.Png); System.Console.WriteLine("Booty-MalTerre Length : " + l); }
protected override void OnModelCreating(ModelBuilder modelBuilder) { string adminRoleName = "admin"; string userRoleName = "user"; string adminEmail = "admin"; string adminPassword = "******"; string userEmail = "user"; string userPassword = "******"; Role adminRole = new Role { Id = 1, TitleRole = "Администратор", DescriptionRole = adminRoleName }; Role userRole = new Role { Id = 2, TitleRole = "Пользователь", DescriptionRole = userRoleName }; Position positionAdmin = new Position { Id = 1, TitlePosition = "admin" }; Position positionUser = new Position { Id = 2, TitlePosition = "user" }; Staff staffAdmin = new Staff { Id = 1, PositionId = positionAdmin.Id, Age = 21, FullNameStaff = "Администратор" }; Staff staffUser = new Staff { Id = 2, PositionId = positionUser.Id, Age = 21, FullNameStaff = "Менеджер" }; User adminUser = new User { Id = 1, LoginUser = adminEmail, PasswordUser = adminPassword, RoleId = adminRole.Id, StaffId = staffAdmin.Id }; User userUser = new User { Id = 2, LoginUser = userEmail, PasswordUser = userPassword, RoleId = userRole.Id, StaffId = staffUser.Id }; Category izmer = new Category { Id = 1, TitleCategory = "Измерительный инструмент", DescriptionCategory = "Измерительный инструмент" }; Category elektro = new Category { Id = 2, TitleCategory = "Электроинструмент", DescriptionCategory = "Электроинструмент" }; Category sant = new Category { Id = 3, TitleCategory = "Сантехника", DescriptionCategory = "Сантехника" }; SubCategory subCategoryIzmer1 = new SubCategory { Id = 1, TitleSubCategory = "Линейки", CategoryId = izmer.Id, DescriptionSubCategory = "1" }; SubCategory subCategoryIzmer2 = new SubCategory { Id = 2, TitleSubCategory = "Уровни", CategoryId = izmer.Id, DescriptionSubCategory = "2" }; SubCategory subCategoryIzmer3 = new SubCategory { Id = 3, TitleSubCategory = "Нивелиры лазерные", CategoryId = izmer.Id, DescriptionSubCategory = "3" }; Product productTest1 = new Product { Id = 1, TitleProduct = "Линейка измерительная 300", Price = 1230, SubCategoryId = subCategoryIzmer1.Id, DescriptionProduct = "1" }; Product productTest2 = new Product { Id = 2, TitleProduct = "Линейка измерительная 500", Price = 1200, SubCategoryId = subCategoryIzmer1.Id, DescriptionProduct = "1" }; Product productTest3 = new Product { Id = 3, TitleProduct = "Линейка измерительная 1000", Price = 1200, SubCategoryId = subCategoryIzmer1.Id, DescriptionProduct = "1" }; Product productTest4 = new Product { Id = 4, TitleProduct = "Тестовый продукт категории 2", Price = 1200, SubCategoryId = subCategoryIzmer2.Id, DescriptionProduct = "2" }; Product productTest5 = new Product { Id = 5, TitleProduct = "Тестовый продукт категории 2", Price = 1200, SubCategoryId = subCategoryIzmer2.Id, DescriptionProduct = "2" }; PathImage pathImagesIzmer1 = new PathImage { Id = 1, NameImage = "izmer.jpg", ProductId = productTest1.Id, CategoryId = izmer.Id, SubCategoryId = subCategoryIzmer1.Id, Slider = false, TypeImage = "image/jpeg" }; PathImage pathImagesTest2 = new PathImage { Id = 2, NameImage = "esteamerby.png", ProductId = productTest2.Id, CategoryId = elektro.Id, SubCategoryId = subCategoryIzmer2.Id, Slider = false, TypeImage = "image/png" }; PathImage pathImagesTest3 = new PathImage { Id = 3, NameImage = "esteamerby.png", ProductId = productTest3.Id, CategoryId = izmer.Id, Slider = false, TypeImage = "image/png" }; PathImage pathImagesTest4 = new PathImage { Id = 4, NameImage = "esteamerby.png", ProductId = productTest4.Id, CategoryId = elektro.Id, SubCategoryId = subCategoryIzmer1.Id, Slider = false, TypeImage = "image/png" }; PathImage pathImagesTest5 = new PathImage { Id = 5, NameImage = "esteamerby.png", ProductId = productTest5.Id, CategoryId = izmer.Id, Slider = false, TypeImage = "image/png" }; PathImage sliderTest1 = new PathImage { Id = 6, ProductId = null, NameImage = "1.jpg", Slider = true, TypeImage = "image/jpeg" }; PathImage sliderTest2 = new PathImage { Id = 7, ProductId = null, NameImage = "2.jpg", Slider = true, TypeImage = "image/jpeg" }; Client client = new Client { Id = 1, EmailClient = "*****@*****.**", Address = "Гомель", FamClient = "Иванов", FirstNameClient = "Иван", LastNameClient = "Иванович", LoginClient = "ivanov", NumberTelephone = "375 44 333 33 33", PasswordClient = "123" }; PayMethod payMethodTest1 = new PayMethod { Id = 1, TitlePayMethod = "Наличными" }; PayMethod payMethodTest2 = new PayMethod { Id = 2, TitlePayMethod = "Кредит или рассрочка" }; PayMethod payMethodTest3 = new PayMethod { Id = 3, TitlePayMethod = "Терминал" }; DeliveryMethod deliveryMethodTest1 = new DeliveryMethod { Id = 1, TitleDeliveryMethod = "Самовывоз - бесплатно" }; DeliveryMethod deliveryMethodTest2 = new DeliveryMethod { Id = 2, TitleDeliveryMethod = "Курьером: по Гомелю" }; DeliveryMethod deliveryMethodTest3 = new DeliveryMethod { Id = 3, TitleDeliveryMethod = "Курьером по Гомельской области" }; modelBuilder.Entity <Position>().HasData(new Position[] { positionAdmin, positionUser }); modelBuilder.Entity <Staff>().HasData(new Staff[] { staffAdmin, staffUser }); modelBuilder.Entity <Role>().HasData(new Role[] { adminRole, userRole }); modelBuilder.Entity <User>().HasData(new User[] { adminUser, userUser }); modelBuilder.Entity <Category>().HasData(new Category[] { izmer, elektro }); modelBuilder.Entity <SubCategory>().HasData(new SubCategory[] { subCategoryIzmer1, subCategoryIzmer2, subCategoryIzmer3 }); modelBuilder.Entity <PathImage>().HasData(new PathImage[] { pathImagesIzmer1, pathImagesTest2, pathImagesTest3, pathImagesTest4, pathImagesTest5, sliderTest1, sliderTest2 }); modelBuilder.Entity <Product>().HasData(new Product[] { productTest1, productTest2, productTest3, productTest4, productTest5 }); modelBuilder.Entity <Client>().HasData(new Client[] { client }); modelBuilder.Entity <PayMethod>().HasData(new PayMethod[] { payMethodTest1, payMethodTest2, payMethodTest3 }); modelBuilder.Entity <DeliveryMethod>().HasData(new DeliveryMethod[] { deliveryMethodTest1, deliveryMethodTest2, deliveryMethodTest3 }); base.OnModelCreating(modelBuilder); }