ivr流程编辑器

CtlIVRBranch.cs 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.IVRControlUtility;
  10. using HySoft.IVRFlowEditor.Utility;
  11. namespace HySoft.IVRFlowEditor.IVRControl
  12. {
  13. public partial class CtlIVRBranch : UserControl
  14. {
  15. IVRBranch _IVRBranch;
  16. public CtlIVRBranch(IVRBranch obj)
  17. {
  18. InitializeComponent();
  19. _IVRBranch = obj;
  20. this.Load += new EventHandler(CtlIVRBranch_Load);
  21. }
  22. void CtlIVRBranch_Load(object sender, EventArgs e)
  23. {
  24. this.tb_NodeID.Text = _IVRBranch.Pos;
  25. this.tb_NodeName.Text = _IVRBranch.Name;
  26. this.rtb_Note.Text = _IVRBranch.Note;
  27. this.cmb_NextNode.DataSource = GlobalController.GetComBoBoxofIVR();
  28. this.cmb_NextNode.DisplayMember = "Note";//2017-5-8将Name改为Note
  29. this.cmb_NextNode.ValueMember = "ID";
  30. //2017-5-9加载变量
  31. this.textBox1.Text = _IVRBranch.Var;
  32. int j = 0;
  33. if (_IVRBranch.DefaultPos != null)
  34. this.cmb_NextNode.SelectedItem = _IVRBranch.DefaultPos;
  35. if (_IVRBranch.Branch != null)
  36. foreach (IVRBranchVar i in _IVRBranch.Branch)
  37. {
  38. //_IVRBranch.Control.Width = this.panel1.Width;
  39. //_IVRBranch.Control.Height = 30;
  40. //_IVRBranch.Control.Location = new Point(0, 30 * (this.panel1.Controls.Count));
  41. i.Control.Width = this.panel1.Width;
  42. i.Control.Height = 30;
  43. i.Control.Location = new Point(0, 30 * j);// (this.panel1.Controls.Count));//2017-5-9修改
  44. this.panel1.Controls.Add(i.Control);
  45. j++;
  46. }
  47. }
  48. private void btn_add_Click(object sender, EventArgs e)
  49. {
  50. IVRBranchVar var = new IVRBranchVar();
  51. var.Control.Width = this.panel1.Width;
  52. var.Control.Height = 30;
  53. var.Control.Location = new Point(0, 30 * (this.panel1.Controls.Count ));
  54. this.panel1.Controls.Add(var.Control);
  55. _IVRBranch.Branch.Add(var);
  56. }
  57. private void btn_delete_Click(object sender, EventArgs e)
  58. {
  59. if (_IVRBranch.Branch.Count > 0)
  60. {
  61. this.panel1.Controls.Remove(_IVRBranch.Branch[_IVRBranch.Branch.Count - 1].Control);
  62. _IVRBranch.Branch.Remove(_IVRBranch.Branch[_IVRBranch.Branch.Count - 1]);
  63. }
  64. }
  65. private void btn_enter_Click(object sender, EventArgs e)
  66. {
  67. _IVRBranch.Name = tb_NodeName.Text;
  68. _IVRBranch.Note = rtb_Note.Text;
  69. //2017-5-9变量
  70. _IVRBranch.Var = textBox1.Text;
  71. foreach (IVRBranchVar i in _IVRBranch.Branch)
  72. {
  73. i.Control.Enter();
  74. }
  75. if (this.cmb_NextNode.SelectedItem != null)
  76. _IVRBranch.DefaultPos = (this.cmb_NextNode.SelectedItem as IVRControlBase);
  77. this.FindForm().DialogResult = DialogResult.OK;
  78. panel1.Controls.Clear();
  79. this.FindForm().Close();
  80. }
  81. private void btn_cancel_Click(object sender, EventArgs e)
  82. {
  83. this.FindForm().DialogResult = DialogResult.No;
  84. panel1.Controls.Clear();
  85. this.FindForm().Close();
  86. }
  87. }
  88. }