| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using HySoft.IVRFlowEditor.IVRControlUtility;
- using HySoft.IVRFlowEditor.Utility;
- using System.Text.RegularExpressions;
- namespace HySoft.IVRFlowEditor
- {
- public partial class FrmIVREdit : Form
- {
- public FrmIVREdit(string text)
- {
- InitializeComponent();
- this.rtb_text.Text = text;
- this.Load += new EventHandler(FrmIVREdit_Load);
- }
- /// <summary>
- /// 编辑变量对象的内容
- /// </summary>
- /// <param name="vars"></param>
- public FrmIVREdit(List<IVRDefaultVar> vars)
- {
- InitializeComponent();
- foreach (IVRDefaultVar var in vars)
- {
- this.rtb_text.Text += "@[" + var.Var + "]@";
- }
- this.Load += new EventHandler(FrmIVREdit_Load);
- }
- void FrmIVREdit_Load(object sender, EventArgs e)
- {
- foreach (IVRDefinevarDefVar var in GlobalController.GetFlowVar())
- {
- this.lv_auto.Items.Add(var.VarName);
- }
- }
- public List<IVRDefaultVar> Vars = new List<IVRDefaultVar>();
- /// <summary>
- /// 把固定格式的内容转换成变量对象集合
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btn_enter_Click(object sender, EventArgs e)
- {
- Regex reg = new Regex(@"@\[.+\]@");
- if(reg.IsMatch(this.rtb_text.Text))
- {
- var vals= reg.Matches(this.rtb_text.Text);
- foreach (Match val in vals)
- {
- Vars.Add(new IVRDefaultVar() { Var = val.Value.Replace("@[", "").Replace("]@", "") });
- }
- }
- this.DialogResult = System.Windows.Forms.DialogResult.OK;
- this.Close();
- }
- public string GetText()
- {
- return rtb_text.Text;
- }
- private void btn_cancel_Click(object sender, EventArgs e)
- {
- this.DialogResult = System.Windows.Forms.DialogResult.No;
- this.Close();
- }
- private void SelectedIndexChanged(object sender, EventArgs e)
- {
- var con=(sender as ListView);
- if (con.SelectedIndices != null && con.SelectedIndices.Count > 0)
- {
- this.rtb_text.Text+="@["+con.SelectedItems[0].Text+"]@";
- }
- }
-
- }
- }
|