ConnectionItem.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace NetworkRemoteControlLib
  7. {
  8. /// <summary>
  9. /// 主机信息项
  10. /// </summary>
  11. public class ConnectionItem
  12. {
  13. public ConnectionItem() {
  14. }
  15. //public ConnectionItem(string connString)
  16. //{
  17. // try
  18. // {
  19. // string[] connStrs = connString.Split('|');
  20. // this.DescriptionName = LYFZ.WinAPI.SDKSecurity.Encode16Hex(connStrs[0]);
  21. // this.HostNameIP = LYFZ.WinAPI.SDKSecurity.Encode16Hex(connStrs[1]);
  22. // this.HostPort = Convert.ToInt32(connStrs[2]);
  23. // this.DescriptionInformation = LYFZ.WinAPI.SDKSecurity.Encode16Hex(connStrs[3]);
  24. // }
  25. // catch { }
  26. //}
  27. public ConnectionItem(string dName,string hostNameIP,int hPort=4500,string desc="")
  28. {
  29. this.DescriptionName = dName;
  30. this.HostNameIP = hostNameIP;
  31. this.DescriptionInformation = desc;
  32. this.HostPort = hPort;
  33. }
  34. public int HostPort { set; get; } = 4500;
  35. /// <summary>
  36. /// 主机描述名称
  37. /// </summary>
  38. public string DescriptionName { get; set; } = "未命名";
  39. /// <summary>
  40. /// 主机名或IP
  41. /// </summary>
  42. public string HostNameIP { get; set; } = "127.0.0.1";
  43. /// <summary>
  44. /// 主机描述说明
  45. /// </summary>
  46. public string DescriptionInformation { get; set; } = "";
  47. public override string ToString()
  48. {
  49. return $"{DescriptionName}[{HostNameIP}:{HostPort.ToString()}]";
  50. }
  51. //public string ToSaveString()
  52. //{
  53. // return $"{LYFZ.WinAPI.SDKSecurity.Encode16Hex(this.DescriptionName)}|{LYFZ.WinAPI.SDKSecurity.Encode16Hex(this.HostNameIP)}|{this.HostPort.ToString()}|{LYFZ.WinAPI.SDKSecurity.Encode16Hex(this.DescriptionInformation)}";
  54. //}
  55. }
  56. }