Ejemplo n.º 1
0
        private void ToolStripMenuItem_DisplaySingleCellHistogram(object sender, EventArgs e)
        {
            cListWells ListWells = new cListWells();
            List<cDescriptorType> LCDT = new List<cDescriptorType>();
            LCDT.Add(cGlobalInfo.CurrentScreening.ListDescriptors.GetActiveDescriptor());

            List<cWellClassType> ListForCurrentClass = new List<cWellClassType>();
            ListForCurrentClass.Add(this);

            cGUI_ListClasses GUIClasses = new cGUI_ListClasses();
            GUIClasses.IsCheckBoxes = true;
            GUIClasses.IsSelectAll = true;
            GUIClasses.ClassType = eClassType.PHENOTYPE;
            if (!GUIClasses.Run().IsSucceed) return;

            cDesignerTab DT = new cDesignerTab();

            if (cGlobalInfo.WindowHCSAnalyzer.ProcessModeEntireScreeningToolStripMenuItem.Checked)
            {
                foreach (cPlate CurrentPlate in cGlobalInfo.CurrentScreening.ListPlatesActive)
                {
                    ListWells.AddRange(CurrentPlate.ListWells.Filter(ListForCurrentClass));
                }
                    cExtendedTable FinalTable = new cExtendedTable();
                    FinalTable.Name = "Stacked Histogram: " + ListWells.Count + " wells";

                    int Idx = 0;
                    foreach (var item in cGlobalInfo.ListCellularPhenotypes)
                    {
                        FinalTable.Add(new cExtendedList());
                        FinalTable[Idx].Name = item.Name;
                        FinalTable[Idx].Tag = item;

                        Idx++;
                    }

                    foreach (cWell TmpWell in ListWells)
                    {
                        TmpWell.AssociatedPlate.DBConnection = new cDBConnection(TmpWell.AssociatedPlate, TmpWell.SQLTableName);

                        int IDx = 0;
                        foreach (var item in cGlobalInfo.ListCellularPhenotypes)
                        {
                            if (GUIClasses.GetOutPut()[0][IDx] == 0) { IDx++; continue; }
                            List<cCellularPhenotype> ListCellularPhenotypesToBeSelected = new List<cCellularPhenotype>();
                            ListCellularPhenotypesToBeSelected.Add(item);

                            cExtendedTable TmpET = TmpWell.AssociatedPlate.DBConnection.GetWellValues(TmpWell,
                                                     LCDT, ListCellularPhenotypesToBeSelected);

                            if (TmpET.Count > 0) FinalTable[IDx].AddRange(TmpET[0]);
                            IDx++;
                        }
                        TmpWell.AssociatedPlate.DBConnection.CloseConnection();
                    }

                    cViewerStackedHistogram VSH = new cViewerStackedHistogram();
                    VSH.SetInputData(FinalTable);
                    VSH.Chart.BinNumber = LCDT[0].GetBinNumber();
                    VSH.Chart.IsShadow = false;
                    VSH.Chart.IsBorder = false;
                    VSH.Chart.IsXGrid = true;
                    VSH.Chart.IsYGrid = true;
                    VSH.Chart.LabelAxisX = LCDT[0].GetName();

                    VSH.Run();
                    VSH.Chart.Width = 0;
                    VSH.Chart.Height = 0;
                    VSH.GetOutPut().Title = cGlobalInfo.CurrentScreening.GetName();
                    DT.SetInputData(VSH.GetOutPut());
            }
            else
            {
                cListPlates ListPlates = new cListPlates();
                if (cGlobalInfo.WindowHCSAnalyzer.ProcessModeplateByPlateToolStripMenuItem.Checked)
                    ListPlates = cGlobalInfo.CurrentScreening.ListPlatesActive;
                else
                    ListPlates.Add(cGlobalInfo.CurrentScreening.GetCurrentDisplayPlate());

                foreach (cPlate CurrentPlate in ListPlates)
                {
                    ListWells = CurrentPlate.ListWells.Filter(ListForCurrentClass);

                    cExtendedTable FinalTable = new cExtendedTable();
                    FinalTable.Name = "Stacked Histogram: " + ListWells.Count + " wells - " + CurrentPlate.GetName();

                    int Idx = 0;
                    foreach (var item in cGlobalInfo.ListCellularPhenotypes)
                    {
                        FinalTable.Add(new cExtendedList());
                        FinalTable[Idx].Name = item.Name;
                        FinalTable[Idx].Tag = item;

                        if (GUIClasses.GetOutPut()[0][Idx] == 0)
                        {
                            Idx++;
                            continue;
                        }

                        Idx++;
                    }

                    foreach (cWell TmpWell in ListWells)
                    {
                        TmpWell.AssociatedPlate.DBConnection = new cDBConnection(TmpWell.AssociatedPlate, TmpWell.SQLTableName);

                        int IDx = 0;
                        foreach (var item in cGlobalInfo.ListCellularPhenotypes)
                        {
                            if (GUIClasses.GetOutPut()[0][IDx] == 0) { IDx++; continue; }
                            List<cCellularPhenotype> ListCellularPhenotypesToBeSelected = new List<cCellularPhenotype>();
                            ListCellularPhenotypesToBeSelected.Add(item);

                            cExtendedTable TmpET = TmpWell.AssociatedPlate.DBConnection.GetWellValues(TmpWell,
                                                     LCDT, ListCellularPhenotypesToBeSelected);

                            if (TmpET.Count > 0) FinalTable[IDx].AddRange(TmpET[0]);
                            IDx++;
                        }
                        TmpWell.AssociatedPlate.DBConnection.CloseConnection();
                    }

                    cViewerStackedHistogram VSH = new cViewerStackedHistogram();
                    VSH.SetInputData(FinalTable);
                    VSH.Chart.BinNumber = LCDT[0].GetBinNumber();
                    VSH.Chart.IsShadow = false;
                    VSH.Chart.IsBorder = false;
                    VSH.Chart.IsXGrid = true;
                    VSH.Chart.IsYGrid = true;
                    VSH.Chart.LabelAxisX = LCDT[0].GetName();

                    VSH.Run();
                    VSH.Chart.Width = 0;
                    VSH.Chart.Height = 0;
                    VSH.GetOutPut().Title = CurrentPlate.GetName();
                    DT.SetInputData(VSH.GetOutPut());
                }
            }
            DT.Run();

            cDisplayToWindow DTW = new cDisplayToWindow();
            DTW.SetInputData(DT.GetOutPut());
            DTW.Title = "Single Cell Histograms";
            DTW.Run();
            DTW.Display();
        }