Esempio n. 1
0
        protected void updateNodeItemsByTreeNode(PathTreeNode AParentNode)
        {
            // remove the treenodes existing subnodes
            AParentNode.Nodes.Clear();

            // remove all items from the items listview
            ItemsListView.Clear();

            this.FolderLinks.Clear();
            this.FileLinks.Clear();
            if (this.ShowLinks)
            {
                loadLinksByTreeNode(AParentNode);
            } // if (this.ShowLinks)

            bool IsRoot = (AParentNode == this.RootNode);
            if (IsRoot)
            {
                updateDrivesByTreeNode(AParentNode);
            }
            else
            {
                updateFoldersByTreeNode(AParentNode);
                if (this.ShowFiles)
                {
                    updateFilesByTreeNode(AParentNode);
                } // if (this.ShowFiles)
            }
        }
Esempio n. 2
0
        protected void updatePathBarByTreeNode(PathTreeNode ANode)
        {
            String thisFullPath = "";

            bool IsRootNode = (ANode == this.RootNode);
            if (IsRootNode)
            {
                thisFullPath = ANode.Text;
            }
            else
            {
                thisFullPath = ANode.ExpandPath();
                thisFullPath = ukt4dotnet.shared.utilities.IO.Paths.MainModule.NormalizedPathToOSPath(thisFullPath);
            }

            // mostrar ruta en barra de direcciones
            thisFullPath += @"\";
            PathTextBox.Text = thisFullPath;
        }
Esempio n. 3
0
        protected void updateFilesByTreeNode(PathTreeNode AParentNode)
        {
            PathTreeNode thisParentNode = (PathTreeNode)AParentNode;
            String thisFullPath = AParentNode.ExpandPath();

            thisFullPath = ukt4dotnet.shared.utilities.IO.Paths.MainModule.NormalizedPathToOSPath(thisFullPath);
            thisFullPath += @"\";

            string[] Files = System.IO.Directory.GetFiles(thisFullPath);
            foreach (string eachFileFullPath in Files)
            {
                String eachPlainFileName = System.IO.Path.GetFileName(eachFileFullPath);
                String eachFileExtension = System.IO.Path.GetExtension(eachPlainFileName);

                bool IsLink = (eachFileExtension == ".lnk");
                if (! IsLink)
                {
                    ItemInfoStruct thisItemInfo = new ItemInfoStruct();

                    thisItemInfo.IsDrive = false;
                    thisItemInfo.Code = eachPlainFileName;
                    thisItemInfo.Text = eachPlainFileName;

                    thisItemInfo.LinkDestPath = "";

                    thisItemInfo.IsFile = true;
                    thisItemInfo.IsFolder = false;
                    thisItemInfo.IsLink = false;

                    String AFullPath =
                        ukt4dotnet.shared.utilities.IO.Paths.MainModule.OSPathToNormalizedPath(eachFileFullPath);
                    thisItemInfo.Code = AFullPath;

                    addItemsListviewNode(thisItemInfo);
                } // if (! IsLink)
            } // foreach

            foreach (ItemInfoStruct eachFileInfo in this.FileLinks)
            {
                addItemsListviewNode(eachFileInfo);
            } // foreach
        }
Esempio n. 4
0
        protected void updateFoldersByTreeNode(PathTreeNode AParentNode)
        {
            PathTreeNode thisParentNode = (PathTreeNode)AParentNode;
            String thisFullPath = AParentNode.ExpandPath();

            thisFullPath = ukt4dotnet.shared.utilities.IO.Paths.MainModule.NormalizedPathToOSPath(thisFullPath);
            thisFullPath += @"\";

            string[] Directories = System.IO.Directory.GetDirectories(thisFullPath);
            foreach (string eachFolderFullPath in Directories)
            {
                String eachPlainFolderName = System.IO.Path.GetFileName(eachFolderFullPath);

                ItemInfoStruct thisItemInfo = new ItemInfoStruct();

                thisItemInfo.IsDrive = false;
                thisItemInfo.Code    = eachPlainFolderName;
                thisItemInfo.Text    = eachPlainFolderName;
                thisItemInfo.LinkDestPath = "";

                thisItemInfo.IsFile = false;
                thisItemInfo.IsFolder = true;
                thisItemInfo.IsLink = false;

                PathTreeNode thisTreeNode =
                    addFoldersTreeviewNode(AParentNode, thisItemInfo);

                String AFullPath = thisTreeNode.ExpandPath();
                thisItemInfo.Code = AFullPath;
                addItemsListviewNode(thisItemInfo);
            } // foreach

            foreach (ItemInfoStruct eachFolderInfo in this.FolderLinks)
            {
                PathTreeNode thisTreeNode =
                    addFoldersTreeviewNode(AParentNode, eachFolderInfo);

                addItemsListviewNode(eachFolderInfo);
            } // foreach
        }
Esempio n. 5
0
        protected void loadLinksByTreeNode(PathTreeNode AParentNode)
        {
            PathTreeNode thisParentNode = (PathTreeNode)AParentNode;
            if (this.RootNode != thisParentNode)
            {
                String thisFullPath = AParentNode.ExpandPath();

                thisFullPath = ukt4dotnet.shared.utilities.IO.Paths.MainModule.NormalizedPathToOSPath(thisFullPath);
                thisFullPath += @"\";

                string[] Files = System.IO.Directory.GetFiles(thisFullPath);
                foreach (string eachFileFullPath in Files)
                {
                    String eachPlainFileName = System.IO.Path.GetFileName(eachFileFullPath);
                    String eachFileExtension = System.IO.Path.GetExtension(eachPlainFileName);

                    bool IsLink = (eachFileExtension == ".lnk");
                    if (IsLink)
                    {
                        ItemInfoStruct thisItemInfo = new ItemInfoStruct();
                        thisItemInfo.IsDrive = false;
                        thisItemInfo.IsLink = true;

                        String AOSPath = string.Empty;
                        String ADescr  = string.Empty;

                        // to-do: add showfilelinks, showfolderlinks

                        bool Result = GetShortcutTargetFile(eachFileFullPath, out AOSPath, out ADescr);
                        if (Result)
                        {
                            String ANormalizedPath =
                                ukt4dotnet.shared.utilities.IO.Paths.MainModule.OSPathToNormalizedPath(AOSPath);

                            thisItemInfo.LinkDestPath = ANormalizedPath;

                            // file or folder ?
                            thisItemInfo.IsFolder = (System.IO.Directory.Exists(AOSPath));
                            thisItemInfo.IsFile = (!thisItemInfo.IsFolder);

                            String AFullPath =
                                ukt4dotnet.shared.utilities.IO.Paths.MainModule.OSPathToNormalizedPath(eachFileFullPath);
                            thisItemInfo.Code = AFullPath;

                            String DestFullPath = System.IO.Path.GetFileName(AOSPath);
                            //thisItemInfo.Text = DestFullPath;

                            thisItemInfo.Text = ADescr;

                            if (thisItemInfo.IsFolder)
                            {
                                this.FolderLinks.Add(thisItemInfo);
                            }
                            else
                            {
                                this.FileLinks.Add(thisItemInfo);
                            }
                        }
                    } // if (IsLink)
                } // foreach
            } // if (this.RootNode != thisParentNode)
        }
Esempio n. 6
0
        protected void updateDrivesByTreeNode(PathTreeNode AParentNode)
        {
            System.IO.DriveInfo[] Drives = System.IO.DriveInfo.GetDrives();
            foreach (System.IO.DriveInfo eachDriveInfo in Drives)
            {
                if (eachDriveInfo.IsReady)
                {
                    ItemInfoStruct thisItemInfo = new ItemInfoStruct();

                    thisItemInfo.Code =
                        ukt4dotnet.shared.utilities.StrUtils.LeftCopyByLength(eachDriveInfo.Name, 1);

                    thisItemInfo.Text =
                        ukt4dotnet.shared.utilities.StrUtils.LeftCopyByLength(eachDriveInfo.Name, 2);

                    thisItemInfo.LinkDestPath = "";

                    thisItemInfo.IsDrive = true;

                    thisItemInfo.IsFile = false;
                    thisItemInfo.IsFolder = true;
                    thisItemInfo.IsLink = false;

                    PathTreeNode thisTreeNode =
                        addFoldersTreeviewNode(AParentNode, thisItemInfo);

                    String AFullPath = thisTreeNode.ExpandPath();
                    thisItemInfo.Code = AFullPath;
                    addItemsListviewNode(thisItemInfo);
                } // if (eachDriveInfo.IsReady)
            } // foreach
        }
Esempio n. 7
0
        protected PathTreeNode addFoldersTreeviewNode(PathTreeNode AParentNode, ItemInfoStruct thisItemInfo)
        {
            PathTreeNode Result = null;

            // add new node as child of current node

                Result = new PathTreeNode();
                Result.Code = thisItemInfo.Code;
                Result.Text = thisItemInfo.Text;

                Result.IsFolder = thisItemInfo.IsFolder;
                Result.IsFile = thisItemInfo.IsFile;
                Result.IsLink = thisItemInfo.IsLink;

                Result.LinkDestPath = thisItemInfo.LinkDestPath;

                if (thisItemInfo.IsDrive)
                {
                    // drives doesn't have "shorcuts"
                    Result.ImageIndex = 3;
                    Result.SelectedImageIndex = 4;
                }
                else
                {
                    Result.ImageIndex = (thisItemInfo.IsLink ? 7 : 5);
                    Result.SelectedImageIndex = (thisItemInfo.IsLink ? 8 : 6);
                }
                AParentNode.Nodes.Add(Result);

            return Result;
        }
Esempio n. 8
0
        protected void LoadExplorer()
        {
            String NormalizedPath =
                ukt4dotnet.shared.utilities.IO.Paths.MainModule.OSPathToNormalizedPath(this.SelectedPath);

            ukt4dotnet.shared.utilities.IO.Paths.MainModule.NormalizedPathScanner
                Scanner = new ukt4dotnet.shared.utilities.IO.Paths.MainModule.NormalizedPathScanner();

            // "virtual pseudoconstructor"
            Scanner.Create();

            Scanner.SourcePath = NormalizedPath;

            String FolderName = "";
            ukt4dotnet.shared.utilities.IO.Paths.MainModule.FileSystemTypeEnum FileSystemType =
                ukt4dotnet.shared.utilities.IO.Paths.MainModule.FileSystemTypeEnum.fsUnknown;

            PathTreeNode LoadingCurrentNode = null;

            FoldersTreeView.Nodes.Clear();
            this.RootNode = null;
            PathTreeNode eachTreeNode = null;

            while (Scanner.readFolderType(out FolderName, out FileSystemType))
            {
                switch (FileSystemType)
                {
                    case MainModule.FileSystemTypeEnum.fsRoot:

                    // add "mypc" item
                    eachTreeNode = new PathTreeNode();
                    eachTreeNode.FileSystemType = FileSystemType;
                    eachTreeNode.Code = "^";
                    eachTreeNode.Text = "My PC";
                    eachTreeNode.ImageIndex = 1;
                    eachTreeNode.SelectedImageIndex = 2;

                    FoldersTreeView.Nodes.Add(eachTreeNode);
                    // select as current parent node
                    LoadingCurrentNode = eachTreeNode;

                    // mark selected node as root
                    this.RootNode = eachTreeNode;
                    break;

                    case MainModule.FileSystemTypeEnum.fsDrive:

                    // add new node as child of current node
                    eachTreeNode = new PathTreeNode();
                    eachTreeNode.FileSystemType = FileSystemType;
                    eachTreeNode.Code = FolderName;
                    eachTreeNode.Text = FolderName + ":";
                    eachTreeNode.ImageIndex = 3;
                    eachTreeNode.SelectedImageIndex = 4;

                    LoadingCurrentNode.Nodes.Add(eachTreeNode);

                    // select as current parent node
                    LoadingCurrentNode = eachTreeNode;

                    break;

                    case MainModule.FileSystemTypeEnum.fsFolder:

                    // add new node as child of current node
                    eachTreeNode = new PathTreeNode();
                    eachTreeNode.FileSystemType = FileSystemType;
                    eachTreeNode.Code = FolderName;
                    eachTreeNode.Text = FolderName;
                    eachTreeNode.ImageIndex = 5;
                    eachTreeNode.SelectedImageIndex = 6;

                    LoadingCurrentNode.Nodes.Add(eachTreeNode);
                    // select as current parent node
                    LoadingCurrentNode = eachTreeNode;

                    break;

                    /*
                    case MainModule.FileSystemTypeEnum.fsFile:

                    // add new node as child of current node
                    eachTreeNode = new PathTreeNode();
                    eachTreeNode.FileSystemType = FileSystemType;
                    eachTreeNode.Code = FolderName;
                    eachTreeNode.Text = FolderName;
                    eachTreeNode.ImageIndex = 5;
                    eachTreeNode.SelectedImageIndex = 6;

                    LoadingCurrentNode.Nodes.Add(eachTreeNode);
                    // select as current parent node
                    LoadingCurrentNode = eachTreeNode;

                    break;
                    */
                } // switch

            } // while

            this.RootNode.ExpandAll();

            FoldersTreeView.SelectedNode = LoadingCurrentNode;

            // "virtual pseudodestructor"
            Scanner.Destroy();

            //String EachFolder = RootFolder;

            // ...
        }
Esempio n. 9
0
        /* nonvirtual */
        protected PathTreeNode NewNodeByText(string text)
        {
            PathTreeNode Result = new PathTreeNode();
            Result.Text = text;

            return Result;
        }
Esempio n. 10
0
 /* nonvirtual */
 protected PathTreeNode NewNodeByKeyValueSelImgKey(
     string key, string value, string ImageKey, string SelImageKey)
 {
     PathTreeNode Result = new PathTreeNode();
         Result.Name = key;
         Result.Text = value;
         Result.ImageKey = ImageKey;
         Result.SelectedImageKey = SelImageKey;
     return Result;
 }
Esempio n. 11
0
 /* nonvirtual */
 protected PathTreeNode NewNodeByKeyValueSelImgIndex(
     string key, string value, int ImageIndex, int SelImageIndex)
 {
     PathTreeNode Result = new PathTreeNode();
         Result.Name = key;
         Result.Text = value;
         Result.ImageIndex = ImageIndex;
         Result.SelectedImageIndex = SelImageIndex;
     return Result;
 }
Esempio n. 12
0
        /* nonvirtual */
        protected PathTreeNode NewNodeByKeyValue(
            string key, string value)
        {
            PathTreeNode Result = new PathTreeNode();
            Result.Name = key;
            Result.Text = value;

            return Result;
        }
Esempio n. 13
0
        /* nonvirtual */
        protected int AddPathNode(PathTreeNode node)
        {
            int Result = -1;

            TreeNode thisNode = (TreeNode)node;
            Result = this.TreeCollection.Add(thisNode);

            return Result;
        }