Beispiel #1
0
        private int ValForID(string s)
        {
            if (s == string.Empty)
            {
                return(0);
            }
            int res = 0;

            char[] splitchars = new char[1] {
                '-'
            };
            var fields = s.Split(splitchars, 2);

            if (fields.Length >= 1)
            {
                if (DataLookups.TryFieldParse(fields[0].Trim(' '), out int n))
                {
                    res = n;
                }
            }
            return(res);
        }
Beispiel #2
0
        private void ValidateFields()
        {
            bool isValid = true;
            bool hasData = false;

            if (isValidating)
            {
                return;
            }
            isValidating = true;

            // Packet directions
            searchParameters.SearchIncoming = (rbAny.Checked || rbIncoming.Checked);
            searchParameters.SearchOutgoing = (rbAny.Checked || rbOutgoing.Checked);

            // Make sure no search options are on before validating
            searchParameters.SearchByPacketID       = false;
            searchParameters.SearchBySync           = false;
            searchParameters.SearchByByte           = false;
            searchParameters.SearchByUInt16         = false;
            searchParameters.SearchByUInt32         = false;
            searchParameters.SearchByParsedData     = false;
            searchParameters.SearchParsedFieldName  = string.Empty;
            searchParameters.SearchParsedFieldValue = string.Empty;

            // PacketID
            if (DataLookups.TryFieldParse(ePacketID.Text, out int nPacketID))
            {
                if ((nPacketID > 0) && (nPacketID < 0x1FF))
                {
                    hasData = true;
                    searchParameters.SearchByPacketID = true;
                    searchParameters.SearchPacketID   = (UInt16)nPacketID;
                    ePacketID.ForeColor = Color.Blue;
                }
                else
                {
                    ePacketID.ForeColor = Color.Red;
                }
            }
            else
            {
                ePacketID.ForeColor = Color.DarkGray;
            }

            // Sync
            if (DataLookups.TryFieldParse(eSync.Text, out int nSync))
            {
                if ((nSync > 0) && (nSync < 0xFFFF))
                {
                    hasData = true;
                    searchParameters.SearchBySync = true;
                    searchParameters.SearchSync   = (UInt16)nSync;
                    eSync.ForeColor = Color.Blue;
                }
                else
                {
                    eSync.ForeColor = Color.Red;
                }
            }
            else
            {
                eSync.ForeColor = Color.DarkGray;
            }

            // Value
            if (DataLookups.TryFieldParseUInt64(eValue.Text, out UInt64 nValue))
            {
                // Check the correct type
                if ((nValue > 0xFFFF) && (rbByte.Checked || rbUInt16.Checked))
                {
                    rbUInt32.Checked = true;
                }
                else
                if ((nValue > 0xFF) && (rbByte.Checked))
                {
                    rbUInt16.Checked = true;
                }

                if ((nValue >= 0) && (nValue <= 0xFF) && (rbByte.Checked))
                {
                    hasData = true;
                    searchParameters.SearchByByte   = true;
                    searchParameters.SearchByUInt16 = false;
                    searchParameters.SearchByUInt32 = false;
                    searchParameters.SearchByte     = (byte)nValue;
                    eValue.ForeColor = Color.Navy;
                }
                else
                if ((nValue >= 0) && (nValue <= 0xFFFF) && (rbUInt16.Checked))
                {
                    hasData = true;
                    searchParameters.SearchByByte   = false;
                    searchParameters.SearchByUInt16 = true;
                    searchParameters.SearchByUInt32 = false;
                    searchParameters.SearchUInt16   = (UInt16)nValue;
                    eValue.ForeColor = Color.RoyalBlue;
                }
                else
                if ((nValue >= 0) && (nValue <= 0xFFFFFFFF) && (rbUInt32.Checked))
                {
                    hasData = true;
                    searchParameters.SearchByByte   = false;
                    searchParameters.SearchByUInt16 = false;
                    searchParameters.SearchByUInt32 = true;
                    searchParameters.SearchUInt32   = (UInt32)nValue;
                    eValue.ForeColor = Color.Blue;
                }
                else
                {
                    rbByte.Checked   = true;
                    eValue.ForeColor = Color.Red;
                }
            }
            else
            {
                rbByte.Checked   = true;
                eValue.ForeColor = Color.DarkGray;
            }

            if (eFieldValue.Text != string.Empty)
            {
                hasData = true;
                searchParameters.SearchByParsedData     = true;
                searchParameters.SearchParsedFieldName  = cbFieldNames.Text.ToLower();
                searchParameters.SearchParsedFieldValue = eFieldValue.Text.ToLower();
            }

            if ((!isValid) || (!hasData))
            {
                searchParameters.Clear();
            }
            btnFindNext.Enabled = isValid && hasData;
            btnAsNewTab.Enabled = isValid && hasData;
            isValidating        = false;
        }