private void OkPB_Click(object sender, RoutedEventArgs e) { MaskContainer mc = new MaskContainer(); mc.MaskID = m_mask.Mask.MaskID; mc.Angle = m_mask.Mask.Angle; mc.Cols = m_mask.Mask.Cols; mc.Description = m_mask.Mask.Description; mc.IsDefault = m_mask.Mask.IsDefault; mc.PlateTypeID = m_mask.Mask.PlateTypeID; mc.ReferenceImageID = m_mask.Mask.ReferenceImageID; mc.Rows = m_mask.Mask.Rows; mc.Shape = m_mask.Mask.Shape; mc.XOffset = m_mask.Mask.XOffset; mc.XSize = m_mask.Mask.XSize; mc.XStep = m_mask.Mask.XStep; mc.YOffset = m_mask.Mask.YOffset; mc.YSize = m_mask.Mask.YSize; mc.YStep = m_mask.Mask.YStep; if (wgDB == null) { wgDB = new WaveguideDB(); } bool success = wgDB.UpdateMask(mc); if (!success) { MessageBox.Show(wgDB.GetLastErrorMsg(), "Database Error: Failed to Update Mask", MessageBoxButton.OK, MessageBoxImage.Error); } Close(); }
private void xamDataGrid_EditModeEnded(object sender, Infragistics.Windows.DataPresenter.Events.EditModeEndedEventArgs e) { // use this method to update a record after one of the cells of the record has been edited if (((string)e.Cell.Record.Tag) == "AddRecord") { return; // not updating the AddRecord here } if (e.Cell.Record.DataItem.GetType() == typeof(PlateTypeItem)) { PlateTypeItem pti = (PlateTypeItem)e.Cell.Record.DataItem; if (pti.PlateType.PlateTypeID != 0) { bool success = wgDB.UpdatePlateType(pti.PlateType); } } else if (e.Cell.Record.DataItem.GetType() == typeof(MaskContainer)) { MaskContainer mc = (MaskContainer)e.Cell.Record.DataItem; if (mc.MaskID != 0) { bool succcess = wgDB.UpdateMask(mc); } } }
public void SetupMaskFromContainer(MaskContainer cont) { _mask.MaskID = cont.MaskID; _mask.Rows = cont.Rows; _mask.Cols = cont.Cols; _mask.XOffset = cont.XOffset; _mask.YOffset = cont.YOffset; _mask.XSize = cont.XSize; _mask.YSize = cont.YSize; _mask.XStep = cont.XStep; _mask.YStep = cont.YStep; _mask.Angle = cont.Angle; _mask.Shape = cont.Shape; _mask.Description = cont.Description; _mask.PlateTypeID = cont.PlateTypeID; _mask.ReferenceImageID = cont.ReferenceImageID; _mask.IsDefault = cont.IsDefault; WaveguideDB wgDB = new WaveguideDB(); PlateTypeContainer ptc; bool success = wgDB.GetPlateType(Mask.PlateTypeID, out ptc); if (success) { PlateType = ptc; } else { PlateType = null; } }
private void xamDataGrid_RecordsDeleting(object sender, Infragistics.Windows.DataPresenter.Events.RecordsDeletingEventArgs e) { bool success; foreach (DataRecord record in e.Records) { if (record.DataItem.GetType() == typeof(PlateTypeItem)) { PlateTypeItem pti = (PlateTypeItem)record.DataItem; foreach (MaskContainer mc in pti.MaskList) { success = wgDB.DeleteMask(mc.MaskID); if (!success) { break; } } success = wgDB.DeletePlateType(pti.PlateType.PlateTypeID); if (!success) { break; } } else if (record.DataItem.GetType() == typeof(MaskContainer)) { MaskContainer mc = (MaskContainer)record.DataItem; success = wgDB.DeleteMask(mc.MaskID); if (!success) { break; } } } }
public void Configure(ImagingParameters iParams, ProjectContainer project, PlateContainer plate, ExperimentContainer experiment, MethodContainer method, MaskContainer mask, PlateTypeContainer plateType, ObservableCollection <ExperimentIndicatorContainer> indicatorList, ObservableCollection <ExperimentCompoundPlateContainer> compoundPlateList, ObservableCollection <Tuple <int, int> > controlSubtractionWellList, int numFoFrames, ExperimentIndicatorContainer dynamicRatioNumerator, ExperimentIndicatorContainer dynamicRatioDenominator) { m_iParams = iParams; m_project = project; m_experimentPlate = plate; m_experiment = experiment; m_method = method; m_mask = mask; m_plateType = plateType; m_indicatorList = indicatorList; m_compoundPlateList = compoundPlateList; m_controlSubtractionWellList = controlSubtractionWellList; m_numFoFrames = numFoFrames; m_dynamicRatioNumerator = dynamicRatioNumerator; m_dynamicRatioDenominator = dynamicRatioDenominator; m_vworksProtocolFilename = m_method.BravoMethodFile; ChartArray.BuildChartArray(mask.Rows, mask.Cols, m_iParams.HorzBinning, m_iParams.VertBinning, m_indicatorList); Dictionary <int, ImageDisplay> idDictionary = ChartArray.GetImageDisplayDictionary(); m_displayPipeline = m_imager.CreateDisplayPipeline(m_uiTask, idDictionary); m_storagePipeline = m_imager.CreateImageStoragePipeline(GlobalVars.CompressionAlgorithm, m_iParams.imageWidth, m_iParams.imageHeight); int numerID = 0; int denomID = 0; if (m_dynamicRatioNumerator != null) { numerID = m_dynamicRatioNumerator.ExperimentIndicatorID; } if (m_dynamicRatioDenominator != null) { denomID = m_dynamicRatioDenominator.ExperimentIndicatorID; } m_analysisPipeline = m_imager.CreateAnalysisPipeline(ChartArray, m_mask, m_iParams.imageWidth, m_iParams.imageHeight, m_iParams.HorzBinning, m_iParams.VertBinning, m_iParams.ExperimentIndicatorID, m_controlSubtractionWellList, m_numFoFrames, numerID, denomID); if (m_histogram != null) { m_histogramPipeline = m_imager.CreateHistogramPipeline(m_uiTask, m_histogram); } }
public Histogram(int numBuckets = 1024) { m_numBuckets = numBuckets; m_histogramHeight = 256; m_histogramBitmap = BitmapFactory.New(m_numBuckets, m_histogramHeight); m_histogramBucket = new int[m_numBuckets]; m_maxBucketCount = 0; // maximum value in a bucket, across all buckets m_bucketWidth = (GlobalVars.MaxPixelValue + 1) / m_numBuckets; m_mask = null; }
private static void CreateMask(MaskContainer maskContainer, Dictionary <IntVector2, PieceInfo> pieceInfos, int row, int column, Color[] maskPixels) { var pieceInfo = pieceInfos[new IntVector2(column, row)]; var left = maskContainer.GetTextureAsArray(pieceInfo.edgeLeft); var top = maskContainer.GetTextureAsArray(pieceInfo.edgeTop); var right = maskContainer.GetTextureAsArray(pieceInfo.edgeRight); var bottom = maskContainer.GetTextureAsArray(pieceInfo.edgeBottom); MaskCreator.CreateMask(left, top, right, bottom, maskPixels); }
void EditMask(MaskContainer mask) { //MessageBox.Show("not yet implemented","Edit Mask: " + mask.Description, MessageBoxButton.OK, MessageBoxImage.Error); MaskManager mm = new MaskManager(); mm.Owner = Window.GetWindow(this); mm.m_mask.SetupMaskFromContainer(mask); if (mask.ReferenceImageID != 0) { mm.LoadReferenceImage(mask.ReferenceImageID); } mm.DrawMask(); mm.ShowDialog(); if (wgDB == null) { wgDB = new WaveguideDB(); } MaskContainer mc; bool success = wgDB.GetMask(mask.MaskID, out mc); if (success) { mask.Angle = mc.Angle; mask.Cols = mc.Cols; mask.Description = mc.Description; mask.IsDefault = mc.IsDefault; mask.MaskID = mc.MaskID; mask.PlateTypeID = mc.PlateTypeID; mask.ReferenceImageID = mc.ReferenceImageID; mask.Rows = mc.Rows; mask.Shape = mc.Shape; mask.XOffset = mc.XOffset; mask.XSize = mc.XSize; mask.XStep = mc.XStep; mask.YOffset = mc.YOffset; mask.YSize = mc.YSize; mask.YStep = mc.YStep; } }
void SetMaskIsDefault(MaskContainer mask, bool isDefault) { bool success; if (wgDB == null) { wgDB = new WaveguideDB(); } if (isDefault) // if setting to true, set any others are true to false (to make sure we don't have multiple defaults) { PlateTypeItem ptItem = null; // find parent PlateTypeItem foreach (PlateTypeItem pti in VM.PlateTypeList) { if (mask.PlateTypeID == pti.PlateType.PlateTypeID) { ptItem = pti; break; } } if (ptItem != null) { foreach (MaskContainer mc in ptItem.MaskList) { if (mc.IsDefault) { mc.IsDefault = false; success = wgDB.UpdateMask(mc); } } } } mask.IsDefault = isDefault; success = wgDB.UpdateMask(mask); if (!success) { MessageBox.Show("Failed to Update Mask", wgDB.GetLastErrorMsg(), MessageBoxButton.OK, MessageBoxImage.Error); } }
public MaskViewModel() { _mask = new MaskContainer(); _mask.MaskID = 0; _mask.Rows = 16; _mask.Cols = 24; _mask.XOffset = 180; _mask.YOffset = 30; _mask.XSize = 25; _mask.YSize = 25; _mask.XStep = 40; _mask.YStep = 40; _mask.Angle = 0.0; _mask.Shape = 0; _mask.Description = ""; _mask.PlateTypeID = 0; _mask.ReferenceImageID = 0; _mask.IsDefault = false; PlateType = null; }
public void SetMask(MaskContainer mask) { m_mask = mask; m_histogram.SetMask(m_mask, VM.HorzBinning, VM.VertBinning); }
// This is how slicing works: // take the original image, and copy it in chunks - each equal to a size of a piece, including padding around the sides // to the new "sliced" texture. But when copying, also do a UV lookup into the array that represents the mask; and only // copy those pixels that are not blocked (and also take the masks's borders into consideration). So essentially bake // the masked pieces onto a larger texture. Then we can use that one and only texture, with different UVs, to draw every // single piece. public static IEnumerator CreateAndSaveSlicedTextureRoutine(SlicingInfo slicingInfo, Texture2D originalTexture, Texture2D slicedTexture, string originalTexturePath, MaskContainer maskContainer, Dictionary <IntVector2, PieceInfo> pieceInfos, System.Action <float> onProgress) { //TODO maybe we could rationalize these var rows = slicingInfo.rows; var columns = slicingInfo.columns; var originalSize = new Vector2(originalTexture.width, originalTexture.height); var paddedPieceSize = GetPaddedPieceSize(rows, columns, originalSize); var pieceSize = new Vector2((float)originalSize.x / (float)columns, (float)originalSize.y / (float)rows); var padding = (paddedPieceSize - pieceSize) / 2f; var borderColor = Color.black; var paddedPixelCountX = Mathf.FloorToInt(paddedPieceSize.x); var paddedPixelCountY = Mathf.FloorToInt(paddedPieceSize.y); var piecePixels = new Color[paddedPixelCountX * paddedPixelCountY]; var maskPixels = new Color[MaskCreator.width * MaskCreator.height]; onProgress(0f); var thingsToLoadCount = rows * columns + 1; // "+1" for the extra step in the end, assigning textures etc. // this is just cosmetics- showing the loading indicator var thingsLoadedSoFar = 0f; for (int column = 0; column < columns; ++column) { for (int row = 0; row < rows; ++row) { CreateMask(maskContainer, pieceInfos, row, column, maskPixels); var sourceOffsetX = Mathf.RoundToInt(pieceSize.x * column - padding.x); var sourceOffsetY = Mathf.RoundToInt(pieceSize.y * row - padding.y); var destOffsetX = Mathf.RoundToInt(paddedPieceSize.x * column); var destOffsetY = Mathf.RoundToInt(paddedPieceSize.y * row); var dimensions = new Dimension { currentRow = row, currentColumn = column, rows = rows, columns = columns }; var paddingInfo = new PaddingInfo { padding = padding, paddedPieceSize = paddedPieceSize, paddedPixelCount = new IntVector2(paddedPixelCountX, paddedPixelCountY) }; TextureUtility.CopyMaskedPieceDataIntoPiecePixelsArray(dimensions, originalTexture, paddingInfo, new IntVector2(sourceOffsetX, sourceOffsetY), piecePixels, maskPixels, borderColor); slicedTexture.SetPixels(destOffsetX, destOffsetY, paddedPixelCountX, paddedPixelCountY, piecePixels, 0); thingsLoadedSoFar += 1f; onProgress(thingsLoadedSoFar / thingsToLoadCount); yield return(null); } } TextureUtility.ExportTexture(slicedTexture, rows, columns, originalSize, originalTexturePath); }
private void Mask_Save_Click(object sender, EventArgs e) { MaskContainer mask = new MaskContainer(); mask.Rows = m_mask.Mask.Rows; mask.Cols = m_mask.Mask.Cols; mask.XOffset = m_mask.Mask.XOffset; mask.YOffset = m_mask.Mask.YOffset; mask.XSize = m_mask.Mask.XSize; mask.YSize = m_mask.Mask.YSize; mask.XStep = m_mask.Mask.XStep; mask.YStep = m_mask.Mask.YStep; mask.Angle = m_mask.Mask.Angle; mask.Shape = m_mask.Mask.Shape; mask.Description = m_mask.Mask.Description; bool available = true; int existingMaskID = 0; if (m_refImage == null) { MessageBoxResult result = MessageBox.Show("Mask cannot be saved without a Reference Image. You must Load a Reference Image.", "No Image Loaded", MessageBoxButton.OK, MessageBoxImage.Error); } else if (mask.Description.Length < 1) { MessageBoxResult result = MessageBox.Show("Mask cannot be saved without a Name. Please give the Mask a Name.", "No Name given for Mask", MessageBoxButton.OK, MessageBoxImage.Error); } else { if (m_mask.PlateType != null) { mask.PlateTypeID = m_mask.PlateType.PlateTypeID; } else { mask.PlateTypeID = 0; } bool exists = false; bool success = wgDB.ReferenceImageExists(m_refImage.ReferenceImageID, ref exists); if (!exists) { MessageBoxResult result = MessageBox.Show("Image being used is not in Database. Save the Image to database first.", "Reference Image not saved in Database", MessageBoxButton.OK, MessageBoxImage.Error); } else if (wgDB.MaskDescriptionAvailable(mask.Description, ref available, ref existingMaskID)) { if (available) { success = wgDB.InsertMask(ref mask); if (success) { m_mask.Mask.MaskID = mask.MaskID; } } else { MessageBoxResult result = MessageBox.Show("'" + mask.Description + "' already exists. Do you want to over write it?", "Overwrite Existing Mask", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { mask.MaskID = existingMaskID; success = wgDB.UpdateMask(mask); if (success) { m_mask.Mask.MaskID = mask.MaskID; } } } } } }
public void SetMask(MaskContainer mask, int hBinning, int vBinning) { m_mask = mask; m_mask.BuildPixelList(GlobalVars.PixelWidth, GlobalVars.PixelHeight, hBinning, vBinning); }
public PlateTypeManager() { wgDB = new WaveguideDB(); VM = new PlateTypeManagerViewModel(); InitializeComponent(); //Initialize data in the XamDataGrid - NOTE: A blank record is added FIRST, this is key to this approach for the XamDataGrid PlateTypeItem blank = new PlateTypeItem(); blank.PlateType.Description = ""; blank.PlateType.Rows = 16; blank.PlateType.Cols = 24; blank.PlateType.PlateTypeID = 0; blank.PlateType.IsDefault = false; VM.PlateTypeList.Add(blank); // load all plate types in database bool success = wgDB.GetAllPlateTypes(); if (success) { foreach (PlateTypeContainer ptc in wgDB.m_plateTypeList) { PlateTypeItem pti = new PlateTypeItem(); pti.PlateType.PlateTypeID = ptc.PlateTypeID; pti.PlateType.Description = ptc.Description; pti.PlateType.Cols = ptc.Cols; pti.PlateType.Rows = ptc.Rows; pti.PlateType.IsDefault = ptc.IsDefault; VM.PlateTypeList.Add(pti); // add a blank mask for this platetype MaskContainer mask = new MaskContainer(); mask.Angle = 0; mask.Cols = blank.PlateType.Cols; mask.Description = ""; mask.IsDefault = false; mask.MaskID = 0; mask.PlateTypeID = pti.PlateType.PlateTypeID; mask.ReferenceImageID = 0; mask.Rows = blank.PlateType.Rows; mask.Shape = 0; mask.XOffset = 50; mask.YOffset = 50; mask.XSize = 50; mask.YSize = 50; mask.XStep = 50; mask.YStep = 50; pti.MaskList.Add(mask); success = wgDB.GetAllMasksForPlateType(pti.PlateType.PlateTypeID); if (success) { foreach (MaskContainer mc in wgDB.m_maskList) { pti.MaskList.Add(mc); } } } } this.DataContext = VM; }
void LoadSimulationConfiguration() { // m_iParams = iParams; // m_project = project; // m_experimentPlate = plate; // m_method = method; // m_mask = mask; // m_plateType = plateType; // m_indicatorList = indicatorList; // m_compoundPlateList = compoundPlateList; // m_controlSubtractionWellList = controlSubtractionWellList; //m_numFoFrames = numFoFrames; //m_dynamicRatioNumerator = dynamicRatioNumerator; //m_dynamicRatioDenominator = dynamicRatioDenominator; //ChartArray.BuildChartArray(mask.Rows, mask.Cols, m_indicatorList); //////////////////////// // set up project m_project = null; bool success = m_wgDB.GetAllProjects(false); foreach (ProjectContainer project in m_wgDB.m_projectList) { if (project.Description.Equals("Debug", StringComparison.OrdinalIgnoreCase)) { m_project = project; break; } } if (m_project == null) // not found in database, so create it { m_project = new ProjectContainer(); m_project.Description = "Debug"; m_project.TimeStamp = DateTime.Now; m_project.Archived = false; success = m_wgDB.InsertProject(ref m_project); } //////////////////////// // set up plateType m_plateType = null; success = m_wgDB.GetAllPlateTypes(); if (m_wgDB.m_plateTypeList.Count() > 0) { m_plateType = m_wgDB.m_plateTypeList.ElementAt(0); } else { // create a new plateType m_plateType = new PlateTypeContainer(); m_plateType.Cols = 24; m_plateType.Description = "Debug"; m_plateType.IsDefault = false; m_plateType.Rows = 16; success = m_wgDB.InsertPlateType(ref m_plateType); } //////////////////////// // set up experiment plate m_experimentPlate = null; success = m_wgDB.GetAllPlatesForProject(m_project.ProjectID); if (m_wgDB.m_plateList.Count() > 0) { m_experimentPlate = m_wgDB.m_plateList.ElementAt(0); } else { // create a new plate m_experimentPlate = new PlateContainer(); m_experimentPlate.Barcode = "12345678"; m_experimentPlate.Description = "Debug"; m_experimentPlate.IsPublic = true; m_experimentPlate.OwnerID = GlobalVars.UserID; m_experimentPlate.PlateTypeID = m_plateType.PlateTypeID; m_experimentPlate.ProjectID = m_project.ProjectID; success = m_wgDB.InsertPlate(ref m_experimentPlate); } //////////////////////// // set up method m_method = null; success = m_wgDB.GetAllMethodsForUser(GlobalVars.UserID); foreach (MethodContainer method in m_wgDB.m_methodList) { if (method.Description.Equals("Debug", StringComparison.OrdinalIgnoreCase)) { m_method = method; break; } } if (m_method == null) { m_method = new MethodContainer(); m_method.BravoMethodFile = ""; m_method.Description = "Debug"; m_method.IsPublic = true; m_method.OwnerID = GlobalVars.UserID; success = m_wgDB.InsertMethod(ref m_method); } success = m_wgDB.GetAllIndicatorsForMethod(m_method.MethodID); if (m_wgDB.m_indicatorList.Count < 1) { // create indicators for this new method IndicatorContainer ind = new IndicatorContainer(); ind.Description = "Debug"; ind.EmissionsFilterPosition = 6; ind.ExcitationFilterPosition = 4; ind.MethodID = m_method.MethodID; ind.SignalType = SIGNAL_TYPE.UP; success = m_wgDB.InsertIndicator(ref ind); } //////////////////////// // set up experiment m_experiment = null; ObservableCollection <ExperimentContainer> expList; success = m_wgDB.GetAllExperimentsForPlate(m_experimentPlate.PlateID, out expList); if (expList.Count() > 0) { m_experiment = expList.ElementAt(0); } else { m_experiment = new ExperimentContainer(); m_experiment.Description = "Debug"; m_experiment.HorzBinning = 1; m_experiment.MethodID = m_method.MethodID; m_experiment.PlateID = m_experimentPlate.PlateID; m_experiment.ROI_Height = GlobalVars.PixelHeight; m_experiment.ROI_Width = GlobalVars.PixelWidth; m_experiment.ROI_Origin_X = 1; m_experiment.ROI_Origin_Y = 1; m_experiment.TimeStamp = DateTime.Now; m_experiment.VertBinning = 1; success = m_wgDB.InsertExperiment(ref m_experiment); } //////////////////////// // set up mask m_mask = null; success = m_wgDB.GetAllMasksForPlateType(m_experimentPlate.PlateTypeID); if (m_wgDB.m_maskList.Count() > 0) { m_mask = m_wgDB.m_maskList.ElementAt(0); } else { // create a new mask m_mask = new MaskContainer(); m_mask.Angle = 0.0; m_mask.Cols = 24; m_mask.Description = "Debug"; m_mask.IsDefault = false; m_mask.NumEllipseVertices = 24; m_mask.PlateTypeID = m_experimentPlate.PlateTypeID; m_mask.ReferenceImageID = 0; m_mask.Rows = 16; m_mask.Shape = 0; m_mask.XOffset = 28; m_mask.XSize = 28; m_mask.XStep = 41.522; m_mask.YOffset = 190; m_mask.YSize = 28; m_mask.YStep = 41.467; success = m_wgDB.InsertMask(ref m_mask); } //////////////////////////////////// // setup test indicator(s) m_indicatorList = new ObservableCollection <ExperimentIndicatorContainer>(); ObservableCollection <ExperimentIndicatorContainer> expIndList; success = m_wgDB.GetAllExperimentIndicatorsForExperiment(m_experiment.ExperimentID, out expIndList); if (expIndList.Count > 0) { foreach (ExperimentIndicatorContainer ex in expIndList) { m_indicatorList.Add(ex); } } else { success = m_wgDB.GetAllIndicatorsForMethod(m_method.MethodID); foreach (IndicatorContainer ind in m_wgDB.m_indicatorList) { ExperimentIndicatorContainer exInd = new ExperimentIndicatorContainer(); exInd.Description = ind.Description; FilterContainer filter; success = m_wgDB.GetExcitationFilterAtPosition(ind.ExcitationFilterPosition, out filter); exInd.ExcitationFilterDesc = filter.Description; success = m_wgDB.GetEmissionFilterAtPosition(ind.EmissionsFilterPosition, out filter); exInd.EmissionFilterDesc = filter.Description; exInd.EmissionFilterPos = ind.EmissionsFilterPosition; exInd.ExcitationFilterPos = ind.ExcitationFilterPosition; exInd.ExperimentID = m_experiment.ExperimentID; exInd.Exposure = 150; exInd.Gain = 5; exInd.MaskID = m_mask.MaskID; exInd.SignalType = SIGNAL_TYPE.UP; exInd.Verified = true; success = m_wgDB.InsertExperimentIndicator(ref exInd); m_indicatorList.Add(exInd); } } //////////////////////////////////// // compound plates m_compoundPlateList = new ObservableCollection <ExperimentCompoundPlateContainer>(); //////////////////////////////////// // control subtraction well list m_controlSubtractionWellList = new ObservableCollection <Tuple <int, int> >(); // all wells in last row = control wells for (int c = 0; c < m_mask.Cols; c++) { m_controlSubtractionWellList.Add(Tuple.Create(m_mask.Rows - 1, c)); } //////////////////////////////////// //m_numFoFrames = numFoFrames; m_numFoFrames = 5; if (m_indicatorList.Count() > 1) { //////////////////////////////////// //m_dynamicRatioNumerator = dynamicRatioNumerator; m_dynamicRatioNumerator = m_indicatorList.ElementAt(0); //////////////////////////////////// //m_dynamicRatioDenominator = dynamicRatioDenominator; m_dynamicRatioDenominator = m_indicatorList.ElementAt(1); } else { m_dynamicRatioNumerator = new ExperimentIndicatorContainer(); m_dynamicRatioNumerator.ExperimentIndicatorID = 0; m_dynamicRatioDenominator = new ExperimentIndicatorContainer(); m_dynamicRatioDenominator.ExperimentIndicatorID = 0; } if (m_iParams == null) { m_iParams = new ImagingParameters(); } m_iParams.maxPixelValue = GlobalVars.MaxPixelValue; m_iParams.imageWidth = GlobalVars.PixelWidth; m_iParams.imageHeight = GlobalVars.PixelHeight; m_iParams.Image_StartCol = 1; m_iParams.Image_EndCol = GlobalVars.PixelWidth; m_iParams.Image_StartRow = 1; m_iParams.Image_EndRow = GlobalVars.PixelHeight; m_iParams.BravoMethodFilename = ""; m_iParams.CameraTemperature = GlobalVars.CameraTargetTemperature; m_iParams.HorzBinning = 1; m_iParams.VertBinning = 1; m_iParams.EmissionFilterChangeSpeed = GlobalVars.FilterChangeSpeed; m_iParams.ExcitationFilterChangeSpeed = GlobalVars.FilterChangeSpeed; m_iParams.LightIntensity = 100; m_iParams.NumImages = 1000000; // artificial limit on number of images m_iParams.NumIndicators = m_indicatorList.Count; m_iParams.SyncExcitationFilterWithImaging = true; m_iParams.CycleTime = new int[m_indicatorList.Count]; m_iParams.EmissionFilter = new byte[m_indicatorList.Count]; m_iParams.ExcitationFilter = new byte[m_indicatorList.Count]; m_iParams.Exposure = new float[m_indicatorList.Count]; m_iParams.Gain = new int[m_indicatorList.Count]; m_iParams.ExperimentIndicatorID = new int[m_indicatorList.Count]; m_iParams.IndicatorName = new string[m_indicatorList.Count]; m_iParams.LampShutterIsOpen = new bool[m_indicatorList.Count]; int i = 0; foreach (ExperimentIndicatorContainer ind in m_indicatorList) { m_iParams.CycleTime[i] = 1000; m_iParams.EmissionFilter[i] = (byte)ind.EmissionFilterPos; m_iParams.ExcitationFilter[i] = (byte)ind.ExcitationFilterPos; m_iParams.Exposure[i] = (float)ind.Exposure / 1000; m_iParams.Gain[i] = ind.Gain; m_iParams.ExperimentIndicatorID[i] = 0; // created by the RunExperiment object when the experiment is run m_iParams.IndicatorName[i] = ind.Description; m_iParams.LampShutterIsOpen[i] = true; m_iParams.ExperimentIndicatorID[i] = ind.ExperimentIndicatorID; i++; } }
private void xamDataGrid_RecordUpdated(object sender, Infragistics.Windows.DataPresenter.Events.RecordUpdatedEventArgs e) { if (e.Record.Tag == null) { return; } if (((string)e.Record.Tag).Equals("AddRecord")) // is this the "AddRecord"? { if (e.Record.DataItem.GetType() == typeof(PlateTypeItem)) { DataRecord plateTypeRecord = (DataRecord)e.Record; PlateTypeItem pti = ((PlateTypeItem)(plateTypeRecord.DataItem)); PlateTypeContainer ptc = pti.PlateType; bool success = wgDB.InsertPlateType(ref ptc); if (success) { UnMarkAddNewRecord(plateTypeRecord); // add new blank plate type PlateTypeItem newPti = new PlateTypeItem(); newPti.PlateType.Description = ""; newPti.PlateType.Cols = ptc.Cols; newPti.PlateType.Rows = ptc.Rows; newPti.PlateType.IsDefault = false; newPti.PlateType.PlateTypeID = 0; VM.PlateTypeList.Insert(0, newPti); // mark the new PlateType as the AddRecord RecordCollectionBase coll = e.Record.ParentCollection; DataRecord newPlateTypeRecord = (DataRecord)coll.ElementAt(0); MarkAddNewRecord(newPlateTypeRecord); // add the blank AddRecord Mask for this new platetype MaskContainer newMask = new MaskContainer(); newMask.Description = ""; newMask.Angle = 0.0; newMask.Cols = ptc.Cols; newMask.IsDefault = false; newMask.MaskID = 0; newMask.PlateTypeID = ptc.PlateTypeID; newMask.ReferenceImageID = 0; newMask.Rows = ptc.Rows; newMask.Shape = 0; newMask.XOffset = 50; newMask.XSize = 50; newMask.XStep = 50; newMask.YOffset = 50; newMask.YSize = 50; newMask.YStep = 50; newPti.MaskList.Add(newMask); // mark the new Mask as the AddRecord ExpandableFieldRecord expRecord = (ExpandableFieldRecord)newPlateTypeRecord.ChildRecords[0]; DataRecord maskRecord = (DataRecord)expRecord.ChildRecords[0]; if (maskRecord.DataItem.GetType() == typeof(MaskContainer)) { MarkAddNewRecord(maskRecord); } } } else if (e.Record.DataItem.GetType() == typeof(MaskContainer)) { MaskContainer mc = (MaskContainer)(e.Record.DataItem); bool success = wgDB.InsertMask(ref mc); if (success) { UnMarkAddNewRecord(e.Record); // add new blank mask for AddRecord MaskContainer newMask = new MaskContainer(); newMask.Description = ""; newMask.Angle = 0.0; newMask.Cols = mc.Cols; newMask.IsDefault = false; newMask.MaskID = 0; newMask.PlateTypeID = mc.PlateTypeID; newMask.ReferenceImageID = 0; newMask.Rows = mc.Rows; newMask.Shape = 0; newMask.XOffset = 50; newMask.XSize = 50; newMask.XStep = 50; newMask.YOffset = 50; newMask.YSize = 50; newMask.YStep = 50; PlateTypeItem pti = (PlateTypeItem)(((DataRecord)e.Record.ParentRecord.ParentRecord).DataItem); pti.MaskList.Insert(0, newMask); DataRecord newMaskRecord = (DataRecord)e.Record.ParentCollection[0]; MarkAddNewRecord(newMaskRecord); } } } }