Пример #1
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();
        }
Пример #2
0
 // check2
 public bool Contains(canMessageId canId)
 {
     return(list.Contains(canId));
 }