コード例 #1
0
        private void SearchResultProcessing(NotifyTaskCompletion <List <APIData> > searchResult, PropertyChangedEventArgs e = null)
        {
            // ... вимикаємо ActivityIndicator
            if (e == null || e.PropertyName == "IsCompleted")
            {
                if (searchResult.IsCompleted)
                {
                    ActivityIndicatorOff();
                }
            }

            // ... обробляємо помилки, якщо вони є
            if (e == null || e.PropertyName == "IsFaulted")
            {
                if (searchResult.ErrorMessage != null)
                {
                    searchBar.Unfocus();
                    Text             = null;
                    OutputDataObject = null;

                    ErrorMessage = searchResult.ErrorMessage;

                    return;
                }
            }

            // ... виводимо результат пошуку у вигляді списку
            if (e == null || e.PropertyName == "Result")
            {
                dropDownList.ItemsSource = searchResult.Result;
            }
        }
コード例 #2
0
        NotifyTaskCompletion <List <APIData> > Search(string queryTemplate, int id, string inputText)
        {
            var encodedInputText = WebUtility.UrlEncode(inputText.Replace("'", "''"));
            var query            = string.Format(queryTemplate, encodedInputText, id);
            var serchResult      = new NotifyTaskCompletion <List <APIData> >(InternetHelper.LoadControlsDataAsync <APIData>(query));

            return(serchResult);
        }
コード例 #3
0
        // При отриманны результату пошуку...
        private static void OnSearchResultChanged(BindableObject bindable, object oldValue, object newValue)
        {
            ImproveSearchBar control = (ImproveSearchBar)bindable;
            NotifyTaskCompletion <List <APIData> > searchResult = (NotifyTaskCompletion <List <APIData> >)newValue;

            // ...очищаємо можливе повідомлення про помилку з минулого пошуку
            control.ErrorMessage = null;

            searchResult.PropertyChanged += control.OnSearchResultPropertyChanged;
            control.SearchResultProcessing(searchResult);
        }
コード例 #4
0
ファイル: AppVM.cs プロジェクト: KnuazLich/TestTask
 public AppVM(ICommandsMethods commandsMethods)
 {
     DellComand     = new NotifyTaskCompletion <int>(MyStaticService.DoNothing());
     this.close     = commandsMethods.DoCloseWindowCommand;
     chekRemoveBook = commandsMethods.ChekSelected;
     newAdd         = commandsMethods.DoAddBookCommand;
     changeBook     = commandsMethods.DoChangeCommand;
     give           = commandsMethods.DoGiveCommand;
     chekGiveBook   = commandsMethods.ChekGiveAllowed;
     take_away      = commandsMethods.DoReturnCommand;
     chekNail       = commandsMethods.ChekReturnAllowed;
     chuse          = commandsMethods.DoChuseGivenBooksCommand;
     using (AppContext db = new AppContext())
     {
         Books = new ObservableCollection <Book>(db.Books.ToList());
     }
 }
コード例 #5
0
        private async Task ChooseState(NotifyTaskCompletion <List <APIData> > stateSource)
        {
            if (Conditions == null && Conditions?.Count == 0)
            {
                return;
            }

            if (stateSource.IsFaulted)
            {
                if (ErrorMessage != stateSource.ErrorMessage)
                {
                    ErrorMessage = stateSource.ErrorMessage;
                }
                await ShowState("Error");
            }
            else if (stateSource.IsNotCompleted)
            {
                await ShowState("Loading");
            }
            else
            {
                await ShowState("Normal");
            }
        }
コード例 #6
0
 private void LoadRegions()
 {
     Regions = new NotifyTaskCompletion <List <APIData> >(InternetHelper.LoadControlsDataAsync <APIData>(_urlAPIRegions));
 }