diff --git a/IconMapper/App.config b/IconMapper/App.config index c612aa6..c335b45 100644 --- a/IconMapper/App.config +++ b/IconMapper/App.config @@ -5,5 +5,6 @@ + \ No newline at end of file diff --git a/IconMapper/ContextMenuOptions.cs b/IconMapper/ContextMenuOptions.cs new file mode 100644 index 0000000..176fb25 --- /dev/null +++ b/IconMapper/ContextMenuOptions.cs @@ -0,0 +1,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."); + } + } + } +} diff --git a/IconMapper/Form/MainForm.Designer.cs b/IconMapper/Form/MainForm.Designer.cs index b69b161..dc55e84 100644 --- a/IconMapper/Form/MainForm.Designer.cs +++ b/IconMapper/Form/MainForm.Designer.cs @@ -40,6 +40,7 @@ private void InitializeComponent() this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.settingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.importIconsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.changeThemeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.DirectoryFinder.SuspendLayout(); @@ -156,7 +157,8 @@ private void InitializeComponent() // this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.settingToolStripMenuItem, - this.importIconsToolStripMenuItem}); + this.importIconsToolStripMenuItem, + this.changeThemeToolStripMenuItem}); this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); this.fileToolStripMenuItem.Text = "File"; @@ -165,7 +167,7 @@ private void InitializeComponent() // this.settingToolStripMenuItem.Image = global::IconMapper.Properties.Resources.settings_24dp; this.settingToolStripMenuItem.Name = "settingToolStripMenuItem"; - this.settingToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.settingToolStripMenuItem.Size = new System.Drawing.Size(155, 22); this.settingToolStripMenuItem.Text = "Setting"; this.settingToolStripMenuItem.Click += new System.EventHandler(this.SettingsMenuItem_Click); // @@ -173,10 +175,18 @@ private void InitializeComponent() // this.importIconsToolStripMenuItem.Image = global::IconMapper.Properties.Resources.upload_24dp; this.importIconsToolStripMenuItem.Name = "importIconsToolStripMenuItem"; - this.importIconsToolStripMenuItem.Size = new System.Drawing.Size(152, 22); + this.importIconsToolStripMenuItem.Size = new System.Drawing.Size(155, 22); this.importIconsToolStripMenuItem.Text = "Import Icons"; this.importIconsToolStripMenuItem.Click += new System.EventHandler(this.ImportMenuItem_Click); // + // changeThemeToolStripMenuItem + // + this.changeThemeToolStripMenuItem.Image = global::IconMapper.Properties.Resources.themes; + this.changeThemeToolStripMenuItem.Name = "changeThemeToolStripMenuItem"; + this.changeThemeToolStripMenuItem.Size = new System.Drawing.Size(155, 22); + this.changeThemeToolStripMenuItem.Text = "Change Theme"; + this.changeThemeToolStripMenuItem.Click += new System.EventHandler(this.changeThemeToolStripMenuItem_Click); + // // helpToolStripMenuItem // this.helpToolStripMenuItem.Name = "helpToolStripMenuItem"; @@ -197,6 +207,7 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoSize = true; this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.BackColor = System.Drawing.SystemColors.Control; this.ClientSize = new System.Drawing.Size(834, 361); this.Controls.Add(this.IconBox); this.Controls.Add(this.DirectoryFinder); @@ -235,6 +246,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem importIconsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem changeThemeToolStripMenuItem; diff --git a/IconMapper/Form/MainForm.cs b/IconMapper/Form/MainForm.cs index a46698f..6e4b097 100644 --- a/IconMapper/Form/MainForm.cs +++ b/IconMapper/Form/MainForm.cs @@ -11,14 +11,86 @@ namespace IconMapper public partial class MainForm : Form { private string selectedIconPath; + private enum Theme { Light, Dark }; + Theme themeselected = Theme.Light; + /// + /// Main Form + /// public MainForm() { InitializeComponent(); + themeselected = (Theme)Convert.ToInt32(ConfigurationManager.AppSettings["LastTheme"]); + setTheme(themeselected); LoadDrives(); LoadIcons(); } + /// + /// Dark Theme + /// + private void DarkTheme() + { + // Background and Foreground + this.BackColor = Color.FromArgb(30, 30, 30); // Dark theme + this.ForeColor = Color.White; + + // TreeView Styling + folderTreeView.BackColor = Color.FromArgb(45, 45, 48); + folderTreeView.ForeColor = Color.White; + folderTreeView.BorderStyle = BorderStyle.FixedSingle; + + // ListBox Styling + iconListBox.BackColor = Color.FromArgb(40, 40, 42); + iconListBox.ForeColor = Color.LightGreen; + iconListBox.BorderStyle = BorderStyle.FixedSingle; + + // PictureBox Styling (border if needed) + iconPreviewPictureBox.BackColor = Color.FromArgb(50, 50, 50); + iconPreviewPictureBox.BorderStyle = BorderStyle.FixedSingle; + + // Apply Button Styling (if you use a button called applyIconButton) + applyIconButton.BackColor = Color.FromArgb(70, 130, 180); // SteelBlue + applyIconButton.ForeColor = Color.White; + applyIconButton.FlatStyle = FlatStyle.Flat; + applyIconButton.FlatAppearance.BorderColor = Color.White; + applyIconButton.FlatAppearance.BorderSize = 1; + + DirectoryFinder.ForeColor = Color.White; + IconBox.ForeColor = Color.White; + + themeselected = Theme.Dark; + } + + /// + /// Light Theme (Default) + /// + private void LightTheme() + { + // Standard Theme + //this.DoubleBuffered = true; + DirectoryFinder.ForeColor = Color.Black; + IconBox.ForeColor = Color.Black; + + this.ForeColor = SystemColors.ControlText; + this.BackColor = SystemColors.Control; + + folderTreeView.ForeColor = SystemColors.ControlText; + folderTreeView.BackColor = SystemColors.Control; + + applyIconButton.ForeColor = SystemColors.ControlText; + applyIconButton.BackColor = SystemColors.Control; + + iconListBox.ForeColor = SystemColors.ControlText; + iconListBox.BackColor = SystemColors.Control; + + iconPreviewPictureBox.BackColor = SystemColors.Control; + iconPreviewPictureBox.BorderStyle = BorderStyle.None; + + themeselected = Theme.Light; + } + + /// /// Loads the available drives and adds them to the TreeView. /// @@ -248,6 +320,13 @@ private void RefreshFolderView() SHChangeNotify(SHCNE_UPDATEDIR, SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero); } + /// + /// Folder Refresh + /// + /// + /// + /// + /// [DllImport("shell32.dll", CharSet = CharSet.Auto)] private static extern void SHChangeNotify(int wEventId, int uFlags, IntPtr dwItem1, IntPtr dwItem2); @@ -309,17 +388,16 @@ protected override void OnResize(EventArgs e) /// private void SettingsMenuItem_Click(object sender, EventArgs e) { + string selectedPath = string.Empty; using (FolderBrowserDialog folderDialog = new FolderBrowserDialog()) { if (folderDialog.ShowDialog() == DialogResult.OK) { - string selectedPath = folderDialog.SelectedPath; - // Update app.config with the new path - Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); - config.AppSettings.Settings["IconFolderPath"].Value = selectedPath; - config.Save(ConfigurationSaveMode.Modified); - ConfigurationManager.RefreshSection("appSettings"); - MessageBox.Show("Icon folder path updated successfully."); + selectedPath = folderDialog.SelectedPath; + + if (UpdateConfig("IconFolderPath", selectedPath)) + MessageBox.Show("Icon folder path updated successfully."); + } } } @@ -388,5 +466,57 @@ private void AboutMenuItem_Click(object sender, EventArgs e) MessageBoxButtons.OK, MessageBoxIcon.Information); } + + /// + /// Change Theme from Menu + /// + /// + /// + 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))); + + } + + /// + /// Set Theme for the Application + /// + /// + private void SetApplicationTheme(Theme theme) + { + if (themeselected == Theme.Light) + LightTheme(); + else + DarkTheme(); + } + + /// + /// Update Cofig File + /// + /// + /// + /// + /// + 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; + } } } diff --git a/IconMapper/Icon/dark_mode_24dp.png b/IconMapper/Icon/dark_mode_24dp.png new file mode 100644 index 0000000..32d3367 Binary files /dev/null and b/IconMapper/Icon/dark_mode_24dp.png differ diff --git a/IconMapper/Icon/light_mode_24dp.png b/IconMapper/Icon/light_mode_24dp.png new file mode 100644 index 0000000..77174bc Binary files /dev/null and b/IconMapper/Icon/light_mode_24dp.png differ diff --git a/IconMapper/Icon/themes.png b/IconMapper/Icon/themes.png new file mode 100644 index 0000000..0c49f36 Binary files /dev/null and b/IconMapper/Icon/themes.png differ diff --git a/IconMapper/IconMapper.csproj b/IconMapper/IconMapper.csproj index 06754da..9f48f5a 100644 --- a/IconMapper/IconMapper.csproj +++ b/IconMapper/IconMapper.csproj @@ -48,6 +48,7 @@ + Form @@ -100,6 +101,7 @@ + diff --git a/IconMapper/Properties/Resources.Designer.cs b/IconMapper/Properties/Resources.Designer.cs index 959d811..1e17578 100644 --- a/IconMapper/Properties/Resources.Designer.cs +++ b/IconMapper/Properties/Resources.Designer.cs @@ -70,6 +70,16 @@ internal static System.Drawing.Bitmap settings_24dp { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap themes { + get { + object obj = ResourceManager.GetObject("themes", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/IconMapper/Properties/Resources.resx b/IconMapper/Properties/Resources.resx index 6d2c182..b3de17e 100644 --- a/IconMapper/Properties/Resources.resx +++ b/IconMapper/Properties/Resources.resx @@ -118,10 +118,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Icon\upload_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Icon\settings_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Icon\upload_24dp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Icon\themes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file