コード例 #1
0
 public void LoadItems(object [] items)
 {
     this.Cursor = Cursors.WaitCursor;
     MyCheckedListBox.TheCheckedListBox.Items.Clear();
     MyCheckedListBox.TheCheckedListBox.Items.AddRange(items);
     MyCheckedListBox.RefreshCounterText();
     this.Cursor = Cursors.Default;
 }
コード例 #2
0
        private void FillPlate(int plateId)
        {
            DataSet      plateDataSet;
            DataTable    positionTable, allItemTable;
            Identifiable tempListItem;
            int          x, y;

            string [] colHeader, rowHeader;
            object [,] matrix;

            const int cellsX = 24, cellsY = 16;

            this.Cursor  = Cursors.WaitCursor;
            plateDataSet = MyDataServer.GetPlateContents(plateId);

            positionTable = plateDataSet.Tables[0];
            //Save item and experiment tables in "object global" variables to
            //be able to read information later.
            MyItemTable       = plateDataSet.Tables[1];
            MyExperimentTable = plateDataSet.Tables[2];
            MyWellTable       = plateDataSet.Tables[3];

            //Get a list of all items, including controls.
            allItemTable = MyDataServer.GetAllItems();

            colHeader = new string[cellsX];
            rowHeader = new string[cellsY];
            matrix    = new object[cellsX, cellsY];

            //Check that we don't have more position info than number of cells.
            if (positionTable.Rows.Count > cellsX * cellsY)
            {
                throw new Exception("Invalid number of plate positions.");
            }

            //Create column headers.
            for (int i = 1; i <= 24; i++)
            {
                colHeader[i - 1] = i.ToString();
            }

            //Create row headers.
            for (int i = 1; i <= 16; i++)
            {
                rowHeader[i - 1] = Convert.ToChar(i + 64).ToString();
            }

            //Read the positions and set the corresponding cells to indicate that they are used.
            for (int i = 0; i < positionTable.Rows.Count; i++)
            {
                x = Convert.ToInt32(positionTable.Rows[i]["pos_x"]);
                y = Convert.ToInt32(positionTable.Rows[i]["pos_y"]);
                if (x > cellsX || y > cellsY)
                {
                    throw new Exception("Invalid plate position.");
                }
                //Set the matrix position to anything other than null, in this case the integer 1.
                matrix[x - 1, y - 1] = 1;
            }

            //Show used wells.
            Plate.ShowGrid(matrix, colHeader, rowHeader, new Size(19, 17), new Size(17, 15));
            WellRateListView.ShowFormattedTable(MyWellTable);

            //Show used items.
            ItemCheckedListBox.TheCheckedListBox.BeginUpdate();
            ItemCheckedListBox.TheCheckedListBox.Items.Clear();
            for (int i = 0; i < allItemTable.Rows.Count; i++)
            {
                tempListItem = new Identifiable(Convert.ToInt32(allItemTable.Rows[i]["item_id"]),
                                                allItemTable.Rows[i]["Item"].ToString());
                ItemCheckedListBox.TheCheckedListBox.Items.Add(tempListItem, CheckState.Checked);
            }
            ItemCheckedListBox.TheCheckedListBox.EndUpdate();
            ItemRateListView.ShowFormattedTable(MyItemTable);
            ItemCheckedListBox.RefreshCounterText();

            //Show used experiments.
            ExperimentCheckedListBox.TheCheckedListBox.BeginUpdate();
            ExperimentCheckedListBox.TheCheckedListBox.Items.Clear();
            for (int i = 0; i < MyExperimentTable.Rows.Count; i++)
            {
                tempListItem = new Identifiable(Convert.ToInt32(MyExperimentTable.Rows[i]["experiment_id"]),
                                                MyExperimentTable.Rows[i]["Experiment"].ToString());
                ExperimentCheckedListBox.TheCheckedListBox.Items.Add(tempListItem, CheckState.Checked);
            }
            ExperimentCheckedListBox.TheCheckedListBox.EndUpdate();
            ExperimentRateListView.ShowFormattedTable(MyExperimentTable);
            ExperimentCheckedListBox.RefreshCounterText();
            this.Cursor = Cursors.Default;
        }