Example #1
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (radioBtnOpenSample.Checked == true)
            {
                DialogResult dr = ofd.ShowDialog();
                if (dr == System.Windows.Forms.DialogResult.OK)
                {
                    FileOperator fo = new FileOperator();
                    var          lstTreeViewData = fo.ReadTextFile(ofd.FileName);

                    OpenFile(lstTreeViewData);
                    this.Close();
                }
            }
            else if (radioBtnCustomSample.Checked == true)
            {
                frmCustomSample customSample = new frmCustomSample(mainForm);
                customSample.ShowDialog();
                this.Close();
            }
            else
            {
                RandomSample rndSmple = new RandomSample(mainForm);
                rndSmple.CreateRandomSample(frmOptions.NumberOfSpeciesInRandomSample);
                this.Close();
            }
        }
Example #2
0
        public void CreateRandomSample(int numOfCompounds)
        {
            DB_Operator dbo = new DB_Operator();
            DataTable   dt  = dbo.GetTable("Compound_Data");

            List <string> lstCompounds = new List <string>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var compound = (string)dt.Rows[i].ItemArray[1];
                if (!compound.Contains('_'))
                {
                    lstCompounds.Add(compound);
                }
            }


            Random        r         = new Random();
            List <string> lstSample = new List <string>();

            int j = 0;

            while (lstCompounds.Count > 0 && j < numOfCompounds)
            {
                int index = r.Next(lstCompounds.Count);
                lstSample.Add(lstCompounds.ElementAt(index));
                lstCompounds.RemoveAt(index);
                j += 1;
            }

            Sample.lst_Samples.Add(lstSample);
            frmCustomSample fc = new frmCustomSample(mainForm);

            fc.PopulateAesthetics(lstSample);
        }