Exemplo n.º 1
0
        public List <AssociationItem> GetAssociations()
        {
            List <AssociationItem> myAssociations = new List <AssociationItem>();

            try
            {
                //We allways need to remove the focus from the table so we can get all the updated values.
                numericUpDownChromTolerance.Focus();
                for (int i = 1; i < dataGridViewRules.Columns.Count; i += 2)
                {
                    for (int j = 0; j < dataGridViewRules.Rows.Count; j++)
                    {
                        string[] cols        = Regex.Split(dataGridViewRules.Columns[i].HeaderText, ":");
                        int      label       = int.Parse(cols[0]);
                        string   directory   = cols[1];
                        string   fileName    = dataGridViewRules.Rows[j].Cells[i - 1].Value.ToString();
                        int      association = int.Parse(Convert.ToString(dataGridViewRules.Rows[j].Cells[i].FormattedValue.ToString()));

                        AssociationItem ai = new AssociationItem(label, directory, fileName, association);
                        myAssociations.Add(ai);
                    }
                }
            } catch (Exception e)
            {
                MessageBox.Show("Error generating associations: " + e.Message);
            }
            return(myAssociations);
        }
Exemplo n.º 2
0
        private void GenerateAssociationItems()
        {
            MyAssociationItems = new List <AssociationItem>();

            List <int> classes = (from q in myQuantPkgs
                                  select q.ClassLabel).Distinct().ToList();

            foreach (int c in classes)
            {
                List <string> directories = (from q in myQuantPkgs
                                             where q.ClassLabel == c
                                             select new DirectoryInfo(q.FullDirPath).Name).Distinct().ToList();

                foreach (string dir in directories)
                {
                    List <string> files = (from q in myQuantPkgs
                                           where q.ClassLabel == c && new DirectoryInfo(q.FullDirPath).Name.Equals(dir)
                                           select q.FileName).Distinct().ToList();

                    foreach (string file in files)
                    {
                        AssociationItem ai = new AssociationItem(c, dir, file, -1);
                        MyAssociationItems.Add(ai);
                    }
                }
            }
        }