public static void LoadFileAndMasterFile(IMainViewModel mainViewModel, string fileName, bool checkAutoLoadMasterFileSetting) { _mainViewModel = mainViewModel; // Load file. KorgFileReader korgFileReader = new KorgFileReader(); IMemory memory = korgFileReader.Read(fileName); // Model type/file type only used when error if (memory == null) { _mainViewModel.ShowMessageBox( string.Format(Strings.FileTypeNotSupportedForThisWorkstation, Memory.FileTypeAsString(korgFileReader.FileType), Model.Common.Synth.MemoryAndFactory.Model.ModelTypeAsString(korgFileReader.ModelType)), Strings.PcgTools, WindowUtils.EMessageBoxButton.Ok, WindowUtils.EMessageBoxImage.Error, WindowUtils.EMessageBoxResult.Ok); return; } _mainViewModel.SelectedMemory = memory; // Load master file if requested. LoadMasterFileIfRequested(checkAutoLoadMasterFileSetting, fileName); // Create child window. MdiChild mdiChild; if (memory is IPcgMemory) { int width = Settings.Default.UI_PcgWindowWidth == 0 ? 700 : Settings.Default.UI_PcgWindowWidth; int height = Settings.Default.UI_PcgWindowHeight == 0 ? 500 : Settings.Default.UI_PcgWindowHeight; mdiChild = _mainViewModel.CreateMdiChildWindow(fileName, MainViewModel.ChildWindowType.Pcg, memory, width, height); ((PcgWindow)(mdiChild.Content)).ViewModel.SelectedMemory = memory; _mainViewModel.CurrentChildViewModel = ((PcgWindow)(mdiChild.Content)).ViewModel; ((IPcgMemory)memory).SelectFirstBanks(); } else if (memory is ISongMemory) { int width = Settings.Default.UI_SongWindowWidth == 0 ? 700 : Settings.Default.UI_SongWindowWidth; int height = Settings.Default.UI_SongWindowHeight == 0 ? 500 : Settings.Default.UI_SongWindowHeight; mdiChild = _mainViewModel.CreateMdiChildWindow(fileName, MainViewModel.ChildWindowType.Song, memory, width, height); _mainViewModel.CurrentChildViewModel = ((SongWindow)(mdiChild.Content)).ViewModel; ((SongWindow)(mdiChild.Content)).ViewModel.SelectedMemory = memory; } else { throw new ApplicationException("Unknown memory type"); } }