示例#1
0
        private void DeleteRuleBtn_Click(object sender, EventArgs e)
        {
            this.urlTextBox.Enabled = false;

            this.DeleteRuleBtn.Enabled   = false;
            this.ModifiedRuleBtn.Enabled = false;
            this.SaveRuleBtn.Enabled     = true;

            //add on 2008年7月18日
            TextRuleControlEnable(false);
            ruleState = WebRuleState.Delete;
        }
示例#2
0
        private void SwitchOperState()
        {
            if (ruleState != WebRuleState.None)
            {
                if (MessageBox.Show("是否要保存规则!", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    SaveRule();
                    activeRule = null;
                }
                else
                {
                    activeRule = null;
                    ruleState  = WebRuleState.None;

                    BtnDefaultState();
                    ClearControl();
                }
            }
        }
示例#3
0
        private void SaveRule()
        {
            BtnDefaultState();

            //如果是删除保存,则显示第一条
            switch (ruleState)
            {
            case WebRuleState.None:
                break;

            case WebRuleState.New:
                //保存所作修改
                GetModifiedRule(activeRule);

                //添加webRule到集合里
                activeRules.Add(activeRule);
                ruleState = WebRuleState.None;

                //规则列表重新显示
                ShowRuleList(activeRules, activeRule.RuleName);

                //清空
                this.ruleNameTextBox.Text = "";
                this.urlTextBox.Text      = "";

                break;

            case WebRuleState.Modify:
                if (activeRule.RuleState != WebRuleState.New)
                {
                    activeRule.RuleState = WebRuleState.Modify;
                }

                //保存所作修改
                GetModifiedRule(activeRule);

                ruleState = WebRuleState.None;

                _ParamPanel.Enabled = false;
                break;

            case WebRuleState.Delete:
                if (activeRule.RuleState == WebRuleState.New)
                {
                    //直接删除此条记录
                    activeRules.Remove(activeRule);
                }
                else
                {
                    activeRule.RuleState = WebRuleState.Delete;
                }

                ruleState = WebRuleState.None;
                //规则列表重新显示
                ShowRuleList(activeRules, "");
                break;

            default:
                break;
            }
        }
示例#4
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;
        }