// POST: ImageGroups/Delete/5 public ActionResult Delete([Bind(Include = "Id")] ImageGroup imageGroup) { var password = Request["Password"] != null ? Request["Password"] : null; var realImageGroup = db.ImageGroups.Find(imageGroup.ID); if (password == null) { return(View(imageGroup)); } else if (password != Properties.Resources.Password) { return(new HttpUnauthorizedResult()); } else { var images = realImageGroup.ImageValue.ToArray(); foreach (var image in images) { db.Images.Remove(image); } db.ImageGroups.Remove(realImageGroup); db.SaveChanges(); return(RedirectToAction("Index")); } }
public static void PutAsMetadata([NotNull] ProvidedTrack builder, [NotNull] ImageGroup group) { foreach (var image in group.Image) { String key; switch (image.Size) { case global::SpotifyProto.Image.Types.Size.Default: key = "image_url"; break; case global::SpotifyProto.Image.Types.Size.Small: key = "image_small_url"; break; case global::SpotifyProto.Image.Types.Size.Large: key = "image_large_url"; break; case global::SpotifyProto.Image.Types.Size.Xlarge: key = "image_xlarge_url"; break; default: continue; } builder.Metadata[key] = new ImageId(image.FileId).Uri; } }
public static void GenerateSnapshot(ImageGroup group) { if (group == null || group.entries.Count <= 0) { return; } GenerateSnapshot(group.entries[0]); }
internal void SetImageGroupLabels(ImageGroup data, string imageId, DataLabels labels) { data.Labels[imageId] = labels; var path = Path.Combine(_rootDataPath, data.Id, "labels.json"); var json = JsonConvert.SerializeObject(data.Labels); File.WriteAllText(path, json); }
public AudiosurfSkin() { SkySpheres = new ImageGroup(); Cliffs = new ImageGroup(); Hits = new ImageGroup(); Particles = new ImageGroup(); Rings = new ImageGroup(); Tiles = new NamedBitmap(); TilesFlyup = new NamedBitmap(); }
public async Task SetImageGroupLabels(ImageGroup group, Dictionary <string, DataLabels> labels) { var groupLabels = new Dictionary <string, DataLabels>(labels); foreach (var pair in group.Labels) { groupLabels[pair.Key] = pair.Value; } var file = Path.Combine(_rootDataPath, group.Id, "labels.json"); var content = JsonConvert.SerializeObject(groupLabels); await File.WriteAllTextAsync(file, content); }
private static bool GroupResourcesReferenceIsCorrect(ImageGroup group) { foreach (var entry in group.entries) { var path = entry.resourcePath; if (Resources.Load <Sprite>(path) == null) { return(false); } } return(true); }
public static ImageId BiggestImage(ImageGroup group) { global::SpotifyProto.Image biggest = null; foreach (var image in group.Image) { if (biggest == null || biggest.Size < image.Size) { biggest = image; } } return(biggest == null ? null : new ImageId(biggest.FileId)); }
// GET: ImageGroups/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ImageGroup imageGroup = db.ImageGroups.Find(id); if (imageGroup == null) { return(HttpNotFound()); } return(View(imageGroup)); }
public ActionResult Edit([Bind(Include = "ID,Date,Name,Description")] ImageGroup imageGroup) { if (ModelState.IsValid) { var password = Request["Password"] != null ? Request["Password"] : null; if (password == Properties.Resources.Password) { db.Entry(imageGroup).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(imageGroup)); }
public AudiosurfSkin CreateSkinFromFolder(string path) { var result = new AudiosurfSkin(); string[] AllPictures = Directory.GetFiles(path); if (!AllPictures.Any(fileName => texturesNames.Contains(Path.GetFileName(fileName)))) { return(null); } foreach (var mask in masks) { if (mask == EnvironmentalVeriables.CliffImagesMask) { result.Cliffs = GetAllImagesByNameMask("cliffs", mask, path); } if (mask == EnvironmentalVeriables.HitImageMask) { result.Hits = GetAllImagesByNameMask("hits", mask, path); } if (mask == EnvironmentalVeriables.ParticlesImageMask) { result.Particles = GetAllImagesByNameMask("particles", mask, path); } if (mask == EnvironmentalVeriables.RingsImageMask) { result.Rings = GetAllImagesByNameMask("rings", mask, path); } if (mask == EnvironmentalVeriables.SkysphereImagesMask) { result.SkySpheres = GetAllImagesByNameMask("skysphere", mask, path); } } ImageGroup tiles = GetAllImagesByNameMask("tiles", "tiles.png", path); ImageGroup tileflyup = GetAllImagesByNameMask("tiles flyup", "tileflyup.png", path); if (tiles.Group.Count > 1 || tileflyup.Group.Count > 1) { MessageBox.Show("Ooops! May be folder with your skin contain more that 1 texture with name 'tiles.png' or 'tileflyup.png' (or ***tiles.png / ***tileflyup.png).\nPlease, check folder with skin and correct names of textures", "Package Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } result.Tiles = new NamedBitmap("tiles.png", (Bitmap)tiles); result.TilesFlyup = new NamedBitmap("tileflyup.png", (Bitmap)tileflyup); return(result); }
void ShowAnimation(bool show) { CoffeeAnimationView.SetHidden(!show); ImageGroup.SetHidden(!show); if (show) { ImageGroup.SetBackgroundColor(UIColor.FromRGB(239, 235, 233)); CoffeeAnimationView.SetImage("ic_mug"); CoffeeAnimationView.StartAnimating(new NSRange(0, 9), 3.0, Int32.MaxValue); } else { ImageGroup.SetBackgroundColor(UIColor.Black); CoffeeAnimationView.StopAnimating(); } }
private static bool GroupSnapshotAspectRatioIsCorrect(ImageGroup group) { if (group.entries.Count == 0) { return(true); } var entry = group.entries[0]; var path = entry.resourcePath; var sprite = Resources.Load <Sprite>(path); if (sprite == null) { return(true); } var tex = sprite.texture; var size = entry.snapshotScale * new Vector2(tex.width, tex.height); return(Math.Abs(ImageGroupEditor.SnapshotAspectRatio - size.y / size.x) < 3 * float.Epsilon); }
private ImageGroup GetAllImagesByNameMask(string groupName, string nameMask, string path) { var group = new ImageGroup(groupName); string[] AllFiles = Directory.GetFiles(path); foreach (var file in AllFiles) { var origName = Path.GetFileName(file); var fname = origName.ToLower(); var fileExt = Path.GetExtension(fname); if (fname.Contains(nameMask) && new[] { ".png", ".jpg" }.Any(x => x == fileExt)) { var image = new NamedBitmap(origName, Image.FromFile(file)); group.AddImage(image); } } return(group); }
void ReleaseDesignerOutlets() { if (CoffeeAnimationView != null) { CoffeeAnimationView.Dispose(); CoffeeAnimationView = null; } if (PlacesTable != null) { PlacesTable.Dispose(); PlacesTable = null; } if (ImageGroup != null) { ImageGroup.Dispose(); ImageGroup = null; } if (WarningGroup != null) { WarningGroup.Dispose(); WarningGroup = null; } if (WarningMessageLabel != null) { WarningMessageLabel.Dispose(); WarningMessageLabel = null; } if (TryAgainButton != null) { TryAgainButton.Dispose(); TryAgainButton = null; } }
public ActionResult Create([Bind(Include = "ID,Name,Description,Date")] ImageGroup imageGroup) { if (ModelState.IsValid) { var unformattedUrlSet = Request["images"] != null ? Request["images"] : null; string[] imageUrlSet = null; if (!string.IsNullOrEmpty(unformattedUrlSet)) { imageUrlSet = this.stripImageUrl(unformattedUrlSet); imageGroup.ImageValue = new List <Image>(); foreach (var image in imageUrlSet) { Image imageEntity = new Image(); imageEntity.ImageUrl = image.Trim(); ImagesController.Create(imageEntity); imageGroup.ImageValue.Add(imageEntity); } } imageGroup.Date = DateTime.Now; db.ImageGroups.Add(imageGroup); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(imageGroup)); }
public EditAttractionViewModel() { ImageGroup = new ImageGroup(); }
private static bool GroupIsEmpty(ImageGroup group) { return(group.entries.Count == 0); }
public static int Build(EFContext db, string fileExt, string fileName, string fullFilePath, string path, int fileId, string name) { { var group = new ImageGroup(); group.Name = name; group.Updated = DateTime.UtcNow; group.Active = true; db.ImageGroups.Add(group); db.SaveChanges(); var img = new ImageRecord(); img.Name = name; img.FileId = fileId; img.ImageGroupId = group.Id; img.ImageSize = ImageSize.src; db.Images.Add(img); db.SaveChanges(); // image resizing int w; int h; var f2048 = fileName + "_h2048." + fileExt; var file2048 = Path.Combine(path, f2048); if (ImageResizeService.ResizeImageFile(fullFilePath, file2048, ImageSize.h2048, out w, out h)) { var fileInfo = new FileInfo(file2048); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f2048, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h2048; db.Images.Add(i); db.SaveChanges(); } var f1024 = fileName + "_h1024." + fileExt; var file1024 = Path.Combine(path, f1024); if (ImageResizeService.ResizeImageFile(fullFilePath, file1024, ImageSize.h1024, out w, out h)) { var fileInfo = new FileInfo(file1024); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f1024, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h1024; db.Images.Add(i); db.SaveChanges(); } var f720 = fileName + "_h720." + fileExt; var file720 = Path.Combine(path, f720); if (ImageResizeService.ResizeImageFile(fullFilePath, file720, ImageSize.h720, out w, out h)) { var fileInfo = new FileInfo(file720); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f720, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h720; db.Images.Add(i); db.SaveChanges(); } var f480 = fileName + "_h480." + fileExt; var file480 = Path.Combine(path, f480); if (ImageResizeService.ResizeImageFile(fullFilePath, file480, ImageSize.h480, out w, out h)) { var fileInfo = new FileInfo(file480); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f480, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h480; db.Images.Add(i); db.SaveChanges(); } var f240 = fileName + "_h240." + fileExt; var file240 = Path.Combine(path, f240); if (ImageResizeService.ResizeImageFile(fullFilePath, file240, ImageSize.h240, out w, out h)) { var fileInfo = new FileInfo(file240); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f240, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h240; db.Images.Add(i); db.SaveChanges(); } var f128 = fileName + "_h128." + fileExt; var file128 = Path.Combine(path, f128); if (ImageResizeService.ResizeImageFile(fullFilePath, file128, ImageSize.h128, out w, out h)) { var fileInfo = new FileInfo(file128); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f128, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h128; db.Images.Add(i); db.SaveChanges(); } var f64 = fileName + "_h64." + fileExt; var file64 = Path.Combine(path, f64); if (ImageResizeService.ResizeImageFile(fullFilePath, file64, ImageSize.h64, out w, out h)) { var fileInfo = new FileInfo(file64); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f64, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h64; db.Images.Add(i); db.SaveChanges(); } var f32 = fileName + "_h32." + fileExt; var file32 = Path.Combine(path, f32); if (ImageResizeService.ResizeImageFile(fullFilePath, file32, ImageSize.h32, out w, out h)) { var fileInfo = new FileInfo(file32); var sizekb = fileInfo.Length * 0.001M; var f = new FileRecord() { FilePath = f32, Key = name, FileExt = fileExt, Name = fileName, FileType = FileType.Image, SizeKb = sizekb }; db.Files.Add(f); db.SaveChanges(); var i = new ImageRecord() { FileId = f.Id, Name = name, Width = w, Height = h }; i.ImageGroupId = group.Id; i.ImageSize = ImageSize.h32; db.Images.Add(i); db.SaveChanges(); } db.SaveChanges(); return(group.Id); } }
private bool IsPrt(Stream s) { var start = s.Position; var h = new PrtFile() { ID = s.ReadASCII(4), PalCount = s.ReadInt32(), }; if (h.ID != "CPAL") { s.Position = start; return(false); } h.PalData = new Ppal[h.PalCount]; // Parse palettes for (var i = 0; i < h.PalCount; i++) { var ppal = new Ppal { ID = s.ReadASCII(4), Size = s.ReadInt32(), HeadID = s.ReadASCII(4), BytesPerEntry = s.ReadInt32(), Unknown = s.ReadInt32(), DataID = s.ReadASCII(4), PalSize = s.ReadInt32() }; if (ppal.ID != "PPAL" || ppal.HeadID != "head" || ppal.DataID != "data") { s.Position = start; return(false); } var numPaletteEntries = ppal.PalSize / ppal.BytesPerEntry; ppal.PaletteData = new RgbQuad[numPaletteEntries]; // Populate palette for (var j = 0; j < numPaletteEntries; j++) { var rgba = new RgbQuad { Red = s.ReadByte(), Green = s.ReadByte(), Blue = s.ReadByte(), Reserved = s.ReadByte(), }; ppal.PaletteData[j] = rgba; } h.PalData[i] = ppal; } h.ImageCount = s.ReadInt32(); h.ImageHeader = new Op2Image[h.ImageCount]; for (var i = 0; i < h.ImageCount; i++) { var img = new Op2Image { SizeScanline = s.ReadInt32(), }; img.ImgData = s.ReadBytes(img.SizeScanline); img.SizeX = s.ReadInt32(); img.SizeY = s.ReadInt32(); img.Unknown = s.ReadInt16(); img.Palette = s.ReadInt16(); h.ImageHeader[i] = img; } h.AllGroupCount = s.ReadInt32(); h.AllFrameCount = s.ReadInt32(); h.AllPicCount = s.ReadInt32(); h.AllExtInfoCount = s.ReadInt32(); h.Groups = new ImageGroup[h.AllGroupCount]; for (var i = 0; i < h.AllGroupCount; i++) { var img = new ImageGroup { Unknown1 = s.ReadInt32(), SelLeft = s.ReadInt32(), SelTop = s.ReadInt32(), SelRight = s.ReadInt32(), SelBottom = s.ReadInt32(), CenterX = s.ReadInt32(), CenterY = s.ReadInt32(), Unknown8 = s.ReadInt32(), FrameCount = s.ReadInt32() }; img.Frames = new Op2Frame[img.FrameCount]; for (var j = 0; j < img.FrameCount; j++) { var frame = new Op2Frame { PicCount = s.ReadUInt8(), Unknown = s.ReadUInt8(), }; frame.ExtUnknown1 = new BytePair[frame.PicCount >> 7]; for (var k = 0; k < frame.PicCount >> 7; k++) { var bp = new BytePair { Byte1 = s.ReadUInt8(), Byte2 = s.ReadUInt8(), }; frame.ExtUnknown1[k] = bp; } frame.ExtUnknown2 = new BytePair[frame.Unknown >> 7]; for (var k = 0; k < frame.Unknown >> 7; k++) { var bp = new BytePair { Byte1 = s.ReadUInt8(), Byte2 = s.ReadUInt8(), }; frame.ExtUnknown2[k] = bp; } frame.Pictures = new Op2Picture[frame.PicCount & 0x7F]; for (var k = 0; k < frame.Pictures.Length; k++) { var pic = new Op2Picture { ImgNumber = s.ReadInt16(), Reserved = s.ReadUInt8(), PicOrder = s.ReadUInt8(), PosX = s.ReadInt16(), PosY = s.ReadInt16() }; frame.Pictures[k] = pic; } img.Frames[j] = frame; } img.GroupExtCount = s.ReadInt32(); img.Extended = new GroupExt[img.GroupExtCount]; for (var j = 0; j < img.GroupExtCount; j++) { var ext = new GroupExt { Unknown1 = s.ReadInt32(), Unknown2 = s.ReadInt32(), Unknown3 = s.ReadInt32(), Unknown4 = s.ReadInt32(), }; img.Extended[j] = ext; } h.Groups[i] = img; } file = h; return(true); }
internal static void Update_ImageGroup_ImagesCollection(ImageGroup imageGroup, ImageCollection localCollection, ImageCollection masterCollection) { // Nothing to do for now }