示例#1
0
        public void SetRule(RuleFile rule)
        {
            this.rule = (RuleFileDate) rule;

            dateFirst.SelectedDate = this.rule.DateFirst;
            dateLast.SelectedDate = this.rule.DateLast;
        }
示例#2
0
        public RuleFile GetRule()
        {
            if (rule == null)
                rule = new RuleFileDate();

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

            return rule;
        }
示例#3
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;
        }
示例#4
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();
        }