private void Open(string fileName) { try { using (var file = File.Open(fileName, FileMode.Open)) { var ent = Bar.Read(file, (str, type) => str == "lvup" && type == Bar.EntryType.List) .FirstOrDefault(); if (ent != null) { FileName = fileName; stream = ent.Stream; Characters = new CharactersViewModel(Lvup.Read(stream)); Characters.SelectedItem = Characters.Items[0]; OnPropertyChanged(nameof(Characters)); IsFileLoaded = true; OnPropertyChanged(nameof(IsFileLoaded)); } else { MessageBox.Show("This file does not contain an 'lvup' entry!", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void WriteTest() => File.OpenRead(@"kh2/res/lvup_fm.bin").Using(stream => { Helpers.AssertStream(stream, inStream => { var outStream = new MemoryStream(); Lvup.Read(inStream).Write(outStream); return(outStream); }); });
public LvupViewModel(IEnumerable <Bar.Entry> entries) : this(Lvup.Read(entries.GetBattleStream(entryName))) { }
public LvupViewModel(Stream stream) { Characters = new CharactersViewModel(Lvup.Read(stream)); OnPropertyChanged(nameof(Characters)); }
public void LvupTableTest() => Common.FileOpenRead(@"kh2/res/lvup_fm.bin", x => x.Using(stream => { var table = Lvup.Read(stream); Assert.Equal(0xE, table.Count); }));