ivr流程编辑器

CtlIVRSocket.cs 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using HySoft.IVRFlowEditor;
  10. using HySoft.IVRFlowEditor.Utility;
  11. using HySoft.IVRFlowEditor.IVRControlUtility;
  12. using HySoft.IVRFlowEditor.Model;
  13. namespace HySoft.IVRFlowEditor.IVRControl
  14. {
  15. public partial class CtlIVRSocket : UserControl
  16. {
  17. IVRSocket _IVRSocket;
  18. public CtlIVRSocket(IVRSocket obj)
  19. {
  20. InitializeComponent();
  21. _IVRSocket = obj;
  22. this.Load += new EventHandler(CtlIVRSocket_Load);
  23. }
  24. void CtlIVRSocket_Load(object sender, EventArgs e)
  25. {
  26. this.ctlDefaultListVar1.SetData(_IVRSocket.OutputVar.Select(a => a.Var).ToList());
  27. this.tb_NodeID.Text = _IVRSocket.Pos;
  28. this.tb_NodeName.Text = _IVRSocket.Name;
  29. this.rtb_Note.Text = _IVRSocket.Note;
  30. this.cmb_SuccessPos.DataSource = GlobalController.GetComBoBoxofIVR();
  31. this.cmb_SuccessPos.DisplayMember = "Note";//2017-5-8将Name改为Note
  32. this.cmb_SuccessPos.ValueMember = "ID";
  33. if (_IVRSocket.SuccessPos != null)
  34. this.cmb_SuccessPos.SelectedItem = _IVRSocket.SuccessPos;
  35. this.cmb_FailPos.DataSource = GlobalController.GetComBoBoxofIVR();
  36. this.cmb_FailPos.DisplayMember = "Note";//2017-5-8将Name改为Note
  37. this.cmb_FailPos.ValueMember = "ID";
  38. if (_IVRSocket.FailPos != null)
  39. this.cmb_FailPos.SelectedItem = _IVRSocket.FailPos;
  40. GlobalController.BindComBoBoxOfEnumDesc(this.cmb_OpType, _IVRSocket.OpType);
  41. this.tb_FarIp.Text = _IVRSocket.FarIp;
  42. this.num_Port.Value = _IVRSocket.FarPort;
  43. this.num_timeOut.Value = _IVRSocket.RecvTimeOut;
  44. this.panel1.Controls.Clear();
  45. if (_IVRSocket.IVRInputVar != null)
  46. {
  47. foreach (IVRInputVar i in _IVRSocket.IVRInputVar)
  48. {
  49. i.Control.Width = this.panel1.Width;
  50. i.Control.Height = 30;
  51. i.Control.Location = new Point(0, 30 * (this.panel1.Controls.Count));
  52. this.panel1.Controls.Add(i.Control);
  53. }
  54. }
  55. }
  56. private void rtb_Rvar_MouseDoubleClick(object sender, MouseEventArgs e)
  57. {
  58. FrmIVREdit frm = new FrmIVREdit(_IVRSocket.OutputVar);
  59. if (frm.ShowDialog() == DialogResult.OK)
  60. {
  61. _IVRSocket.OutputVar = frm.Vars;
  62. }
  63. }
  64. private void btn_add_Click(object sender, EventArgs e)
  65. {
  66. IVRInputVar var = new IVRInputVar();
  67. var.Control.Width = this.panel1.Width;
  68. var.Control.Height = 30;
  69. var.Control.Location = new Point(0, 30 * (this.panel1.Controls.Count));
  70. this.panel1.Controls.Add(var.Control);
  71. _IVRSocket.IVRInputVar.Add(var);
  72. }
  73. private void btn_delete_Click(object sender, EventArgs e)
  74. {
  75. if (_IVRSocket.IVRInputVar.Count > 0)
  76. {
  77. this.panel1.Controls.Remove(_IVRSocket.IVRInputVar[_IVRSocket.IVRInputVar.Count - 1].Control);
  78. _IVRSocket.IVRInputVar.Remove(_IVRSocket.IVRInputVar[_IVRSocket.IVRInputVar.Count - 1]);
  79. }
  80. }
  81. private void btn_enter_Click(object sender, EventArgs e)
  82. {
  83. _IVRSocket.Name = tb_NodeName.Text;
  84. _IVRSocket.Note = rtb_Note.Text;
  85. foreach (IVRInputVar i in _IVRSocket.IVRInputVar)
  86. {
  87. i.Control.Enter();
  88. }
  89. _IVRSocket.OutputVar.Clear();
  90. _IVRSocket.OutputVar.AddRange(this.ctlDefaultListVar1.GetListVar());
  91. if (this.cmb_SuccessPos.SelectedItem != null)
  92. _IVRSocket.SuccessPos = (this.cmb_SuccessPos.SelectedItem as IVRControlBase);
  93. if (this.cmb_FailPos.SelectedItem != null)
  94. _IVRSocket.FailPos = (this.cmb_FailPos.SelectedItem as IVRControlBase);
  95. _IVRSocket.OpType = GlobalController.GetEnumByComBoBoxValueOFDesc<OpType>(this.cmb_OpType.Text);
  96. _IVRSocket.FarIp = this.tb_FarIp.Text;
  97. _IVRSocket.FarPort = (int)this.num_Port.Value;
  98. _IVRSocket.RecvTimeOut = (int)this.num_timeOut.Value;
  99. this.FindForm().DialogResult = DialogResult.OK;
  100. this.FindForm().Close();
  101. }
  102. private void btn_cancel_Click(object sender, EventArgs e)
  103. {
  104. this.FindForm().DialogResult = DialogResult.No;
  105. this.FindForm().Close();
  106. }
  107. }
  108. }