diff --git a/LANCommander/Data/Enums/ScriptType.cs b/LANCommander/Data/Enums/ScriptType.cs index e183dfe..095d348 100644 --- a/LANCommander/Data/Enums/ScriptType.cs +++ b/LANCommander/Data/Enums/ScriptType.cs @@ -1,12 +1,18 @@ -namespace LANCommander.Data.Enums +using System.ComponentModel.DataAnnotations; + +namespace LANCommander.Data.Enums { public enum ScriptType { Install, Uninstall, + [Display(Name = "Name Change")] NameChange, + [Display(Name = "Key Change")] KeyChange, + [Display(Name = "Save Upload")] SaveUpload, + [Display(Name = "Save Download")] SaveDownload } } diff --git a/LANCommander/Extensions/EnumExtensions.cs b/LANCommander/Extensions/EnumExtensions.cs new file mode 100644 index 0000000..213ffb4 --- /dev/null +++ b/LANCommander/Extensions/EnumExtensions.cs @@ -0,0 +1,18 @@ +using System.ComponentModel.DataAnnotations; +using System.Reflection; + +namespace LANCommander.Extensions +{ + public static class EnumExtensions + { + public static string GetDisplayName(this Enum value) + { + return value + .GetType() + .GetMember(value.ToString()) + .First() + .GetCustomAttribute()? + .GetName() ?? value.ToString(); + } + } +} diff --git a/LANCommander/Pages/Games/Components/ScriptEditor.razor b/LANCommander/Pages/Games/Components/ScriptEditor.razor index b935d02..ea7e28a 100644 --- a/LANCommander/Pages/Games/Components/ScriptEditor.razor +++ b/LANCommander/Pages/Games/Components/ScriptEditor.razor @@ -1,4 +1,5 @@ @using LANCommander.Data.Enums; +@using LANCommander.Extensions; @using LANCommander.Models @using LANCommander.Services @using System.IO.Compression; @@ -68,7 +69,7 @@ - + @context.Type.GetDisplayName() @context.CreatedBy?.UserName