//将配置文件里面的一行(一个过滤器)转换成一个filter结构 public static filter createFilter(string txt) { filter filterNew = new filter(); int lastYinHao = txt.LastIndexOf('"'); filterNew.filterName = txt.Substring(1, lastYinHao - 1); filterNew.filterExpression = txt.Substring(lastYinHao + 2); return filterNew; }
//将配置文件里面的一行(一个过滤器)转换成一个filter结构 public static filter createFilter(string txt) { filter filterNew = new filter(); int lastYinHao = txt.LastIndexOf('"'); filterNew.filterName = txt.Substring(1, lastYinHao - 1); filterNew.filterExpression = txt.Substring(lastYinHao + 2); return(filterNew); }
//点击保存按钮 private void btnFilterOK_Click(object sender, EventArgs e) { ArrayList structArrayList = filterClass.Filters; //保存操作的过滤器可能是新增的,也可能是修改的。 //如果过滤器列表中有其名字,则是修改,则将老的删掉 for (int i = 0; i < structArrayList.Count; i++) { if (((filter)structArrayList[i]).filterName == txtbFilterName.Text) { structArrayList.RemoveAt(i); } } filter filterNew = new filter(txtbFilterName.Text, txtbFilterExpression.Text); structArrayList.Add(filterNew); filterClass.saveFilters(structArrayList); refresh(); }