private void UpdatePreview() { try { string splashImagePath = Path.Combine(_ide.Project.EnginePath, "splash.bmp"); if (File.Exists(splashImagePath)) { using (Image image = Image.FromFile(Path.Combine(_ide.Project.EnginePath, "splash.bmp"))) { if ((image.Width == 1024 && image.Height == 512) || (image.Width == 768 && image.Height == 384) || (image.Width == 512 && image.Height == 256)) { panel_Preview.BackgroundImage = ImageHandling.ResizeImage(image, 460, 230); label_Blank.Visible = false; } else { label_Blank.Visible = true; } } } else { label_Blank.Visible = true; } } catch (Exception ex) { DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateIcons() // This method is trash I know, but I couldn't find a better one { // Generate a random string to create a temporary .exe file. // We will extract the icon from the .exe copy because Windows is caching icons which doesn't allow us to easily extract // icons larger than 32x32 px. Random random = new Random(); const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; string randomString = new string(Enumerable.Repeat(chars, 8).Select(s => s[random.Next(s.Length)]).ToArray()); // Create the temporary .exe file string tempFilePath = _ide.Project.LaunchFilePath + "." + randomString + ".exe"; File.Copy(_ide.Project.LaunchFilePath, tempFilePath); Bitmap ico_256 = ImageHandling.CropBitmapWhitespace(IconExtractor.GetIconFrom(tempFilePath, IconSize.Jumbo, false).ToBitmap()); // Windows doesn't seem to have a name for 128x128 px icons, therefore we must resize the Jumbo one Bitmap ico_128 = (Bitmap)ImageHandling.ResizeImage(IconExtractor.GetIconFrom(tempFilePath, IconSize.Jumbo, false).ToBitmap(), 128, 128);; Bitmap ico_48 = ImageHandling.CropBitmapWhitespace(IconExtractor.GetIconFrom(tempFilePath, IconSize.ExtraLarge, false).ToBitmap()); Bitmap ico_16 = IconExtractor.GetIconFrom(tempFilePath, IconSize.Small, false).ToBitmap(); if (ico_256.Width == ico_48.Width && ico_256.Height == ico_48.Height) { panel_256.BorderStyle = BorderStyle.FixedSingle; panel_128.BorderStyle = BorderStyle.FixedSingle; panel_256.BackgroundImage = ico_48; panel_128.BackgroundImage = ico_48; panel_48.BackgroundImage = ico_48; panel_16.BackgroundImage = ico_16; } else { panel_256.BorderStyle = BorderStyle.None; panel_128.BorderStyle = BorderStyle.None; panel_256.BackgroundImage = ico_256; panel_128.BackgroundImage = ico_128; panel_48.BackgroundImage = ico_48; panel_16.BackgroundImage = ico_16; } // Now delete the temporary .exe file File.Delete(tempFilePath); }
private void radioButton_Standard_CheckedChanged(object sender, EventArgs e) { if (radioButton_Standard.Checked) { try { using (Image image = Image.FromFile(Path.Combine(_ide.Project.EnginePath, "load.bmp"))) panel_Preview.BackgroundImage = ImageHandling.ResizeImage(image, 320, 240); _ide.IDEConfiguration.StandardAspectRatioPreviewEnabled = true; _ide.IDEConfiguration.Save(); } catch (Exception ex) { DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void AddPinnedProgramsToContextMenu() { foreach (string programPath in _ide.IDEConfiguration.PinnedProgramPaths) { string exeFileName = Path.GetFileName(programPath).ToLower(); // Exclude these programs from the list if (exeFileName == "tombeditor.exe" || exeFileName == "wadtool.exe" || exeFileName == "soundtool.exe" || exeFileName == "tombide.exe" || exeFileName == "ng_center.exe" || exeFileName == "tomb4.exe" || exeFileName == "pctomb5.exe") { continue; } // Exclude batch files if (exeFileName.EndsWith(".bat")) { continue; } // Get the ProductName and the icon of the program string programName = FileVersionInfo.GetVersionInfo(programPath).ProductName; Image image = ImageHandling.ResizeImage(Icon.ExtractAssociatedIcon(programPath).ToBitmap(), 16, 16); if (string.IsNullOrEmpty(programName)) { programName = Path.GetFileNameWithoutExtension(programPath); } // Create the menu item ToolStripMenuItem item = new ToolStripMenuItem { Image = image, Text = "Open with " + programName, Tag = programPath }; // Bind the OnContextMenuProgramClicked event method to the item and add it to the list item.Click += OnContextMenuProgramClicked; contextMenu.Items.Add(item); } }
private void Initialize() { // Core.KillExplorer(); Taskbar.Hide(); WindowState = FormWindowState.Maximized; Thread.Sleep(250); Image img = Wallpaper.Image; Wallpaper.Image = ImageHandling.ResizeImage(img, Wallpaper.Size.Width, Wallpaper.Size.Height); Thread.Sleep(100); LoadApps(); Thread.Sleep(100); Opacity = 1; }
private void UpdatePreview() { try { using (Image image = Image.FromFile(Path.Combine(_ide.Project.EnginePath, "load.bmp"))) { if (radioButton_Wide.Checked) { panel_Preview.BackgroundImage = ImageHandling.ResizeImage(image, 426, 240); } else if (radioButton_Standard.Checked) { panel_Preview.BackgroundImage = ImageHandling.ResizeImage(image, 320, 240); } label_Blank.Visible = image.Width == 1 && image.Height == 1; } } catch (Exception ex) { DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }