예제 #1
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            CancelAction = false;
            ConditionalSelectParameters.FileNameFilterTypes fnf = (ConditionalSelectParameters.FileNameFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.FileNameFilterTypes), ((ConditionalSelectComboBoxItem)namefilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.FileSizeFilterTypes fsf = (ConditionalSelectParameters.FileSizeFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.FileSizeFilterTypes), ((ConditionalSelectComboBoxItem)sizefilter.SelectedItem).IdentifyingName);
            FriendlySizeConverter.FileSizeMeasurements      sd1 = (FriendlySizeConverter.FileSizeMeasurements)Enum.Parse(typeof(FriendlySizeConverter.FileSizeMeasurements), ((ConditionalSelectComboBoxItem)sizebox1.SelectedItem).IdentifyingName);
            FriendlySizeConverter.FileSizeMeasurements      sd2 = (FriendlySizeConverter.FileSizeMeasurements)Enum.Parse(typeof(FriendlySizeConverter.FileSizeMeasurements), ((ConditionalSelectComboBoxItem)sizebox2.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes     dcf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dcfilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes     dmf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dmfilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes     daf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dafilter.SelectedItem).IdentifyingName);

            csd = new ConditionalSelectData(
                new ConditionalSelectParameters.FileNameParameters(namequery.Text, fnf, namecase.IsChecked.Value),
                new ConditionalSelectParameters.FileSizeParameters(FriendlySizeConverter.GetByteLength(
                                                                       Convert.ToDouble(sizequery1.Text.Replace(",", ci.NumberFormat.NumberDecimalSeparator).Replace(
                                                                                            ".", ci.NumberFormat.NumberDecimalSeparator)), sd1),
                                                                   FriendlySizeConverter.GetByteLength(Convert.ToDouble(sizequery2.Text.Replace(
                                                                                                                            ",", ci.NumberFormat.NumberDecimalSeparator).Replace(
                                                                                                                            ".", ci.NumberFormat.NumberDecimalSeparator)), sd2), fsf),
                new ConditionalSelectParameters.DateParameters(dcquery.SelectedDate.Value.Date, dcf),
                new ConditionalSelectParameters.DateParameters(dmquery.SelectedDate.Value.Date, dmf),
                new ConditionalSelectParameters.DateParameters(daquery.SelectedDate.Value.Date, daf),
                namecheck.IsChecked.Value, sizecheck.IsChecked.Value, dccheck.IsChecked.Value, dmcheck.IsChecked.Value, dacheck.IsChecked.Value);
            this.Close();
        }
예제 #2
0
        private void ConditionallySelectFiles(ConditionalSelectData csd)
        {

            if (csd == null)
            {
                return;
            }

            ShellObjectCollection shells = Explorer.Items;
            ShellObjectCollection l1shells = new ShellObjectCollection();
            ShellObjectCollection l2shells = new ShellObjectCollection();
            ShellObjectCollection l3shells = new ShellObjectCollection();
            ShellObjectCollection l4shells = new ShellObjectCollection();
            ShellObjectCollection l5shells = new ShellObjectCollection();

            Explorer.DeSelectAllItems();

            if (csd.FilterByFileName == true)
            {
                foreach (ShellObject item in shells)
                {
                    if (Directory.Exists(item.ParsingName) == false)
                    {
                        FileInfo data = new FileInfo(item.ParsingName);
                        if (csd.FileNameData.matchCase == true)
                        {
                            switch (csd.FileNameData.filter)
                            {
                                case ConditionalSelectParameters.FileNameFilterTypes.Contains:
                                    if (data.Name.Contains(csd.FileNameData.query) == true)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.StartsWith:
                                    if (data.Name.StartsWith(csd.FileNameData.query) == true)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.EndsWith:
                                    if (data.Name.EndsWith(csd.FileNameData.query) == true)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.Equals:
                                    if (data.Name == csd.FileNameData.query)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.DoesNotContain:
                                    if (data.Name.Contains(csd.FileNameData.query) == false)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.NotEqualTo:
                                    if (data.Name != csd.FileNameData.query)
                                        l1shells.Add(item);
                                    break;
                                default:
                                    break;
                            }
                        }
                        else
                        {
                            switch (csd.FileNameData.filter)
                            {
                                case ConditionalSelectParameters.FileNameFilterTypes.Contains:
                                    if (data.Name.ToLower().Contains(csd.FileNameData.query.ToLower()) == true)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.StartsWith:
                                    if (data.Name.ToLower().StartsWith(csd.FileNameData.query.ToLower()) == true)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.EndsWith:
                                    if (data.Name.ToLower().EndsWith(csd.FileNameData.query.ToLower()) == true)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.Equals:
                                    if (data.Name.ToLower() == csd.FileNameData.query.ToLower())
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.DoesNotContain:
                                    if (data.Name.ToLower().Contains(csd.FileNameData.query.ToLower()) == false)
                                        l1shells.Add(item);
                                    break;
                                case ConditionalSelectParameters.FileNameFilterTypes.NotEqualTo:
                                    if (data.Name.ToLower() != csd.FileNameData.query.ToLower())
                                        l1shells.Add(item);
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (ShellObject item in shells)
                {
                    if (Directory.Exists(item.ParsingName) == false)
                    {
                        l1shells.Add(item);
                    }
                }
            }

            if (csd.FilterByFileSize == true)
            {
                foreach (ShellObject item in l1shells)
                {
                    FileInfo data = new FileInfo(item.ParsingName);
                    switch (csd.FileSizeData.filter)
                    {
                        case ConditionalSelectParameters.FileSizeFilterTypes.LargerThan:
                            if (data.Length > csd.FileSizeData.query1)
                                l2shells.Add(item);
                            break;
                        case ConditionalSelectParameters.FileSizeFilterTypes.SmallerThan:
                            if (data.Length < csd.FileSizeData.query1)
                                l2shells.Add(item);
                            break;
                        case ConditionalSelectParameters.FileSizeFilterTypes.Equals:
                            if (data.Length == csd.FileSizeData.query1)
                                l2shells.Add(item);
                            break;
                        case ConditionalSelectParameters.FileSizeFilterTypes.Between:
                            long smallbound;
                            long largebound;
                            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
                                {
                                    // they are the same, use Equal code

                                    //MessageBox.Show("Could not continue Conditional Select operation. When searching for files that is between a certain size, make sure the upper and lower bounds of the search parameters are not the same.", "BetterExplorer Conditional Select - Filter by File Size", MessageBoxButton.OK, MessageBoxImage.Error);
                                    //return;

                                    if (data.Length == csd.FileSizeData.query1)
                                        l2shells.Add(item);
                                    break;
                                }
                            }

                            if (data.Length > smallbound)
                                if (data.Length < largebound)
                                    l2shells.Add(item);

                            break;
                        case ConditionalSelectParameters.FileSizeFilterTypes.NotEqualTo:
                            if (data.Length != csd.FileSizeData.query1)
                                l2shells.Add(item);
                            break;
                        case ConditionalSelectParameters.FileSizeFilterTypes.NotBetween:
                            long smallbound2;
                            long largebound2;
                            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)
                                        l2shells.Add(item);
                                    break;
                                    //MessageBox.Show("Could not continue Conditional Select operation. When searching for files that is not between a certain size, make sure the upper and lower bounds of the search parameters are not the same.", "BetterExplorer Conditional Select - Filter by File Size", MessageBoxButton.OK, MessageBoxImage.Error);
                                    //return;
                                }
                            }

                            if (data.Length < smallbound2 || data.Length > largebound2)
                                l2shells.Add(item);

                            break;
                        default:
                            break;
                    }

                }
            }
            else
            {
                foreach (ShellObject item in l1shells)
                {
                    l2shells.Add(item);
                }
            }

            if (csd.FilterByDateCreated == true)
            {
                foreach (ShellObject item in FilterByCreateDate(l2shells, csd.DateCreatedData.queryDate, csd.DateCreatedData.filter))
                {
                    l3shells.Add(item);
                }
            }
            else
            {
                foreach (ShellObject item in l2shells)
                {
                    l3shells.Add(item);
                }
            }

            if (csd.FilterByDateModified == true)
            {
                foreach (ShellObject item in FilterByWriteDate(l3shells, csd.DateModifiedData.queryDate, csd.DateModifiedData.filter))
                {
                    l4shells.Add(item);
                }
            }
            else
            {
                foreach (ShellObject item in l2shells)
                {
                    l4shells.Add(item);
                }
            }

            if (csd.FilterByDateAccessed == true)
            {
                foreach (ShellObject item in FilterByAccessDate(l4shells, csd.DateAccessedData.queryDate, csd.DateAccessedData.filter))
                {
                    l5shells.Add(item);
                }
            }
            else
            {
                foreach (ShellObject item in l4shells)
                {
                    l5shells.Add(item);
                }
            }

            List<ShellObject> sel = new List<ShellObject>();

            foreach (ShellObject item in l5shells)
            {
                // this is where the code should be to select multiple files.
                //
                // However, the Explorer control does not support selecting multiple files.

                Explorer.SelectItem(item);
            }

            Explorer.Focus();

        }
        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 button2_Click(object sender, RoutedEventArgs e)
        {
            CancelAction = false;
            ConditionalSelectParameters.FileNameFilterTypes fnf = (ConditionalSelectParameters.FileNameFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.FileNameFilterTypes), ((ConditionalSelectComboBoxItem)namefilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.FileSizeFilterTypes fsf = (ConditionalSelectParameters.FileSizeFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.FileSizeFilterTypes), ((ConditionalSelectComboBoxItem)sizefilter.SelectedItem).IdentifyingName);
            FriendlySizeConverter.FileSizeMeasurements sd1 = (FriendlySizeConverter.FileSizeMeasurements)Enum.Parse(typeof(FriendlySizeConverter.FileSizeMeasurements), ((ConditionalSelectComboBoxItem)sizebox1.SelectedItem).IdentifyingName);
            FriendlySizeConverter.FileSizeMeasurements sd2 = (FriendlySizeConverter.FileSizeMeasurements)Enum.Parse(typeof(FriendlySizeConverter.FileSizeMeasurements), ((ConditionalSelectComboBoxItem)sizebox2.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes dcf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dcfilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes dmf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dmfilter.SelectedItem).IdentifyingName);
            ConditionalSelectParameters.DateFilterTypes daf = (ConditionalSelectParameters.DateFilterTypes)Enum.Parse(typeof(ConditionalSelectParameters.DateFilterTypes), ((ConditionalSelectComboBoxItem)dafilter.SelectedItem).IdentifyingName);

            csd = new ConditionalSelectData(
                new ConditionalSelectParameters.FileNameParameters(namequery.Text, fnf, namecase.IsChecked.Value),
                new ConditionalSelectParameters.FileSizeParameters(FriendlySizeConverter.GetByteLength(
                    Convert.ToDouble(sizequery1.Text.Replace(",",ci.NumberFormat.NumberDecimalSeparator).Replace(
                      ".",ci.NumberFormat.NumberDecimalSeparator)), sd1),
                      FriendlySizeConverter.GetByteLength(Convert.ToDouble(sizequery2.Text.Replace(
                      ",", ci.NumberFormat.NumberDecimalSeparator).Replace(
                      ".", ci.NumberFormat.NumberDecimalSeparator)), sd2), fsf),
                new ConditionalSelectParameters.DateParameters(dcquery.SelectedDate.Value.Date, dcf),
                new ConditionalSelectParameters.DateParameters(dmquery.SelectedDate.Value.Date, dmf),
                new ConditionalSelectParameters.DateParameters(daquery.SelectedDate.Value.Date, daf),
                namecheck.IsChecked.Value, sizecheck.IsChecked.Value, dccheck.IsChecked.Value, dmcheck.IsChecked.Value, dacheck.IsChecked.Value);
            this.Close();
        }
		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) {
					var 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) 
				Matches_DateCreated.AddRange(!csd.FilterByDateCreated ? Matches_Size : DateFilter(Matches_Size, csd.DateCreatedData, x => x.CreationTimeUtc));

			if (csd.FilterByDateModified) 
				Matches_DateLastModified.AddRange(!csd.FilterByDateModified ? Matches_Size : DateFilter(Matches_DateCreated, csd.DateModifiedData, x => x.LastWriteTimeUtc));

			if (csd.FilterByDateAccessed) 
				Matches_LastAccessed.AddRange(!csd.FilterByDateAccessed ? Matches_DateLastModified : DateFilter(Matches_DateLastModified, csd.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();
		}
        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);
        }