private void Open(object parameter) { var item = parameter as ListItem; if (item == null) return; try { if (item.IsDirectory) { if (item.Name == "..") { if (CurrentPath.IsRoot) return; CurrentPath.SwitchToParent(); RefreshCurrentDirectory(); } else { CurrentPath = new DirectoryPath(item.Path, item.Name); } } else { var tmpFile = Path.GetTempPath() + item.Name; if (File.Exists(tmpFile)) File.Delete(tmpFile); var vm = new OperationProgressViewModel(); ViewModelHelper.RunAsyncAction(() => _manipulator.Export(item.Path + item.Name, tmpFile, vm.Callbacks)); vm.ShowDialog(); Process.Start("explorer", tmpFile); } } catch (Exception ex) { UserMessage.Exception(ex); } }
private void OpenVfsWithPassword(string fileName) { var passwordDialog = new PasswordDialogViewModel(); if (passwordDialog.ShowDialog() != true) return; try { var manipulator = _container.Resolve<IFileSystemTextManipulatorFactory>().Open(fileName, passwordDialog.Password); // Close last vfs DisposeManipulator(); if (_manipulator != null) _manipulator.FileSystemChanged -= FileSystemChanged; _manipulator = manipulator; _manipulator.FileSystemChanged += FileSystemChanged; CurrentPath = new DirectoryPath(); OnPropertyChanged("FileSystemName"); } catch (Exception ex) { UserMessage.Exception(ex); } UpdateVersion(); }
private void NewVfs(object parameter) { var pathToVFS = ViewModelHelper.ChoosePlaceForNewVFSFile(); if (pathToVFS == null) return; // Close last vfs DisposeManipulator(); var vm = new NewVFSViewModel(); if (vm.ShowDialog() != true) return; try { var fileSystemData = new FileSystemOptions(pathToVFS, vm.EncryptionType, vm.CompressionType); _manipulator = _container.Resolve<IFileSystemTextManipulatorFactory>().Create(fileSystemData, vm.Password); _manipulator.FileSystemChanged += FileSystemChanged; CurrentPath = new DirectoryPath(); OnPropertyChanged("FileSystemName"); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } UpdateVersion(); }