Пример #1
0
        private void View_Poll(object sender, EventArgs e)
        {
            if (_queryEvaluator != null)
            {
                View.Items    = _queryEvaluator.Update();
                View.ItemSize = CurrentItemSize;
                View.UpdateItems();

                // update query evaluation status
                if (StatusLabel != null)
                {
                    var loadingPath = _queryEvaluator.Progress.LoadingPath;
                    var loadedCount = _queryEvaluator.Progress.FileCount;
                    StatusLabel.Text = loadingPath != null?
                                       string.Format(Strings.Loading_Message, loadedCount, loadingPath) :
                                           Strings.Done_Label;
                }

                // update item count
                if (ItemCountLabel != null)
                {
                    var itemCount = View.Items.Sum(pair => pair.Items.Count);
                    ItemCountLabel.Text = itemCount.ToString("N0") + " " + Strings.ItemCount_Label;
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Execute given query and show all entities in the result.
        /// </summary>
        /// <param name="query">Query to show</param>
        public async Task LoadQueryAsync(IExecutableQuery query)
        {
            // release all resources used by the previous query
            DisposeQuery();

            _selection.Clear();

            // start the query
            _queryEvaluator = _queryEvaluatorFactory.Create(query);
            View.Query      = _queryEvaluator.Query.Text;
            View.Items      = _queryEvaluator.Update();
            View.History.CanGoBackInHistory    = _queryHistory.Previous != null;
            View.History.CanGoForwardInHistory = _queryHistory.Next != null;
            View.BeginLoading();
            View.BeginPolling(PollingRate);

            try
            {
                await _queryEvaluator.RunAsync();

                if (!_isDisposed)
                {
                    View.UpdateItems();
                }
            }
            catch (OperationCanceledException)
            {
            }
            finally
            {
                if (!_isDisposed)
                {
                    View.EndLoading();
                }
            }
        }