Exemplo n.º 1
0
        private void OnDeleted(object source, FileSystemEventArgs e)
        {
            int index = FileInfos.FindIndex(x => x == CurrentFileInfo); // Get the index of the current file being displayed (-1 if not found [no files])

            // Try and find the item in the list, if it's there, remote it, if not, continue
            FileInfo fi = FileInfos.Find(x => x.FullName == e.FullPath);

            FileInfos.Remove(fi);

            if (!FileInfos.Contains(CurrentFileInfo)) // is the selected file removed? If not, just continue the day
            {
                if (index >= FileInfos.Count())       // is the index above what's suppose to be?
                {
                    index = FileInfos.Count() - 1;    // Move it down a Markus Persson (Notch)
                }

                if (FileInfos.Count() > 0)              // Is there still items in the list?
                {
                    CurrentFileInfo = FileInfos[index]; // Select that file
                }
                else // No items in the list
                {
                    CurrentFileInfo = null; // Select nothing for the current file info
                }

                UpdateImage(); // update only if it's a new file
            }

            Changed(); // Something changed! (Removed a file!)
        }
Exemplo n.º 2
0
        public void PrevImage()
        {
            if (FileInfos.Count() > 0) // Is there even an image?
            {
                int index = FileInfos.FindIndex(x => x == CurrentFileInfo);
                index--;
                while (index < 0)
                {
                    index += FileInfos.Count();
                }
                CurrentFileInfo = FileInfos[index];

                UpdateImage();
                Changed();
            }
        }