Exemple #1
0
 /// <summary>
 /// Returns true or false depending on if a string is detected in a array list of arrayLists. used by GetSelectedData().
 /// </summary>
 /// <param name="arrayListOfArrayLists"></param>
 /// <returns></returns>
 public bool StringDetection(ArrayList[] arrayListOfArrayLists)
 {
     try
     {
         //If a string is detected in a selectedColumn. Set bool stringDetected to true
         for (int columnIndex = 0; columnIndex < arrayListOfArrayLists.Length; columnIndex++)
         {
             try
             {
                 if (StatisticCalculator.ConvertToList(arrayListOfArrayLists[columnIndex])[0] == -1)//-1 == string
                 {
                     stringArrayIndex = columnIndex;
                     return(true);
                 }
             }
             catch (ArgumentOutOfRangeException)
             {
                 return(false);
             }
         }
     }
     catch (NullReferenceException nRe)
     {
         throw nRe;
     }
     return(false);
 }
Exemple #2
0
        /// <summary>
        /// Returns a Array with arraylists ith the content of the selected columns
        /// </summary>
        /// <param name="dataGrid">The dataGrid with the selected data.</param>
        /// <returns></returns>
        public ArrayList[] getResultSelection(CustomDataGridView dataGrid)
        {
            ArrayList[] lijsten = new ArrayList[2];
            lijsten[0] = new ArrayList();
            lijsten[1] = new ArrayList();

            //Get number of unique columns.
            try
            {
                List <int> columns = new List <int>();
                foreach (DataGridViewTextBoxCell item in dataView.SelectedCells)
                {
                    columns.Add(item.ColumnIndex);
                }
                var        unique_items  = new HashSet <int>(columns);
                List <int> uniekeColumns = new List <int>();
                foreach (int i in unique_items)
                {
                    uniekeColumns.Add(i);
                }

                //if 1 of 2 colomns are selected.
                if (uniekeColumns.Count < 3 && uniekeColumns.Count > 0)
                {
                    int       column1     = uniekeColumns[0];
                    int       column2     = uniekeColumns.Count == 2 ? uniekeColumns[1] : 0;
                    ArrayList listColomn1 = new ArrayList();
                    ArrayList listColomn2 = new ArrayList();

                    //add to column resultList.
                    foreach (DataGridViewTextBoxCell item in dataView.SelectedCells)
                    {
                        if (item.ColumnIndex == column1)
                        {
                            listColomn1.Add(item.Value.ToString());
                        }
                        if (item.ColumnIndex == column2)
                        {
                            listColomn2.Add(item.Value.ToString());
                        }
                    }

                    //if both resultList are the same size or list2 is empty, set the lists to the arrayListOfArrayLists.
                    if (listColomn1.Count == listColomn2.Count || listColomn2.Count == 0)
                    {
                        listColomn1.Reverse();
                        listColomn2.Reverse();
                        lijsten[0] = (listColomn1);
                        lijsten[1] = (listColomn2);

                        foreach (ArrayList a in lijsten)
                        {
                            foreach (String s in a)
                            {
                                Console.WriteLine(s);
                            }
                            Console.WriteLine();
                        }
                        List <int> lijst1 = StatisticCalculator.ConvertToList(lijsten[0]);
                        List <int> lijst2 = new List <int>();
                        if (listColomn2.Count != 0)
                        {
                            lijst2 = StatisticCalculator.ConvertToList(lijsten[1]);
                        }

                        //If the selection is only a string or string + string give a message
                        if (lijst1[0] == -1 && lijst2.Count == 0 || (lijst1[0] == -1 && lijst2[0] == -1))
                        {
                            MessageBox.Show("Selecteer a.u.b. ook getallen.", "Selectie bevat geen getallen.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            mainController.statisticView.ClearData();
                            //mainController.mainViewController.SelectTab(1);
                            lijsten = null;
                            return(lijsten);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Selecteer twee evenlange kolommen a.u.b.", "Kolommen zijn niet even lang.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        mainController.statisticView.ClearData();
                    }
                }
                else
                {
                    MessageBox.Show("Selecteer a.u.b. eerst één of twee kolommen in de resultaten tap.", "Er kan geen scatter plot van uw selectie gemaakt worden.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    mainController.statisticView.ClearData();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Sellecteer alleen kolom met tekst a.u.b.", "U mag geen knopjes selecteren.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                mainController.statisticView.ClearData();
            }

            return(lijsten);
        }