private void ConditionallySelectFiles(ConditionalSelectData csd, ShellView ShellListView)
        {
            if (csd == null)
            {
                return;
            }

            //The following items are added
            var Matches_Name             = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var Matches_Size             = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var Matches_DateCreated      = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var Matches_DateLastModified = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var Matches_LastAccessed     = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();

            ShellListView.DeSelectAllItems();

            if (csd.FilterByFileName)
            {
                foreach (var item in ShellListView.Items)
                {
                    var    data   = new FileInfo(item.ParsingName);
                    string ToFind = csd.FileNameData.matchCase ? data.Name : data.Name.ToLowerInvariant();

                    switch (csd.FileNameData.filter)
                    {
                    case ConditionalSelectParameters.FileNameFilterTypes.Contains:
                        if (ToFind.Contains(csd.FileNameData.matchCase ? csd.FileNameData.query : csd.FileNameData.query.ToLowerInvariant()))
                        {
                            Matches_Name.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.StartsWith:
                        if (ToFind.StartsWith(csd.FileNameData.query))
                        {
                            Matches_Name.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.EndsWith:
                        if (ToFind.EndsWith(csd.FileNameData.query))
                        {
                            Matches_Name.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.Equals:
                        if (ToFind == csd.FileNameData.query)
                        {
                            Matches_Name.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.DoesNotContain:
                        if (!ToFind.Contains(csd.FileNameData.query))
                        {
                            Matches_Name.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.NotEqualTo:
                        if (ToFind != csd.FileNameData.query)
                        {
                            Matches_Name.Add(item);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                //Matches_Name.AddRange(shells.Where((x) => !Directory.Exists(x.ParsingName)));
            }

            if (csd.FilterByFileSize)
            {
                foreach (var item in Matches_Name)
                {
                    FileInfo data = new FileInfo(item.ParsingName);
                    switch (csd.FileSizeData.filter)
                    {
                    case ConditionalSelectParameters.FileSizeFilterTypes.LargerThan:
                        if (data.Length > csd.FileSizeData.query1)
                        {
                            Matches_Size.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.SmallerThan:
                        if (data.Length < csd.FileSizeData.query1)
                        {
                            Matches_Size.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.Equals:
                        if (data.Length == csd.FileSizeData.query1)
                        {
                            Matches_Size.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.Between:
                        long largebound, smallbound;
                        if (csd.FileSizeData.query2 > csd.FileSizeData.query1)
                        {
                            smallbound = csd.FileSizeData.query1;
                            largebound = csd.FileSizeData.query2;
                        }
                        else if (csd.FileSizeData.query2 < csd.FileSizeData.query1)
                        {
                            smallbound = csd.FileSizeData.query2;
                            largebound = csd.FileSizeData.query1;
                        }
                        else
                        {
                            if (data.Length == csd.FileSizeData.query1)
                            {
                                Matches_Size.Add(item);
                            }
                            break;
                        }

                        if (data.Length > smallbound && data.Length < largebound)
                        {
                            Matches_Size.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.NotEqualTo:
                        if (data.Length != csd.FileSizeData.query1)
                        {
                            Matches_Size.Add(item);
                        }
                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.NotBetween:
                        long largebound2, smallbound2;
                        if (csd.FileSizeData.query2 > csd.FileSizeData.query1)
                        {
                            smallbound2 = csd.FileSizeData.query1;
                            largebound2 = csd.FileSizeData.query2;
                        }
                        else if (csd.FileSizeData.query2 < csd.FileSizeData.query1)
                        {
                            smallbound2 = csd.FileSizeData.query2;
                            largebound2 = csd.FileSizeData.query1;
                        }
                        else
                        {
                            // they are the same, use Unequal code
                            if (data.Length != csd.FileSizeData.query1)
                            {
                                Matches_Size.Add(item);
                            }
                            break;
                        }

                        if (data.Length < smallbound2 || data.Length > largebound2)
                        {
                            Matches_Size.Add(item);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                Matches_Size.AddRange(Matches_Name);
            }

            if (csd.FilterByDateCreated)
            {
                Func <FileInfo, DateTime> GetCreateDate = (x) => x.CreationTimeUtc;
                foreach (var item in !csd.FilterByDateCreated ? Matches_Size : DateFilter(Matches_Size, csd.DateCreatedData, GetCreateDate))
                {
                    Matches_DateCreated.Add(item);
                }
            }

            if (csd.FilterByDateModified)
            {
                Func <FileInfo, DateTime> GetDateModified = (x) => x.LastWriteTimeUtc;
                foreach (var item in !csd.FilterByDateModified ? Matches_Size : DateFilter(Matches_DateCreated, csd.DateModifiedData, GetDateModified))
                {
                    Matches_DateLastModified.Add(item);
                }
            }

            if (csd.FilterByDateAccessed)
            {
                Func <FileInfo, DateTime> GetDateAccessed = (x) => x.LastAccessTimeUtc;
                foreach (var item in !csd.FilterByDateAccessed ? Matches_DateLastModified : DateFilter(Matches_DateLastModified, csd.DateAccessedData, GetDateAccessed))
                {
                    Matches_LastAccessed.Add(item);
                }
            }

            //ShellListView.SelectItems(Matches_LastAccessed.ToArray());


            //TODO: Inline these!!!


            /*
             * ShellListView.SelectedItems.Clear();
             * ShellListView.SelectedItems.AddRange(Matches_Name);
             * ShellListView.SelectedItems.AddRange(Matches_Size);
             * ShellListView.SelectedItems.AddRange(Matches_DateCreated);
             * ShellListView.SelectedItems.AddRange(Matches_DateLastModified);
             * ShellListView.SelectedItems.AddRange(Matches_LastAccessed);
             */

            /*
             * var Indexes = new List<int>();
             * Indexes.AddRange(Matches_Name.Select(x => x.ItemIndex));
             * Indexes.AddRange(Matches_Size.Select(x => x.ItemIndex));
             * Indexes.AddRange(Matches_DateCreated.Select(x => x.ItemIndex));
             * Indexes.AddRange(Matches_DateLastModified.Select(x => x.ItemIndex));
             * Indexes.AddRange(Matches_LastAccessed.Select(x => x.ItemIndex));
             *
             * foreach (var item in Indexes) {
             *      ShellListView.SelectItemByIndex(item);
             * }
             */


            var SelectedItems = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();

            SelectedItems.AddRange(Matches_Name);
            SelectedItems.AddRange(Matches_Size);
            SelectedItems.AddRange(Matches_DateCreated);
            SelectedItems.AddRange(Matches_DateLastModified);
            SelectedItems.AddRange(Matches_LastAccessed);

            ShellListView.SelectItems(SelectedItems.ToArray());

            ShellListView.Focus();
        }
        private void ConditionallySelectFiles(ConditionalSelectData csdItem, ShellView shellListView)
        {
            if (csdItem == null)
            {
                return;
            }

            //The following items are added
            var matches_Name             = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var matches_Size             = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var matches_DateCreated      = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var matches_DateLastModified = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();
            var matches_LastAccessed     = new List <BExplorer.Shell._Plugin_Interfaces.IListItemEx>();

            shellListView.DeSelectAllItems();

            if (csdItem.FilterByFileName)
            {
                foreach (var item in shellListView.Items)
                {
                    var    data   = new FileInfo(item.ParsingName);
                    string ToFind = csdItem.FileNameData.matchCase ? data.Name : data.Name.ToLowerInvariant();

                    switch (csdItem.FileNameData.filter)
                    {
                    case ConditionalSelectParameters.FileNameFilterTypes.Contains:
                        if (ToFind.Contains(csdItem.FileNameData.matchCase ? csdItem.FileNameData.query : csdItem.FileNameData.query.ToLowerInvariant()))
                        {
                            matches_Name.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.StartsWith:
                        if (ToFind.StartsWith(csdItem.FileNameData.query))
                        {
                            matches_Name.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.EndsWith:
                        if (ToFind.EndsWith(csdItem.FileNameData.query))
                        {
                            matches_Name.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.Equals:
                        if (ToFind == csdItem.FileNameData.query)
                        {
                            matches_Name.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.DoesNotContain:
                        if (!ToFind.Contains(csdItem.FileNameData.query))
                        {
                            matches_Name.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileNameFilterTypes.NotEqualTo:
                        if (ToFind != csdItem.FileNameData.query)
                        {
                            matches_Name.Add(item);
                        }

                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                //Matches_Name.AddRange(shells.Where((x) => !Directory.Exists(x.ParsingName)));
            }

            if (csdItem.FilterByFileSize)
            {
                foreach (var item in shellListView.Items.Where(w => !w.IsFolder && w.IsFileSystem))
                {
                    var data = new FileInfo(item.ParsingName);
                    switch (csdItem.FileSizeData.filter)
                    {
                    case ConditionalSelectParameters.FileSizeFilterTypes.LargerThan:
                        if (data.Length > csdItem.FileSizeData.query1)
                        {
                            matches_Size.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.SmallerThan:
                        if (data.Length < csdItem.FileSizeData.query1)
                        {
                            matches_Size.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.Equals:
                        if (data.Length == csdItem.FileSizeData.query1)
                        {
                            matches_Size.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.Between:
                        long largebound, smallbound;
                        if (csdItem.FileSizeData.query2 > csdItem.FileSizeData.query1)
                        {
                            smallbound = csdItem.FileSizeData.query1;
                            largebound = csdItem.FileSizeData.query2;
                        }
                        else if (csdItem.FileSizeData.query2 < csdItem.FileSizeData.query1)
                        {
                            smallbound = csdItem.FileSizeData.query2;
                            largebound = csdItem.FileSizeData.query1;
                        }
                        else
                        {
                            if (data.Length == csdItem.FileSizeData.query1)
                            {
                                matches_Size.Add(item);
                            }

                            break;
                        }

                        if (data.Length > smallbound && data.Length < largebound)
                        {
                            matches_Size.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.NotEqualTo:
                        if (data.Length != csdItem.FileSizeData.query1)
                        {
                            matches_Size.Add(item);
                        }

                        break;

                    case ConditionalSelectParameters.FileSizeFilterTypes.NotBetween:
                        long largebound2, smallbound2;
                        if (csdItem.FileSizeData.query2 > csdItem.FileSizeData.query1)
                        {
                            smallbound2 = csdItem.FileSizeData.query1;
                            largebound2 = csdItem.FileSizeData.query2;
                        }
                        else if (csdItem.FileSizeData.query2 < csdItem.FileSizeData.query1)
                        {
                            smallbound2 = csdItem.FileSizeData.query2;
                            largebound2 = csdItem.FileSizeData.query1;
                        }
                        else
                        {
                            // they are the same, use Unequal code
                            if (data.Length != csdItem.FileSizeData.query1)
                            {
                                matches_Size.Add(item);
                            }

                            break;
                        }

                        if (data.Length < smallbound2 || data.Length > largebound2)
                        {
                            matches_Size.Add(item);
                        }

                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                matches_Size.AddRange(matches_Name);
            }

            if (csdItem.FilterByDateCreated)
            {
                matches_DateCreated.AddRange(!csdItem.FilterByDateCreated ? matches_Size : this.DateFilter(shellListView.Items, csdItem.DateCreatedData, x => x.CreationTimeUtc));
            }

            if (csdItem.FilterByDateModified)
            {
                matches_DateLastModified.AddRange(!csdItem.FilterByDateModified ? matches_Size : this.DateFilter(shellListView.Items, csdItem.DateModifiedData, x => x.LastWriteTimeUtc));
            }

            if (csdItem.FilterByDateAccessed)
            {
                matches_LastAccessed.AddRange(!csdItem.FilterByDateAccessed ? matches_DateLastModified : this.DateFilter(shellListView.Items, csdItem.DateAccessedData, x => x.LastAccessTimeUtc));
            }

            shellListView.SelectItems(
                matches_Name.
                Union(matches_Size).
                Union(matches_Size).
                Union(matches_DateCreated).
                Union(matches_DateLastModified).
                Union(matches_LastAccessed
                      ).ToArray());
            shellListView.Focus(false, true);
        }