示例#1
0
        void addClick(object sender, EventArgs e)
        {
            using (InputBox box = new InputBox()) {
                box.Label.Text = ResourceService.GetString("Dialog.HighlightingEditor.RuleSets.EnterName");
                if (box.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }

                if (box.TextBox.Text == "")
                {
                    return;
                }
                foreach (ListViewItem item in listView.Items)
                {
                    if (item.Text == box.TextBox.Text)
                    {
                        return;
                    }
                }

                RuleSetNode  rsn = new RuleSetNode(box.TextBox.Text, "&<>~!@%^*()-+=|\\#/{}[]:;\"' ,	.?", "", false, false);
                ListViewItem lv  = new ListViewItem(box.TextBox.Text);
                lv.Tag = rsn;
                parentNode.Nodes.Add(rsn);
                listView.Items.Add(lv);
            }
        }
示例#2
0
        public void RuleSetHasRuleNameAsNodeName()
        {
            ValidationRulesetData ruleData    = new ValidationRulesetData("Rule");
            RuleSetNode           ruleSetNode = new RuleSetNode(ruleData);

            Assert.AreEqual("Rule", ruleSetNode.Name);
        }
示例#3
0
        public void AddRuleSetCommandAddsRuleNode()
        {
            AddRuleSetNodeCommand cmd = new AddRuleSetNodeCommand(ServiceProvider);

            cmd.Execute(ApplicationNode);

            RuleSetNode ruleNode = (RuleSetNode)Hierarchy.FindNodeByType(typeof(RuleSetNode));

            Assert.IsNotNull(ruleNode);
        }
        public RuleSetOptionPanel(RuleSetNode parent) : base(parent)
        {
            SetupFromXmlFile(System.IO.Path.Combine(PropertyService.DataDirectory,
                                                    @"resources\panels\HighlightingEditor\RuleSet.xfrm"));

            nameBox  = (TextBox)ControlDictionary["nameBox"];
            refBox   = (TextBox)ControlDictionary["refBox"];
            delimBox = (TextBox)ControlDictionary["delimBox"];

            igcaseBox = (CheckBox)ControlDictionary["igcaseBox"];
            noEscBox  = (CheckBox)ControlDictionary["noEscBox"];
        }
        public override void StoreSettings()
        {
            RuleSetNode node = (RuleSetNode)parentNode;

            if (!node.IsRoot)
            {
                node.Name = nameBox.Text;
            }
            node.Reference         = refBox.Text;
            node.Delimiters        = delimBox.Text;
            node.NoEscapeSequences = noEscBox.Checked;
            node.IgnoreCase        = igcaseBox.Checked;
        }
        private List <RuleSetNode> GetDistinctRuleSetNode(List <RuleSetNode> currentRuleSetList)
        {
            //Filter ruleset list to identify duplication
            var distinctRuleSetNodeList = new List <RuleSetNode>();

            foreach (var ruleSet in currentRuleSetList)
            {
                if (distinctRuleSetNodeList.Any(c => c.RuleSetId == ruleSet.RuleSetId))
                {
                    continue;
                }

                var selectedList = currentRuleSetList.Where(x => x.RuleSetId == ruleSet.RuleSetId).ToList();

                if (selectedList.Count > 1)
                {
                    var globalRuleSet = selectedList.Where(c => c.IsGlobal == true).FirstOrDefault();
                    if (globalRuleSet != null)
                    {
                        var generatedRS = new RuleSetNode
                        {
                            TextTemplates        = new List <TextTemplateNode>(),
                            RuleSetId            = globalRuleSet.RuleSetId,
                            ExcludedOrgUnitNames = globalRuleSet.ExcludedOrgUnitNames,
                            Name               = globalRuleSet.Name,
                            IsGlobal           = globalRuleSet.IsGlobal,
                            DaysCountBeforeApt = globalRuleSet.DaysCountBeforeApt
                        };

                        generatedRS.TextTemplates.AddRange(globalRuleSet.TextTemplates);

                        foreach (var rule in selectedList)
                        {
                            if (!rule.IsGlobal)
                            {
                                generatedRS.TextTemplates.AddRange(rule.TextTemplates);
                            }
                        }
                        distinctRuleSetNodeList.Add(generatedRS);
                    }
                }
                else
                {
                    distinctRuleSetNodeList.Add(ruleSet);
                }
            }
            return(distinctRuleSetNodeList);
        }
        public override void LoadSettings()
        {
            RuleSetNode node = (RuleSetNode)parentNode;

            nameBox.Text = node.Name;

            if (node.IsRoot)
            {
                nameBox.Text    = ResourceService.GetString("Dialog.HighlightingEditor.TreeView.RootRuleSet");
                nameBox.Enabled = false;
            }

            refBox.Text   = node.Reference;
            delimBox.Text = node.Delimiters;

            noEscBox.Checked  = node.NoEscapeSequences;
            igcaseBox.Checked = node.IgnoreCase;
        }
示例#8
0
        public void RuleSetHasProperDefaultName()
        {
            RuleSetNode ruleSetNode = new RuleSetNode();

            Assert.AreEqual("Rule Set", ruleSetNode.Name);
        }