コード例 #1
0
        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.Binary)
                              .FirstOrDefault();

                    if (ent != null)
                    {
                        FileName   = fileName;
                        stream     = ent.Stream;
                        Characters = new CharactersViewModel(Lvup.Open(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);
            }
        }
コード例 #2
0
 public LvupViewModel(Stream stream)
 {
     Characters = new CharactersViewModel(Lvup.Open(stream));
     OnPropertyChanged(nameof(Characters));
 }