예제 #1
0
        //-----------------------------------------------------------------------

        #endregion

        // the region contains some public utils
        #region Utils (Public)

        // returns a list of selected messages
        public UniqueDataSetCan getSelectedMessages2()
        {
            UniqueDataSetCan list = new UniqueDataSetCan();

            for (int i = 0; i < RowList.Count; i++)
            {
                var row = RowList.GetAt(i);
                if (row.Row.Selected)
                {
                    list.Add(row.Msg);
                }
            }

            return(list);
        }
예제 #2
0
        // push a message list
        public void pushList(List <canMessage2> ls, UniqueDataSetCan selected)
        {
            // append new messages
            storage_msg_list.AddRange(ls);
            // try to store
            store();

            // paused?
            // just do return
            if (traceMode.pause == mode)
            {
                return;
            }

            // lock
            lockMutex.WaitOne();

            // below we're using add range because it works much faster
            DataGridViewRow[] rows = null;

            // trace only selected messages
            if (mode == traceMode.traceSelected)
            {
                // step 1: get a number of rows we gonna push
                int cnt = 0;
                for (int i = 0; i < ls.Count; i++)
                {
                    if (selected.Contains(ls[i].Id))
                    {
                        cnt++;
                    }
                }

                // step 2: create the rows and then push them
                if (cnt > 0)
                {
                    // create
                    rows = new DataGridViewRow[cnt];
                    // prepare
                    int rowPos = 0;
                    for (int i = 0; i < ls.Count; i++)
                    {
                        if (selected.Contains(ls[i].Id))
                        {
                            rows[rowPos] = new DataGridViewRow();
                            rows[rowPos++].CreateCells(grid, conv.msg2row(ls[i], MsgIdx++));
                        }
                    }
                    // add
                    grid.Rows.AddRange(rows);
                }
            }
            // trace all the data we've just received
            else
            {
                // create
                rows = new DataGridViewRow[ls.Count];
                // prepare
                int rowPos = 0;

                for (int i = 0; i < ls.Count; i++)
                {
                    // new DataGridViewRow is too slow but this is the fastest way
                    rows[rowPos] = new DataGridViewRow();
                    rows[rowPos++].CreateCells(grid, conv.msg2row(ls[i], MsgIdx++));
                }
                // add
                grid.Rows.AddRange(rows);
            }

            // unlock
            lockMutex.ReleaseMutex();
            // update
            updateMsgCounter();
            updateButtons();
        }
예제 #3
0
 // constructor
 public canFilter()
 {
     list = new UniqueDataSetCan();
 }