public ContextMenuStrip Create(ref PhysicalDisk currentDisk) { try { ToolStripMenuItem disks = new ToolStripMenuItem(Resources.SelectDisk); List <string> instanceNames = PhysicalDisk.GetPerformableDiskInstanceNames(IgnoreDriveType); foreach (string instanceName in instanceNames) { ToolStripRadioButtonMenuItem disk = new ToolStripRadioButtonMenuItem(Regex.Replace(instanceName, @"\d\s", "")); disk.Click += Disk_Clicked; disk.Tag = instanceName; if ((string.IsNullOrEmpty(Settings.Default.LastSelectedDrive) && disks.DropDownItems.Count == 0) || (Settings.Default.LastSelectedDrive == instanceName)) { disk.Checked = true; currentDisk = new PhysicalDisk(instanceName); } disks.DropDownItems.Add(disk); } if (disks.DropDownItems.Count > 0 && instanceNames.Count > 0 && string.IsNullOrEmpty(currentDisk.InstanceName)) { ((ToolStripRadioButtonMenuItem)disks.DropDownItems[0]).Checked = true; currentDisk = new PhysicalDisk(instanceNames[0]); Settings.Default.LastSelectedDrive = currentDisk.InstanceName; Settings.Default.Save(); } ToolStripMenuItem interval = new ToolStripMenuItem(Resources.UpdateInterval); for (int i = 100; i <= 1000; i += 100) { ToolStripRadioButtonMenuItem updateIntervalItem = new ToolStripRadioButtonMenuItem(string.Format("{0:#,0}", i)); updateIntervalItem.Checked = i == Settings.Default.UpdateInterval; updateIntervalItem.Tag = i; updateIntervalItem.Click += UpdateIntervalItem_Clicked; interval.DropDownItems.Add(updateIntervalItem); } ToolStripMenuItem ignoreDriveType = new ToolStripMenuItem(Resources.IgnoreDriveType); ignoreDriveType.Checked = Settings.Default.IgnoreDriveType; ignoreDriveType.Click += IgnoreDriveType_Clicked; ToolStripMenuItem allowMultipleInstances = new ToolStripMenuItem(Resources.AllowMultipleInstances); allowMultipleInstances.Checked = Settings.Default.AllowMutipleInstances; allowMultipleInstances.Click += AllowMultipleInstances_Clicked; //ToolStripMenuItem addShortcutToStartup = new ToolStripMenuItem(Resources.AddShortcutToStartup); //addShortcutToStartup.Checked = Settings.Default.AddShortcutToStartup; //addShortcutToStartup.Click += AddShortcutToStartup_Clicked; //if (addShortcutToStartup.Checked) AutoStart.CreateStartupShortcut(); else AutoStart.RemoveStartupShortcut(); ToolStripMenuItem addRunKeyToRegistry = new ToolStripMenuItem(Resources.AddRunKeyToRegistry); addRunKeyToRegistry.Checked = Settings.Default.AddRunKeyToRegistry; addRunKeyToRegistry.Click += AddRunKeyToRegistry_Clicked; if (addRunKeyToRegistry.Checked) { AutoStart.CreateRunKey(); } else { AutoStart.RemoveRunKey(); } ToolStripMenuItem settings = new ToolStripMenuItem(Resources.Settings); settings.DropDownItems.AddRange(new ToolStripItem[] { interval, ignoreDriveType, allowMultipleInstances, addRunKeyToRegistry }); ToolStripMenuItem exit = new ToolStripMenuItem(Resources.Exit); exit.Click += Exit_Clicked; ContextMenuStrip contextMenuStrip = new ContextMenuStrip(); contextMenuStrip.Items.AddRange(new ToolStripItem[] { disks, settings, new ToolStripSeparator(), exit }); return(contextMenuStrip); } catch { throw; } }