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 BitmapSource RenderToImage(ArmorSetViewModel searchResult, IEnumerable <int> weaponSlots) { var root = new StackPanel { UseLayoutRounding = true, SnapsToDevicePixels = true, Orientation = Orientation.Horizontal, }; root.Children.Add(new Rectangle { Fill = Brushes.Transparent, Width = 2.0, Height = 1.0 }); var weaponSlotsAndAbilities = new StackPanel { UseLayoutRounding = true, SnapsToDevicePixels = true, }; var weaponSlotsPanel = new StackPanel { UseLayoutRounding = true, SnapsToDevicePixels = true, Orientation = Orientation.Horizontal, Margin = new Thickness(4.0), }; weaponSlotsPanel.Children.Add(new TextBlock { Text = "Weapon slots: ", VerticalAlignment = VerticalAlignment.Center }); var factoryPanel = new FrameworkElementFactory(typeof(StackPanel)); factoryPanel.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); if (weaponSlots.Any(x => x > 0)) { weaponSlotsPanel.Children.Add(new ItemsControl { ItemsSource = weaponSlots, Height = 24.0, VerticalAlignment = VerticalAlignment.Center, ItemTemplate = (DataTemplate)App.Current.FindResource("SlotImageView"), ItemsPanel = new ItemsPanelTemplate(factoryPanel) }); } else { weaponSlotsPanel.Children.Add(new TextBlock { Text = "none", VerticalAlignment = VerticalAlignment.Center, FontStyle = FontStyles.Italic }); } weaponSlotsAndAbilities.Children.Add(weaponSlotsPanel); weaponSlotsAndAbilities.Children.Add(new ItemsControl { UseLayoutRounding = true, SnapsToDevicePixels = true, VerticalAlignment = VerticalAlignment.Top, ItemsSource = searchResult.DesiredAbilities.Select(x => new AbilityViewModel(x, null) { IsChecked = true }).ToArray(), ItemTemplate = (DataTemplate)App.Current.FindResource("SelectedAbilityView"), Margin = new Thickness(4.0), Focusable = false }); root.Children.Add(weaponSlotsAndAbilities); root.Children.Add(new ContentControl { UseLayoutRounding = true, SnapsToDevicePixels = true, Content = searchResult, ContentTemplate = (DataTemplate)App.Current.FindResource("SearchResultArmorSetView") }); return(ServicesContainer.GetService <IRenderService>().RenderToImage(root)); }