/// <summary> /// プロパティの初期設定を行います。 /// </summary> private void Initialize() { // SearchCondition初期化 SearchFolderItemFactory.SetCondition(this.SearchCondition.SearchConditionNative); // SearchScopePaths初期化 var shellItems = new List <IShellItem>(this.SearchScopePaths.Length); var shellItemGuid = new Guid(ShellIID.IShellItem); foreach (var path in this.SearchScopePaths) { IShellItem scopeShellItem; var hr = ShellNativeMethods.SHCreateItemFromParsingName(path, IntPtr.Zero, ref shellItemGuid, out scopeShellItem); if (HRESULT.Succeeded(hr)) { shellItems.Add(scopeShellItem); } } var scopeShellItemArray = new ShellItemArray(shellItems.ToArray()); var result = SearchFolderItemFactory.SetScope(scopeShellItemArray); if (HRESULT.Failed(result)) { throw ShellException.FromHRESULT(result); } }
public IEnumerable <ShellObject> GetSelectedItems() { var shellItemArray = GetSelectedItemsArray(); var count = ShellItemArray.GetShellItemCount(shellItemArray); for (var index = 0; index < count; ++index) { var shellItem = ShellItemArray.GetShellItemAt(shellItemArray, index); var shellObject = ShellFactory.FromShellItem(new ShellItem((IShellItem2)shellItem)); if (shellObject != null) { yield return(shellObject); } } }
public static Task <bool> LaunchApplicationFromAUMIDAsync(string AppUserModelId, params string[] PathArray) { if (PathArray.Length > 0) { return(ExecuteOnSTAThreadAsync(() => { List <ShellItem> SItemList = new List <ShellItem>(PathArray.Length); try { if (new Shell32.ApplicationActivationManager() is Shell32.IApplicationActivationManager Manager) { foreach (string Path in PathArray) { SItemList.Add(new ShellItem(Path)); } using (ShellItemArray ItemArray = new ShellItemArray(SItemList)) { Manager.ActivateForFile(AppUserModelId, ItemArray.IShellItemArray, "Open", out _); } return true; } else { return false; } } catch { return false; } finally { SItemList.ForEach((Item) => Item.Dispose()); } })); } else { return(LaunchApplicationFromAUMIDAsync(AppUserModelId)); } }
/// <summary> /// Gets a collection of files selected by the user. /// </summary> /// <returns>A collection of files.</returns> public IEnumerable <ShellFile> GetShellFiles() { var fileDialogNative = (IFileOpenDialog)this.FileDialogInternal.FileDialogNative; IShellItemArray shellItemArray; fileDialogNative.GetResults(out shellItemArray); var count = ShellItemArray.GetShellItemCount(shellItemArray); for (var index = 0; index < count; ++index) { var shellItem = ShellItemArray.GetShellItemAt(shellItemArray, index); var shellFile = ShellFactory.FromShellItem(new ShellItem((IShellItem2)shellItem)) as ShellFile; if (shellFile != null) { yield return(shellFile); } } }
/// <summary>Initializes a new instance of the <see cref="ShellView"/> class.</summary> /// <param name="baseInterface">The base interface.</param> internal ShellView(IShellView baseInterface) { iObj = baseInterface; History = new ShellNavigationHistory(); Items = new ShellItemArray(GetItemArray(iObj, SVGIO.SVGIO_ALLVIEW)); }