public void SetupForm(PipeTest current, BindingList<Category> categoryTypes, IReadOnlyList<PipeTest> pipeTestList, IReadOnlyList<string> usedCodes)
 {
     this.pipeTestList = pipeTestList;
     this.usedCodes = usedCodes;
     viewModel = this.GetInspectionViewModel(current, categoryTypes);
     SetControlsTextLength();
     ChangeExpected();
     ChangeFrequency();
     if(current != null)
     {
         this.Text = current.Name;
     }
 }
        private MillInspectionViewModel GetInspectionViewModel(PipeTest current, BindingList<Category> categoryTypes)
        {
            if(viewModel == null)
            {
                viewModel = new MillInspectionViewModel(current, categoryTypes, pipeTestList);
            }
            else
            {
                viewModel.SetupViewModel(current, categoryTypes, pipeTestList);
            }

            return viewModel;
        }
        public void SetupViewModel(PipeTest current, BindingList<Category> CategoryTypes, IReadOnlyList<PipeTest> pipeTests) 
        {
            this.CategoryTypes = CategoryTypes;
            IList<PipeTest> list = pipeTests.Where(_ => _.IsActive && !String.IsNullOrEmpty( _.Code)).OrderBy(x => x.Code).ToList<PipeTest>();
            RepeatTestCandidates = new BindingList<Domain.Entity.Setup.PipeTest>(list);
            pipeTest = new PipeTest();

            if (current != null)
            {
                pipeTest.CustomShallowCopy(current);
                if (current.Id != Guid.Empty)
                {
                    PipeTest curr = RepeatTestCandidates.Where(s => s.Id == pipeTest.Id).SingleOrDefault();
                    RepeatTestCandidates.Remove(curr);
                }
            }
        }
        private MillInspectionXtraForm GetInspectionForm(PipeTest selectedTest,
                 BindingList<Prizm.Domain.Entity.Mill.Category> categoryTypes, List<string> usedCodes)
        {
            if (inspectionForm == null)
            {
                inspectionForm = new MillInspectionXtraForm(selectedTest, categoryTypes, viewModel.PipeTests, usedCodes);
            }
            else
            {
                inspectionForm.SetupForm(selectedTest, categoryTypes, viewModel.PipeTests, usedCodes);
            }

            return inspectionForm;
        }
 public MillInspectionXtraForm(PipeTest current, BindingList<Category> categoryTypes, IReadOnlyList<PipeTest> pipeTestList, IReadOnlyList<string> usedCodes)
 {
     InitializeComponent();
     this.SetupForm(current, categoryTypes, pipeTestList, usedCodes);
     percentOfSelect.Properties.MinValue = Constants.MinSelectivePercent;
 }
 public MillInspectionViewModel(PipeTest current, BindingList<Category> CategoryTypes, IReadOnlyList<PipeTest> pipeTests)
 {
     SetupViewModel(current, CategoryTypes, pipeTests);
 }