public static async Task OpenDocument(string[] droppedFilePaths) { var shell = IoC.Get <IShell>(); var providers = IoC.GetAllInstances(typeof(IEditorProvider)).Cast <IEditorProvider>(); foreach (var newPath in droppedFilePaths) { // Check if file type is supprted if (providers.FirstOrDefault(p => p.Handles(newPath)) == null) { continue; } // Check if the document is already open bool foundInShell = false; foreach (var document in shell.Documents.OfType <PersistedDocument>().Where(d => !d.IsNew)) { if (string.IsNullOrEmpty(document.FilePath)) { continue; } var docPath = Path.GetFullPath(document.FilePath); if (string.Equals(newPath, docPath, System.StringComparison.OrdinalIgnoreCase)) { shell.OpenDocument(document); foundInShell = true; break; } } if (!foundInShell) { shell.OpenDocument(await OpenFileCommandHandler.GetEditor(newPath)); // Add the file to the recent documents list //shell.RecentFiles.Update(newPath); } } }
private static IDocument GetEditor(string path) { return(OpenFileCommandHandler.GetEditor(path).Result); }