JD2022-TU1/main/tools/modules/JD.Remoting.WPF.Module/Settings/EngineConnection.cs

54 lines
1.5 KiB
C#

using System.ComponentModel;
using JD.Remoting.WPF.Module.Serialization;
using Newtonsoft.Json;
using Plume.WPF.Mvvm;
namespace JD.Remoting.WPF.Module.Settings
{
[TypeConverter(typeof(ExpandableObjectConverter))]
[JsonConverter(typeof(NoTypeConverterJsonConverter<EngineConnection>))]
public class EngineConnection : BindableBase
{
private string _name;
private string _ip = "127.0.0.1";
private int _port = 1001;
public EngineConnection()
{
}
[Browsable(true), Description("Name of the connection")]
public string Name
{
get => _name;
set => SetProperty(ref _name, value);
}
[Browsable(true), DefaultValue("127.0.0.1"), Description("Ip of the console to connect to (e.g. 127.0.0.1)")]
public string Ip
{
get => _ip;
set => SetProperty(ref _ip, value);
}
[Browsable(true), DefaultValue(1001), Description("Port of the console to connect to (e.g. 1001)")]
public int Port
{
get => _port;
set => SetProperty(ref _port, value);
}
/// <inheritdoc />
public override string ToString()
{
if (string.IsNullOrEmpty(Name))
{
return $"{Ip}:{Port}";
}
return $"{Name} - {Ip}:{Port}";
}
public static EngineConnection Default { get; } = new EngineConnection {Name = "localhost", Ip = "127.0.0.1", Port = 1001};
}
}