void buttonUndo_Click(object sender, EventArgs e) { if (_shelvedFiles.Count == 0) { return; } if (_shelvedFiles.Count == 1) { buttonUndo.Enabled = false; } var userPrefs = new PersistedUserPreferences(); var shelvedFile = _shelvedFiles.Pop(); var host = new ImageHost( new FileNameHandler(userPrefs), userPrefs.ShelfName, new FileInfo(shelvedFile.Item1) ) { Parent = _currentFiles }; host.ShelvePicture(); var nextNode = _currentFiles.First; while (nextNode != null && string.Compare(nextNode.Value.FileInfo.Name, host.FileInfo.Name, StringComparison.InvariantCultureIgnoreCase) < 0 ) { nextNode = nextNode.Next; } NodesTuple displayLocation; if (nextNode == null) { _currentFiles.AddLast(host); displayLocation = _currentFiles.Count == 1 ? new NodesTuple(_currentFiles.First, _currentFiles.First) : new NodesTuple(_currentFiles.Last.Previous, _currentFiles.Last); } else { var newNode = _currentFiles.AddBefore(nextNode, host); if (shelvedFile.Item2 == Side.Right && newNode.Previous != null) { displayLocation = new NodesTuple(newNode.Previous, newNode); } else { displayLocation = new NodesTuple(newNode, newNode.Next); } } _fileIndex = LoadPictures(displayLocation, 0, 0, noRelease: true); }
void MovePictureImpl(ImageHost imageHost, Side side, int step1, int step2) { folderBrowserDialog.SelectedPath = _lastDestinationDirectory?.FullName ?? _currentDirectory?.FullName ?? new PersistedUserPreferences().FolderImportStart; folderBrowserDialog.ShowDialog(); // OpenFolderImpl(new DirectoryInfo(folderBrowserDialog.SelectedPath)); _lastDestinationDirectory = new DirectoryInfo(folderBrowserDialog.SelectedPath); _shelvedFiles.Push(Tuple.Create(imageHost.MovePicture(_lastDestinationDirectory), side)); buttonUndo.Enabled = true; ArchivePicture(imageHost, step1, step2); }
void ArchivePicture(ImageHost imageHost, int step1, int step2) { _fileIndex = LoadPictures(_fileIndex, step1, step2); _currentFiles.Remove(imageHost); imageHost.Dispose(); }