frm_Connection.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. namespace RDClient
  9. {
  10. /// <summary>
  11. /// 建立连接的对话框
  12. /// </summary>
  13. public partial class frm_Connection : Form
  14. {
  15. public NetworkRemoteControlLib.ConnectionItem HostConnectionItem { get; set; }
  16. public frm_Connection()
  17. {
  18. InitializeComponent();
  19. this.Load += Frm_Connection_Load;
  20. }
  21. private void Frm_Connection_Load(object sender, EventArgs e)
  22. {
  23. if (this.HostConnectionItem == null)
  24. {
  25. this.HostConnectionItem = new NetworkRemoteControlLib.ConnectionItem();
  26. }
  27. this.txt_Hostname.Text = this.HostConnectionItem.HostNameIP;
  28. this.nuprot.Value = this.HostConnectionItem.HostPort;
  29. this.txtDName.Text = this.HostConnectionItem.DescriptionName;
  30. this.txtDinfo.Text = this.HostConnectionItem.DescriptionInformation;
  31. }
  32. private void btn_Enter_Click(object sender, EventArgs e)
  33. {
  34. if (string.IsNullOrEmpty(this.txt_Hostname.Text))
  35. {
  36. MessageBox.Show($"{this.label3.Text}不能为空");
  37. return;
  38. }
  39. if (string.IsNullOrEmpty(this.txtDName.Text))
  40. {
  41. MessageBox.Show($"{this.label1.Text}不能为空");
  42. return;
  43. }
  44. this.HostConnectionItem.HostNameIP = this.txt_Hostname.Text.Trim();
  45. this.HostConnectionItem.HostPort=Convert.ToInt32(this.nuprot.Value);
  46. this.HostConnectionItem.DescriptionName = this.txtDName.Text;
  47. this.HostConnectionItem.DescriptionInformation= this.txtDinfo.Text;
  48. this.DialogResult=DialogResult.OK;
  49. }
  50. private void btn_Cancel_Click(object sender, EventArgs e)
  51. {
  52. this.DialogResult = DialogResult.Cancel;
  53. }
  54. }
  55. }