// Changes the currently displayed content public void UpdateContent() { // Show specific view when content is empty if (_displayItems.Count == 0) { PreviewContent(); UpdateSettingsChanged(); CreateSortMenu(); return; } // Disable undo menu when there's nothing to undo if (_movedItems.Count == 0) { UndoMenu.IsEnabled = false; } _currentItem = _displayItems[_displayedItemIndex]; // If set, add prefix to previously unviewed images. Also sets a color based on type of prefix if (!_currentItem.GetFileName().StartsWith("=") && !_currentItem.GetFileName().StartsWith(QuickPrefix) && _renameShown) { string updatedName = Path.GetFileNameWithoutExtension(_currentItem.GetFileNameExcludingExtension()); string newInput = "=" + updatedName; RenameFile(newInput); _currentItem.SetIsNew(); ColorInfo.Fill = new SolidColorBrush(Colors.LawnGreen); InfoContainer.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(50, 124, 252, 0)); } else if (_currentItem.GetFileName().StartsWith("++++++")) { // Show animation if color changes if (currentBrush != GoldBrush) { MenuStrip.BeginAnimation(HeightProperty, colorTransitionAnim); } MenuStrip.Background = GoldBrush; ColorInfo.Fill = GoldBrush; InfoContainer.Background = GoldTBrush; currentBrush = GoldBrush; ShowStars(6, new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 69, 0))); } else if (_currentItem.GetFileName().StartsWith("+++++")) { // Show animation if color changes if (currentBrush != PurpleBrush) { MenuStrip.BeginAnimation(HeightProperty, colorTransitionAnim); } MenuStrip.Background = PurpleBrush; ColorInfo.Fill = PurpleBrush; InfoContainer.Background = PurpleTBrush; currentBrush = PurpleBrush; ShowStars(5, new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 224, 187, 228))); } else if (_currentItem.GetFileName().StartsWith("++++")) { // Show animation if color changes if (currentBrush != RedBrush) { MenuStrip.BeginAnimation(HeightProperty, colorTransitionAnim); } MenuStrip.Background = RedBrush; ColorInfo.Fill = RedBrush; InfoContainer.Background = RedTBrush; currentBrush = RedBrush; ShowStars(4, new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 179, 186))); } else if (_currentItem.GetFileName().StartsWith("+++")) { // Show animation if color changes if (currentBrush != BlueBrush) { MenuStrip.BeginAnimation(HeightProperty, colorTransitionAnim); } MenuStrip.Background = BlueBrush; ColorInfo.Fill = BlueBrush; InfoContainer.Background = BlueTBrush; currentBrush = BlueBrush; ShowStars(3, new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 186, 225, 255))); } else if (_currentItem.GetFileName().StartsWith("++")) { // Show animation if color changes if (currentBrush != YellowBrush) { MenuStrip.BeginAnimation(HeightProperty, colorTransitionAnim); } MenuStrip.Background = YellowBrush; ColorInfo.Fill = YellowBrush; InfoContainer.Background = YellowTBrush; currentBrush = YellowBrush; ShowStars(2, new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 186))); } else if (_currentItem.GetFileName().StartsWith("+")) { // Show animation if color changes if (currentBrush != GreenBrush) { MenuStrip.BeginAnimation(HeightProperty, colorTransitionAnim); } MenuStrip.Background = GreenBrush; ColorInfo.Fill = GreenBrush; InfoContainer.Background = GreenTBrush; currentBrush = GreenBrush; ShowStars(1, new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 186, 255, 201))); } else if (_currentItem.IsNew()) { ColorInfo.Fill = new SolidColorBrush(Colors.LawnGreen); InfoContainer.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(50, 124, 252, 0)); ShowStars(0, new SolidColorBrush(System.Windows.Media.Color.FromArgb(50, 124, 252, 0))); } else { MenuStrip.Background = new SolidColorBrush(System.Windows.Media.Color.FromRgb(0, 0, 0)); ColorInfo.Fill = new SolidColorBrush(Colors.Gray); currentBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(100, 0, 0, 0)); InfoContainer.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(50, 128, 128, 128)); ShowStars(0, new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255))); } // Makes all irrelevant elements invisible MakeTypeVisible(_currentItem.GetTypeOfFile()); string currentFileType = _currentItem.GetTypeOfFile(); try { // Preloads images ahead of time AddToCache(); // Gets and show the content switch (currentFileType) { case "image": imageViewer.Source = ((ImageItem)_currentItem).GetImage(); break; case "gif": gifViewer.Source = ((GifItem)_currentItem).GetGif(gifViewer); break; case "video": imageViewer.Source = ((VideoItem)_currentItem).GetThumbnail(); break; case "text": textViewer.Text = ((TextItem)_currentItem).GetText(); break; case "file": iconViewer.Source = (_currentItem).GetThumbnail(); break; } } catch (System.OutOfMemoryException) { Console.WriteLine("Out of memory!"); _displayItems.Clear(); _movedItems.Clear(); isInCache.Clear(); GC.Collect(); RemoveOldContext(); } catch { // If content can't get loaded, show a blank black screen MakeTypeVisible(""); // TODO Eventual default view for images that have failed to load } _loadedOffset = 0; // File may load before WebP conversion finishes, so refresh after every conversion if (currentFileType == "image" && ((ImageItem)_currentItem).wasConverted) { try { System.Threading.Thread.Sleep(200); Refresh(); ((ImageItem)_currentItem).wasConverted = false; } catch { // TODO Eventual default view for images that have failed to load } } PreviewContent(); ResetView(); UpdateSettingsChanged(); imageViewerSize = (int)imageViewer.ActualHeight; if (_changed) { CreateSortMenu(); _changed = false; } }