Exemplo n.º 1
0
        protected override void Initialize(object navigationData)
        {
            base.Initialize(navigationData);
            // TODO: pictureBox1.Image
            var info = (Tuple <OutboundFeature, OutboundRule>)navigationData;

            _feature = info.Item1;
            Rule     = info.Item2;
            if (Rule != null)
            {
                foreach (var preCondition in _feature.PreConditions)
                {
                    cbPreCondition.Items.Add(preCondition.Name);
                }

                foreach (var customTags in _feature.Tags)
                {
                    cbTags.Items.Add(customTags.Name);
                }

                // TODO: invoke RuleSettingsUpdate somewhere.
                Rule.RuleSettingsUpdated = Refresh;
            }

            cbPreCondition.Items.Add("<None>");
            cbPreCondition.Items.Add("<Create New Precondition...>");
            cbTags.Items.Add("<Create New Tags Collection...>");

            if (Rule == null)
            {
                Rule = new OutboundRule(null);
            }

            Refresh();
        }
Exemplo n.º 2
0
        protected override bool ApplyChanges()
        {
            var filter = GetFilter(cbMatch);

            if (Rule == null)
            {
                Rule = new OutboundRule(null);
            }

            Rule.Name             = txtName.Text;
            Rule.PreCondition     = cbPreCondition.Text == "<None>" ? string.Empty : cbPreCondition.Text;
            Rule.CustomTags       = cbTags.Text;
            Rule.Enabled          = true;
            Rule.Syntax           = cbUsing.SelectedIndex;
            Rule.Stopping         = cbStop.Checked;
            Rule.Filter           = filter;
            Rule.ServerVariable   = txtVariable.Text;
            Rule.Pattern          = txtPattern.Text;
            Rule.Negate           = cbContent.SelectedIndex == 1;
            Rule.IgnoreCase       = cbIgnoreCase.Checked;
            Rule.TrackAllCaptures = cbTrack.Checked;
            Rule.LogicalGrouping  = cbAny.SelectedIndex;
            Rule.Action           = cbAction.SelectedIndex;
            Rule.Value            = txtValue.Text;
            Rule.Replace          = !string.IsNullOrWhiteSpace(txtValue.Text);

            if (txtName.ReadOnly)
            {
                _feature.EditItem(Rule);
            }
            else
            {
                txtName.ReadOnly = true;
                _feature.AddItem(Rule);
            }

            if (!Rule.ApplyChanges())
            {
                return(false);
            }

            ClearChanges();
            return(true);
        }