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); } /// /// 编辑变量对象的内容 /// /// public FrmIVREdit(List 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 Vars = new List(); /// /// 把固定格式的内容转换成变量对象集合 /// /// /// 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+"]@"; } } } }