示例#1
0
        private void RuleComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SwitchOperState();

            this._ParamPanel.Controls.Clear();
            //清空正文规则列表 on2008年7月18日
            this.TextRuleNameComboBox.Items.Clear();

            //显示参数列表
            string ruleName = this.RuleComboBox.Text;

            activeRule = activeRules[ruleName];

            Dictionary <string, ParamState> paramDic = activeRule.ParamStates;

            Debug.Assert(paramDic != null, "paramDic为空");
            if (paramDic == null)
            {
                return;
            }
            foreach (string key in paramDic.Keys)
            {
                ParamState  state = paramDic[key];
                ParamCotrol ctr   = new ParamCotrol();
                ctr.ParaName = key;
                ctr.KeyValid = state.KeyState;
                ctr.Size     = new Size(140, 28);
                this._ParamPanel.Controls.Add(ctr);
            }

            this._ParamPanel.Enabled = false;

            //add by zl on2008年7月18日
            ShowTextRuleName(activeRules[ruleName]);
        }
示例#2
0
 /// <summary>
 /// 将修改后的参数属性保存到对象中
 /// </summary>
 /// <param name="rule"></param>
 /// <returns></returns>
 private void GetModifiedRule(WebRule rule)
 {
     Control.ControlCollection ctrls = this._ParamPanel.Controls;
     foreach (Control ctrl in ctrls)
     {
         if (ctrl.GetType() == typeof(ParamCotrol))
         {
             ParamCotrol paramCtrl = (ParamCotrol)ctrl;
             rule.SetParamSate(paramCtrl.ParaName, paramCtrl.KeyValid, paramCtrl.IsModified);
         }
     }
 }
示例#3
0
        private void BuildRuleBtn_Click(object sender, EventArgs e)
        {
            string url = this.urlTextBox.Text.Trim();

            #region  判断url的合理性
            if (!url.StartsWith("http://", StringComparison.OrdinalIgnoreCase))
            {
                url = "http://" + url;
            }

            //检查url是否是在此域名下的 及url的格式是否正确
            bool flag = CheckURl(url);
            if (!flag)
            {
                MessageBox.Show("此url不是当前域名下的网址,请重新填写");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }

            flag = Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute);
            if (!flag)
            {
                MessageBox.Show("Url的网址格式不正确,请重新填写");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }

            if (url.IndexOf("?") == -1)
            {
                MessageBox.Show("请输入动态的网址,当前网址是不能生成规则的!");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }
            #endregion

            this._ParamPanel.Controls.Clear();
            this._ParamPanel.Enabled  = true;
            this.BuildRuleBtn.Enabled = false;
            this.SaveRuleBtn.Enabled  = true;


            Uri uri = new Uri(url);
            activeRule = new WebRule(uri);
            bool isExist = activeRules.IsExistRule(activeRule.RuleName);
            if (isExist)
            {
                MessageBox.Show("此规则已存在,请重新输入Url!");
                this.urlTextBox.Focus();
                this.urlTextBox.SelectAll();
                return;
            }
            this.ruleNameTextBox.Text = activeRule.RuleName;
            this.RuleComboBox.Text    = activeRule.RuleName;

            //如果是静态网址,则不需要显示参数列表

            Dictionary <string, ParamState> paramDic = activeRule.ParamStates;
            foreach (string key in paramDic.Keys)
            {
                ParamState  state = paramDic[key];
                ParamCotrol ctr   = new ParamCotrol();
                ctr.ParaName = key;
                ctr.KeyValid = state.KeyState;
                ctr.Size     = new Size(140, 28);
                this._ParamPanel.Controls.Add(ctr);
            }

            //add on 2008年7月18日
            TextRuleControlEnable(true);

            ruleState = WebRuleState.New;

            this.urlTextBox.ReadOnly = true;
        }