Esempio n. 1
0
 public NTextSearchPresenter(ITextSearchView view, string folderName){
     View = view;
     SetFolderName(folderName);
     _notificationHandlers = InitTextSearchNotifyHandlers();
     _engine = InitEngine();
     _searchEngineWorker = InitSearchEngineWorker();
 }
Esempio n. 2
0
        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();
        }
Esempio n. 3
0
        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
                );
        }
Esempio n. 4
0
 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;
     }
 }
Esempio n. 5
0
 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;
     }
 }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
 public TextSearchPresenter(ITextSearchModel model, ITextSearchView view)
     : base(model, view)
 {
 }
 public TextSearchPresenter(ITextSearchModel model, ITextSearchView view)
     : base(model, view) {
 }