private Task DoEditFileLocation(object o) { return(Task.Factory.StartNew(() => { Parent.SyncContext.Post(c => { CustomDialog customDialog = new CustomDialog() { Title = "New Location" }; var dataContext = new NewFileLocationDialogModel(obj => { Parent.DialogCoordinator.HideMetroDialogAsync(Parent, customDialog); }, obj => { Parent.DialogCoordinator.HideMetroDialogAsync(Parent, customDialog); Parent.SyncContext.Post(d => { FileLocation location = new FileLocation() { Name = obj.FileName, Path = obj.Path }; FileLocations.Add(location); FileLocations.Remove((FileLocation)o); }, null); }); dataContext.FileName = ((FileLocation)o).Name; dataContext.Path = ((FileLocation)o).Path; customDialog.Content = new NewFileLocationDialog { DataContext = dataContext }; Parent.DialogCoordinator.ShowMetroDialogAsync(Parent, customDialog); }, null); })); }
static void Pack(List <String> files, string outfile, string ebootname) { files.Sort(); bool useEboot = ebootname != null; List <int> FileLocations = null; List <int> FileSizes = null; if (useEboot) { FileLocations = new List <int>(files.Count); FileSizes = new List <int>(files.Count); } uint byteswritten = 0; FileStream newFile = new FileStream(outfile, FileMode.Create); newFile.Write(BitConverter.GetBytes(files.Count), 0, 4); byteswritten += 4; int firstfilestart = Align(files.Count * 4 + 4, 0x10); int filestart = firstfilestart; for (int i = 0; i < files.Count; ++i) { newFile.Write(BitConverter.GetBytes(filestart), 0, 4); byteswritten += 4; int size = (int)new System.IO.FileInfo(files[i]).Length; if (useEboot) { FileLocations.Add(filestart); FileSizes.Add(size); } filestart += size; } while (byteswritten < firstfilestart) { newFile.WriteByte(0x00); byteswritten++; } for (int i = 0; i < files.Count; ++i) { FileStream f = new System.IO.FileStream(files[i], FileMode.Open); Util.CopyStream(f, newFile, (int)f.Length); f.Close(); } newFile.Close(); if (useEboot) { // write vals to eboot byte[] eboot = System.IO.File.ReadAllBytes(ebootname); int currentEbootLoc = 0xF5200; for (int i = 0; i < FileLocations.Count; ++i) { byte[] loc = BitConverter.GetBytes(FileLocations[i]); byte[] siz = BitConverter.GetBytes(FileSizes[i]); loc.CopyTo(eboot, currentEbootLoc + 4); siz.CopyTo(eboot, currentEbootLoc + 8); currentEbootLoc += 12; } System.IO.File.WriteAllBytes(ebootname, eboot); } }