public IList <SaveDataInfo> GetSaveInfo() { IMessageBoxService messageBoxService = ServicesContainer.GetService <IMessageBoxService>(); IList <SaveDataInfo> saveDataInfoItems = FileSystemUtils.EnumerateSaveDataInfo().ToList(); if (saveDataInfoItems.Count > 0) { return(saveDataInfoItems); } var options = new MessageBoxServiceOptions { Title = "Save data not found", MessageBoxText = "Could not automatically find location of save data.\nPlease select it manually.", Buttons = MessageBoxButton.OK, Icon = MessageBoxImage.Warning }; messageBoxService.Show(options); var dialog = new OpenFileDialog { AddExtension = false, CheckFileExists = true, CheckPathExists = true, FileName = FileSystemUtils.GameSaveDataFilename, Filter = $"Save data|{FileSystemUtils.GameSaveDataFilename}|All files (*.*)|*.*", Multiselect = false, ShowReadOnly = true, Title = "Select Monster Hunter: World save data file" }; if (dialog.ShowDialog() != true) { options = new MessageBoxServiceOptions { Title = "Operation cancelled", MessageBoxText = "Operation cancelled.", Buttons = MessageBoxButton.OK, Icon = MessageBoxImage.Warning }; messageBoxService.Show(options); return(null); } saveDataInfoItems.Add(new SaveDataInfo("<unknown>", dialog.FileName)); return(saveDataInfoItems); }
public Core.ServiceContracts.MessageBoxResult Show(MessageBoxServiceOptions options) { Window ownerWindow = null; if (options != null && options.Owner != IntPtr.Zero) { ownerWindow = (Window)HwndSource.FromHwnd(options.Owner).RootVisual; } return((Core.ServiceContracts.MessageBoxResult)MessageBox.Show( ownerWindow ?? Application.Current.MainWindow, options?.MessageBoxText ?? string.Empty, options?.Title ?? string.Empty, (System.Windows.MessageBoxButton)(options?.Buttons ?? Core.ServiceContracts.MessageBoxButton.OK), (System.Windows.MessageBoxImage)(options?.Icon ?? Core.ServiceContracts.MessageBoxImage.None), (System.Windows.MessageBoxResult)(options?.DefaultResult ?? Core.ServiceContracts.MessageBoxResult.None) )); }