public void SetFilter(LogViewerFilter filter) { if( _navigationTrack != null && _navigationTrack.CurrentTab != null //there is a back navigation stack setup && filter != _navigationTrack.CurrentTab //we are not doing a Back operation ) _navigationTrack.CurrentTab.Tag = tbContentFilter.Text; //Since user is making a new navigation to a new location, record the current text filter to preserve it for Back operations. Filter = filter; //push the old filter if(_navigationTrack != null) _navigationTrack.Append(Filter); if(_back != null) _back.Enabled = _navigationTrack.CanBack(); if (filter.IsEmpty) panel1.Controls.Remove(pFilter); else { panel1.Controls.Add(pFilter); lblCurrentFilter.Text = filter.ToString(); } FetchDataTable(); //clear/restore the current user entered text filter tbContentFilter.Text = filter.Tag as string ?? ""; }
public override void SetDatabaseObject(IActivateItems activator, ExternalDatabaseServer databaseObject) { base.SetDatabaseObject(activator, databaseObject); if (_navigationTrack == null) { //what happens when user clicks back/forward _navigationTrack = new NavigationTrack <LogViewerFilter>(f => true, f => { if (f.LoggingTable != LoggingTables.None) { var cmd = new ExecuteCommandViewLoggedData(activator, f); cmd.Execute(); } }); //set the initial filter _navigationTrack.Append(Filter); _back = new ToolStripButton("Back", FamFamFamIcons.Back, (s, e) => _navigationTrack.Back(true)) { DisplayStyle = ToolStripItemDisplayStyle.Image }; } CommonFunctionality.Add(_back); CommonFunctionality.Add(label1); CommonFunctionality.Add(tbContentFilter); CommonFunctionality.Add(label2); CommonFunctionality.Add(tbTop); CommonFunctionality.Add(cbPreferNewer); if (!databaseObject.DiscoverExistence(DataAccessContext.Logging, out string reason)) { activator.KillForm(ParentForm, "Database " + databaseObject + " did not exist:" + reason); return; } LogManager = new LogManager(databaseObject); FetchDataTable(); }