private bool filterSet; // filters can only be set once #region Constructors /// <summary> /// Creates a new instance of this class. /// </summary> protected CommonFileDialog() { filenames = new Collection<string>(); filters = new CommonFileDialogFilterCollection(); items = new Collection<IShellItem>(); controls = new CommonFileDialogControlCollection<CommonFileDialogControl>(this); }
/// <summary> /// Parses the <see cref="CommonFileDialogFilter"/> from the specified <paramref name="filter"/> and adds them to the <see cref="filters"/> collection. /// </summary> /// <param name="filters">The filters collection to add the parsed filters to.</param> /// <param name="filter">The filter to parse.</param> private void AddFilters(CommonFileDialogFilterCollection filters, string filter) { var segments = filter.Split('|'); for (var i = 0; i < segments.Length; i += 2) { filters.Add(new CommonFileDialogFilter(segments[i], segments[i + 1])); } }
/// <summary> /// Creates a new instance of this class. /// </summary> protected CommonFileDialog() { if (!Helpers.RunningOnVista) throw new PlatformNotSupportedException( "Common File Dialog requires Windows Vista or later."); fileNames = new Collection<string>(); filters = new CommonFileDialogFilterCollection(); controls = new DialogControlCollection<CommonFileDialogControl>(this); }
private bool filterSet; // filters can only be set once #region Constructors /// <summary> /// Creates a new instance of this class. /// </summary> protected CommonFileDialog() { if (!CoreHelpers.RunningOnVista) { throw new PlatformNotSupportedException(LocalizedMessages.CommonFileDialogRequiresVista); } filenames = new Collection<string>(); filters = new CommonFileDialogFilterCollection(); items = new Collection<IShellItem>(); controls = new CommonFileDialogControlCollection<CommonFileDialogControl>(this); }
private static void SetFilter(string filter, CommonFileDialogFilterCollection col) { var parts = filter.Split('|'); if (parts.Length > 1) { for (var part = 0; parts.Length >= part + 2; part += 2) { col.Add(new CommonFileDialogFilter(parts[part], parts[part + 1])); } } else { col.Add(new CommonFileDialogFilter(filter, filter)); } }