/// <summary>
        /// CompareVerbActionOpen is a helper function used to perform locale specific
        /// comparison of the verb action Open exposed by various control panel items.
        /// </summary>
        /// <param name="verbActionName">Locale specific verb action exposed by the control panel item.</param>
        /// <returns>True if the control panel item supports verb action open or else returns false.</returns>
        private static bool CompareVerbActionOpen(string verbActionName)
        {
            if (s_verbActionOpenName == null)
            {
                const string    allItemFolderPath = ControlPanelShellFolder + "\\0";
                IShellDispatch4 shell2            = (IShellDispatch4) new Shell();
                Folder2         allItemFolder     = (Folder2)shell2.NameSpace(allItemFolderPath);
                FolderItems3    allItems          = (FolderItems3)allItemFolder.Items();

                foreach (ShellFolderItem item in allItems)
                {
                    string canonicalName = (string)item.ExtendedProperty("System.ApplicationName");
                    canonicalName = !String.IsNullOrEmpty(canonicalName)
                                        ? canonicalName.Substring(0, canonicalName.IndexOf("\0", StringComparison.OrdinalIgnoreCase))
                                        : null;

                    if (canonicalName != null && canonicalName.Equals(RegionCanonicalName, StringComparison.OrdinalIgnoreCase))
                    {
                        // The 'Region' control panel item always has '&Open' (english or other locale) as the first verb name
                        s_verbActionOpenName = item.Verbs().Item(0).Name;
                        break;
                    }
                }

                Dbg.Assert(s_verbActionOpenName != null, "The 'Region' control panel item is available on all SKUs and it always "
                           + "has '&Open' as the first verb item, so VerbActionOpenName should never be null at this point");
            }

            return(s_verbActionOpenName.Equals(verbActionName, StringComparison.OrdinalIgnoreCase));
        }
Example #2
0
        public override void RequestRoot(TreeViewFolderBrowserHelper helper)
        {
            _helper = helper;
            AttachSystemImageList(helper);
            //
            // setup up root node collection
            switch (helper.TreeView.RootFolder)
            {
            case Environment.SpecialFolder.Desktop:
                Folder2 desktopFolder = (Folder2)_shell.GetDesktop();
                // create root node <Desktop>
                TreeNodePath desktopNode = CreateTreeNode(helper, desktopFolder.Title, desktopFolder.Self.Path, false, false,
                                                          true);
                helper.TreeView.Nodes.Add(desktopNode);
                desktopNode.Tag = desktopFolder;
                //
                Folder2 myComputer = (Folder2)_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES);
                foreach (FolderItem fi in desktopFolder.Items())
                {
                    if (!fi.IsFolder)
                    {
                        continue;
                    }
                    //
                    TreeNodePath node = CreateTreeNode(helper, fi.Name, fi.Path, true, false, true);
                    node.Tag = fi;
                    desktopNode.Nodes.Add(node);
                    //
                    if (_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES).Title == fi.Name)
                    {
                        _rootCollection = node.Nodes;
                    }
                }
                break;

            case Environment.SpecialFolder.MyComputer:
                FillMyComputer(((Folder2)_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES)).Self,
                               helper.TreeView.Nodes, helper);
                break;

            default:
                // create root node with specified SpecialFolder
                Folder2      root     = (Folder3)_shell.Shell.NameSpace(helper.TreeView.RootFolder);
                TreeNodePath rootNode = CreateTreeNode(helper, root.Title, root.Self.Path, true, false, true);
                rootNode.Tag = root.Self;
                helper.TreeView.Nodes.Add(rootNode);
                _rootCollection = rootNode.Nodes;
                break;
            }
        }
        /// <summary>
        /// Get the category number and name map
        /// </summary>
        internal void GetCategoryMap()
        {
            if (CategoryMap.Count != 0)
            {
                return;
            }

            IShellDispatch4 shell2         = (IShellDispatch4) new Shell();
            Folder2         categoryFolder = (Folder2)shell2.NameSpace(ControlPanelShellFolder);
            FolderItems3    catItems       = (FolderItems3)categoryFolder.Items();

            foreach (ShellFolderItem category in catItems)
            {
                string path   = category.Path;
                string catNum = path.Substring(path.LastIndexOf("\\", StringComparison.OrdinalIgnoreCase) + 1);

                CategoryMap.Add(catNum, category.Name);
            }
        }
Example #4
0
 internal void GetCategoryMap()
 {
     if (this.CategoryMap.Count == 0)
     {
         IShellDispatch4 variable  = CreateShellImpl();
         Folder2         variable1 = (Folder2)variable.NameSpace("shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}");
         FolderItems3    variable2 = (FolderItems3)variable1.Items();
         foreach (ShellFolderItem variable3 in variable2)
         {
             string path = variable3.Path;
             string str  = path.Substring(path.LastIndexOf("\\", StringComparison.OrdinalIgnoreCase) + 1);
             this.CategoryMap.Add(str, variable3.Name);
         }
         return;
     }
     else
     {
         return;
     }
 }
Example #5
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            List <string> items = new();

            Type shellAppType = Type.GetTypeFromProgID("Shell.Application");

            if (shellAppType is not null)
            {
                object  shell = Activator.CreateInstance(shellAppType);
                Folder2 f2    = (Folder2)shellAppType.InvokeMember("NameSpace",
                                                                   System.Reflection.BindingFlags.InvokeMethod, null, shell,
                                                                   new object[] { "shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}" });

                if (f2 != null)
                {
                    items.AddRange(from FolderItem fi in f2.Items() where fi.IsFolder select fi.Path);
                }
            }


            list.ItemsSource = items;
        }
Example #6
0
        private static bool CompareVerbActionOpen(string verbActionName)
        {
            string str;
            bool   flag = false;

            if (!string.IsNullOrEmpty(verbActionName))
            {
                if (ControlPanelItemBaseCommand.VerbActionOpenName == null)
                {
                    new List <ShellFolderItem>();
                    string          str1      = "shell:::{26EE0668-A00A-44D7-9371-BEB064C98683}\\0";
                    IShellDispatch4 variable  = CreateShellImpl();
                    Folder2         variable1 = (Folder2)variable.NameSpace(str1);
                    FolderItems3    variable2 = (FolderItems3)variable1.Items();
                    foreach (ShellFolderItem variable3 in variable2)
                    {
                        string str2 = (string)((dynamic)variable3.ExtendedProperty("System.ApplicationName"));
                        if (str2 != null)
                        {
                            str = str2.Substring(0, str2.IndexOf("\0", StringComparison.OrdinalIgnoreCase));
                        }
                        else
                        {
                            str = null;
                        }
                        str2 = str;
                        if (str2 == null || !str2.Equals("Microsoft.RegionAndLanguage", StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        ControlPanelItemBaseCommand.VerbActionOpenName = verbActionName;
                        break;
                    }
                }
                flag = ControlPanelItemBaseCommand.VerbActionOpenName.Equals(verbActionName, StringComparison.OrdinalIgnoreCase);
            }
            return(flag);
        }
Example #7
0
        public override void RequestRoot(TreeViewFolderBrowserHelper helper)
        {
            _helper = helper;
            AttachSystemImageList(helper);
            //
            // setup up root node collection
            switch (helper.TreeView.RootFolder)
            {
            case Environment.SpecialFolder.Desktop:
                Folder2 desktopFolder = (Folder2)_shell.GetDesktop();
                // create root node <Desktop>
                TreeNodePath desktopNode = CreateTreeNode(helper, desktopFolder.Title, desktopFolder.Self.Path, false, false,
                                                          true);
                helper.TreeView.Nodes.Add(desktopNode);
                desktopNode.Tag = desktopFolder;
                //
                foreach (FolderItem fi in desktopFolder.Items())
                {
                    // Don't list Non-Folders, Control Panel and Waste BAsket
                    if (!fi.IsFolder)
                    {
                        continue;
                    }
                    if (_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfBITBUCKET).Title == fi.Name)
                    {
                        continue;
                    }
                    if (fi.Path == "::{26EE0668-A00A-44D7-9371-BEB064C98683}")
                    {
                        continue;
                    }

                    TreeNodePath node = CreateTreeNode(helper, fi.Name, fi.Path, true, false, true);
                    node.Tag = fi;
                    desktopNode.Nodes.Add(node);

                    if (_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES).Title == fi.Name)
                    {
                        _rootCollection = node.Nodes;
                    }

                    if (fi.Path == "::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}")
                    {
                        _rootCollectionNetwork = node.Nodes;
                    }
                }
                break;

            case Environment.SpecialFolder.MyComputer:
                FillMyComputer(((Folder2)_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES)).Self,
                               helper.TreeView.Nodes, helper);
                break;

            default:
                // create root node with specified SpecialFolder
                Folder2      root     = (Folder3)_shell.Shell.NameSpace(helper.TreeView.RootFolder);
                TreeNodePath rootNode = CreateTreeNode(helper, root.Title, root.Self.Path, true, false, true);
                rootNode.Tag = root.Self;
                helper.TreeView.Nodes.Add(rootNode);
                _rootCollection = rootNode.Nodes;
                break;
            }
        }
Example #8
0
        /// <summary>
        /// Create the Root Collection when building the Tree View
        /// </summary>
        /// <param name="helper"></param>
        public virtual void RequestRoot(TreeViewHelper helper)
        {
            log.Trace(">>>");
            // setup up root node collection
            switch (helper.TreeView.RootFolder)
            {
            case Environment.SpecialFolder.Desktop:
                Folder2 desktopFolder = (Folder2)_shell.GetDesktop();
                // create root node <Desktop>
                var desktopNode = CreateTreeNode(helper, desktopFolder.Title, desktopFolder.Self.Path,
                                                 true, desktopFolder.Self);
                helper.TreeView.Nodes.Add(desktopNode);
                foreach (FolderItem fi in desktopFolder.Items())
                {
                    log.Trace($"Folder: {fi.Name} | Type: {fi.Type} | IsFolder: {fi.IsFolder} | IsFileSystem: {fi.IsFileSystem}");
                    // Don't list Non-Folders, Control Panel and Waste Basket
                    if (!fi.IsFolder)
                    {
                        continue;
                    }

                    if (_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfBITBUCKET).Title == fi.Name)
                    {
                        continue;
                    }

                    if (fi.Path == "::{26EE0668-A00A-44D7-9371-BEB064C98683}")
                    {
                        continue;
                    }

                    // Create the Tree Node
                    var node = CreateTreeNode(helper, fi.Name, fi.Path, true, fi);
                    desktopNode.Nodes.Add(node);

                    // Handle My Computer
                    if (_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES).Title == fi.Name)
                    {
                        FillMyComputer(fi, node.Nodes, helper);
                    }

                    // Add to Network Node
                    if (fi.Path == "::{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}")
                    {
                        _rootCollectionNetwork = node.Nodes;
                    }
                }
                break;

            case Environment.SpecialFolder.MyComputer:
                FillMyComputer(((Folder2)_shell.Shell.NameSpace(ShellSpecialFolderConstants.ssfDRIVES)).Self,
                               helper.TreeView.Nodes, helper);
                break;

            default:
                // create root node with specified SpecialFolder
                Folder2 root     = (Folder3)_shell.Shell.NameSpace(helper.TreeView.RootFolder);
                var     rootNode = CreateTreeNode(helper, root.Title, root.Self.Path, false, root);
                //rootNode.Tag = root.Self;
                helper.TreeView.Nodes.Add(rootNode);
                _rootCollection = rootNode.Nodes;
                break;
            }
            log.Trace("<<<");
        }