public static FilterItem[] ParseFilterString(string filterString, string existing, out int existingIndex) { List <FilterItem> result = new List <FilterItem>(); string[] items; existingIndex = -1; if (filterString != string.Empty) { items = filterString.Split('|'); } else { items = new string[0]; } if ((items.Length % 2) != 0) { throw new ArgumentException( "Filter string you provided is not valid. The filter " + "string must contain a description of the filter, " + "followed by the vertical bar (|) and the filter pattern." + "The strings for different filtering options must also be " + "separated by the vertical bar. Example: " + "\"Text files|*.txt|All files|*.*\""); } for (int n = 0; n < items.Length; n += 2) { FilterItem item = new FilterItem(items[n], items[n + 1]); result.Add(item); if (item.Filter == existing) { existingIndex = result.Count - 1; } } return(result.ToArray()); }
public static FilterItem[] ParseFilterString(string filterString, string existing, out int existingIndex) { List<FilterItem> result = new List<FilterItem>(); string[] items; existingIndex = -1; if (filterString != string.Empty) { items = filterString.Split('|'); } else { items = new string[0]; } if ((items.Length % 2) != 0) { throw new ArgumentException( "Filter string you provided is not valid. The filter " + "string must contain a description of the filter, " + "followed by the vertical bar (|) and the filter pattern." + "The strings for different filtering options must also be " + "separated by the vertical bar. Example: " + "\"Text files|*.txt|All files|*.*\""); } for (int n = 0; n < items.Length; n += 2) { FilterItem item = new FilterItem(items[n], items[n + 1]); result.Add(item); if (item.Filter == existing) existingIndex = result.Count - 1; } return result.ToArray(); }
private bool ShouldCreateItem(ShellItem folder) { var e = new FilterItemEventArgs(folder); // ReSharper disable once UnusedVariable var myComputer = new ShellItem(Environment.SpecialFolder.MyComputer); e.Include = false; if (ShellItem.Desktop.IsImmediateParentOf(folder) || _mComputer.IsImmediateParentOf(folder)) { e.Include = folder.IsFileSystemAncestor; } else if ((folder == _mSelectedFolder) || folder.IsParentOf(_mSelectedFolder)) { e.Include = true; } FilterItem?.Invoke(this, e); return(e.Include); }