当前位置: 首页>>代码示例>>C#>>正文


C# TreeNode.ToString方法代码示例

本文整理汇总了C#中System.Windows.Forms.TreeNode.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.ToString方法的具体用法?C# TreeNode.ToString怎么用?C# TreeNode.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TreeNode的用法示例。


在下文中一共展示了TreeNode.ToString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CopyChildren

 public void CopyChildren(TreeNode parent, TreeNode original)
 {
     TreeNode newTn;
     foreach (TreeNode tn in original.Nodes)
     {
         newTn = new TreeNode(tn.Text);
         parent.Nodes.Add(newTn);
         CopyChildren(newTn, tn);
         if (newTn.ToString().Contains("."))
         {
             newTn.ImageIndex = 0;
         }
         else
         {
             newTn.ImageIndex = 1;
         }
     }
 }
开发者ID:PHPPlay,项目名称:RAT,代码行数:18,代码来源:FileForm.cs

示例2: CopyTreeNodes

 public void CopyTreeNodes(TreeView treeview1, TreeView treeview2)
 {
     treeview2.ImageList = fileDirImgList;
     treeview2.SelectedImageIndex = 2;
     TreeNode newTn;
     foreach (TreeNode tn in treeview1.Nodes)
     {
         newTn = new TreeNode(tn.Text);                
         CopyChildren(newTn, tn);
         if (newTn.ToString().Contains("."))
         {
             newTn.ImageIndex = 0;
         }
         else
         {
             newTn.ImageIndex = 1;
         }
         treeview2.Nodes.Add(newTn);
     }
 }
开发者ID:PHPPlay,项目名称:RAT,代码行数:20,代码来源:FileForm.cs

示例3: FillTreeNode

 public void FillTreeNode(TreeNode node, string root)
 {
     if (root == null)
     {
         throw new ArgumentNullException("root");
     }
     try
     {
         Cursor = Cursors.WaitCursor;
         var text = node.FullPath;
         if (string.CompareOrdinal(text, "\\") == 0)
         {
             text = node.ToString();
         }
         else
         {
             if (string.CompareOrdinal(text.Substring(1, 1), ":") != 0)
             {
                 root = node.Text;
                 text = root + text.Substring(text.IndexOf("\\", StringComparison.Ordinal));
             }
         }
         var directoryInfo = new DirectoryInfo(text);
         var directories = directoryInfo.GetDirectories();
         var comparer = new Comparer(CultureInfo.InvariantCulture);
         Array.Sort(directories, comparer);
         foreach (var current in
             from d in directories
             select new TreeNode(d.Name, 0, 1)
             {
                 Tag = node.Tag.ToString()
             })
         {
             node.Nodes.Add(current);
             current.Nodes.Add("");
         }
         var files = Directory.GetFiles(text, FileExplorerControl.Instance.Filter);
         Array.Sort(files);
         var array = files;
         var array2 = array;
         foreach (var path in array2)
         {
             var treeNode = new TreeNode(Path.GetFileName(path))
             {
                 Tag = node.Tag.ToString()
             };
             var extension = Path.GetExtension(path);
             if (extension != null)
             {
                 var text2 = extension.ToLower();
                 var text3 = text2;
                 // ReSharper disable once ConditionIsAlwaysTrueOrFalse
                 if (text3 == null)
                 {
                     goto IL_260;
                 }
                 if (text3 != ".src")
                 {
                     if (text3 != ".dat")
                     {
                         if (text3 != ".sub")
                         {
                             if (text3 != ".zip")
                             {
                                 goto IL_260;
                             }
                             treeNode.SelectedImageIndex = 6;
                             treeNode.ImageIndex = 6;
                         }
                         else
                         {
                             treeNode.SelectedImageIndex = 6;
                             treeNode.ImageIndex = 6;
                         }
                     }
                     else
                     {
                         treeNode.SelectedImageIndex = 6;
                         treeNode.ImageIndex = 6;
                     }
                 }
                 else
                 {
                     treeNode.SelectedImageIndex = 6;
                     treeNode.ImageIndex = 6;
                 }
                 goto IL_275;
                 IL_260:
                 treeNode.SelectedImageIndex = 6;
                 treeNode.ImageIndex = 6;
             }
             IL_275:
             node.Nodes.Add(treeNode);
         }
         Cursor = Cursors.Default;
     }
     catch (Exception ex)
     {
         var msg = new ErrorMessage("ExplorerClass.FillTreeNode", ex, MessageType.Error);
         Messenger.Default.Send<IMessage>(msg);
//.........这里部分代码省略.........
开发者ID:mookiejones,项目名称:miEditor,代码行数:101,代码来源:ExplorerClass.cs

示例4: PopulateFiles

        /// <summary>
        /// Populate files info into listview
        /// </summary>
        /// <param name="nodeCurrent"></param>
        protected void PopulateFiles(TreeNode nodeCurrent)
        {
            //Populate listview with files
            string[] lvData =  new string[4];

            //update status
            updateStatus("Getting directory files...");

            //clear list
            InitListView();

            if (nodeCurrent.SelectedImageIndex != 0)
            {
                //check path
                if(Directory.Exists((string) getFullPath(nodeCurrent.FullPath)) == false)
                {
                    MessageBox.Show("Directory or path " + nodeCurrent.ToString() + " does not exist.");
                }
                else
                {
                    try
                    {
                        string[] stringFiles = Directory.GetFiles(getFullPath(nodeCurrent.FullPath));
                        string stringFileName = "";
                        DateTime dtCreateDate, dtModifyDate;
                        Int64 lFileSize = 0;

                        //loop throught all files
                        foreach (string stringFile in stringFiles)
                        {
                            stringFileName = stringFile;
                            FileInfo objFileSize = new FileInfo(stringFileName);
                            lFileSize = objFileSize.Length;
                            dtCreateDate = objFileSize.CreationTime; //GetCreationTime(stringFileName);
                            dtModifyDate = objFileSize.LastWriteTime; //GetLastWriteTime(stringFileName);

                            //create listview data
                            lvData[0] = GetPathName(stringFileName);
                            lvData[1] = formatSize(lFileSize);

                            //check if this machine have Day light saving time set
                            if (TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) == true)
                            {
                                //check if file is in local current day light saving time
                                if (TimeZone.CurrentTimeZone.IsDaylightSavingTime(dtCreateDate) == false)
                                {
                                    //not in day light saving time adjust time
                                    lvData[2] = formatDate(dtCreateDate.AddHours(1));
                                }
                                else
                                {
                                    //is in day light saving time adjust time
                                    lvData[2] = formatDate(dtCreateDate);
                                }

                                //check if file is in local current day light saving time
                                if (TimeZone.CurrentTimeZone.IsDaylightSavingTime(dtModifyDate) == false)
                                {
                                    //not in day light saving time adjust time
                                    lvData[3] = formatDate(dtModifyDate.AddHours(1));
                                }
                                else
                                {
                                    //not in day light saving time adjust time
                                    lvData[3] = formatDate(dtModifyDate);
                                }
                            }
                            else
                            {
                                //machine Day Light Saving Time not set
                                lvData[2] = formatDate(dtCreateDate);
                                lvData[3] = formatDate(dtModifyDate);
                            }
                            //Create actual list item
                            ListViewItem lvItem = new ListViewItem(lvData,0);
                            lvFiles.Items.Add(lvItem);

                        }
                    }
                    catch (IOException)
                    {
                        MessageBox.Show("Error: Drive not ready or directory does not exist.");
                    }
                    catch (UnauthorizedAccessException)
                    {
                        MessageBox.Show("Error: Drive or directory access denided.");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Error: " + e);
                    }
                }
            }

            //update status
            updateStatus("Ready");
//.........这里部分代码省略.........
开发者ID:priceLiu,项目名称:ServerController,代码行数:101,代码来源:ExplorerControl.cs

示例5: PopulateDirectory

        protected void PopulateDirectory(TreeNode nodeCurrent, TreeNodeCollection nodeCurrentCollection)
        {
            TreeNode nodeDir;
            int imageIndex = 2;		//unselected image index
            int selectIndex = 3;	//selected image index

            if (nodeCurrent.SelectedImageIndex != 0)
            {
                //populate treeview with folders
                try
                {
                    //check path
                    if(Directory.Exists(getFullPath(nodeCurrent.FullPath)) == false)
                    {
                        MessageBox.Show("Directory or path " + nodeCurrent.ToString() + " does not exist.");
                    }
                    else
                    {
                        //populate files
                        PopulateFiles(nodeCurrent);

                        string[] stringDirectories = Directory.GetDirectories(getFullPath(nodeCurrent.FullPath));
                        string stringFullPath = "";
                        string stringPathName = "";

                        //loop throught all directories
                        foreach (string stringDir in stringDirectories)
                        {
                            stringFullPath = stringDir;
                            stringPathName = GetPathName(stringFullPath);

                            //create node for directories
                            nodeDir = new TreeNode(stringPathName.ToString(),imageIndex,selectIndex);
                            nodeCurrentCollection.Add(nodeDir);
                        }

                        //expand tree node
                        nodeCurrent.ExpandAll();
                    }
                }
                catch (IOException)
                {
                    MessageBox.Show("Error: Drive not ready or directory does not exist.");
                }
                catch (UnauthorizedAccessException)
                {
                    MessageBox.Show("Error: Drive or directory access denided.");
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error: " + e);
                }
            }
        }
开发者ID:priceLiu,项目名称:ServerController,代码行数:54,代码来源:ExplorerControl.cs

示例6: PopulatePhoneDirectory

        //显示目录列表
        protected void PopulatePhoneDirectory(TreeNode nodeCurrent, TreeNodeCollection nodeCurrentCollection)
        {
            TreeNode nodeDir;
            int imageIndex = 2;		//unselected image index
            int selectIndex = 3;	//selected image index

            //if (nodeCurrent.SelectedImageIndex != 0)
            {
                //populate treeview with folders
                try
                {
                    //check path
                    if (AdbFile.DirExists((string)nodeCurrent.Tag) == false)
                    {
                        MessageBox.Show("Directory or path " + nodeCurrent.ToString() + " does not exist.");
                    }
                    else
                    {
                        //populate files
                        /*PopulatePcFiles(nodeCurrent);

                        string[] stringDirectories = Directory.GetDirectories(getPcFullPath(nodeCurrent.FullPath));
                        string stringFullPath = "";
                        string stringPathName = "";

                        //loop throught all directories
                        foreach (string stringDir in stringDirectories)
                        {
                            stringFullPath = stringDir;
                            stringPathName = GetPcFileName(stringFullPath);

                            //create node for directories
                            nodeDir = new TreeNode(stringPathName.ToString(), imageIndex, selectIndex);
                            nodeCurrentCollection.Add(nodeDir);
                        }*/
                        //clear list
                        InitPhoneListView();

                        strPhoneDir = (string)nodeCurrent.Tag;

                        bool bret = false;
                        if (nodeCurrent.SelectedImageIndex == 0)
                            bret = AdbFile.GetAllFileInfo("/", out phoneFiles);
                        else
                            bret = AdbFile.GetAllFileInfo(strPhoneDir, out phoneFiles);
                        if (!bret)
                            return;

                        for (int i = 0; i < phoneFiles.Count; i++)
                        {
                            PhoneFileInfo info = phoneFiles[i];
                            string[] lvData = new string[5];
                            if (info != null)
                            {
                                lvData[0] = info.name;
                                lvData[1] = info.size;
                                lvData[2] = info.modifyDate+" "+info.modifyTime;
                                lvData[3] = info.permission;

                                if (!info.isFile)
                                {
                                    //if (!info.isLink)
                                    {
                                        nodeDir = new TreeNode(info.name, imageIndex, selectIndex);
                                        if (info.isLink)
                                            nodeDir.Tag = strPhoneDir+info.linkName;
                                        else
                                            nodeDir.Tag = strPhoneDir + "/" + info.name;
                                        nodeCurrentCollection.Add(nodeDir);
                                    }

                                    if (info.isLink)
                                    {
                                        lvData[4] = info.linkName;
                                    }
                                    ListViewItem lvItem = new ListViewItem(lvData, 0);
                                    lvItem.ImageKey = fileIconKey[DIR_IMAGE_KEY];
                                    lvItem.Tag = info;
                                    listPhoneFile.Items.Add(lvItem);
                                }
                                else
                                {
                                    if (info.isLink)
                                    {
                                        lvData[4] = info.linkName;
                                    }
                                    ListViewItem lvItem = new ListViewItem(lvData, 0);
                                    string ext = "";
                                    if (info.name.LastIndexOf('.') >=0)
                                    {
                                        ext = info.name.Substring(info.name.LastIndexOf('.'));
                                    }
                                    if (ext.Length > 0)
                                    {
                                        lvItem.ImageKey = GetFileIconKey(ext);
                                    }
                                    else
                                    {
                                        lvItem.ImageKey = fileIconKey[FILE_NOEXT_IMAGE_KEY];
//.........这里部分代码省略.........
开发者ID:kanyun157,项目名称:adbfile,代码行数:101,代码来源:MainFrom.cs

示例7: PopulatePhoneDirectory

        //显示目录列表
        protected void PopulatePhoneDirectory(TreeNode nodeCurrent, TreeNodeCollection nodeCurrentCollection)
        {
            TreeNode nodeDir;
            int imageIndex = 2;		//unselected image index
            int selectIndex = 3;	//selected image index

            //if (nodeCurrent.SelectedImageIndex != 0)
            {
                //populate treeview with folders
                try
                {
                    //check path
                    if (AdbFile.DirExists(getPhoneFullPath(nodeCurrent.FullPath)) == false)
                    {
                        MessageBox.Show("Directory or path " + nodeCurrent.ToString() + " does not exist.");
                    }
                    else
                    {
                        //populate files
                        /*PopulatePcFiles(nodeCurrent);

                        string[] stringDirectories = Directory.GetDirectories(getPcFullPath(nodeCurrent.FullPath));
                        string stringFullPath = "";
                        string stringPathName = "";

                        //loop throught all directories
                        foreach (string stringDir in stringDirectories)
                        {
                            stringFullPath = stringDir;
                            stringPathName = GetPcFileName(stringFullPath);

                            //create node for directories
                            nodeDir = new TreeNode(stringPathName.ToString(), imageIndex, selectIndex);
                            nodeCurrentCollection.Add(nodeDir);
                        }*/
                        bool bret = false;
                        if (nodeCurrent.SelectedImageIndex == 0)
                            bret = AdbFile.GetAllFileInfo("/", out phoneFiles);
                        else
                            bret = AdbFile.GetAllFileInfo(getPhoneFullPath(nodeCurrent.FullPath), out phoneFiles);
                        if (!bret)
                            return;
                        for (int i = 0; i < phoneFiles.Count; i++)
                        {
                            PhoneFileInfo info = phoneFiles[i];
                            if (info != null)
                            {
                                if (!info.isFile)
                                {
                                    nodeDir = new TreeNode(info.name, imageIndex, selectIndex);
                                    nodeCurrentCollection.Add(nodeDir);
                                }
                            }
                        }
                    }
                }
                catch (IOException e)
                {
                    MessageBox.Show("Error: Drive not ready or directory does not exist.");
                }
                catch (UnauthorizedAccessException e)
                {
                    MessageBox.Show("Error: Drive or directory access denided.");
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error: " + e);
                }
            }
        }
开发者ID:kanyun157,项目名称:adbfile,代码行数:71,代码来源:Form1.cs

示例8: PopulatePcFiles

        //显示文件列表
        protected void PopulatePcFiles(TreeNode nodeCurrent)
        {
            //Populate listview with files
            string[] lvData = new string[4];

            //clear list
            InitPcListView();

            if (nodeCurrent.SelectedImageIndex != 0)
            {
                //check path
                if (Directory.Exists((string)getPcFullPath(nodeCurrent.FullPath)) == false)
                {
                    MessageBox.Show("Directory or path " + nodeCurrent.ToString() + " does not exist.");
                }
                else
                {
                    try
                    {
                        string[] stringFiles = Directory.GetFiles(getPcFullPath(nodeCurrent.FullPath));
                        string stringFileName = "";
                        DateTime dtCreateDate, dtModifyDate;
                        Int64 lFileSize = 0;

                        //loop throught all files
                        foreach (string stringFile in stringFiles)
                        {
                            stringFileName = stringFile;
                            FileInfo objFileSize = new FileInfo(stringFileName);
                            lFileSize = objFileSize.Length;
                            dtCreateDate = objFileSize.CreationTime; //GetCreationTime(stringFileName);
                            dtModifyDate = objFileSize.LastWriteTime; //GetLastWriteTime(stringFileName);

                            //create listview data
                            lvData[0] = GetPcFileName(stringFileName);
                            lvData[1] = formatSize(lFileSize);

                            //check if file is in local current day light saving time
                            if (TimeZone.CurrentTimeZone.IsDaylightSavingTime(dtCreateDate) == false)
                            {
                                //not in day light saving time adjust time
                                lvData[2] = formatDate(dtCreateDate.AddHours(1));
                            }
                            else
                            {
                                //is in day light saving time adjust time
                                lvData[2] = formatDate(dtCreateDate);
                            }

                            //check if file is in local current day light saving time
                            if (TimeZone.CurrentTimeZone.IsDaylightSavingTime(dtModifyDate) == false)
                            {
                                //not in day light saving time adjust time
                                lvData[3] = formatDate(dtModifyDate.AddHours(1));
                            }
                            else
                            {
                                //not in day light saving time adjust time
                                lvData[3] = formatDate(dtModifyDate);
                            }

                            //Create actual list item
                            ListViewItem lvItem = new ListViewItem(lvData, 0);

                            // Set a default icon for the file.
                            Icon iconForFile = SystemIcons.WinLogo;
                            iconForFile = Icon.ExtractAssociatedIcon(stringFileName);
                            // Check to see if the image collection contains an image
                            // for this extension, using the extension as a key.
                            if (!imageListFile.Images.ContainsKey(objFileSize.Extension))
                            {
                                // If not, add the image to the image list.
                                iconForFile = System.Drawing.Icon.ExtractAssociatedIcon(stringFileName);
                                imageListFile.Images.Add(objFileSize.Extension, iconForFile);
                            }
                            lvItem.ImageKey = objFileSize.Extension;

                            listPCFile.Items.Add(lvItem);

                        }
                    }
                    catch (IOException e)
                    {
                        MessageBox.Show("Error: Drive not ready or directory does not exist.");
                    }
                    catch (UnauthorizedAccessException e)
                    {
                        MessageBox.Show("Error: Drive or directory access denided.");
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Error: " + e);
                    }
                }
            }
        }
开发者ID:kanyun157,项目名称:adbfile,代码行数:97,代码来源:Form1.cs


注:本文中的System.Windows.Forms.TreeNode.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。