public void SetRule(RuleFile rule)
        {
            this.rule = rule;

            dateFirst.SelectedDate = this.rule.DateFirst;
            dateLast.SelectedDate = this.rule.DateLast;
        }
        public RuleFile GetRule()
        {
            if (rule == null)
                rule = new RuleFile();

            rule.NamePattern = txtNombre.Text;

            return rule;
        }
        public RuleFile GetRule()
        {
            if (rule == null)
                rule = new RuleFile();

            rule.ExtensionPattern = txtExtension.Text;

            return rule;
        }
        public RuleFile GetRule()
        {
            if (rule == null)
                rule = new RuleFile();

            rule.DateFirst = dateFirst.SelectedDate.Value;
            rule.DateLast = dateLast.SelectedDate.Value;

            return rule;
        }
        public NewRule(RuleFile rule)
        {
            InitializeComponent();
            Rule = rule;

            rbtDate.IsEnabled = false;
            rbtExtension.IsEnabled = false;
            rbtName.IsEnabled = false;

            Owner = App.ActualInspectorDetail;
        }
Exemple #6
0
        public static RuleFile GetFileRule(RuleFile.TypeFileRule type)
        {
            RuleFile res = null;

            switch(type)
            {
                case RuleFile.TypeFileRule.Date:
                    res = new RuleFileDate();
                    break;
                case RuleFile.TypeFileRule.Extension:
                    res = new RuleFileExtension();
                    break;
                case RuleFile.TypeFileRule.FileName:
                    res = new RuleFileName();
                    break;
            }

            if(res != null)
            {
                res.RuleType = (int) type;
            }

            return res;
        }
        public void SetRule(RuleFile rule)
        {
            this.rule = (RuleFile)rule;

            txtNombre.Text = this.rule.NamePattern;
        }
        public static RuleFile GetFileRule(RuleFile.TypeFileRule type)
        {
            var res = new RuleFile {RuleType = (int) type};

            return res;
        }
        private void SaveRule()
        {
            Boolean typeChoose = false;
            var ruleAux = new RuleFile();

            if (rbtDate.IsChecked.HasValue && rbtDate.IsChecked.Value)
            {

                ruleAux.RuleType = (int)RuleFile.TypeFileRule.Date;
                ruleAux.ImagePath = @"/images/icon_ruleFileDate.png";

                typeChoose = true;
            }
            else if (rbtExtension.IsChecked.HasValue && rbtExtension.IsChecked.Value)
            {
                ruleAux.RuleType = (int)RuleFile.TypeFileRule.Extension;
                ruleAux.ImagePath = @"/images/icon_ruleFileExtension.png";

                typeChoose = true;
            }
            else if (rbtName.IsChecked.HasValue && rbtName.IsChecked.Value)
            {
                ruleAux.RuleType = (int)RuleFile.TypeFileRule.FileName;
                ruleAux.ImagePath = @"/images/icon_ruleFileName.png";

                typeChoose = true;
            }

            if (!typeChoose)
            {
                MessageBox.Show("Necesita especificar el tipo de la regla");
                return;
            }

            var rControl = (RuleControl) pnlExtensionControl.Children[0];
            Rule = rControl.GetRule();

            Rule.RuleType = ruleAux.RuleType;
            Rule.ImagePath = ruleAux.ImagePath;
            Rule.RuleName = txtName.Text;

            if (string.IsNullOrWhiteSpace(Rule.NamePattern) && string.IsNullOrWhiteSpace(Rule.ExtensionPattern)
                && (!Rule.DateFirst.HasValue && !Rule.DateLast.HasValue))
            {
                MessageBox.Show("El detalle de la regla es obligatorio.");
                return;
            }

            _isSaved = true;

            Close();
        }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (!_isSaved)
     {
         Rule = null;
     }
 }
Exemple #11
0
        private void SaveRule()
        {
            Boolean typeChoose = false;
            RuleFile ruleAux = null;

            if (rbtDate.IsChecked.HasValue && rbtDate.IsChecked.Value)
            {
                ruleAux = new RuleFileDate();
                ruleAux.RuleType = (int)RuleFile.TypeFileRule.Date;
                ruleAux.ImagePath = @"/images/icon_ruleFileDate.png";

                typeChoose = true;
            }
            else if (rbtExtension.IsChecked.HasValue && rbtExtension.IsChecked.Value)
            {
                ruleAux = new RuleFileExtension();
                ruleAux.RuleType = (int)RuleFile.TypeFileRule.Extension;
                ruleAux.ImagePath = @"/images/icon_ruleFileExtension.png";

                typeChoose = true;
            }
            else if (rbtName.IsChecked.HasValue && rbtName.IsChecked.Value)
            {
                ruleAux = new RuleFileName();
                ruleAux.RuleType = (int)RuleFile.TypeFileRule.FileName;
                ruleAux.ImagePath = @"/images/icon_ruleFileName.png";

                typeChoose = true;
            }

            if (!typeChoose)
            {
                MessageBox.Show("Necesita especificar el tipo de la regla");
                return;
            }

            RuleControl rControl = (RuleControl) pnlExtensionControl.Children[0];
            rule = rControl.GetRule();

            rule.RuleType = ruleAux.RuleType;
            rule.ImagePath = ruleAux.ImagePath;
            rule.Name = txtName.Text;

            this.Close();
        }
        public void SetRule(RuleFile rule)
        {
            this.rule = rule;

            txtExtension.Text = this.rule.ExtensionPattern;
        }
 private void SetImageRule(RuleFile rule)
 {
     if (rule.RuleType != null)
         switch ((RuleFile.TypeFileRule)rule.RuleType)
         {
             case RuleFile.TypeFileRule.Date:
                 rule.ImagePath = @"/images/icon_ruleFileDate.png";
                 break;
             case RuleFile.TypeFileRule.Extension:
                 rule.ImagePath = @"/images/icon_ruleFileExtension.png";
                 break;
             case RuleFile.TypeFileRule.FileName:
                 rule.ImagePath = @"/images/icon_ruleFileName.png";
                 break;
         }
 }
        private void RulesRefresh(RuleFile rule_, Boolean added = false)
        {
            List<RuleFile> lstRules;

            if (rule_ == null)
            {
                Inspector.Rules.Value.ToList().ForEach(SetImageRule);
                lstRules = Inspector.Rules.Value.ToList();
            }
            else
            {

                lstRules = (List<RuleFile>)lstVRules.ItemsSource ?? new List<RuleFile>();

                if (added)
                {
                    lstRules.Add(rule_);
                }
                else
                    lstRules.Remove(rule_);
            }

            lstVRules.ItemsSource = null;
            lstVRules.ItemsSource = lstRules;
        }
        private void RulesRefresh(RuleFile rule_, Boolean added = false)
        {
            List<RuleFile> lstRules = new List<RuleFile>();

            if (rule_ == null)
            {
                using (var db = new DataContext())
                {
                    db.AttachEntity(inspector);

                    inspector.Rules.ToList().ForEach(rule => SetImageRule(rule));
                    lstRules = inspector.Rules.ToList();
                }
            }
            else
            {

                lstRules = (List<RuleFile>)lstVRules.ItemsSource;

                if (added)
                {
                    lstRules.Add(rule_);
                }
                else
                    lstRules.Remove(rule_);
            }

            lstVRules.ItemsSource = null;
            lstVRules.ItemsSource = lstRules;
        }