Ejemplo n.º 1
0
        /*********************************************************************/
        /// <summary>
        ///
        /// </summary>
        public void UpdateView()
        {
            try
            {
                s19ListView.SetObjects(_S19Record.SRecordLines);

                /* set the address length to display */
                int addrDispLen = (int)((_S19Record.MaxAddressLength / 8) * 2);
                addressColumn.AspectToStringFormat = "{0:X" + addrDispLen.ToString() + "}";
            }
            catch
            {
                ExceptionTrap.Trap("Error Displaying S19 File!!");
            }
        }
Ejemplo n.º 2
0
        /*********************************************************************/
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lineNumberBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            SRecordView activeDoc = (SRecordView)dockPanel.ActiveDocument;

            if (activeDoc != null)
            {
                if (e.KeyChar == '\r')
                {
                    try
                    {
                        int num = System.Convert.ToInt32(lineNumberBox.Text);
                        activeDoc.GoToLine(num);
                        lineNumberBox.Visible = false;
                    }
                    catch
                    {
                        ExceptionTrap.Trap("Error with line number entered!");
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /*********************************************************************/
        /// <summary>
        ///
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="newFile"></param>
        public SRecordView(string filename, bool newFile)
        {
            InitializeComponent();

            try
            {
                FileInfo info = new FileInfo(filename);
                _S19Record = new S19(filename, newFile);
                this.Text  = info.Name;
                //SRecordizer.LogIt(LogView.LogType.Info, "Loaded \'" + filename + "\'...");

                /* set highlighted row style */
                RowBorderDecoration rbd = new RowBorderDecoration();
                rbd.BorderPen     = new Pen(Color.DarkOliveGreen, 1);
                rbd.BoundsPadding = new Size(0, -1);

                s19ListView.SelectedRowDecoration = rbd;
            }
            catch
            {
                ExceptionTrap.Trap("Error Parsing S19 File!!");
            }
        }
Ejemplo n.º 4
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! */
            }
        }