Esempio n. 1
0
        /// <summary>
        /// Updaet the DataGridView with the newest info from sendingData
        /// </summary>
        /// <param name="idx"></param>
        private void updateGridRow(int idx)
        {
            FrameSendData temp       = sendingData[idx];
            int           gridLine   = idx;
            StringBuilder dataString = new StringBuilder();

            dataGridView1.Rows[gridLine].Cells[7].Value = temp.count.ToString();
            for (int i = 0; i < temp.len; i++)
            {
                dataString.Append("0x");
                dataString.Append(temp.data[i].ToString("X2"));
                dataString.Append(" ");
            }
            dataGridView1.Rows[gridLine].Cells[4].Value = dataString.ToString();
        }
Esempio n. 2
0
        private void processCellChange(int line, int col)
        {
            FrameSendData tempData;
            int tempVal;

            //if this is a new line then create the base object for the line
            if ((line >= sendingData.Count) || (sendingData[line] == null))
            {
                tempData = new FrameSendData();
                sendingData.Add(tempData);
            }

            sendingData[line].count = 0;

            switch (col)
            {
                case 0: //Enable check box
                    if (dataGridView1.Rows[line].Cells[0].Value != null)
                    {
                        sendingData[line].enabled = (bool)dataGridView1.Rows[line].Cells[0].Value;
                    }
                    else sendingData[line].enabled = false;
                    break;
                case 1: //Bus designation
                    tempVal = Utility.ParseStringToNum((string)dataGridView1.Rows[line].Cells[1].Value);
                    if (tempVal < 0) tempVal = 0;
                    if (tempVal > 1) tempVal = 1;
                    sendingData[line].bus = tempVal;
                    break;
                case 2: //ID field
                    tempVal = Utility.ParseStringToNum((string)dataGridView1.Rows[line].Cells[2].Value);
                    if (tempVal < 1) tempVal = 1;
                    if (tempVal > 0x7FFFFFFF) tempVal = 0x7FFFFFFF;
                    sendingData[line].ID = tempVal;
                    if (sendingData[line].ID <= 0x7FF) sendingData[line].extended = false;
                    else sendingData[line].extended = true;
                    break;
                case 3: //length field
                    tempVal = Utility.ParseStringToNum((string)dataGridView1.Rows[line].Cells[3].Value);
                    if (tempVal < 0) tempVal = 0;
                    if (tempVal > 8) tempVal = 8;
                    sendingData[line].len = tempVal;
                    break;
                case 4: //Data bytes
                    for (int i = 0; i < 8; i++) sendingData[line].data[i] = 0;

                    string[] tokens = ((string)dataGridView1.Rows[line].Cells[4].Value).Split(' ');
                    for (int j = 0; j < tokens.Length; j++)
                    {
                        sendingData[line].data[j] = (byte)Utility.ParseStringToNum(tokens[j]);
                    }
                    break;
                case 5: //triggers
                    processTriggerText(line);
                    break;
                case 6: //modifiers
                    processModifierText(line);
                    break;
            }
        }
Esempio n. 3
0
        private void processCellChange(int line, int col)
        {
            FrameSendData tempData;
            int           tempVal;

            //if this is a new line then create the base object for the line
            if ((line >= sendingData.Count) || (sendingData[line] == null))
            {
                tempData = new FrameSendData();
                sendingData.Add(tempData);
            }

            sendingData[line].count = 0;

            switch (col)
            {
            case 0:     //Enable check box
                if (dataGridView1.Rows[line].Cells[0].Value != null)
                {
                    sendingData[line].enabled = (bool)dataGridView1.Rows[line].Cells[0].Value;
                }
                else
                {
                    sendingData[line].enabled = false;
                }
                break;

            case 1:     //Bus designation
                tempVal = Utility.ParseStringToNum((string)dataGridView1.Rows[line].Cells[1].Value);
                if (tempVal < 0)
                {
                    tempVal = 0;
                }
                if (tempVal > 1)
                {
                    tempVal = 1;
                }
                sendingData[line].bus = tempVal;
                break;

            case 2:     //ID field
                tempVal = Utility.ParseStringToNum((string)dataGridView1.Rows[line].Cells[2].Value);
                if (tempVal < 1)
                {
                    tempVal = 1;
                }
                if (tempVal > 0x7FFFFFFF)
                {
                    tempVal = 0x7FFFFFFF;
                }
                sendingData[line].ID = tempVal;
                if (sendingData[line].ID <= 0x7FF)
                {
                    sendingData[line].extended = false;
                }
                else
                {
                    sendingData[line].extended = true;
                }
                break;

            case 3:     //length field
                tempVal = Utility.ParseStringToNum((string)dataGridView1.Rows[line].Cells[3].Value);
                if (tempVal < 0)
                {
                    tempVal = 0;
                }
                if (tempVal > 8)
                {
                    tempVal = 8;
                }
                sendingData[line].len = tempVal;
                break;

            case 4:     //Data bytes
                for (int i = 0; i < 8; i++)
                {
                    sendingData[line].data[i] = 0;
                }

                string[] tokens = ((string)dataGridView1.Rows[line].Cells[4].Value).Split(' ');
                for (int j = 0; j < tokens.Length; j++)
                {
                    sendingData[line].data[j] = (byte)Utility.ParseStringToNum(tokens[j]);
                }
                break;

            case 5:     //triggers
                processTriggerText(line);
                break;

            case 6:     //modifiers
                processModifierText(line);
                break;
            }
        }