示例#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 RestorePlanViewControl))
                {
                    continue;
                }

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

            // Remove them.
            foreach (Control ctrl in toBeRemoved)
            {
                this.layoutPanel.Controls.Remove(ctrl);
            }
        }
示例#2
0
        public bool ControlsAlreadyContainControlForPlan(Models.RestorePlan plan)
        {
            foreach (Control ctrl in this.layoutPanel.Controls)
            {
                if (!(ctrl is RestorePlanViewControl))
                {
                    continue;
                }

                RestorePlanViewControl obj     = ctrl as RestorePlanViewControl;
                Models.RestorePlan     objPlan = obj.Model as Models.RestorePlan;

                if (objPlan.Id.Equals(plan.Id))
                {
                    return(true);
                }
            }
            return(false);
        }
示例#3
0
        public void LoadPlans()
        {
            RemoveAllExceptRunning();

            var plans = dao.GetAllActive();

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

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