Exemplo n.º 1
0
        /*********************************************************************/
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void s19ListView_FormatRow(object sender, FormatRowEventArgs e)
        {
            S19Line line = (S19Line)e.Model;

            switch (line.ErrorInRow)
            {
            case S19Line.S19LineError.NotTested:
                e.Item.BackColor = System.Drawing.Color.White;
                infoLabel.Text   = "";
                break;

            case S19Line.S19LineError.InstructionError:
                e.Item.BackColor = System.Drawing.Color.LightCoral;
                infoLabel.Text   = ">> ERROR: Instruction Error!";
                break;

            case S19Line.S19LineError.SizeError:
                e.Item.BackColor = System.Drawing.Color.LightCoral;
                infoLabel.Text   = ">> ERROR: Size Error!";
                break;

            case S19Line.S19LineError.AddressError:
                e.Item.BackColor = System.Drawing.Color.LightCoral;
                infoLabel.Text   = ">> ERROR: General Address Error!";
                break;

            case S19Line.S19LineError.AddressLengthError:
                e.Item.BackColor = System.Drawing.Color.LightCoral;
                infoLabel.Text   = ">> ERROR: Address Length Error!";
                break;

            case S19Line.S19LineError.DataError:
                e.Item.BackColor = System.Drawing.Color.LightCoral;
                infoLabel.Text   = ">> ERROR: Data Error!";
                break;

            case S19Line.S19LineError.ChecksumError:
                e.Item.BackColor = System.Drawing.Color.LightCoral;
                infoLabel.Text   = ">> ERROR: Checksum Error!";
                break;

            case S19Line.S19LineError.NoError:
            default:
                e.Item.BackColor = System.Drawing.Color.YellowGreen;
                infoLabel.Text   = ">> Line OK!";
                break;
            }
        }
Exemplo n.º 2
0
 /*********************************************************************/
 /// <summary>
 ///
 /// </summary>
 /// <param name="col"></param>
 /// <param name="row"></param>
 private void UpdateCurrentAddress(OLVColumn col, S19Line row)
 {
 }
Exemplo n.º 3
0
        /*********************************************************************/
        /// <summary>
        /// Called when a cells editing context has completed. If it wasn't cancelled
        /// the update will be performed.
        /// </summary>
        /// <param name="sender">Called of the handler</param>
        /// <param name="e">Cell editing event information</param>
        private void s19ListView_CellEditFinishing(object sender, CellEditEventArgs e)
        {
            /* if the editing was cancelled, return with out any updating (the cell will
             * only hold onto the new value if is gets assigned to the row object) */
            if (e.Cancel)
            {
                return;
            }

            /* get the changed line object and an identifier to which column was changed */
            S19Line   s19line = (S19Line)e.RowObject;
            OLVColumn col     = e.Column;

            /* process the column and the parent row that was changed */
            if (col == instructionColumn)
            {
                try
                {
                    string newValue = Util.RemoveSpaces(e.NewValue.ToString());
                    if (Util.CheckValidSrecInstruction(newValue))
                    {
                        s19line.UpdateLine(S19Line.S19ElementType.Instruction, e.NewValue);
                    }
                    else
                    {
                        ShowWarning("Invalid SRecord Instruction!");
                    }
                }
                catch { ExceptionTrap.Trap("Input Error! (Instruction)"); }
            }
            else if (col == sizeColumn)
            {
                try
                {
                    string newValue = Util.RemoveSpaces(e.NewValue.ToString());
                    if ((Util.CheckStringIsHexOnly(newValue)) &&
                        (Util.CheckStringIsCorrectByteLength(newValue)))
                    {
                        s19line.UpdateLine(S19Line.S19ElementType.Size, e.NewValue);
                    }
                    else
                    {
                        ShowWarning("Invalid HEX byte(s) entered in 'Size'!\n\n - Check all bytes are complete (e.g. '0xAA')\n - Check all characters are Hex (0-F)");
                    }
                }
                catch { ExceptionTrap.Trap("Input Error! (Size)"); }
            }
            else if (col == addressColumn)
            {
                try
                {
                    string newValue = Util.RemoveSpaces(e.NewValue.ToString());
                    if ((Util.CheckStringIsHexOnly(newValue)) &&
                        (Util.CheckStringIsCorrectByteLength(newValue)))
                    {
                        s19line.UpdateLine(S19Line.S19ElementType.Address, e.NewValue);
                    }
                    else
                    {
                        ShowWarning("Invalid HEX byte(s) entered in 'Address'!\n\n - Check all bytes are complete (e.g. '0xAA')\n - Check all characters are Hex (0-F)");
                    }
                }
                catch { ExceptionTrap.Trap("Input Error! (Address)"); }
            }
            else if (col == dataColumn)
            {
                try
                {
                    string newValue = Util.RemoveSpaces(e.NewValue.ToString());
                    if ((Util.CheckStringIsHexOnly(newValue)) &&
                        (Util.CheckStringIsCorrectByteLength(newValue)))
                    {
                        s19line.UpdateLine(S19Line.S19ElementType.Data, newValue);
                    }
                    else
                    {
                        ShowWarning("Invalid HEX byte(s) entered in 'Data'!\n\n - Check all bytes are complete (e.g. '0xAA')\n - Check all characters are Hex (0-F)");
                    }
                }
                catch { ExceptionTrap.Trap("Input Error! (Data)"); }
            }
            else if (col == checksumColumn)
            {
                try
                {
                    string newValue = Util.RemoveSpaces(e.NewValue.ToString());
                    if ((Util.CheckStringIsHexOnly(newValue)) &&
                        (Util.CheckStringIsCorrectByteLength(newValue)))
                    {
                        s19line.UpdateLine(S19Line.S19ElementType.Checksum, e.NewValue);;
                    }
                    else
                    {
                        ShowWarning("Invalid HEX byte(s) entered in 'CSum'!\n\n - Check all bytes are complete (e.g. '0xAA')\n - Check all characters are HEX");
                    }
                }
                catch { ExceptionTrap.Trap(" Input Error! (Checksum)"); }
            }
            else
            { /* should never get here - do nothing! */
            }
        }