Exemplo n.º 1
0
        public void RemoveAllExceptRunning()
        {
            List <Control> toBeRemoved = new List <Control>();

            // Remove all that are not running.
            foreach (Control ctrl in this.layoutPanel.Controls)
            {
                if (!(ctrl is BackupPlanViewControl))
                {
                    continue;
                }

                BackupPlanViewControl obj = ctrl as BackupPlanViewControl;
                if (!obj.OperationIsRunning)
                {
                    toBeRemoved.Add(ctrl);
                }
            }

            // Remove them.
            foreach (Control ctrl in toBeRemoved)
            {
                this.layoutPanel.Controls.Remove(ctrl);
            }
        }
Exemplo n.º 2
0
        public bool ControlsAlreadyContainControlForPlan(Models.BackupPlan plan)
        {
            foreach (Control ctrl in this.layoutPanel.Controls)
            {
                if (!(ctrl is BackupPlanViewControl))
                {
                    continue;
                }

                BackupPlanViewControl obj     = ctrl as BackupPlanViewControl;
                Models.BackupPlan     objPlan = obj.Model as Models.BackupPlan;

                if (objPlan.Id.Equals(plan.Id))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        public void LoadPlans()
        {
            RemoveAllExceptRunning();

            var plans = dao.GetAllActive();

            foreach (var plan in plans)
            {
                if (ControlsAlreadyContainControlForPlan(plan))
                {
                    continue;
                }

                BackupPlanViewControl viewControl = new BackupPlanViewControl();
                viewControl.Model    = plan;
                viewControl.Deleted += (object sender, EventArgs e) =>
                {
                    BackupPlanViewControl control = sender as BackupPlanViewControl;
                    layoutPanel.Controls.Remove(control);
                };
                this.layoutPanel.Controls.Add(viewControl);
            }
        }