Fix Disable edit server if the server is in a group

This commit is contained in:
ChsBuffer
2021-07-15 16:06:34 +08:00
parent 88f3a4940b
commit f8b1c4acd6
3 changed files with 10 additions and 14 deletions

View File

@@ -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";

View File

@@ -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();

View File

@@ -17,7 +17,7 @@ namespace Netch.Models
/// <summary>
/// 组
/// </summary>
public string Group { get; set; } = "None";
public string Group { get; set; } = Constants.DefaultGroup;
/// <summary>
/// 地址
@@ -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;
}
}
}