private void buttonItemFolderDefaultIcon_Click(object sender, RoutedEventArgs e) { // TODO: Check for valid extension? Or nah? // TODO: There's also a lot of code duplication here. Fix. OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { Bitmap bitmap; try { bitmap = new Bitmap(openFileDialog.FileName); } catch (Exception exception) { MessageBox.Show("Could not load icon."); return; } string oldPath = Config.FolderDefaultIcon.ImagePath; Config.FolderDefaultIcon.ImagePath = openFileDialog.FileName; Config.FolderDefaultIcon.ImageBitmap = bitmap; // Again, already preloaded. Config.FolderDefaultIcon.CreateCache(); // Just in case it doesn't get preloaded before refreshing the icons. // But, to my knowledge, it should. textBoxItemFolderDefaultIcon.Text = Config.FolderDefaultIcon.ImagePath; TheMainWindow.ClearCachedImagesDefaultFolder(TheMainWindow.RootFolder, oldPath, Config.FolderDefaultIcon.ImagePath); TheMainWindow.PreloadIconsRecursive(TheMainWindow.RootFolder); // Icons outside the folder could be modified TheMainWindow.RefreshFolder(); } }
private void buttonBrowseInnerDiskIcon_Click(object sender, RoutedEventArgs e) { // TODO: Check for valid extension OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { Bitmap rootFolderBitmap; try { rootFolderBitmap = new Bitmap(openFileDialog.FileName); } catch (Exception exception) { MessageBox.Show("Could not load icon."); return; } // Valid image from here on. Config.InnerDiskImagePath = openFileDialog.FileName; TheMainWindow.RootFolder.Icon.ImagePath = Config.InnerDiskImagePath; TheMainWindow.RootFolder.Icon.ImageBitmap = rootFolderBitmap; // We've already preloaded. Why not? textBoxInnerDiskIcon.Text = Config.InnerDiskImagePath; if (TheMainWindow.CurrentFolder == TheMainWindow.RootFolder) { TheMainWindow.RefreshFolder(); } } }