Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
-add: search by parsed fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeromusXYZ committed May 12, 2019
1 parent b5f4e7d commit fdbb55b
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 92 deletions.
7 changes: 6 additions & 1 deletion MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,11 @@ private void MmSearchSearch_Click(object sender, EventArgs e)
return;
using (SearchForm SearchDlg = new SearchForm())
{
if (tp.PL.IsPreParsed == false)
{
searchParameters.SearchByParsedData = false;
SearchDlg.gbSearchByField.Enabled = false;
}
SearchDlg.searchParameters.CopyFrom(this.searchParameters);
var res = SearchDlg.ShowDialog();
if ((res == DialogResult.OK) || (res == DialogResult.Retry))
Expand Down Expand Up @@ -1191,7 +1196,7 @@ private void TcPackets_ControlRemoved(object sender, ControlEventArgs e)
{
PacketTabPage tp = (e.Control as PacketTabPage);
tp.SaveProjectFile();
if ((CurrentPP != null) && (tp.GetSelectedPacket().PP == CurrentPP))
if ((CurrentPP != null) && (tp.GetSelectedPacket().PP != null) && (tp.GetSelectedPacket().PP == CurrentPP))
{
CurrentPP = null;
dGV.Rows.Clear();
Expand Down
20 changes: 20 additions & 0 deletions PacketDefs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,26 @@ public bool MatchesSearch(SearchParameters p)
}
}

if ((res) && (PP != null) && (p.SearchByParsedData) && (p.SearchParsedFieldValue != string.Empty))
{
res = false;
foreach(var f in PP.ParsedView)
{
if (p.SearchParsedFieldName != string.Empty)
{
// Field Name Specified
res = ((f.Var.ToLower().IndexOf(p.SearchParsedFieldName) >= 0) && (f.Data.ToLower().IndexOf(p.SearchParsedFieldValue) >= 0));
}
else
{
// No field name defined
res = (f.Data.ToLower().IndexOf(p.SearchParsedFieldValue) >= 0);
}
if (res)
break;
}
}

return res;
}

Expand Down
2 changes: 2 additions & 0 deletions PacketParsers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public class PacketParser

static protected void AddFieldNameToList(string fieldName)
{
if (fieldName.StartsWith("??"))
return;
if (AllFieldNames.IndexOf(fieldName) < 0)
AllFieldNames.Add(fieldName);
}
Expand Down
180 changes: 90 additions & 90 deletions SearchForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion SearchForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void ValidateFields()
eValue.ForeColor = Color.DarkGray;
}

if ((cbFieldNames.Text != string.Empty) && (eFieldValue.Text != string.Empty))
if (eFieldValue.Text != string.Empty)
{
hasData = true;
searchParameters.SearchByParsedData = true;
Expand Down

0 comments on commit fdbb55b

Please sign in to comment.