diff --git a/ShareX.HelpersLib/EnumInfo.cs b/ShareX.HelpersLib/EnumInfo.cs
new file mode 100644
index 000000000..94ebc008e
--- /dev/null
+++ b/ShareX.HelpersLib/EnumInfo.cs
@@ -0,0 +1,46 @@
+#region License Information (GPL v3)
+
+/*
+ ShareX - A program that allows you to take screenshots and share any file type
+ Copyright © 2007-2015 ShareX Developers
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Optionally you can also view the license at .
+*/
+
+#endregion License Information (GPL v3)
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace ShareX.HelpersLib
+{
+ public class EnumInfo
+ {
+ public Enum Value { get; set; }
+ public string Description { get; set; }
+ public string Category { get; set; }
+
+ public EnumInfo(Enum value)
+ {
+ Value = value;
+ Description = Value.GetLocalizedDescription();
+ Category = Value.GetLocalizedCategory();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ShareX.HelpersLib/Extensions/EnumExtensions.cs b/ShareX.HelpersLib/Extensions/EnumExtensions.cs
index 8cd8c4ad3..7c58833b1 100644
--- a/ShareX.HelpersLib/Extensions/EnumExtensions.cs
+++ b/ShareX.HelpersLib/Extensions/EnumExtensions.cs
@@ -70,6 +70,19 @@ public static string GetLocalizedDescription(this Enum value, ResourceManager re
return description;
}
+ public static string GetLocalizedCategory(this Enum value)
+ {
+ return value.GetLocalizedCategory(Resources.ResourceManager);
+ }
+
+ public static string GetLocalizedCategory(this Enum value, ResourceManager resourceManager)
+ {
+ string resourceName = value.GetType().Name + "_" + value + "_Category";
+ string description = resourceManager.GetString(resourceName);
+
+ return description;
+ }
+
public static int GetIndex(this Enum value)
{
Array values = Enum.GetValues(value.GetType());
diff --git a/ShareX.HelpersLib/Properties/Resources.Designer.cs b/ShareX.HelpersLib/Properties/Resources.Designer.cs
index dad760bc0..b5a05de1e 100644
--- a/ShareX.HelpersLib/Properties/Resources.Designer.cs
+++ b/ShareX.HelpersLib/Properties/Resources.Designer.cs
@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.34209
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -690,6 +690,15 @@ internal static string HotkeyType_ActiveMonitor {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_ActiveMonitor_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ActiveMonitor_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture active window.
///
@@ -699,6 +708,15 @@ internal static string HotkeyType_ActiveWindow {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_ActiveWindow_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ActiveWindow_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Auto capture.
///
@@ -708,6 +726,15 @@ internal static string HotkeyType_AutoCapture {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_AutoCapture_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_AutoCapture_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Open/Stop Automate tool.
///
@@ -717,6 +744,15 @@ internal static string HotkeyType_Automate {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_Automate_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_Automate_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Upload from clipboard.
///
@@ -726,6 +762,15 @@ internal static string HotkeyType_ClipboardUpload {
}
}
+ ///
+ /// Looks up a localized string similar to Upload.
+ ///
+ internal static string HotkeyType_ClipboardUpload_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ClipboardUpload_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Upload from clipboard with content viewer.
///
@@ -735,6 +780,15 @@ internal static string HotkeyType_ClipboardUploadWithContentViewer {
}
}
+ ///
+ /// Looks up a localized string similar to Upload.
+ ///
+ internal static string HotkeyType_ClipboardUploadWithContentViewer_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ClipboardUploadWithContentViewer_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Color picker.
///
@@ -744,6 +798,15 @@ internal static string HotkeyType_ColorPicker {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_ColorPicker_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ColorPicker_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture custom region.
///
@@ -753,6 +816,15 @@ internal static string HotkeyType_CustomRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_CustomRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_CustomRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture diamond region.
///
@@ -762,6 +834,15 @@ internal static string HotkeyType_DiamondRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_DiamondRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_DiamondRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Drag and drop upload.
///
@@ -771,6 +852,15 @@ internal static string HotkeyType_DragDropUpload {
}
}
+ ///
+ /// Looks up a localized string similar to Upload.
+ ///
+ internal static string HotkeyType_DragDropUpload_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_DragDropUpload_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture ellipse region.
///
@@ -780,6 +870,15 @@ internal static string HotkeyType_EllipseRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_EllipseRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_EllipseRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Upload file.
///
@@ -789,6 +888,15 @@ internal static string HotkeyType_FileUpload {
}
}
+ ///
+ /// Looks up a localized string similar to Upload.
+ ///
+ internal static string HotkeyType_FileUpload_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_FileUpload_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Upload folder.
///
@@ -798,6 +906,15 @@ internal static string HotkeyType_FolderUpload {
}
}
+ ///
+ /// Looks up a localized string similar to Upload.
+ ///
+ internal static string HotkeyType_FolderUpload_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_FolderUpload_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture freehand region.
///
@@ -807,6 +924,15 @@ internal static string HotkeyType_FreeHandRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_FreeHandRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_FreeHandRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to FTP client.
///
@@ -816,6 +942,15 @@ internal static string HotkeyType_FTPClient {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_FTPClient_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_FTPClient_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Hash check.
///
@@ -825,6 +960,15 @@ internal static string HotkeyType_HashCheck {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_HashCheck_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_HashCheck_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Image effects.
///
@@ -834,6 +978,15 @@ internal static string HotkeyType_ImageEffects {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_ImageEffects_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ImageEffects_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Index folder.
///
@@ -843,6 +996,15 @@ internal static string HotkeyType_IndexFolder {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_IndexFolder_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_IndexFolder_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture last region.
///
@@ -852,6 +1014,15 @@ internal static string HotkeyType_LastRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_LastRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_LastRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to None.
///
@@ -870,6 +1041,15 @@ internal static string HotkeyType_OpenScreenshotsFolder {
}
}
+ ///
+ /// Looks up a localized string similar to Miscellaneous.
+ ///
+ internal static string HotkeyType_OpenScreenshotsFolder_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_OpenScreenshotsFolder_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture polygon region.
///
@@ -879,6 +1059,15 @@ internal static string HotkeyType_PolygonRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_PolygonRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_PolygonRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture entire screen.
///
@@ -888,6 +1077,15 @@ internal static string HotkeyType_PrintScreen {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_PrintScreen_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_PrintScreen_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to QR code.
///
@@ -897,6 +1095,15 @@ internal static string HotkeyType_QRCode {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_QRCode_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_QRCode_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture rectangle region (Annotate).
///
@@ -906,6 +1113,15 @@ internal static string HotkeyType_RectangleAnnotate {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_RectangleAnnotate_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_RectangleAnnotate_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture rectangle region (Light).
///
@@ -915,6 +1131,15 @@ internal static string HotkeyType_RectangleLight {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_RectangleLight_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_RectangleLight_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture rectangle region.
///
@@ -924,6 +1149,15 @@ internal static string HotkeyType_RectangleRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_RectangleRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_RectangleRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture rectangle region (Transparent).
///
@@ -933,6 +1167,15 @@ internal static string HotkeyType_RectangleTransparent {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_RectangleTransparent_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_RectangleTransparent_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture rounded rectangle region.
///
@@ -942,6 +1185,15 @@ internal static string HotkeyType_RoundedRectangleRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_RoundedRectangleRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_RoundedRectangleRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Ruler.
///
@@ -951,6 +1203,15 @@ internal static string HotkeyType_Ruler {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_Ruler_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_Ruler_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Screen color picker.
///
@@ -960,6 +1221,15 @@ internal static string HotkeyType_ScreenColorPicker {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_ScreenColorPicker_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ScreenColorPicker_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Screen recording.
///
@@ -969,6 +1239,15 @@ internal static string HotkeyType_ScreenRecorder {
}
}
+ ///
+ /// Looks up a localized string similar to Screen record.
+ ///
+ internal static string HotkeyType_ScreenRecorder_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ScreenRecorder_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Screen recording (GIF).
///
@@ -978,6 +1257,15 @@ internal static string HotkeyType_ScreenRecorderGIF {
}
}
+ ///
+ /// Looks up a localized string similar to Screen record.
+ ///
+ internal static string HotkeyType_ScreenRecorderGIF_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_ScreenRecorderGIF_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Start auto capture using last region.
///
@@ -987,6 +1275,15 @@ internal static string HotkeyType_StartAutoCapture {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_StartAutoCapture_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_StartAutoCapture_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Start screen recording using last region.
///
@@ -996,6 +1293,15 @@ internal static string HotkeyType_StartScreenRecorder {
}
}
+ ///
+ /// Looks up a localized string similar to Screen record.
+ ///
+ internal static string HotkeyType_StartScreenRecorder_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_StartScreenRecorder_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Start screen recording (GIF) using last region.
///
@@ -1005,6 +1311,15 @@ internal static string HotkeyType_StartScreenRecorderGIF {
}
}
+ ///
+ /// Looks up a localized string similar to Screen record.
+ ///
+ internal static string HotkeyType_StartScreenRecorderGIF_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_StartScreenRecorderGIF_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Stop all active uploads.
///
@@ -1014,6 +1329,15 @@ internal static string HotkeyType_StopUploads {
}
}
+ ///
+ /// Looks up a localized string similar to Upload.
+ ///
+ internal static string HotkeyType_StopUploads_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_StopUploads_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture triangle region.
///
@@ -1023,6 +1347,15 @@ internal static string HotkeyType_TriangleRegion {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_TriangleRegion_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_TriangleRegion_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Tweet message.
///
@@ -1032,6 +1365,15 @@ internal static string HotkeyType_TweetMessage {
}
}
+ ///
+ /// Looks up a localized string similar to Tools.
+ ///
+ internal static string HotkeyType_TweetMessage_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_TweetMessage_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Upload from URL.
///
@@ -1041,6 +1383,15 @@ internal static string HotkeyType_UploadURL {
}
}
+ ///
+ /// Looks up a localized string similar to Upload.
+ ///
+ internal static string HotkeyType_UploadURL_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_UploadURL_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Capture rectangle region (Window).
///
@@ -1050,6 +1401,15 @@ internal static string HotkeyType_WindowRectangle {
}
}
+ ///
+ /// Looks up a localized string similar to Screen capture.
+ ///
+ internal static string HotkeyType_WindowRectangle_Category {
+ get {
+ return ResourceManager.GetString("HotkeyType_WindowRectangle_Category", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Hue: {0:0.0}°, Saturation: {1:0.0}%, Brightness: {2:0.0}%.
///
diff --git a/ShareX.HelpersLib/Properties/Resources.resx b/ShareX.HelpersLib/Properties/Resources.resx
index 7a70dafaf..5dc567cda 100644
--- a/ShareX.HelpersLib/Properties/Resources.resx
+++ b/ShareX.HelpersLib/Properties/Resources.resx
@@ -646,4 +646,124 @@ Would you like to download and install it?
Octree quantizer (Medium quality)
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Tools
+
+
+ Upload
+
+
+ Upload
+
+
+ Tools
+
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Upload
+
+
+ Screen capture
+
+
+ Upload
+
+
+ Upload
+
+
+ Screen capture
+
+
+ Tools
+
+
+ Tools
+
+
+ Tools
+
+
+ Tools
+
+
+ Screen capture
+
+
+ Miscellaneous
+
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Tools
+
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Screen capture
+
+
+ Tools
+
+
+ Tools
+
+
+ Screen record
+
+
+ Screen record
+
+
+ Screen capture
+
+
+ Screen record
+
+
+ Screen record
+
+
+ Upload
+
+
+ Screen capture
+
+
+ Tools
+
+
+ Upload
+
+
+ Screen capture
+
\ No newline at end of file
diff --git a/ShareX.HelpersLib/ShareX.HelpersLib.csproj b/ShareX.HelpersLib/ShareX.HelpersLib.csproj
index 64b81e34d..f9a049690 100644
--- a/ShareX.HelpersLib/ShareX.HelpersLib.csproj
+++ b/ShareX.HelpersLib/ShareX.HelpersLib.csproj
@@ -121,6 +121,7 @@
+
diff --git a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptions.cs b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptions.cs
index e60d55f49..38a2fb776 100644
--- a/ShareX.ScreenCaptureLib/Screencast/FFmpegOptions.cs
+++ b/ShareX.ScreenCaptureLib/Screencast/FFmpegOptions.cs
@@ -64,7 +64,6 @@ public string Extension
case FFmpegVideoCodec.libx265:
case FFmpegVideoCodec.gif:
return "mp4";
- break;
case FFmpegVideoCodec.libvpx:
return "webm";
case FFmpegVideoCodec.libxvid:
diff --git a/ShareX/Enums.cs b/ShareX/Enums.cs
index f360c653c..19c4f09c4 100644
--- a/ShareX/Enums.cs
+++ b/ShareX/Enums.cs
@@ -130,7 +130,7 @@ public enum CaptureType
LastRegion
}
- public enum HotkeyType // Localized
+ public enum HotkeyType // Localized + Category
{
None,
FileUpload,
@@ -162,7 +162,6 @@ public enum HotkeyType // Localized
StartScreenRecorderGIF,
AutoCapture,
StartAutoCapture,
- OpenScreenshotsFolder,
ColorPicker,
ScreenColorPicker,
Ruler,
@@ -172,7 +171,8 @@ public enum HotkeyType // Localized
ImageEffects,
QRCode,
TweetMessage,
- Automate
+ Automate,
+ OpenScreenshotsFolder
}
public enum HotkeyStatus
diff --git a/ShareX/Forms/TaskSettingsForm.cs b/ShareX/Forms/TaskSettingsForm.cs
index ad5a6d095..7e0db3bc5 100644
--- a/ShareX/Forms/TaskSettingsForm.cs
+++ b/ShareX/Forms/TaskSettingsForm.cs
@@ -378,44 +378,71 @@ private void UpdateDestinationStates()
private void AddEnumItemsContextMenu(Action selectedEnum, params ToolStripDropDown[] parents)
{
- string[] enums = Helpers.GetLocalizedEnumDescriptions().Select(x => x.Replace("&", "&&")).ToArray();
+ EnumInfo[] enums = Helpers.GetEnums().OfType().Select(x => new EnumInfo(x)).ToArray();
foreach (ToolStripDropDown parent in parents)
{
- for (int i = 0; i < enums.Length; i++)
+ foreach (EnumInfo enumInfo in enums)
{
- ToolStripMenuItem tsmi = new ToolStripMenuItem(enums[i]);
-
- int index = i;
+ ToolStripMenuItem tsmi = new ToolStripMenuItem(enumInfo.Description.Replace("&", "&&"));
+ tsmi.Tag = enumInfo;
tsmi.Click += (sender, e) =>
{
- foreach (ToolStripDropDown parent2 in parents)
- {
- for (int i2 = 0; i2 < enums.Length; i2++)
- {
- ToolStripMenuItem tsmi2 = (ToolStripMenuItem)parent2.Items[i2];
- tsmi2.Checked = index == i2;
- }
- }
+ SetEnumCheckedContextMenu(enumInfo, parents);
- selectedEnum((T)Enum.ToObject(typeof(T), index));
+ selectedEnum((T)Enum.ToObject(typeof(T), enumInfo.Value));
UpdateUploaderMenuNames();
};
- parent.Items.Add(tsmi);
+ if (!string.IsNullOrEmpty(enumInfo.Category))
+ {
+ ToolStripMenuItem tsmiParent = parent.Items.OfType().FirstOrDefault(x => x.Text == enumInfo.Category);
+
+ if (tsmiParent == null)
+ {
+ tsmiParent = new ToolStripMenuItem(enumInfo.Category);
+ parent.Items.Add(tsmiParent);
+ }
+
+ tsmiParent.DropDownItems.Add(tsmi);
+ }
+ else
+ {
+ parent.Items.Add(tsmi);
+ }
}
}
}
private void SetEnumCheckedContextMenu(Enum value, params ToolStripDropDown[] parents)
{
- int index = value.GetIndex();
+ SetEnumCheckedContextMenu(new EnumInfo(value), parents);
+ }
+ private void SetEnumCheckedContextMenu(EnumInfo enumInfo, params ToolStripDropDown[] parents)
+ {
foreach (ToolStripDropDown parent in parents)
{
- ((ToolStripMenuItem)parent.Items[index]).Checked = true;
+ foreach (ToolStripMenuItem tsmiParent in parent.Items)
+ {
+ EnumInfo currentEnumInfo;
+
+ if (tsmiParent.DropDownItems.Count > 0)
+ {
+ foreach (ToolStripMenuItem tsmiCategoryParent in tsmiParent.DropDownItems)
+ {
+ currentEnumInfo = (EnumInfo)tsmiCategoryParent.Tag;
+ tsmiCategoryParent.Checked = currentEnumInfo.Value == enumInfo.Value;
+ }
+ }
+ else
+ {
+ currentEnumInfo = (EnumInfo)tsmiParent.Tag;
+ tsmiParent.Checked = currentEnumInfo.Value == enumInfo.Value;
+ }
+ }
}
}