예제 #1
0
        public RuleBuilder(Rule rule)
        {
            InitializeComponent();

            this.CurrentRule = rule;
            this.id = rule.ID;

            this.txt_Extensions.Text = String.Join(",", rule.Extensions);
            this.txt_Filters.Text = String.Join(",", rule.Filters);
            this.txt_ParentDirectory.Text = rule.ParentDirectory;
            this.txt_TargetDirectory.Text = rule.TargetDirectory;
            this.chk_IncludeSubdirectories.IsChecked = rule.SearchSubdirectories;

            switch (rule.Instruction) {
                case Rule.Operation.Copy:
                    this.rd_Copy.IsChecked = true;
                    break;
                case Rule.Operation.Move:
                    this.rd_Move.IsChecked = true;
                    break;
                case Rule.Operation.Delete:
                    this.rd_Delete.IsChecked = true;
                    break;
                default:
                    break;
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: nagyben/fclib
        static void TestSave()
        {
            string name = "Herp";
            int id = 1;
            string parentdir = "derpie";
            string targetdir = "herbie";
            List<string> extensions = new List<string>();
            extensions.Add(".mkv");

            List<string> filters = new List<string>();
            filters.Add("anyad");

            Console.WriteLine("Creating new Rule class instance");
            Rule rule1 = new Rule(id, parentdir, targetdir, extensions, filters, name);
            List<Rule> rulelist = new List<Rule>();
            rulelist.Add(rule1);

            Console.WriteLine(String.Format("Rule class created. Serializing to file {0} ...", filepath));

            UserData.SaveRules(rulelist, filepath);

            Console.ReadLine();
        }
예제 #3
0
        private void btn_OK_Click(object sender, RoutedEventArgs e)
        {
            try {
                this.CurrentRule = new Rule(this.id,
                                            this.txt_ParentDirectory.Text,
                                            this.txt_TargetDirectory.Text,
                                            this.txt_Extensions.Text.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries).ToList<string>(),
                                            this.txt_Filters.Text.Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries).ToList<string>(),
                                            GetOp(),
                                            (bool)this.chk_IncludeSubdirectories.IsChecked); // TODO: implement rule name box

                if (this.CurrentRule.IsValid()) {
                    this.DialogResult = true;
                    this.Close();
                } else {
                    MessageBox.Show("There are some errors in the rule parameters. Please check them again", "Rule error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }