Skip to content

Commit f0f559f

Browse files
committed
ref #654
1 parent a4c420f commit f0f559f

File tree

2 files changed

+59
-26
lines changed

2 files changed

+59
-26
lines changed

Analogy/Properties/licenses.licx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v19.1, Version=19.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
2+
DevExpress.XtraEditors.TextEdit, DevExpress.XtraEditors.v19.1, Version=19.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
3+
DevExpress.XtraBars.BarManager, DevExpress.XtraBars.v19.1, Version=19.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
4+
DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v19.1, Version=19.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a
5+
DevExpress.XtraEditors.DateEdit, DevExpress.XtraEditors.v19.1, Version=19.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a

Analogy/UserControls/UCLogs.cs

+54-26
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
using System.Windows.Forms;
2929
using Analogy.DataTypes;
3030
using Analogy.Forms;
31+
using ChangeEventArgs = DevExpress.XtraEditors.Controls.ChangeEventArgs;
3132

3233
namespace Analogy
3334
{
@@ -209,24 +210,21 @@ private void UCLogs_Load(object sender, EventArgs e)
209210
}
210211
});
211212

212-
LogGrid.RowCountChanged += (s, arg) =>
213-
{
214-
if (Settings.AutoScrollToLastMessage && !IsDisposed)
215-
{
216-
BeginInvoke(new MethodInvoker(() =>
217-
{
218-
LogGrid.MoveLast();
219-
LogGrid.MakeRowVisible(LogGrid.FocusedRowHandle);
220-
}));
221-
222-
}
223-
};
213+
224214

225215

226216
gridControl.DataSource = _messageData.DefaultView;
227217
_bookmarkedMessages = Utils.DataTableConstructor();
228218
gridControlBookmarkedMessages.DataSource = _bookmarkedMessages;
229219

220+
if (Settings.SaveSearchFilters)
221+
{
222+
txtbInclude.Text = string.IsNullOrEmpty(Settings.IncludeText) || Settings.IncludeText == txtbInclude.Properties.NullText ? null : Settings.IncludeText;
223+
txtbExclude.Text = string.IsNullOrEmpty(Settings.ExcludeText) || Settings.ExcludeText == txtbExclude.Properties.NullText ? null : Settings.ExcludeText; ;
224+
txtbSource.Text = string.IsNullOrEmpty(Settings.SourceText) || Settings.SourceText == txtbSource.Properties.NullText ? null : Settings.SourceText;
225+
txtbModule.Text = string.IsNullOrEmpty(Settings.ModuleText) || Settings.ModuleText == txtbModule.Properties.NullText ? null : Settings.ModuleText;
226+
}
227+
230228
gridControl.Focus();
231229
}
232230
private void rgSearchMode_SelectedIndexChanged(object s, EventArgs e)
@@ -286,6 +284,19 @@ private void SetupEventsHandlers()
286284
bbiDatetiemFilterFrom.ItemClick += tsmiDateFilterNewer_Click;
287285
#endregion
288286

287+
LogGrid.RowCountChanged += (s, arg) =>
288+
{
289+
if (Settings.AutoScrollToLastMessage && !IsDisposed)
290+
{
291+
BeginInvoke(new MethodInvoker(() =>
292+
{
293+
LogGrid.MoveLast();
294+
LogGrid.MakeRowVisible(LogGrid.FocusedRowHandle);
295+
}));
296+
297+
}
298+
};
299+
289300
gridControl.KeyUp += (s, e) =>
290301
{
291302
Keys excludeModifier = e.KeyCode & ~Keys.Control & ~Keys.Shift & ~Keys.Alt;
@@ -407,9 +418,15 @@ private void SetupEventsHandlers()
407418

408419
}
409420
};
421+
422+
txtbInclude.EditValueChanged += EditValueChanged;
423+
txtbExclude.EditValueChanged += EditValueChanged;
424+
txtbSource.EditValueChanged += EditValueChanged;
425+
txtbModule.EditValueChanged += EditValueChanged;
410426
txtbInclude.TextChanged += async (s, e) =>
411427
{
412-
if (OldTextInclude.Equals(txtbInclude.Text))
428+
if (OldTextInclude.Equals(txtbInclude.Text) ||
429+
txtbInclude.Text.Equals(txtbInclude.Properties.NullText))
413430
{
414431
return;
415432
}
@@ -419,6 +436,7 @@ private void SetupEventsHandlers()
419436
if (string.IsNullOrEmpty(txtbInclude.Text))
420437
{
421438
ceIncludeText.Checked = false;
439+
txtbInclude.EditValue = null;
422440
return;
423441
}
424442

@@ -441,7 +459,8 @@ private void SetupEventsHandlers()
441459
};
442460
txtbExclude.TextChanged += async (s, e) =>
443461
{
444-
if (OldTextExclude.Equals(txtbExclude.Text))
462+
if (OldTextExclude.Equals(txtbExclude.Text)||
463+
txtbExclude.Text.Equals(txtbExclude.Properties.NullText))
445464
{
446465
return;
447466
}
@@ -451,6 +470,7 @@ private void SetupEventsHandlers()
451470
if (string.IsNullOrEmpty(txtbExclude.Text))
452471
{
453472
ceExcludeText.Checked = false;
473+
txtbExclude.EditValue = null;
454474
return;
455475
}
456476

@@ -460,9 +480,11 @@ private void SetupEventsHandlers()
460480

461481
txtbSource.TextChanged += async (s, e) =>
462482
{
463-
if (string.IsNullOrEmpty(txtbSource.Text))
483+
if (string.IsNullOrEmpty(txtbSource.Text) ||
484+
txtbSource.Text.Equals(txtbSource.Properties.NullText))
464485
{
465486
ceSources.Checked = false;
487+
txtbSource.EditValue = null;
466488
}
467489
else
468490
{
@@ -478,9 +500,11 @@ private void SetupEventsHandlers()
478500

479501
txtbModule.TextChanged += async (s, e) =>
480502
{
481-
if (string.IsNullOrEmpty(txtbModule.Text))
503+
if (string.IsNullOrEmpty(txtbModule.Text) ||
504+
txtbModule.Text.Equals(txtbModule.Properties.NullText))
482505
{
483506
ceModulesProcess.Checked = false;
507+
txtbModule.EditValue = null;
484508
}
485509
else
486510
{
@@ -505,6 +529,16 @@ private void SetupEventsHandlers()
505529

506530
}
507531

532+
private void EditValueChanged(object sender, EventArgs e)
533+
{
534+
535+
if (sender is BaseEdit edit && e is ChangingEventArgs change && change.NewValue == string.Empty)
536+
{
537+
edit.EditValue = null;
538+
}
539+
}
540+
541+
508542
private void MainView_Layout(object sender, EventArgs e)
509543
{
510544
try
@@ -867,15 +901,6 @@ private void LoadUISettings()
867901
gridControl.MainView.RestoreLayoutFromXml(Settings.LogGridFileName);
868902
gridControlBookmarkedMessages.MainView.RestoreLayoutFromXml(Settings.LogGridFileName);
869903
}
870-
871-
if (Settings.SaveSearchFilters)
872-
{
873-
txtbInclude.Text = Settings.IncludeText;
874-
txtbExclude.Text = Settings.ExcludeText;
875-
txtbSource.Text = Settings.SourceText;
876-
txtbModule.Text = Settings.ModuleText;
877-
}
878-
879904
btswitchRefreshLog.Checked = true;
880905
gridColumnCategory.Visible = false;
881906
LogGrid.BestFitColumns();
@@ -1507,7 +1532,7 @@ private void AddExtraColumnsToLogGrid(GridView gridView, AnalogyLogMessage messa
15071532
if (!gridView.Columns.Select(g => g.FieldName).Contains(info.Key))
15081533
{
15091534
gridView.Columns.Add(new GridColumn()
1510-
{ Caption = info.Key, FieldName = info.Key, Name = info.Key, Visible = true });
1535+
{ Caption = info.Key, FieldName = info.Key, Name = info.Key, Visible = true });
15111536
CurrentColumnsFields.Add((info.Key, info.Key));
15121537
IncludeFilterCriteriaUIOptions.Add(new FilterCriteriaUIOption(info.Key, info.Key, false));
15131538
ExcludeFilterCriteriaUIOptions.Add(new FilterCriteriaUIOption(info.Key, info.Key, false));
@@ -1644,6 +1669,7 @@ private void UpdatePage(DataTable page)
16441669

16451670
public void FilterResults(string module)
16461671
{
1672+
if (IsDisposed) return;
16471673
txtbModule.Text = module;
16481674
FilterResults();
16491675
}
@@ -3023,11 +3049,13 @@ private void tsmiAddCommentToMessage_Click(object sender, EventArgs e)
30233049

30243050
private void txtbInclude_KeyPress(object sender, KeyPressEventArgs e)
30253051
{
3052+
if (IsDisposed) return;
30263053
xtcFilters.SelectedTabPage = xtpFiltersIncludes;
30273054
}
30283055

30293056
private void txtbExclude_EditValueChanged(object sender, EventArgs e)
30303057
{
3058+
if (IsDisposed) return;
30313059
xtcFilters.SelectedTabPage = xtpFiltersExclude;
30323060
}
30333061
}

0 commit comments

Comments
 (0)