public void Execute(object parameter) { if (parameter is int) { ResourceDirectory resource = _resourceService.GetResourceDirectory((int)parameter); if (resource == null) { return; } var result = new ObservableCollection <WorkspaceItem>(); string[] files = Directory.GetFiles(resource.Path); foreach (var file in files) { result.Add(new WorkspaceItem() { WorkspaceId = App.CurrentWorkspace.WorkspaceId, Name = Path.GetFileNameWithoutExtension(file), Extension = Path.GetExtension(file), PathToOriginal = file }); } SelectionDialogWindow dialog = new SelectionDialogWindow("Importieren", "Wählen Sie die Dateien, die Sie importieren wollen.", result); dialog.SubmitButtonText = "Importieren"; _viewModel.ToggleDialogOpened(); if (dialog.ShowDialog() != true) { _viewModel.ToggleDialogOpened(); return; } else { foreach (var item in dialog.SelectedItems) { _workspaceService.AddItem(item); } _viewModel.RefreshView(); } } }
public void Execute(object parameter) { if (parameter is string && (string)parameter != string.Empty) { string path = parameter as string; // Get file information FileInfo file = new FileInfo(path); // Is workspace item if (file.Extension != string.Empty) { _workspaceService.AddItem(new WorkspaceItem() { WorkspaceId = _workspace.WorkspaceId, Name = Path.GetFileNameWithoutExtension(path), Extension = file.Extension, PathToOriginal = file.FullName, LastAccessed = DateTime.Now }); new DialogWindow("Datei gespeichert!", file.FullName).ShowDialog(); } // Is resource directory else { _resourceDirectoryService.AddResourceDirectory(new ResourceDirectory() { Name = file.Name, Path = file.FullName, LastAccessed = DateTime.Now }); new DialogWindow("Ressource gespeichert!", file.Name).ShowDialog(); } _viewModel.RefreshView(); } }