public MethodManager() { InitializeComponent(); wgDB = new WaveguideDB(); VM = new MethodManagerViewModel(); RefreshSignalTypeList(); RefreshFilterList(); //Initialize data in the XamDataGrid - NOTE: A blank record is added FIRST, this is key to this approach for the XamDataGrid MethodItem blank = new MethodItem(); blank.Description = ""; blank.BravoMethodFile = ""; blank.OwnerID = GlobalVars.UserID; blank.MethodID = 0; blank.IsPublic = false; VM.Methods.Add(blank); // load all methods for user bool success = wgDB.GetAllMethodsForUser(GlobalVars.UserID); if (success) { foreach (MethodContainer mc in wgDB.m_methodList) { MethodItem mi = new MethodItem(); mi.Description = mc.Description; mi.BravoMethodFile = mc.BravoMethodFile; mi.OwnerID = mc.OwnerID; mi.MethodID = mc.MethodID; mi.IsPublic = mc.IsPublic; VM.Methods.Add(mi); // load all indicators for the method // add blank Indicator container to hold the AddRecord ObservableCollection <FilterContainer> exFilts = VM.ExcitationFilters; ObservableCollection <FilterContainer> emFilts = VM.EmissionsFilters; ObservableCollection <SignalTypeContainer> stList = VM.SignalTypeList; IndicatorItem blankInd = new IndicatorItem(0, mi.MethodID, "", ref stList, ref exFilts, ref emFilts); mi.Indicators.Add(blankInd); success = wgDB.GetAllIndicatorsForMethod(mc.MethodID); if (success) { foreach (IndicatorContainer ic in wgDB.m_indicatorList) { IndicatorItem ii = new IndicatorItem(ic.IndicatorID, ic.MethodID, ic.Description, ic.ExcitationFilterPosition, ic.EmissionsFilterPosition, ic.SignalType, ref stList, ref exFilts, ref emFilts); mi.Indicators.Add(ii); } } // load all compound plates for the method // add blank Compound Plate container to hold the AddRecord CompoundPlateItem blankCP = new CompoundPlateItem(); blankCP.CompoundPlateID = 0; blankCP.MethodID = mi.MethodID; blankCP.Description = ""; mi.CompoundPlates.Add(blankCP); success = wgDB.GetAllCompoundPlatesForMethod(mc.MethodID); if (success) { foreach (CompoundPlateContainer cpc in wgDB.m_compoundPlateList) { CompoundPlateItem cpi = new CompoundPlateItem(); cpi.CompoundPlateID = cpc.CompoundPlateID; cpi.MethodID = cpc.MethodID; cpi.Description = cpc.Description; mi.CompoundPlates.Add(cpi); } } } } xamDataGrid.DataContext = VM; }
private void MethodComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (VM.ExpParams.compoundPlateList != null) { VM.ExpParams.compoundPlateList.Clear(); } if (VM.ExpParams.indicatorList != null) { VM.ExpParams.indicatorList.Clear(); } // get selection VM.ExpParams.method = (MethodContainer)MethodComboBox.SelectedItem; if (VM.ExpParams.method != null) { // get all the compound plates for the Method bool success = wgDB.GetAllCompoundPlatesForMethod(VM.ExpParams.method.MethodID); if (success) { if (VM.ExpParams.compoundPlateList != null) { VM.ExpParams.compoundPlateList.Clear(); } else { VM.ExpParams.compoundPlateList = new ObservableCollection <ExperimentCompoundPlateContainer>(); } foreach (CompoundPlateContainer cpdPlate in wgDB.m_compoundPlateList) { ExperimentCompoundPlateContainer expCpdPlate = new ExperimentCompoundPlateContainer(); expCpdPlate.Barcode = ""; expCpdPlate.Description = cpdPlate.Description; expCpdPlate.ExperimentCompoundPlateID = 0; expCpdPlate.ExperimentID = 0; expCpdPlate.PlateIDResetBehavior = cpdPlate.BarcodeReset; VM.ExpParams.compoundPlateList.Add(expCpdPlate); } // get all the indicators for the Method success = wgDB.GetAllIndicatorsForMethod(VM.ExpParams.method.MethodID); if (success) { if (VM.ExpParams.indicatorList != null) { VM.ExpParams.indicatorList.Clear(); } else { VM.ExpParams.indicatorList = new ObservableCollection <ExperimentIndicatorContainer>(); } int i = 0; foreach (IndicatorContainer indicator in wgDB.m_indicatorList) { ExperimentIndicatorContainer expIndicator = new ExperimentIndicatorContainer(); expIndicator.Description = indicator.Description; expIndicator.EmissionFilterPos = indicator.EmissionsFilterPosition; expIndicator.ExcitationFilterPos = indicator.ExcitationFilterPosition; expIndicator.ExperimentID = 0; // defined when experiment launched expIndicator.ExperimentIndicatorID = i; // defined when experiment launched expIndicator.Exposure = 1; // default expIndicator.Gain = 1; // default expIndicator.PreAmpGain = 1; // default expIndicator.MaskID = 0; // not defined at this point. Assigned when Mask is selected. expIndicator.Verified = false; expIndicator.FlatFieldRefImageID = 0; // defined at Indicator Verify expIndicator.DarkFieldRefImageID = 0; // defined at Indicator Verify expIndicator.FlatFieldCorrection = FLATFIELD_SELECT.NONE; // default expIndicator.CycleTime = GlobalVars.Instance.CameraDefaultCycleTime; expIndicator.SignalType = indicator.SignalType; FilterContainer filter; success = wgDB.GetExcitationFilterAtPosition(indicator.ExcitationFilterPosition, out filter); if (success) { if (filter != null) { expIndicator.ExcitationFilterDesc = filter.Description; } } success = wgDB.GetEmissionFilterAtPosition(indicator.EmissionsFilterPosition, out filter); if (success) { if (filter != null) { expIndicator.EmissionFilterDesc = filter.Description; } } VM.ExpParams.indicatorList.Add(expIndicator); i++; // increment dummy ExperimentIndicatorID } } } } VM.SetExperimentStatus(); if (m_imager.m_ImagingDictionary == null) { m_imager.m_ImagingDictionary = new Dictionary <int, ImagingParamsStruct>(); } else { m_imager.m_ImagingDictionary.Clear(); } foreach (ExperimentIndicatorContainer eic in VM.ExpParams.indicatorList) { ImagingParamsStruct ips = new ImagingParamsStruct(); ips.emissionFilterPos = (byte)eic.EmissionFilterPos; ips.excitationFilterPos = (byte)eic.ExcitationFilterPos; ips.experimentIndicatorID = eic.ExperimentIndicatorID; ips.flatfieldType = eic.FlatFieldCorrection; ips.indicatorName = eic.Description; ips.binning = m_imager.m_camera.m_acqParams.HBin; m_imager.m_ImagingDictionary.Add(eic.ExperimentIndicatorID, ips); } }