diff --git a/Netch/Constants.cs b/Netch/Constants.cs
index 4083e4a4..716639ad 100644
--- a/Netch/Constants.cs
+++ b/Netch/Constants.cs
@@ -14,6 +14,8 @@
public const string OutputTemplate = @"[{Timestamp:yyyy-MM-dd HH:mm:ss}][{Level}] {Message:lj}{NewLine}{Exception}";
public const string EOF = "\r\n";
+ public const string DefaultGroup = "NONE";
+
public static class Parameter
{
public const string Show = "-show";
diff --git a/Netch/Forms/ServerForm.cs b/Netch/Forms/ServerForm.cs
index 10909311..1d8cc253 100644
--- a/Netch/Forms/ServerForm.cs
+++ b/Netch/Forms/ServerForm.cs
@@ -74,7 +74,7 @@ namespace Netch.Forms
AddSaveButton();
i18N.TranslateForm(this);
- ConfigurationGroupBox.Enabled = string.IsNullOrEmpty(Server.Remark);
+ ConfigurationGroupBox.Enabled = !Server.IsInGroup();
ConfigurationGroupBox.ResumeLayout(false);
ConfigurationGroupBox.PerformLayout();
diff --git a/Netch/Models/Server.cs b/Netch/Models/Server.cs
index bc28f48d..c11cdd2d 100644
--- a/Netch/Models/Server.cs
+++ b/Netch/Models/Server.cs
@@ -17,7 +17,7 @@ namespace Netch.Models
///
/// 组
///
- public string Group { get; set; } = "None";
+ public string Group { get; set; } = Constants.DefaultGroup;
///
/// 地址
@@ -62,18 +62,7 @@ namespace Netch.Models
{
var remark = string.IsNullOrWhiteSpace(Remark) ? $"{Hostname}:{Port}" : Remark;
- if (Group.Equals("None") || Group.Equals(""))
- Group = "NONE";
-
- string shortName;
- if (Type == string.Empty)
- {
- shortName = "WTF";
- }
- else
- {
- shortName = ServerHelper.GetUtilByTypeName(Type).ShortName;
- }
+ var shortName = Type.IsNullOrEmpty() ? "WTF" : ServerHelper.GetUtilByTypeName(Type).ShortName;
return $"[{shortName}][{Group}] {remark}";
}
@@ -139,5 +128,10 @@ namespace Netch.Models
return false;
}
}
+
+ public static bool IsInGroup(this Server server)
+ {
+ return server.Group is not Constants.DefaultGroup;
+ }
}
}
\ No newline at end of file