ivr流程编辑器

CtlMenu.cs 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.Utility;
  10. using HySoft.IVRFlowEditor.IVRControlUtility;
  11. using IVRFlowEditor.IVRControlUtility;
  12. namespace IVRFlowEditor
  13. {
  14. public partial class CtlMenu : UserControl
  15. {
  16. public CtlMenu()
  17. {
  18. InitializeComponent();
  19. BindMenu();
  20. }
  21. Dictionary<string,string> Buttons = new Dictionary<string,string>();
  22. /// <summary>
  23. /// 绑定菜单控件
  24. /// </summary>
  25. public void BindMenu()
  26. {
  27. Buttons.Add("开始", "answer.gif");
  28. Buttons.Add("外呼号码", "dial.gif");
  29. Buttons.Add("呼叫转移", "trans.gif");
  30. Buttons.Add("变量", "var.gif");
  31. Buttons.Add("跳转子流程", "SubFlow.gif");
  32. Buttons.Add("放音收按键", "dtmf.gif");
  33. Buttons.Add("传真发送", "StringOperate.gif");
  34. Buttons.Add("传真接收", "StringOperate.gif");
  35. Buttons.Add("留言", "record.gif");
  36. Buttons.Add("请求排队", "WaitQueue.gif");
  37. Buttons.Add("继续排队", "QueueWait.gif");
  38. Buttons.Add("取消排队", "DropQueue.gif");
  39. Buttons.Add("转人工", "CreateData.gif");
  40. Buttons.Add("数据比较", "if.gif");
  41. Buttons.Add("算数运算", "CountCal.gif");
  42. Buttons.Add("分支节点", "case.gif");
  43. Buttons.Add("字符串操作", "StringOperate.gif");
  44. Buttons.Add("数据库读写", "DataBase.gif");
  45. Buttons.Add("数据集映射", "ParseData.gif");
  46. Buttons.Add("定时器", "timer.gif");
  47. Buttons.Add("SOCKET通讯", "AskQueue.gif");
  48. Buttons.Add("挂机", "onhook.gif");
  49. Buttons.Add("结束", "onhook.gif");
  50. int width = 90;
  51. int height = 60;
  52. int i=0;
  53. foreach (string key in Buttons.Keys)
  54. {
  55. Button btn = new Button();
  56. btn.Size = new System.Drawing.Size(width, height);
  57. btn.Text = key;
  58. btn.Click+=new EventHandler(btn_Click);
  59. btn.Location = new Point(i % 2 * width, i / 2 * height);
  60. if (!string.IsNullOrEmpty(Buttons[key]) && GlobalController.ControlImageList.Images.ContainsKey(Buttons[key]))
  61. {
  62. btn.Image = GlobalController.ControlImageList.Images[Buttons[key]];
  63. btn.ImageAlign = ContentAlignment.TopCenter;
  64. btn.TextAlign = ContentAlignment.BottomCenter;
  65. }
  66. this.Controls.Add(btn);
  67. i++;
  68. }
  69. }
  70. bool isCreate;
  71. /// <summary>
  72. /// 根据发生点击事件的控件名称创建相应的节点控件
  73. /// </summary>
  74. /// <param name="sender"></param>
  75. /// <param name="e"></param>
  76. private void btn_Click(object sender, EventArgs e)
  77. {
  78. isCreate = true;
  79. this.Cursor = Cursors.Hand;
  80. var button=(sender as Button);
  81. switch (button.Text)
  82. {
  83. case "开始": GlobalController.SetCreateNodeType(new IVRStartNode(button.Text), Buttons[button.Text]); break;
  84. case "外呼号码": GlobalController.SetCreateNodeType(new IVROutbound(button.Text), Buttons[button.Text]); break;
  85. case "呼叫转移": GlobalController.SetCreateNodeType(new IVRTransfeOut(button.Text), Buttons[button.Text]); break;
  86. case "变量": GlobalController.SetCreateNodeType(new IVRDefinevar(button.Text), Buttons[button.Text]); break;
  87. case "跳转子流程": GlobalController.SetCreateNodeType(new IVRSubflow(button.Text), Buttons[button.Text]); break;
  88. case "放音收按键": GlobalController.SetCreateNodeType(new IVRAudioDTMF(button.Text), Buttons[button.Text]); break;
  89. // case "排队组号": GlobalController.SetCreateNodeType(new IVRQueueBuildNumber(button.Text)); break;
  90. case "传真接收": GlobalController.SetCreateNodeType(new IVRRecvfax(button.Text), Buttons[button.Text]); break;
  91. case "传真发送": GlobalController.SetCreateNodeType(new IVRSendfax(button.Text), Buttons[button.Text]); break;
  92. case "留言": GlobalController.SetCreateNodeType(new IVRLeaveWord(button.Text), Buttons[button.Text]); break;
  93. case "请求排队": GlobalController.SetCreateNodeType(new IVRQueue(button.Text), Buttons[button.Text]); break;
  94. case "继续排队": GlobalController.SetCreateNodeType(new IVRContinueQueue(button.Text), Buttons[button.Text]); break;
  95. case "取消排队": GlobalController.SetCreateNodeType(new IVRCancelQueue(button.Text), Buttons[button.Text]); break;
  96. case "转人工": GlobalController.SetCreateNodeType(new IVRTurnagent(button.Text), Buttons[button.Text]); break;
  97. case "数据比较": GlobalController.SetCreateNodeType(new IVRCompare(button.Text), Buttons[button.Text]); break;
  98. case "算数运算": GlobalController.SetCreateNodeType(new IVRCalculate(button.Text), Buttons[button.Text]); break;
  99. case "分支节点": GlobalController.SetCreateNodeType(new IVRBranch(button.Text), Buttons[button.Text]); break;
  100. case "字符串操作": GlobalController.SetCreateNodeType(new IVRStringop(button.Text), Buttons[button.Text]); break;
  101. case "数据库读写": GlobalController.SetCreateNodeType(new IVRSql(button.Text), Buttons[button.Text]); break;
  102. case "数据集映射": GlobalController.SetCreateNodeType(new IVRRecordSet(button.Text), Buttons[button.Text]); break;
  103. case "定时器": GlobalController.SetCreateNodeType(new IVRTimer(button.Text), Buttons[button.Text]); break;
  104. case "挂机": GlobalController.SetCreateNodeType(new IVRHangUp(button.Text), Buttons[button.Text]); break;
  105. case "SOCKET通讯": GlobalController.SetCreateNodeType(new IVRSocket(button.Text), Buttons[button.Text]); break;
  106. case "结束": GlobalController.SetCreateNodeType(new IVREndNode(button.Text), Buttons[button.Text]); break;
  107. }
  108. }
  109. private void listView1_MouseLeave(object sender, EventArgs e)
  110. {
  111. if (isCreate)
  112. this.Cursor = Cursors.No;
  113. isCreate = false;
  114. }
  115. private void listView1_MouseMove(object sender, MouseEventArgs e)
  116. {
  117. this.Cursor = Cursors.Arrow;
  118. }
  119. }
  120. }