void IPresenter.Show(string initialSearchString) { if (!isVisible) { isVisible = true; changeNotification.Post(); } searchBox.Focus(initialSearchString); }
public Presenter( ILogSourcesManager logSourcesManager, IChangeNotification changeNotification, IView view, Preprocessing.IManager sourcesPreprocessingManager, Preprocessing.IStepsFactory preprocessingStepsFactory, MRU.IRecentlyUsedEntities mru, QuickSearchTextBox.IPresenter searchBoxPresenter, IAlertPopup alerts, ITraceSourceFactory traceSourceFactory ) { this.view = view; this.changeNotification = changeNotification; this.logSourcesManager = logSourcesManager; this.sourcesPreprocessingManager = sourcesPreprocessingManager; this.preprocessingStepsFactory = preprocessingStepsFactory; this.mru = mru; this.searchBoxPresenter = searchBoxPresenter; this.trace = traceSourceFactory.CreateTraceSource("UI", "hist-dlg"); this.alerts = alerts; items = Selectors.Create(() => visible, () => acceptedFilter, MakeItems); actuallySelected = Selectors.Create(() => items().displayItems, () => selected, (items, selected) => items.SelectMany(i => i.Flatten()).Where(i => selected.Contains(i.key)).ToImmutableList()); openButtonEnabled = Selectors.Create(actuallySelected, selected => selected.Any(IsOpenable)); rootViewItem = Selectors.Create(() => items().displayItems, () => selected, () => expanded, MakeRootItem); searchBoxPresenter.OnSearchNow += (s, e) => { acceptedFilter = searchBoxPresenter.Text; FocusItemsListAndSelectFirstItem(); changeNotification.Post(); }; searchBoxPresenter.OnRealtimeSearch += (s, e) => { acceptedFilter = searchBoxPresenter.Text; changeNotification.Post(); }; searchBoxPresenter.OnCancelled += (s, e) => { if (acceptedFilter != "") { acceptedFilter = ""; searchBoxPresenter.Focus(null); } else { visible = false; } changeNotification.Post(); }; view.SetViewModel(this); }
public Presenter( ILogSourcesManager logSourcesManager, IView view, Preprocessing.IManager sourcesPreprocessingManager, Preprocessing.IStepsFactory preprocessingStepsFactory, MRU.IRecentlyUsedEntities mru, QuickSearchTextBox.IPresenter searchBoxPresenter, IAlertPopup alerts, ITraceSourceFactory traceSourceFactory ) { this.view = view; this.logSourcesManager = logSourcesManager; this.sourcesPreprocessingManager = sourcesPreprocessingManager; this.preprocessingStepsFactory = preprocessingStepsFactory; this.mru = mru; this.searchBoxPresenter = searchBoxPresenter; this.trace = traceSourceFactory.CreateTraceSource("UI", "hist-dlg"); this.alerts = alerts; searchBoxPresenter.OnSearchNow += (s, e) => { UpdateItems(); FocusItemsListAndSelectFirstItem(); }; searchBoxPresenter.OnRealtimeSearch += (s, e) => UpdateItems(); searchBoxPresenter.OnCancelled += (s, e) => { if (itemsFiltered) { UpdateItems(); searchBoxPresenter.Focus(null); } else { view.Hide(); } }; view.SetEventsHandler(this); }