Skip to content

Theme Changes#5

Merged
blazingvx merged 3 commits intomasterfrom
4-ui-changes-for-color-and-layout
Apr 6, 2026
Merged

Theme Changes#5
blazingvx merged 3 commits intomasterfrom
4-ui-changes-for-color-and-layout

Conversation

@blazingvx
Copy link
Copy Markdown
Owner

@blazingvx blazingvx commented Jun 6, 2025

Summary by CodeRabbit

Release Notes

  • New Features
    • Added light and dark theme options with automatic preference saving and restoration on app startup
    • Introduced "Change Theme" menu item in the File dropdown for easy theme switching
    • Integrated Windows Registry context menu support for icon management operations
    • Added theme selection icon resource

@blazingvx blazingvx linked an issue Jun 6, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6296993c-a0bc-46cc-ac76-d7337e32e65a

📥 Commits

Reviewing files that changed from the base of the PR and between afc497d and be6fc12.

⛔ Files ignored due to path filters (3)
  • IconMapper/Icon/dark_mode_24dp.png is excluded by !**/*.png
  • IconMapper/Icon/light_mode_24dp.png is excluded by !**/*.png
  • IconMapper/Icon/themes.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • IconMapper/App.config
  • IconMapper/ContextMenuOptions.cs
  • IconMapper/Form/MainForm.Designer.cs
  • IconMapper/Form/MainForm.cs
  • IconMapper/IconMapper.csproj
  • IconMapper/Properties/Resources.Designer.cs
  • IconMapper/Properties/Resources.resx
 ____________________________________________
< Like a moth to a flame, I'm drawn to bugs. >
 --------------------------------------------
  \
   \   \
        \ /\
        ( )
      .( o ).
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)

✅ Unit Test PR creation complete.

  • Create PR with unit tests
  • Commit unit tests in branch 4-ui-changes-for-color-and-layout

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

Note

Unit test generation is a public access feature. Expect some limitations and changes as we gather feedback and continue to improve it.


Generating unit tests... This may take up to 20 minutes.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

🧹 Nitpick comments (1)
IconMapper/Form/MainForm.cs (1)

32-91: Theme methods don't style the MenuStrip controls.

The DarkTheme() and LightTheme() methods style most controls but miss the MenuStrip (menuStrip1) and its ToolStripMenuItem children. In dark mode, the menu bar will remain with default light styling, creating visual inconsistency.

Consider adding MenuStrip theming
         private void DarkTheme()
         {
             // ... existing code ...
+
+            // MenuStrip Styling
+            menuStrip1.BackColor = Color.FromArgb(45, 45, 48);
+            menuStrip1.ForeColor = Color.White;
+            foreach (ToolStripMenuItem item in menuStrip1.Items)
+            {
+                item.ForeColor = Color.White;
+            }
+
             themeselected = Theme.Dark;
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/Form/MainForm.cs` around lines 32 - 91, DarkTheme and LightTheme
currently skip the menu strip; update both methods to style menuStrip1 and its
child ToolStripMenuItem controls: set menuStrip1.BackColor and ForeColor to the
appropriate dark/light colors and update each menuStrip1.Items (cast to
ToolStripMenuItem) to set their ForeColor/BackColor; also ensure dropdown menus
use matching colors by assigning a ToolStripRenderer (e.g.,
ToolStripProfessionalRenderer with a custom ProfessionalColorTable) or by
iterating subitems and setting their BackColor/ForeColor so the popup drop-downs
match the theme. Use the existing method names DarkTheme and LightTheme and the
control identifiers menuStrip1 and ToolStripMenuItem to locate where to add
these changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@IconMapper/ContextMenuOptions.cs`:
- Line 36: The Console.WriteLine calls in ContextMenuOptions.cs are printing the
literal "{iconFile}" and "{iconDirectory}" instead of the variable values;
update those Console.WriteLine invocations to use string interpolation (e.g.,
$"Added {iconFile} to context menu." and $"Icon directory: {iconDirectory}") or
String.Format so the actual variables are output; locate the Console.WriteLine
usages in the ContextMenuOptions class and replace the literal-brace strings
with interpolated/ formatted strings.
- Around line 13-17: Replace the hardcoded iconDirectory in the
contextMenuOptions method with the application setting
ConfigurationManager.AppSettings["IconFolderPath"] and rename the method to
follow PascalCase (e.g., ContextMenuOptions or RegisterContextMenuEntries);
update any internal references to the old method name and ensure the registry
path variable contextMenuPath remains unchanged while using the configured
iconDirectory value for all registry entries.
- Around line 1-45: The ContextMenuOptions class is dead code and should be
removed (delete the ContextMenuOptions class/file) — if you decide to keep it,
fix the string interpolation bugs in contextMenuOptions: use an interpolated
string or string.Format for the Registry.SetValue command and Console.WriteLine
(e.g. Registry.SetValue(iconRegistryPath + "\\command", "",
$"C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\""); and
Console.WriteLine($"Added {iconFile} to context menu.");), ensure iconDirectory
string usage in the error message is interpolated, and remember that writing to
HKEY_CLASSES_ROOT via Registry.SetValue requires administrative privileges and
will fail for non-admin users.
- Line 34: Fix the malformed registry command string passed to
Registry.SetValue: ensure the executable path is quoted correctly, interpolate
the actual iconFile variable (not the literal "{iconFile}"), and avoid
hardcoding the exe path by using a runtime value like Application.ExecutablePath
(or another appropriate app path variable). Update the call to Registry.SetValue
that uses iconRegistryPath and iconFile so the command becomes a properly
escaped, quoted string with the executable path and the iconFile argument
inserted (e.g., "\"<exePath>\" \"%1\" \"<iconFile>\"") so the registry entry
executes correctly.

In `@IconMapper/Form/MainForm.cs`:
- Around line 488-494: SetApplicationTheme currently ignores its theme parameter
and reads the themeselected field, causing the parameter to be unused and
ordering bugs; change SetApplicationTheme to use the incoming Theme parameter
(e.g., assign themeselected = theme or switch on theme) and then call
LightTheme() or DarkTheme() based on that parameter so the field is set before
invoking those methods (update logic in SetApplicationTheme to check the
parameter rather than themeselected and ensure themeselected is updated prior to
calling LightTheme/DarkTheme).
- Around line 475-482: The click handler should call SetApplicationTheme instead
of setTheme and assign themeselected in this handler to avoid redundant
assignments inside theme methods; update changeThemeToolStripMenuItem_Click to
flip themeselected (themeselected = themeselected == Theme.Light ? Theme.Dark :
Theme.Light), then call SetApplicationTheme(themeselected), and finally call
UpdateConfig("LastTheme", Convert.ToString(Convert.ToInt32(themeselected)));
also remove any duplicate themeselected assignments from the theme methods
(e.g., methods named SetLightTheme/SetDarkTheme or SetApplicationTheme
overloads) so the theme selection state is only set here.
- Around line 503-520: The UpdateConfig method currently always returns false,
swallows exceptions, and dereferences a possibly-null Settings[key]; fix it by
checking Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) then var
setting = config.AppSettings.Settings[key]; if setting is null call
config.AppSettings.Settings.Add(key, value) else set setting.Value = value; call
config.Save(ConfigurationSaveMode.Modified) and
ConfigurationManager.RefreshSection(section), then set retValue = true before
returning; in the catch block do not silently ignore the Exception—log or
surface it (e.g. Debug.WriteLine(ex) or show via MessageBox/your logger) and
keep returning false on failure so callers of UpdateConfig get correct feedback.
- Line 497: Fix the typo in the XML documentation comment that reads "Update
Cofig File" by updating it to "Update Config File" in MainForm's XML summary
comment; locate the comment above the related method in the MainForm class (the
XML doc immediately preceding the UpdateConfig/Update... method) and correct the
spelling so the summary reads "Update Config File".
- Around line 23-24: Replace the invalid call to setTheme(themeselected) with
the existing SetApplicationTheme method and add robust parsing/validation for
ConfigurationManager.AppSettings["LastTheme"] by using int.TryParse (or
Enum.TryParse) and verifying the parsed value maps to the Theme enum (e.g.,
Enum.IsDefined or Enum.TryParse) before casting; if parsing/validation fails,
fall back to a safe default Theme and log or ignore the bad config to avoid a
FormatException—apply the same replacement/fix for the other occurrence where
setTheme is used.

---

Nitpick comments:
In `@IconMapper/Form/MainForm.cs`:
- Around line 32-91: DarkTheme and LightTheme currently skip the menu strip;
update both methods to style menuStrip1 and its child ToolStripMenuItem
controls: set menuStrip1.BackColor and ForeColor to the appropriate dark/light
colors and update each menuStrip1.Items (cast to ToolStripMenuItem) to set their
ForeColor/BackColor; also ensure dropdown menus use matching colors by assigning
a ToolStripRenderer (e.g., ToolStripProfessionalRenderer with a custom
ProfessionalColorTable) or by iterating subitems and setting their
BackColor/ForeColor so the popup drop-downs match the theme. Use the existing
method names DarkTheme and LightTheme and the control identifiers menuStrip1 and
ToolStripMenuItem to locate where to add these changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6296993c-a0bc-46cc-ac76-d7337e32e65a

📥 Commits

Reviewing files that changed from the base of the PR and between afc497d and be6fc12.

⛔ Files ignored due to path filters (3)
  • IconMapper/Icon/dark_mode_24dp.png is excluded by !**/*.png
  • IconMapper/Icon/light_mode_24dp.png is excluded by !**/*.png
  • IconMapper/Icon/themes.png is excluded by !**/*.png
📒 Files selected for processing (7)
  • IconMapper/App.config
  • IconMapper/ContextMenuOptions.cs
  • IconMapper/Form/MainForm.Designer.cs
  • IconMapper/Form/MainForm.cs
  • IconMapper/IconMapper.csproj
  • IconMapper/Properties/Resources.Designer.cs
  • IconMapper/Properties/Resources.resx

Comment on lines +1 to +45
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IconMapper
{
class ContextMenuOptions
{
public static void contextMenuOptions()
{
// Define the folder containing the icon files
string iconDirectory = @"C:\Path\To\Your\IconFolder";
string contextMenuPath = @"HKEY_CLASSES_ROOT\Directory\shell\ChangeIcon\submenus";

if (Directory.Exists(iconDirectory))
{
// Scan the directory for .ico files
string[] icoFiles = Directory.GetFiles(iconDirectory, "*.ico");

// Create registry key for sub-menu
foreach (var iconFile in icoFiles)
{
string iconName = Path.GetFileNameWithoutExtension(iconFile);

// Add a new key for each icon file in the submenus
string iconRegistryPath = contextMenuPath+"\\"+iconName;

// Create a registry entry for each .ico file
Registry.SetValue(iconRegistryPath, "", iconName);
Registry.SetValue(iconRegistryPath+"\\command", "", "C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\"");

Console.WriteLine("Added {iconFile} to context menu.");
}
}
else
{
Console.WriteLine("The directory '{iconDirectory}' does not exist.");
}
}
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if ContextMenuOptions is referenced anywhere in the codebase
echo "=== Searching for usages of ContextMenuOptions ==="
rg -n "ContextMenuOptions" --type=cs

echo ""
echo "=== Searching for contextMenuOptions method calls ==="
rg -n "contextMenuOptions\s*\(" --type=cs

Repository: blazingvx/IconMapper

Length of output: 318


Remove dead code and fix string interpolation bug.

The ContextMenuOptions class is never called anywhere in the codebase and should be removed. Additionally, the Registry.SetValue() call contains a string interpolation error—{iconFile} will not be substituted because the string lacks the $ prefix. Use an interpolated string like $"C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\"" or string.Format() to inject the actual file path. Finally, note that writing to HKEY_CLASSES_ROOT requires administrative privileges and will fail for non-admin users.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/ContextMenuOptions.cs` around lines 1 - 45, The ContextMenuOptions
class is dead code and should be removed (delete the ContextMenuOptions
class/file) — if you decide to keep it, fix the string interpolation bugs in
contextMenuOptions: use an interpolated string or string.Format for the
Registry.SetValue command and Console.WriteLine (e.g.
Registry.SetValue(iconRegistryPath + "\\command", "",
$"C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\""); and
Console.WriteLine($"Added {iconFile} to context menu.");), ensure iconDirectory
string usage in the error message is interpolated, and remember that writing to
HKEY_CLASSES_ROOT via Registry.SetValue requires administrative privileges and
will fail for non-admin users.

Comment on lines +13 to +17
public static void contextMenuOptions()
{
// Define the folder containing the icon files
string iconDirectory = @"C:\Path\To\Your\IconFolder";
string contextMenuPath = @"HKEY_CLASSES_ROOT\Directory\shell\ChangeIcon\submenus";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Hardcoded paths break consistency with the rest of the application.

The iconDirectory on line 16 is hardcoded to a placeholder path, while the rest of the application (see MainForm.cs lines 175-184, 390-403, 410-434) reads the icon folder from ConfigurationManager.AppSettings["IconFolderPath"]. This creates a critical divergence where registry entries would point to the wrong location.

Additionally, the method name contextMenuOptions() should follow C# PascalCase convention: ContextMenuOptions() or a more descriptive name like RegisterContextMenuEntries().

Proposed fix
-        public static void contextMenuOptions()
+        public static void RegisterContextMenuEntries()
         {
-        // Define the folder containing the icon files
-            string iconDirectory = @"C:\Path\To\Your\IconFolder";
+            // Get the path from App.config like the rest of the application
+            string iconDirectory = System.Configuration.ConfigurationManager.AppSettings["IconFolderPath"];
             string contextMenuPath = @"HKEY_CLASSES_ROOT\Directory\shell\ChangeIcon\submenus";
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public static void contextMenuOptions()
{
// Define the folder containing the icon files
string iconDirectory = @"C:\Path\To\Your\IconFolder";
string contextMenuPath = @"HKEY_CLASSES_ROOT\Directory\shell\ChangeIcon\submenus";
public static void RegisterContextMenuEntries()
{
// Get the path from App.config like the rest of the application
string iconDirectory = System.Configuration.ConfigurationManager.AppSettings["IconFolderPath"];
string contextMenuPath = @"HKEY_CLASSES_ROOT\Directory\shell\ChangeIcon\submenus";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/ContextMenuOptions.cs` around lines 13 - 17, Replace the hardcoded
iconDirectory in the contextMenuOptions method with the application setting
ConfigurationManager.AppSettings["IconFolderPath"] and rename the method to
follow PascalCase (e.g., ContextMenuOptions or RegisterContextMenuEntries);
update any internal references to the old method name and ensure the registry
path variable contextMenuPath remains unchanged while using the configured
iconDirectory value for all registry entries.


// Create a registry entry for each .ico file
Registry.SetValue(iconRegistryPath, "", iconName);
Registry.SetValue(iconRegistryPath+"\\command", "", "C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\"");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Malformed command string with missing quote and non-interpolated variable.

The command string has critical issues:

  1. Missing opening double-quote before the path (starts with C:\ but ends with a closing quote)
  2. {iconFile} is literal text, not an interpolated variable - the actual icon path won't be substituted

This will write broken registry entries that won't execute correctly.

Proposed fix
-                    Registry.SetValue(iconRegistryPath+"\\command", "", "C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\"");
+                    Registry.SetValue(iconRegistryPath + "\\command", "", $"\"C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\"");

Note: The executable path C:\Path\To\YourApp\ChangeIconApp.exe is also hardcoded and should likely be replaced with the actual application path, e.g., using Application.ExecutablePath.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/ContextMenuOptions.cs` at line 34, Fix the malformed registry
command string passed to Registry.SetValue: ensure the executable path is quoted
correctly, interpolate the actual iconFile variable (not the literal
"{iconFile}"), and avoid hardcoding the exe path by using a runtime value like
Application.ExecutablePath (or another appropriate app path variable). Update
the call to Registry.SetValue that uses iconRegistryPath and iconFile so the
command becomes a properly escaped, quoted string with the executable path and
the iconFile argument inserted (e.g., "\"<exePath>\" \"%1\" \"<iconFile>\"") so
the registry entry executes correctly.

Registry.SetValue(iconRegistryPath, "", iconName);
Registry.SetValue(iconRegistryPath+"\\command", "", "C:\\Path\\To\\YourApp\\ChangeIconApp.exe\" \"%1\" \"{iconFile}\"");

Console.WriteLine("Added {iconFile} to context menu.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Console.WriteLine statements use literal {variable} instead of string interpolation.

The debug output won't show the actual values - {iconFile} and {iconDirectory} will appear literally.

Proposed fix
-                    Console.WriteLine("Added {iconFile} to context menu.");
+                    Console.WriteLine($"Added {iconFile} to context menu.");
-                Console.WriteLine("The directory '{iconDirectory}' does not exist.");
+                Console.WriteLine($"The directory '{iconDirectory}' does not exist.");

Also applies to: 41-41

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/ContextMenuOptions.cs` at line 36, The Console.WriteLine calls in
ContextMenuOptions.cs are printing the literal "{iconFile}" and
"{iconDirectory}" instead of the variable values; update those Console.WriteLine
invocations to use string interpolation (e.g., $"Added {iconFile} to context
menu." and $"Icon directory: {iconDirectory}") or String.Format so the actual
variables are output; locate the Console.WriteLine usages in the
ContextMenuOptions class and replace the literal-brace strings with
interpolated/ formatted strings.

Comment on lines +23 to +24
themeselected = (Theme)Convert.ToInt32(ConfigurationManager.AppSettings["LastTheme"]);
setTheme(themeselected);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

setTheme method does not exist - this will not compile.

Line 24 calls setTheme(themeselected), but the actual method is named SetApplicationTheme. This is also repeated on line 478.

Additionally, line 23 has no error handling - if LastTheme contains an invalid value, Convert.ToInt32 will throw a FormatException.

Proposed fix
         public MainForm()
         {
             InitializeComponent();
-            themeselected = (Theme)Convert.ToInt32(ConfigurationManager.AppSettings["LastTheme"]);
-            setTheme(themeselected);
+            int themeValue;
+            if (int.TryParse(ConfigurationManager.AppSettings["LastTheme"], out themeValue) 
+                && Enum.IsDefined(typeof(Theme), themeValue))
+            {
+                themeselected = (Theme)themeValue;
+            }
+            SetApplicationTheme(themeselected);
             LoadDrives();
             LoadIcons();
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/Form/MainForm.cs` around lines 23 - 24, Replace the invalid call
to setTheme(themeselected) with the existing SetApplicationTheme method and add
robust parsing/validation for ConfigurationManager.AppSettings["LastTheme"] by
using int.TryParse (or Enum.TryParse) and verifying the parsed value maps to the
Theme enum (e.g., Enum.IsDefined or Enum.TryParse) before casting; if
parsing/validation fails, fall back to a safe default Theme and log or ignore
the bad config to avoid a FormatException—apply the same replacement/fix for the
other occurrence where setTheme is used.

Comment on lines +475 to +482
private void changeThemeToolStripMenuItem_Click(object sender, EventArgs e)
{
themeselected = themeselected == Theme.Light ? Theme.Dark : Theme.Light;
setTheme(themeselected);

UpdateConfig("LastTheme", Convert.ToString(Convert.ToInt32(themeselected)));

}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Same issue: setTheme should be SetApplicationTheme.

Additionally, consider setting themeselected here rather than inside the theme methods to avoid redundant assignments.

Proposed fix
         private void changeThemeToolStripMenuItem_Click(object sender, EventArgs e)
         {
             themeselected = themeselected == Theme.Light ? Theme.Dark : Theme.Light;
-            setTheme(themeselected);
+            SetApplicationTheme(themeselected);
 
             UpdateConfig("LastTheme", Convert.ToString(Convert.ToInt32(themeselected)));
-
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void changeThemeToolStripMenuItem_Click(object sender, EventArgs e)
{
themeselected = themeselected == Theme.Light ? Theme.Dark : Theme.Light;
setTheme(themeselected);
UpdateConfig("LastTheme", Convert.ToString(Convert.ToInt32(themeselected)));
}
private void changeThemeToolStripMenuItem_Click(object sender, EventArgs e)
{
themeselected = themeselected == Theme.Light ? Theme.Dark : Theme.Light;
SetApplicationTheme(themeselected);
UpdateConfig("LastTheme", Convert.ToString(Convert.ToInt32(themeselected)));
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/Form/MainForm.cs` around lines 475 - 482, The click handler should
call SetApplicationTheme instead of setTheme and assign themeselected in this
handler to avoid redundant assignments inside theme methods; update
changeThemeToolStripMenuItem_Click to flip themeselected (themeselected =
themeselected == Theme.Light ? Theme.Dark : Theme.Light), then call
SetApplicationTheme(themeselected), and finally call UpdateConfig("LastTheme",
Convert.ToString(Convert.ToInt32(themeselected))); also remove any duplicate
themeselected assignments from the theme methods (e.g., methods named
SetLightTheme/SetDarkTheme or SetApplicationTheme overloads) so the theme
selection state is only set here.

Comment on lines +488 to +494
private void SetApplicationTheme(Theme theme)
{
if (themeselected == Theme.Light)
LightTheme();
else
DarkTheme();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

SetApplicationTheme ignores its theme parameter and uses the field instead.

The method accepts a theme parameter but checks themeselected field, making the parameter useless. This also introduces subtle bugs since themeselected is set inside DarkTheme()/LightTheme() methods rather than before calling them.

Proposed fix
         private void SetApplicationTheme(Theme theme)
         {
-            if (themeselected == Theme.Light)
+            if (theme == Theme.Light)
                 LightTheme();
             else
                 DarkTheme();
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private void SetApplicationTheme(Theme theme)
{
if (themeselected == Theme.Light)
LightTheme();
else
DarkTheme();
}
private void SetApplicationTheme(Theme theme)
{
if (theme == Theme.Light)
LightTheme();
else
DarkTheme();
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/Form/MainForm.cs` around lines 488 - 494, SetApplicationTheme
currently ignores its theme parameter and reads the themeselected field, causing
the parameter to be unused and ordering bugs; change SetApplicationTheme to use
the incoming Theme parameter (e.g., assign themeselected = theme or switch on
theme) and then call LightTheme() or DarkTheme() based on that parameter so the
field is set before invoking those methods (update logic in SetApplicationTheme
to check the parameter rather than themeselected and ensure themeselected is
updated prior to calling LightTheme/DarkTheme).

}

/// <summary>
/// Update Cofig File
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo in XML documentation: "Cofig" should be "Config".

         /// <summary>
-        /// Update Cofig File
+        /// Update Config File
         /// </summary>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Update Cofig File
/// <summary>
/// Update Config File
/// </summary>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/Form/MainForm.cs` at line 497, Fix the typo in the XML
documentation comment that reads "Update Cofig File" by updating it to "Update
Config File" in MainForm's XML summary comment; locate the comment above the
related method in the MainForm class (the XML doc immediately preceding the
UpdateConfig/Update... method) and correct the spelling so the summary reads
"Update Config File".

Comment on lines +503 to +520
private bool UpdateConfig(string key, string value, string section = "appSettings")
{
bool retValue = false;
try
{
// Update app.config with the new path
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings[key].Value = value;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(section);
}
catch (Exception ex)
{

}

return retValue;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

UpdateConfig always returns false and silently swallows exceptions.

The method:

  1. Never sets retValue = true on success, so callers (like line 398-399) receive incorrect feedback
  2. Catches exceptions but does nothing with them - failures are completely hidden
  3. Line 510: If the key doesn't exist in settings, Settings[key] returns null and accessing .Value throws NullReferenceException
Proposed fix
         private bool UpdateConfig(string key, string value, string section = "appSettings")
         {
-            bool retValue = false;
             try
             {
-                // Update app.config with the new path
                 Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
-                config.AppSettings.Settings[key].Value = value;
+                var setting = config.AppSettings.Settings[key];
+                if (setting == null)
+                {
+                    config.AppSettings.Settings.Add(key, value);
+                }
+                else
+                {
+                    setting.Value = value;
+                }
                 config.Save(ConfigurationSaveMode.Modified);
                 ConfigurationManager.RefreshSection(section);
+                return true;
             }
             catch (Exception ex)
             {
-
+                MessageBox.Show($"Error updating configuration: {ex.Message}", "Configuration Error", 
+                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
+                return false;
             }
-
-            return retValue;
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
private bool UpdateConfig(string key, string value, string section = "appSettings")
{
bool retValue = false;
try
{
// Update app.config with the new path
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings[key].Value = value;
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(section);
}
catch (Exception ex)
{
}
return retValue;
}
private bool UpdateConfig(string key, string value, string section = "appSettings")
{
try
{
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
var setting = config.AppSettings.Settings[key];
if (setting == null)
{
config.AppSettings.Settings.Add(key, value);
}
else
{
setting.Value = value;
}
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection(section);
return true;
}
catch (Exception ex)
{
MessageBox.Show($"Error updating configuration: {ex.Message}", "Configuration Error",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@IconMapper/Form/MainForm.cs` around lines 503 - 520, The UpdateConfig method
currently always returns false, swallows exceptions, and dereferences a
possibly-null Settings[key]; fix it by checking Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) then var
setting = config.AppSettings.Settings[key]; if setting is null call
config.AppSettings.Settings.Add(key, value) else set setting.Value = value; call
config.Save(ConfigurationSaveMode.Modified) and
ConfigurationManager.RefreshSection(section), then set retValue = true before
returning; in the catch block do not silently ignore the Exception—log or
surface it (e.g. Debug.WriteLine(ex) or show via MessageBox/your logger) and
keep returning false on failure so callers of UpdateConfig get correct feedback.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 4, 2026

✅ Created PR with unit tests: #8

@blazingvx blazingvx merged commit 1b6ae02 into master Apr 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI Changes for Color and Layout

1 participant