private void TileConfigurator_DialogButtonClicked(object sender, TileDialogButtonClickedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; if (e.DialogResult == DialogResult.OK) { FileInfo imageFileInfo = !string.IsNullOrWhiteSpace(e.Tile.ImagePath) ? new FileInfo(e.Tile.ImagePath) : null; if (imageFileInfo != null && imageFileInfo.Exists) { string localResourcePath = Path.Combine(vm.SelectedCollection.FilePath, "tiles", "resources"); if (!Directory.Exists(localResourcePath)) { Directory.CreateDirectory(localResourcePath); } string localImagePath = Path.Combine(localResourcePath, imageFileInfo.Name); if (!new FileInfo(localImagePath).Exists) { File.Copy(imageFileInfo.FullName, localImagePath); } e.Tile.ImagePath = localImagePath; } if (!vm.IsEditTile) { vm.SelectedCollection.TileFile.Data.Add(e.Tile); } } vm.IsTileConfiguratorOpen = false; }
public void BeginShowDialogForUnsavedCollections(TabItem targetTab) { TileManagerViewModel vm = DataContext as TileManagerViewModel; unsavedCollections = vm.LoadedCollections.Where(x => x.AnyUnsavedChanges).ToList(); abortShowDialogs = false; currentDialogIndex = 0; ShowDialogForUnsavedCollection(targetTab); }
private void CollectionDialog_DialogCompleted(object sender, CreateDialogCompletedEventArgs e) { if (e.DialogResult == DialogResult.OK && e.ResultObject is CollectionSet result) { TileManagerViewModel vm = DataContext as TileManagerViewModel; vm.LoadedCollections.Add(result); vm.SelectedCollection = result; } }
private void DuplicateTile_Click(object sender, RoutedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; Tile duplicate = vm.SelectedTile.Duplicate(true); duplicate.Name += string.Format(" ({0})", vm.SelectedCollection.TileFile.Data.Count(x => x.Name == duplicate.Name)); vm.SelectedCollection.TileFile.Data.Add(duplicate); vm.SelectedTileIndex = vm.SelectedCollection.TileFile.Data.Count - 1; }
private void DeleteCollection_Click(object sender, RoutedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; DialogRemoveObject dialog = new DialogRemoveObject(vm.SelectedCollection.Name); dialog.DialogCompleted += DialogRemoveCollection_DialogCompleted; OnOpenDialog(new OpenDialogEventArgs(dialog)); }
private void RemovePlaceable_Click(object sender, RoutedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; DialogRemoveObject dialog = new DialogRemoveObject(vm.SelectedCollection.PlaceableFile.Data[vm.SelectedPlaceableIndex].Name); dialog.DialogCompleted += DialogRemovePlaceable_DialogCompleted; OnOpenDialog(new OpenDialogEventArgs(dialog)); }
private void DialogRemoveCollection_DialogCompleted(object sender, DialogButtonClickedEventArgs e) { if (e.DialogResult == DialogResult.OK) { TileManagerViewModel vm = DataContext as TileManagerViewModel; CollectionSet selectedCollection = vm.SelectedCollection; selectedCollection.Delete(); vm.LoadedCollections.Remove(selectedCollection); vm.SelectedCollection = null; } }
private void Save_Click(object sender, RoutedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; string collectionDir = Path.Combine(App.BasePath, "Collections", vm.SelectedCollection.Name); Directory.CreateDirectory(collectionDir); var selectedCollectionIndex = App.LoadedCollections.IndexOf(vm.SelectedCollection); vm.SelectedCollection.Save(collectionDir); App.LoadCollections(); vm.SelectedCollection = App.LoadedCollections[selectedCollectionIndex]; }
private void DialogRemovePlaceable_DialogCompleted(object sender, DialogButtonClickedEventArgs e) { if (e.DialogResult == DialogResult.OK) { TileManagerViewModel vm = DataContext as TileManagerViewModel; Placeable selectedPlaceable = vm.SelectedCollection.PlaceableFile.Data[vm.SelectedPlaceableIndex]; int index = vm.SelectedCollection.PlaceableFile.Data.ToList().FindIndex(x => x.Guid == selectedPlaceable.Guid); if (index > -1) { vm.SelectedCollection.PlaceableFile.Data.RemoveAt(index); vm.SelectedPlaceableIndex = -1; } } }
private void Export_Click(object sender, RoutedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; SaveFileDialog dialog = new SaveFileDialog() { Filter = "Collection package|*.col", FileName = vm.SelectedCollection.Name + ".col", AddExtension = true }; if (dialog.ShowDialog() == true) { vm.SelectedCollection.ExportCollection(dialog.FileName); } }
private void ShowPlaceableConfigurator(bool isEdit) { TileManagerViewModel vm = DataContext as TileManagerViewModel; vm.IsPlaceableConfiguratorOpen = true; vm.IsEditPlaceable = isEdit; if (isEdit) { placeableConfigurator.SetPlaceable(vm.SelectedPlaceable); } else { placeableConfigurator.SetPlaceable(new Placeable(true)); } }
private void ShowTileConfigurator(bool isEdit) { TileManagerViewModel vm = DataContext as TileManagerViewModel; vm.IsTileConfiguratorOpen = true; vm.IsEditTile = isEdit; if (isEdit) { tileConfigurator.SetTileAssignment(new TileAssignment(vm.SelectedTile)); } else { tileConfigurator.SetTileAssignment(new TileAssignment(new Tile(true))); } }
private void Import_Click(object sender, RoutedEventArgs e) { TileManagerViewModel vm = DataContext as TileManagerViewModel; OpenFileDialog dialog = new OpenFileDialog() { Filter = "Collection package|*.col", AddExtension = true }; if (dialog.ShowDialog() == true) { CollectionSet imported = CollectionSet.ImportFromFile(dialog.FileName); vm.LoadedCollections.Add(imported); vm.SelectedCollection = imported; } }