public RenameMapWindow(RenameMapViewModel viewModel) { InitializeComponent(); this.ViewModel = viewModel; this.DataContext = this.ViewModel; }
public RenameMapWindow() { InitializeComponent(); this.ViewModel = new RenameMapViewModel(null); this.DataContext = ViewModel; }
/// <summary> /// Opens a window to enter a new name for a map. /// Writes to meta data file if user clicks 'Rename' in window. /// </summary> /// <param name="selectedMap"></param> internal void OpenRenameMapWindow(MapListItem selectedMap) { RenameMapViewModel viewModel = new RenameMapViewModel(selectedMap); RenameMapWindow window = new RenameMapWindow(viewModel) { WindowStartupLocation = WindowStartupLocation.CenterScreen }; bool?result = window.ShowDialog(); if (result.GetValueOrDefault(false) == true) { bool didWrite = MetaDataManager.WriteCustomMapPropertiesToFile(ViewModel.AvailableMaps); if (didWrite == false) { ViewModel.UserMessage = "Failed to update .meta file with new custom name. Your custom name may have not been saved and will be lost when the app restarts."; return; } ViewModel.RefreshFilteredMaps(); ViewModel.UserMessage = $"{selectedMap.MapName} renamed to {selectedMap.CustomName}!"; } }