public ValidatorCoreLib.ValidationRule GetValidationRule()
        {
            string resolveMsg = @"";

            if (ResolveCheck.IsChecked != true)
            {
                resolveMsg = ResolveMsg.Text;
            }

            ValidatorCoreLib.ValidationRule vr = new ValidatorCoreLib.ValidationRule(RuleName.Text, new PropertySelection(ProperyName.Text, ProperyPath.Text), getTypeFromCombo(),
                                                                                     getOperatorFromCombo(), ResolveCheck.IsChecked == true, resolveMsg);

            foreach (Object resolveItem in ResolveValues.Items)
            {
                Object realResolveItem = resolveItem;
                while (realResolveItem.GetType().Equals(typeof(ComboBoxItem)))
                {
                    realResolveItem = ((Object)(((ComboBoxItem)realResolveItem).Content));
                }

                if (realResolveItem.GetType().Equals(typeof(ResolveObjectRow)))
                {
                    vr.validationResolve.ResolveObjects.Add(((ResolveObjectRow)realResolveItem).ResolveValue.Text);
                }
            }

            vr.validationResolve.ResolveObjectSelected = ResolveValues.SelectedIndex;

            return(vr);
        }
Exemple #2
0
        private void AddRule_Click(object sender, RoutedEventArgs e)
        {
            WrapPanel wp             = new WrapPanel();
            bool      WrapPanelFound = false;

            foreach (Object ob in tvItem.Items)
            {
                if (ob.GetType().Equals(typeof(WrapPanel)))   // RuleRow
                {
                    wp             = (WrapPanel)ob;
                    WrapPanelFound = true;
                    break;
                }
            }

            if (!WrapPanelFound)
            {
                tvItem.Items.Add(wp);
            }

            ValidatorCoreLib.ValidationRule rule = new ValidatorCoreLib.ValidationRule(@"New Rule", new PropertySelection("", ""), @"", new EqualOperator(), true, @"");
            RuleRow rr = new RuleRow(rule, wp);

            wp.Children.Add(rr);
            return; // done here!
        }
        public RuleRow(ValidatorCoreLib.ValidationRule rule, WrapPanel ParentWrapPanel)
        {
            InitializeComponent();
            SetComboValues();

            RuleName.Text    = rule.RuleName;
            ProperyName.Text = rule.Property.ContextKey;
            ProperyPath.Text = rule.Property.ReferenceMeaning;

            setOperatorComboValue(rule.Operator);

            setTypeComboValue(rule.ComparedObject);

            ResolveCheck.IsChecked = rule.validationResolve.AutoResolve;
            if (!rule.validationResolve.AutoResolve)
            {
                ResolveMsg.Text = rule.validationResolve.ResolveStringForUI;
            }

            ResolveMsg.IsEnabled = ResolveCheck.IsChecked != true;

            ResolveValues.Items.Clear();
            foreach (string sResolve in rule.validationResolve.ResolveObjects)
            {
                ResolveObjectRow ror = new ResolveObjectRow(this, sResolve);
                ComboBoxItem     cbi = new ComboBoxItem();
                cbi.Content = ror;
                ResolveValues.Items.Add(cbi);
            }


            ResolveObjectRow_AddNew rorNew = new ResolveObjectRow_AddNew(this);
            ComboBoxItem            cbiNew = new ComboBoxItem();

            cbiNew.Content = rorNew;
            ResolveValues.Items.Add(cbiNew);

            if (rule.validationResolve.ResolveObjectSelected >= 0 && rule.validationResolve.ResolveObjectSelected < ResolveValues.Items.Count)
            {
                ResolveValues.SelectedIndex = rule.validationResolve.ResolveObjectSelected;
            }
            else
            {
                ResolveValues.SelectedIndex = ResolveValues.Items.Count - 1;
            }

            this.ParentWrapPanel = ParentWrapPanel;
        }
Exemple #4
0
 public void Add(ValidationRule rule)
 {
     rules.Add(rule);
 }