GenericWindow.GetColumn C# (CSharp) Method

GetColumn() public method

public GetColumn ( int column, bool onlyActive ) : string[]
column int
onlyActive bool
return string[]
    public string[] GetColumn(int column, bool onlyActive)
    {
        //to store active or inactive status of curves
        string [] checkboxes = new string[UtilGtk.CountRows(store)];

        int count = 0;
        Gtk.TreeIter iter;
        bool okIter = store.GetIterFirst(out iter);
        if(okIter) {
            do {
                if(column == 1) {
                    if((bool) store.GetValue (iter, 1))
                        checkboxes[count++] = "active";
                    else
                        checkboxes[count++] = "inactive";
                }
                else
                    if((bool) store.GetValue (iter, 1) || ! onlyActive)
                        checkboxes[count++] = ((string) store.GetValue (iter, column));

            } while ( store.IterNext(ref iter) );
        }
        if(column == 1)
            return checkboxes;
        else {
            string [] checkboxesWithoutGaps = new string[count];
            for(int i=0; i < count; i ++)
                checkboxesWithoutGaps[i] = checkboxes[i];
            return checkboxesWithoutGaps;
        }
    }

Usage Example

    protected void updateEncoderCompareInterAndReps()
    {
        EncoderCompareInter = new ArrayList();

        //find RepsActive
        string [] selectedID   = genericWin.GetColumn(0, true);          //only active
        string [] selectedDate = genericWin.GetColumn(dateColumn, true); //only active
        for (int i = 0; i < selectedID.Length; i++)
        {
            int id = Convert.ToInt32(selectedID[i]);
            RepsActive += genericWin.GetCell(id, allRepsColumn);
            EncoderCompareInter.Add(id + ":" + selectedDate[i]);
        }

        //find RepsAll
        string [] allID = genericWin.GetColumn(0, false);        //unchecked (session or person don't need to be selected)
        for (int i = 0; i < allID.Length; i++)
        {
            int id = Convert.ToInt32(allID[i]);
            RepsAll += genericWin.GetCell(id, allRepsColumn);
        }
    }