public NTextSearchPresenter(ITextSearchView view, string folderName){ View = view; SetFolderName(folderName); _notificationHandlers = InitTextSearchNotifyHandlers(); _engine = InitEngine(); _searchEngineWorker = InitSearchEngineWorker(); }
private void OnCommandMemberSearch(object sender, System.EventArgs e) { ITextSearchModel model = base._model as ITextSearchModel; ITextSearchView view = base._view as ITextSearchView; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); // notify view to mark start of process if (SyncContext != null) { SyncContext.Post(delegate { presenter.EnableControl(false); presenter.ActivateSpinner(true); presenter.UpdateProgressInfo("Processing..."); }, null); } // TODO: to improve stability, we will need to ensure to kill // thread when user exits application while thread is running for REST service call Thread memberSearch = new Thread(() => { if (string.IsNullOrEmpty(model.QueryString)) { SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.MISSING_QUERYSTRING, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } else if (string.IsNullOrEmpty(model.AccessToken)) { SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.INVALID_TOKEN, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } else { // perform search this.SearchMembers(model); if (SyncContext != null) { SyncContext.Post(delegate { // update result and update view. view.RenderMembersSearchResult(); presenter.UpdateProgressInfo("Completed"); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } } }); // start async search memberSearch.Start(); }
private void OnDataChanged(object sender, System.EventArgs e) { ITextSearchView view = base._view as ITextSearchView; ITextSearchModel model = base._model as ITextSearchModel; PresenterBase.SetModelPropertiesFromView <ITextSearchModel, ITextSearchView>( ref model, view ); }
protected override void UnWireViewEvents() { if (IsViewEventsWired) { // TODO // Unwire events ITextSearchView view = base._view as ITextSearchView; view.DataChanged -= OnDataChanged; view.CommandMemberSearch -= OnCommandMemberSearch; view.CommandClear -= OnCommandClear; IsViewEventsWired = false; } }
protected override void WireViewEvents() { if (!IsViewEventsWired) { // TODO: // Wire up events ITextSearchView view = base._view as ITextSearchView; view.DataChanged += OnDataChanged; view.CommandMemberSearch += OnCommandMemberSearch; view.CommandClear += OnCommandClear; IsViewEventsWired = true; } }
protected override void Initialize() { // read data from model ITextSearchView view = base._view as ITextSearchView; ITextSearchModel model = base._model as ITextSearchModel; PresenterBase.SetViewPropertiesFromModel <ITextSearchView, ITextSearchModel>( ref view, model ); SyncContext.Post(delegate { view.RefreshAccessToken(); view.RenderSearchModeSelections(); view.SetSearchResultLimit(model.SearchResultsLimit); }, null); }
private void OnCommandClear(object sender, EventArgs e) { ITextSearchModel model = base._model as ITextSearchModel; ITextSearchView view = base._view as ITextSearchView; IMainPresenter presenter = SimpleResolver.Instance.Get <IMainPresenter>(); model.QueryString = string.Empty; model.SelectedSearchMode = TextSearchModel.TextSearchMode.Filename_only.ToString(); model.SearchResultsLimit = ApplicationResource.SearchDefaultLimit; model.MemberList = new List <MemberListViewItemModel>(); PresenterBase.SetViewPropertiesFromModel <ITextSearchView, ITextSearchModel>( ref view, model ); if (SyncContext != null) { SyncContext.Post(delegate { view.RenderComponents(); }, null); } }
public TextSearchPresenter(ITextSearchModel model, ITextSearchView view) : base(model, view) { }