ivr流程编辑器

FrmIVREdit.cs 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using HySoft.IVRFlowEditor.IVRControlUtility;
  10. using HySoft.IVRFlowEditor.Utility;
  11. using System.Text.RegularExpressions;
  12. namespace HySoft.IVRFlowEditor
  13. {
  14. public partial class FrmIVREdit : Form
  15. {
  16. public FrmIVREdit(string text)
  17. {
  18. InitializeComponent();
  19. this.rtb_text.Text = text;
  20. this.Load += new EventHandler(FrmIVREdit_Load);
  21. }
  22. /// <summary>
  23. /// 编辑变量对象的内容
  24. /// </summary>
  25. /// <param name="vars"></param>
  26. public FrmIVREdit(List<IVRDefaultVar> vars)
  27. {
  28. InitializeComponent();
  29. foreach (IVRDefaultVar var in vars)
  30. {
  31. this.rtb_text.Text += "@[" + var.Var + "]@";
  32. }
  33. this.Load += new EventHandler(FrmIVREdit_Load);
  34. }
  35. void FrmIVREdit_Load(object sender, EventArgs e)
  36. {
  37. foreach (IVRDefinevarDefVar var in GlobalController.GetFlowVar())
  38. {
  39. this.lv_auto.Items.Add(var.VarName);
  40. }
  41. }
  42. public List<IVRDefaultVar> Vars = new List<IVRDefaultVar>();
  43. /// <summary>
  44. /// 把固定格式的内容转换成变量对象集合
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. private void btn_enter_Click(object sender, EventArgs e)
  49. {
  50. Regex reg = new Regex(@"@\[.+\]@");
  51. if(reg.IsMatch(this.rtb_text.Text))
  52. {
  53. var vals= reg.Matches(this.rtb_text.Text);
  54. foreach (Match val in vals)
  55. {
  56. Vars.Add(new IVRDefaultVar() { Var = val.Value.Replace("@[", "").Replace("]@", "") });
  57. }
  58. }
  59. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  60. this.Close();
  61. }
  62. public string GetText()
  63. {
  64. return rtb_text.Text;
  65. }
  66. private void btn_cancel_Click(object sender, EventArgs e)
  67. {
  68. this.DialogResult = System.Windows.Forms.DialogResult.No;
  69. this.Close();
  70. }
  71. private void SelectedIndexChanged(object sender, EventArgs e)
  72. {
  73. var con=(sender as ListView);
  74. if (con.SelectedIndices != null && con.SelectedIndices.Count > 0)
  75. {
  76. this.rtb_text.Text+="@["+con.SelectedItems[0].Text+"]@";
  77. }
  78. }
  79. }
  80. }