private void fireSearchStarted(SuggestedDisplaySortMode suggestedSortMode)
 {
     if (SearchStarted != null)
     {
         SearchStarted.Invoke(suggestedSortMode);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Raises the search started event.
 /// </summary>
 /// <param name="e">The event argument.</param>
 protected virtual void OnSearchStarted(EventArgs e)
 {
     if (SearchStarted != null)
     {
         SearchStarted.GetInvocationList().InvokeEventGUIThreadSafe(this, e);
     }
 }
Esempio n. 3
0
        public void SearchForInterfaces()
        {
            _searching = true;
            SearchStarted?.Invoke(this, EventArgs.Empty);

            SearchTxt();
            SearchTx();
        }
Esempio n. 4
0
        public IEnumerable <FileSystemInfo> Search()
        {
            var startFinishEventArgs = new StartFinishEventArgs();

            SearchStarted?.Invoke(this, startFinishEventArgs);
            if (startFinishEventArgs.StopSearch)
            {
                SearchFinished?.Invoke(this, startFinishEventArgs);
                return(new List <FileSystemInfo>());
            }
            var result = GetFileSystemInfo(new DirectoryInfo(_startPath)).ToList();

            SearchFinished?.Invoke(this, startFinishEventArgs);
            return(result);
        }
Esempio n. 5
0
        public FileSystemInfoCustomCollection <CustomFileItem> GetItemsRecursively(FilterMask filterMask)
        {
            isFirstFilteredFileFound = false;

            SearchStarted?.Invoke(this, new EventArgs());
            var output = GetItemsRecursively(DirectoryPath, filterMask);

            SearchFinished?.Invoke(this, new EventArgs());

            if (filterMask.HasFlag(FilterMask.SortByName))
            {
                output.Sort();
            }

            return(output);
        }
Esempio n. 6
0
        public List <string> Search(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("path to directory is not valid");
            }
            SearchStarted?.Invoke();
            var items = new List <string>();

            try
            {
                foreach (var item in GetFiles(path))
                {
                    var itemFoundArgs = new ItemFoundArgs(item);
                    if (Filter(item))
                    {
                        FilteredItemFound?.Invoke(this, itemFoundArgs);
                    }
                    else
                    {
                        ItemFound?.Invoke(this, itemFoundArgs);
                    }
                    if (itemFoundArgs.RemoveItemFromResult && itemFoundArgs.EndSearch)
                    {
                        break;
                    }
                    if (itemFoundArgs.RemoveItemFromResult)
                    {
                        continue;
                    }
                    items.Add(item);
                    if (itemFoundArgs.EndSearch)
                    {
                        break;
                    }
                }
                return(items);
            }
            finally
            {
                SearchFinished?.Invoke();
            }
        }
Esempio n. 7
0
        public async Task <MoveViewer> CpuMove(int maxDepth)
        {
            SearchStarted?.Invoke(this, new EventArgs());

            var searchResults = await Task.Run(() => search.Go(board, CpuColour, maxDepth));

            SearchCompleted?.Invoke(this, new SearchCompleteEventArgs(searchResults));

            var chosenMove = searchResults.MoveEvaluations
                             .OrderByDescending(x => x.Score)
                             .FirstOrDefault();

            if (chosenMove == null)
            {
                return(new MoveViewer(0));
            }

            ApplyMove(board, CpuColour, chosenMove.Move);

            return(chosenMove.Move);
        }
Esempio n. 8
0
 protected void OnSearchStarted(string keyword)
 {
     SearchStarted?.Invoke(keyword);
 }
Esempio n. 9
0
        private async Task SearchAsync()
        {
            if (string.IsNullOrEmpty(mSearchString))
            {
                return;
            }

            if (mSearchTask?.IsCanceled == false && mSearchTask?.IsCompleted == false)
            {
                //Cancel if previous search is running
                await CancelSearchAsync();
            }

            xSearchBtn.Visibility      = Visibility.Collapsed;
            xSearchClearBtn.Visibility = Visibility.Visible;
            mCancellationTokenSource   = new CancellationTokenSource();
            mSearchTask = new Task(() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    try
                    {
                        mCancellationTokenSource.Token.ThrowIfCancellationRequested();

                        if (SearchStarted == null)
                        {
                            //If event is not hooked we say searching status on main window
                            Reporter.ToStatus(eStatusMsgKey.Search, null, ": " + mSearchString);
                        }
                        else
                        {
                            //If event is hookded then no point in showing status on main window.
                            //child window need to handle it in the window. E.g. Windows Explorer
                            SearchStarted.Invoke(Tree, new EventArgs());
                        }
                        Mouse.OverrideCursor = Cursors.Wait;
                        xTreeViewTree.FilterItemsByText(xTreeViewTree.TreeItemsCollection, mSearchString, mCancellationTokenSource.Token);
                    }
                    catch (Exception ex)
                    {
                        Reporter.ToLog(eLogLevel.ERROR, "Failed to search : ", ex);
                    }
                    finally
                    {
                        if (SearchStarted == null)
                        {
                            Reporter.HideStatusMessage();
                        }
                        else
                        {
                            SearchCompleted.Invoke(Tree, new EventArgs());
                        }

                        Mouse.OverrideCursor = null;
                        mCancellationTokenSource.Dispose();
                    }
                });
            }, mCancellationTokenSource.Token, TaskCreationOptions.LongRunning);

            mSearchTask.Start();
        }
Esempio n. 10
0
 public static void OnSearchStarted()
 {
     SearchStarted?.Invoke();
 }
 protected virtual void OnSearchStarted()
 {
     SearchStarted?.Invoke();
 }
Esempio n. 12
0
 private void RiseSearchStarted()
 {
     SearchStarted?.Invoke();
 }
Esempio n. 13
0
 public void OnSearchStarted(EventArgs e) => SearchStarted?.Invoke(this, e);
 protected virtual void OnSearchStarted(EventArgs args)
 {
     SearchStarted?.Invoke(this, args);
 }