Skip to content

Commit

Permalink
improvefiltering
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorBanai committed Sep 17, 2023
1 parent 85a2113 commit c3afaea
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions Analogy.CommonControls/UserControls/LogMessagesUC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -400,13 +400,13 @@ private async void LogMessagesUC_Load(object sender, EventArgs e)
Settings.ModuleText = string.Empty;
}
string? includeText = string.IsNullOrEmpty(Settings.IncludeText) || Settings.IncludeText == txtbInclude.Properties.NullText ? null : Settings.IncludeText;
txtbInclude.Text = includeText;
SetTextIfDifferent(txtbInclude, includeText);
string? excludeText = string.IsNullOrEmpty(Settings.ExcludeText) || Settings.ExcludeText == txtbExclude.Properties.NullText ? null : Settings.ExcludeText;
txtbExclude.Text = excludeText;
SetTextIfDifferent(txtbExclude, excludeText);
string? source = string.IsNullOrEmpty(Settings.SourceText) || Settings.SourceText == txtbSource.Properties.NullText ? null : Settings.SourceText;
txtbSource.Text = source;
SetTextIfDifferent(txtbSource, source);
string? module = string.IsNullOrEmpty(Settings.ModuleText) || Settings.ModuleText == txtbModule.Properties.NullText ? null : Settings.ModuleText;
txtbModule.Text = module;
SetTextIfDifferent(txtbModule, module);

if (!string.IsNullOrEmpty(includeText) || !string.IsNullOrEmpty(excludeText) ||
!string.IsNullOrEmpty(source) || !string.IsNullOrEmpty(module))
Expand All @@ -419,7 +419,11 @@ private async void LogMessagesUC_Load(object sender, EventArgs e)
{
if (arg.ButtonName == btn1.Name)
{
txtbInclude.Text = txtbExclude.Text = txtbSource.Text = txtbModule.Text = null;
string? text = null;
SetTextIfDifferent(txtbInclude, text);
SetTextIfDifferent(txtbExclude, text);
SetTextIfDifferent(txtbSource, text);
SetTextIfDifferent(txtbModule, text);
ceIncludeText.Checked = ceExcludeText.Checked =
ceModulesProcess.Checked = ceSources.Checked = false;
}
Expand All @@ -435,6 +439,13 @@ private async void LogMessagesUC_Load(object sender, EventArgs e)
LogGrid.Columns[DataGridDateColumnName].SortOrder = Settings.DefaultDescendOrder ? ColumnSortOrder.Descending : ColumnSortOrder.Ascending;
}

private void SetTextIfDifferent(TextEdit control, string? text)
{
if (!control.Text.Equals(text))
{
control.Text = text;
}
}
private void HideColumns()
{
//first restore all
Expand Down Expand Up @@ -781,9 +792,11 @@ private void SetupEventsHandlers()
{
return;
}
Settings.IncludeText = txtbInclude.Text;
//Settings.IncludeText = Settings.SaveSearchFilters && txtbInclude.EditValue != null ? txtbInclude.EditValue.ToString() : string.Empty;
//Settings.ExcludeText = Settings.SaveSearchFilters && txtbExclude.EditValue != null ? txtbExclude.EditValue.ToString() : string.Empty;

OldTextInclude = txtbInclude.Text;
// txtbHighlight.Text = txtbInclude.Text;
if (string.IsNullOrEmpty(txtbInclude.Text))
{
ceIncludeText.Checked = false;
Expand Down Expand Up @@ -1698,7 +1711,8 @@ private async void tsmiInclude_Click(object sender, EventArgs e)
{
string include = ef.MessageText;

txtbInclude.Text = txtbInclude.Text == txtbInclude.Properties.NullText ? include : txtbInclude.Text + "|" + include;
var text = txtbInclude.Text == txtbInclude.Properties.NullText ? include : txtbInclude.Text + "|" + include;
SetTextIfDifferent(txtbInclude, text);
ceIncludeText.Checked = true;
await FilterHasChanged();
}
Expand Down Expand Up @@ -2140,22 +2154,22 @@ private void FilterResults()
{
if (txtbInclude.Text == txtbInclude.Properties.NullText)
{
txtbInclude.Text = null;
SetTextIfDifferent(txtbInclude, null);
}

if (txtbExclude.Text == txtbExclude.Properties.NullText)
{
txtbExclude.Text = null;
SetTextIfDifferent(txtbExclude, null);
}

if (txtbSource.Text == txtbSource.Properties.NullText)
{
txtbSource.Text = null;
SetTextIfDifferent(txtbSource, null);
}

if (txtbModule.Text == txtbModule.Properties.NullText)
{
txtbModule.Text = null;
SetTextIfDifferent(txtbModule, null);
}

string include = txtbInclude.EditValue == null ? string.Empty : txtbInclude.EditValue.ToString().Trim();
Expand All @@ -2179,9 +2193,6 @@ private void FilterResults()
? (txtbExclude.EditValue == null ? string.Empty : txtbExclude.EditValue.ToString().Trim()) + string.Join("|", _excludeMostCommon)
: string.Empty;

Settings.IncludeText = Settings.SaveSearchFilters && txtbInclude.EditValue != null ? txtbInclude.EditValue.ToString() : string.Empty;
Settings.ExcludeText = Settings.SaveSearchFilters && txtbExclude.EditValue != null ? txtbExclude.EditValue.ToString() : string.Empty;

_filterCriteria.Levels = null;
switch (LogLevelSelectionType)
{
Expand Down Expand Up @@ -3593,23 +3604,24 @@ private void UndockViewPerProcess()

private void sbtnTextInclude_Click(object sender, EventArgs e)
{
txtbInclude.Text = "";
SetTextIfDifferent(txtbInclude, "");
}

private void sbtnTextExclude_Click(object sender, EventArgs e)
{
txtbExclude.Text = "";
SetTextIfDifferent(txtbExclude, "");

}

private void sbtnIncludeSources_Click(object sender, EventArgs e)
{
txtbSource.Text = "";
SetTextIfDifferent(txtbSource, "");
}


private void sbtnIncludeModules_Click(object sender, EventArgs e)
{
txtbModule.Text = "";
SetTextIfDifferent(txtbModule, "");
}

private void tsmiDateFilterNewer_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -3662,10 +3674,10 @@ private void sbtnPreDefinedFilters_Click(object sender, EventArgs e)
BarButtonItem item = new BarButtonItem(barManager1, filter.ToString());
item.ItemClick += (s, arg) =>
{
txtbInclude.Text = filter.IncludeText;
txtbExclude.Text = filter.ExcludeText;
txtbSource.Text = filter.Sources;
txtbModule.Text = filter.Modules;
SetTextIfDifferent(txtbInclude, filter.IncludeText);
SetTextIfDifferent(txtbExclude, filter.ExcludeText);
SetTextIfDifferent(txtbSource, filter.Sources);
SetTextIfDifferent(txtbModule, filter.Modules);
};
item.SuperTip = Utils.GetSuperTip(filter.Name, filter.NiceText());
filtersPopupMenu.ItemLinks.Add(item);
Expand Down

0 comments on commit c3afaea

Please sign in to comment.