public async void Open(OpenFileArguments args) { var editor = Get(args.Editor); if (!editor.CanHandleFile(args.FileDefinition)) { throw new FileNotSupportedException("The specified file is not supported by this editor"); } if (_fileService.IsFileOpen(args.Path, out var openEditor)) { _dockingMainWindow.DockingHost.ActiveLayoutItemBase = openEditor; return; } var file = _fileService.OpenExistingFile(args); await editor.LoadFile(file, args.Name); _dockingMainWindow.DockingHost.OpenLayoutItem(editor); }
public bool TryOpenFile(OpenFileArguments args) { try { if (string.IsNullOrEmpty(args.Path)) { return(false); } if (!File.Exists(args.Path)) { return(false); } OpenFile(args); } catch { return(false); } return(true); }
public void OpenFile(OpenFileArguments args) { if (_editorProvider.Handles(args.Path)) { _editorProvider.Open(args); } else { var fileType = NativeMethods.NativeMethods.GetExeType(args.Path); if (fileType == ShellFileType.Windows || fileType == ShellFileType.Dos || fileType == ShellFileType.Console) { MessageBox.Show("Executables will not be opened", IoC.Get <IEnvironmentVariables>().ApplicationName, MessageBoxButton.OK, MessageBoxImage.Error); return; } if (NativeMethods.NativeMethods.GetExeType(args.Path) == ShellFileType.Unknown) { Process.Start(args.Path); } } _mruFilePackage.Manager.AddItem($"{args.Path}|{args.Editor:B}"); }