private void LoadCustomDir_Execute(bool subdirs) { FolderBrowserDialog fbd = new FolderBrowserDialog { Description = "Select Directory to Load", ShowNewFolderButton = false, SelectedPath = Core.EditSaveDir, }; if (fbd.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } SeatDataBlock.ResetSeats(); CharacterCollection collection = DataContext as CharacterCollection; if (collection != null) { while (!collection.ViewModelProvider.Finish()) { MessageBoxResult msg = MessageBox.Show(MESSAGE_ERROR_FINISH_PROVIDER, "Error", MessageBoxButton.OKCancel, MessageBoxImage.Hand); if (msg == MessageBoxResult.Cancel) { return; } } collection.ViewModelProvider.Dispose(); } ICharacterViewModelProvider viewModelProvider = subdirs ? new FileSystemCharacterViewModelProvider(true, fbd.SelectedPath) : new FileSystemCharacterViewModelProvider(false, fbd.SelectedPath); viewModelProvider.Initialize(this); viewModelProvider.CharacterLoaded += ViewModelProviderOnCharacterLoaded; CharacterCollection characterCollection = new CharacterCollection(Dispatcher, viewModelProvider); viewModelProvider.CharacterLoaded -= ViewModelProviderOnCharacterLoaded; SetTitle(); DataContext = characterCollection; SortBox.SelectedValue = viewModelProvider.DefaultSortProperty; OrderBox.SelectedValue = viewModelProvider.DefaultSortDirection; CharactersControl.SelectedIndex = 0; }
private void LoadEditorSave_Execute(bool subdirs) { SeatDataBlock.ResetSeats(); CharacterCollection collection = DataContext as CharacterCollection; if (collection != null) { while (!collection.ViewModelProvider.Finish()) { MessageBoxResult msg = MessageBox.Show(MESSAGE_ERROR_FINISH_PROVIDER, "Error", MessageBoxButton.OKCancel, MessageBoxImage.Hand); if (msg == MessageBoxResult.Cancel) { return; } } collection.ViewModelProvider.Dispose(); } ICharacterViewModelProvider viewModelProvider; if (subdirs) { viewModelProvider = new FileSystemCharacterViewModelProvider(true, Core.EditSaveDir); } else { viewModelProvider = new FileSystemCharacterViewModelProvider(false, Path.Combine(Core.EditSaveDir, "Male"), Path.Combine(Core.EditSaveDir, "Female")); } viewModelProvider.CharacterLoaded += ViewModelProviderOnCharacterLoaded; viewModelProvider.Initialize(this); CharacterCollection characterCollection = new CharacterCollection(Dispatcher, viewModelProvider); viewModelProvider.CharacterLoaded -= ViewModelProviderOnCharacterLoaded; SetTitle(); DataContext = characterCollection; SortBox.SelectedValue = viewModelProvider.DefaultSortProperty; OrderBox.SelectedValue = viewModelProvider.DefaultSortDirection; CharactersControl.SelectedIndex = 0; }
private void LoadGameSave_Execute() { SeatDataBlock.ResetSeats(); string saveDir = Path.Combine(Core.PlaySaveDir, "class"); OpenFileDialog opfd = new OpenFileDialog { AddExtension = true, CheckFileExists = true, Filter = "Save Files (*.sav)|*.sav", InitialDirectory = saveDir }; opfd.CustomPlaces.Add(new FileDialogCustomPlace(saveDir)); if (!opfd.ShowDialog(this) .Value) { return; } CharacterCollection collection = DataContext as CharacterCollection; if (collection != null) { while (!collection.ViewModelProvider.Finish()) { MessageBoxResult msg = MessageBox.Show(MESSAGE_ERROR_FINISH_PROVIDER, "Error", MessageBoxButton.OKCancel, MessageBoxImage.Hand); if (msg == MessageBoxResult.Cancel) { return; } } collection.Dispose(); } ICharacterViewModelProvider viewModelProvider = new SaveFileCharacterViewModelProvider(opfd.FileName); viewModelProvider.Initialize(this); viewModelProvider.CharacterLoaded += ViewModelProviderOnCharacterLoaded; CharacterCollection characterCollection = new CharacterCollection(Dispatcher, viewModelProvider); viewModelProvider.CharacterLoaded -= ViewModelProviderOnCharacterLoaded; SetTitle(); DataContext = characterCollection; SortBox.SelectedValue = viewModelProvider.DefaultSortProperty; OrderBox.SelectedValue = viewModelProvider.DefaultSortDirection; CharactersControl.SelectedIndex = 0; characterCollection.Characters.ForEach (model => { int seat = (int)model.ExtraData["PLAY_SEAT"]; SeatDataBlock.SetSeat(seat, model.Profile.FullName); model.Character.PropertyChanged += (sender, args) => { if (!args.PropertyName.Contains("NAME")) { return; } string name = model.Profile.FullName; SeatDataBlock.SetSeat(seat, name); }; }); }