コード例 #1
0
        private void pnlActDesactInspector_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (lstVInspectors.SelectedIndex != -1)
            {
                Inspector inspSelected = (Inspector)lstVInspectors.SelectedValue;

                using (var db = new DataContext())
                {
                    inspSelected.Enable = !inspSelected.Enable;

                    db.PersistEntity(inspSelected);
                    db.SaveChanges();
                }

                if (inspSelected.Enable)
                {
                    inspSelected.ImageEnable = @"/Resources/play.png";

                    App.Single.AddWork(inspSelected);
                }
                else
                {
                    inspSelected.ImageEnable = @"/Resources/pausa.png";

                    App.Single.RemoveWork(inspSelected);
                }

                List<Inspector> lstInspectors = (List<Inspector>)lstVInspectors.ItemsSource;

                lstVInspectors.ItemsSource = null;
                lstVInspectors.ItemsSource = lstInspectors;
            }
            else
            {
                MessageBox.Show("Por favor, seleccione un inspector de la lista");
            }
        }
コード例 #2
0
        private void pnlNewInspector_MouseUp(object sender, MouseButtonEventArgs e)
        {
            if (!optionPressed)
                return;

            using (var db = new DataContext())
            {
                inspector.Name = txtName.Text;
                inspector.Path = txtPath.Text;

                if (rbtMoveSubDir.IsChecked.HasValue && rbtMoveSubDir.IsChecked.Value)
                {
                    inspector.Action = (int) Inspector.TypeActions.MoveSubDir;
                    inspector.SubDirAction = txtPathAction.Text;
                }
                else
                {
                    inspector.Action = (int)Inspector.TypeActions.DeleteFiles;
                    inspector.SubDirAction = String.Empty;
                }

                Boolean exist = true;

                if (inspector.InspectorId == 0)
                {
                    exist = false;
                }

                db.PersistEntity(inspector);
                db.SaveChanges();

                if (!exist)
                {
                    App.Single.AddWork(inspector);
                }
                else
                {
                    App.Single.UpdateWork(inspector);
                }
            }

            this.Close();
        }
コード例 #3
0
        private void pnlNewRule_MouseUp(object sender, MouseButtonEventArgs e)
        {
            NewRule newRule = new NewRule();
            newRule.ShowDialog();

            if (newRule.rule != null)
            {
                RuleFile rule = newRule.rule;

                using (var db = new DataContext())
                {
                    db.AttachEntity(inspector);
                    inspector.Rules.Add(rule);

                    Boolean exist = true;

                    if (inspector.InspectorId == 0)
                    {
                        inspector.Name = txtName.Text;
                        inspector.Path = txtPath.Text;

                        if (rbtMoveSubDir.IsChecked.HasValue && rbtMoveSubDir.IsChecked.Value)
                        {
                            inspector.Action = (int)Inspector.TypeActions.MoveSubDir;
                            inspector.SubDirAction = txtPathAction.Text;
                        }
                        else
                        {
                            inspector.Action = (int)Inspector.TypeActions.DeleteFiles;
                            inspector.SubDirAction = String.Empty;
                        }

                        db.PersistEntity(inspector);
                        exist = false;
                    }

                    db.SaveChanges();

                    if(!exist)
                    {
                        App.Single.AddWork(inspector);
                    }
                    else
                    {
                        App.Single.UpdateWork(inspector);
                    }
                }

                RulesRefresh(rule, true);
            }
        }
コード例 #4
0
        private void lstVRules_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lstVRules.SelectedIndex != -1)
            {
                RuleFile ruleSelected = (RuleFile)lstVRules.SelectedValue;

                NewRule ruleDetail = new NewRule(ruleSelected);
                ruleDetail.ShowDialog();

                ruleSelected = ruleDetail.rule;

                using (var db = new DataContext())
                {
                    db.PersistEntity(ruleSelected);
                    db.SaveChanges();
                }

                App.Single.UpdateWork(inspector);

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

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