Beispiel #1
0
        private FileSystemTreeNode AddDriveNode(TreeView view, EntryInfo info)
        {
            FileSystemTreeNode node = FileSystemTreeNode.CreateDriveNode(info);

            view.Nodes.Add(node);
            return(node);
        }
Beispiel #2
0
        private FileSystemTreeNode AddFileNode(EntryInfo info)
        {
            FileSystemTreeNode node = FileSystemTreeNode.CreateFileNode(info);

            Nodes.Add(node);
            return(node);
        }
Beispiel #3
0
        public static FileSystemTreeNode CreateFileNode(EntryInfo info)
        {
            FileSystemTreeNode node = new FileSystemTreeNode(info.Name, 0, 0);

            node.ImageKey        = "file";
            node.Data.InfoObject = info;
            return(node);
        }
Beispiel #4
0
        public static FileSystemTreeNode CreateFolderNode(EntryInfo info)
        {
            FileSystemTreeNode node = new FileSystemTreeNode(info.Name, 0, 0);

            node.ImageKey        = "folder";
            node.Data.InfoObject = info;
            node.AddLazyLoadingNode();
            return(node);
        }
Beispiel #5
0
        public static BackupPlanTreeNode CreateFileVersionNode(BackupPlanPathNode pathNode, IFileVersion version)
        {
            Assert.AreEqual(EntryType.FILE, pathNode.Type);
            BackupPlanTreeNode node = new BackupPlanTreeNode(version.Name, 0, 0);

            node.ImageKey = "file_version";
            EntryInfo info = new EntryInfo(TypeEnum.FILE_VERSION, pathNode.Name, pathNode.Path, version);

            node.Data.InfoObject = info;
            node.Data.UserObject = pathNode;
            return(node);
        }
Beispiel #6
0
        public static BackupPlanTreeNode CreateFileNode(BackupPlanPathNode pathNode)
        {
            Assert.AreEqual(EntryType.FILE, pathNode.Type);
            BackupPlanTreeNode node = new BackupPlanTreeNode(pathNode.Name, 0, 0);

            node.ImageKey = "file";
            EntryInfo info = new EntryInfo(TypeEnum.FILE, pathNode.Name, pathNode.Path);

            node.Data.InfoObject = info;
            node.Data.UserObject = pathNode;
            node.AddLazyLoadingNode();
            return(node);
        }
Beispiel #7
0
        private void ExpandCheckedDataSourceAddParents(Dictionary <string, BackupPlanTreeNodeData> expandedDict, string path)
        {
            PathNodes nodes      = new PathNodes(path);
            PathNode  nodeParent = nodes.ParentNode;

            while (nodeParent != null)
            {
                EntryTreeNodeData newTag = null;
                switch (nodeParent.Type)
                {
                default: throw new ArgumentException("Unhandled TypeEnum", "nodeParent.Type");

                case PathNode.TypeEnum.FILE:
                {
                    EntryInfo info = new EntryInfo(TypeEnum.FILE, nodeParent.Name, nodeParent.Path);
                    newTag       = new BackupPlanTreeNodeData(StorageAccount, info);
                    newTag.State = CheckState.Mixed;
                    break;
                }

                case PathNode.TypeEnum.FOLDER:
                {
                    EntryInfo info = new EntryInfo(TypeEnum.FOLDER, nodeParent.Name, nodeParent.Path);
                    newTag       = new BackupPlanTreeNodeData(StorageAccount, info);
                    newTag.State = CheckState.Mixed;
                    break;
                }

                case PathNode.TypeEnum.DRIVE:
                {
                    EntryInfo info = new EntryInfo(TypeEnum.DRIVE, nodeParent.Name, nodeParent.Path);
                    newTag       = new BackupPlanTreeNodeData(StorageAccount, info);
                    newTag.State = CheckState.Mixed;
                    break;
                }
                }

                if (newTag != null)
                {
                    if (!expandedDict.ContainsKey(nodeParent.Path))
                    {
                        expandedDict.Add(nodeParent.Path, newTag as BackupPlanTreeNodeData);
                    }
                }

                nodeParent = nodeParent.Parent;
            }
        }
Beispiel #8
0
        private void ExpandCheckedDataSourceAddParents(Dictionary <string, FileSystemTreeNodeData> expandedDict, string path)
        {
            PathNodes nodes      = new PathNodes(path);
            PathNode  nodeParent = nodes.ParentNode;

            while (nodeParent != null)
            {
                EntryTreeNodeData newTag = null;
                switch (nodeParent.Type)
                {
                case PathNode.TypeEnum.FILE:
                {
                    EntryInfo info = new EntryInfo(TypeEnum.FILE, nodeParent.Name, nodeParent.Path);
                    newTag       = new FileSystemTreeNodeData(info);
                    newTag.State = CheckState.Mixed;
                    break;
                }

                case PathNode.TypeEnum.FOLDER:
                {
                    EntryInfo info = new EntryInfo(TypeEnum.FOLDER, nodeParent.Name, nodeParent.Path);
                    newTag       = new FileSystemTreeNodeData(info);
                    newTag.State = CheckState.Mixed;
                    break;
                }

                case PathNode.TypeEnum.DRIVE:
                {
                    EntryInfo info = new EntryInfo(TypeEnum.DRIVE, nodeParent.Name, nodeParent.Path);
                    newTag       = new FileSystemTreeNodeData(info);
                    newTag.State = CheckState.Mixed;
                    break;
                }
                }

                if (newTag != null)
                {
                    if (!expandedDict.ContainsKey(nodeParent.Path))
                    {
                        expandedDict.Add(nodeParent.Path, newTag as FileSystemTreeNodeData);
                    }
                }

                nodeParent = nodeParent.Parent;
            }
        }
Beispiel #9
0
        private void ExpandCheckedDataSourceFileVersionNode(Dictionary <string, BackupPlanTreeNodeData> expandedDict, BackupPlanTreeNodeData nodeData)
        {
            Assert.AreEqual(TypeEnum.FILE_VERSION, nodeData.Type);

            nodeData.State = CheckState.Checked;

            EntryInfo         info   = new EntryInfo(TypeEnum.FILE, nodeData.Name, nodeData.Path, null);
            EntryTreeNodeData newTag = new BackupPlanTreeNodeData(StorageAccount, info);

            newTag.State = CheckState.Mixed;

            string nodeKey = BuildNodeKey(nodeData, info.Version);

            if (!expandedDict.ContainsKey(nodeKey))
            {
                expandedDict.Add(nodeKey, newTag as BackupPlanTreeNodeData);
            }
        }
Beispiel #10
0
        public static FileSystemTreeNode CreateDriveNode(EntryInfo info)
        {
            //string nodeName = null;
            // TODO: Support showing drive label!
            //try
            //{
            //	string driveLabel = info.VolumeLabel;
            //	if (string.IsNullOrEmpty(driveLabel))
            //		nodeName = info.Name;
            //	else
            //		nodeName = string.Format("{0} ({1})", info.Name, driveLabel);
            //}
            //catch (Exception)
            //{
            //	nodeName = info.Name;
            //}

            FileSystemTreeNode node = new FileSystemTreeNode(info.Name, 0, 0);

            node.ImageKey        = "drive";
            node.Data.InfoObject = info;
            node.AddLazyLoadingNode();
            return(node);
        }
Beispiel #11
0
        // May throw System.SystemException
        private void PopuplateDirectory(EntryInfo info)
        {
            if (info.Type != TypeEnum.DRIVE && info.Type != TypeEnum.FOLDER)
            {
                throw new ArgumentException("Unexpected TypeEnum", "info.Type");
            }

            ZetaLongPaths.ZlpDirectoryInfo dir = info.Type == TypeEnum.DRIVE
                                ? new ZetaLongPaths.ZlpDirectoryInfo(new DriveInfo(info.Path).RootDirectory.FullName)
                                : new ZetaLongPaths.ZlpDirectoryInfo(info.Path);

            ZetaLongPaths.ZlpDirectoryInfo[] subDirs  = dir.GetDirectories();
            ZetaLongPaths.ZlpFileInfo[]      subFiles = dir.GetFiles();
            foreach (ZetaLongPaths.ZlpDirectoryInfo subDir in subDirs)
            {
                EntryInfo          subInfo       = new EntryInfo(TypeEnum.FOLDER, subDir.Name, subDir.FullName + System.IO.Path.DirectorySeparatorChar);
                FileSystemTreeNode subFolderNode = AddFolderNode(subInfo);
            }
            foreach (var file in subFiles)
            {
                EntryInfo          subInfo     = new EntryInfo(TypeEnum.FILE, file.Name, file.FullName);
                FileSystemTreeNode subFileNode = AddFileNode(subInfo);
            }
        }
Beispiel #12
0
        public void PopulateDrives()
        {
            try
            {
                DriveInfo[] drives = DriveInfo.GetDrives();
                foreach (var drive in drives)
                {
                    string infoName = null;
                    try
                    {
                        string driveLabel = drive.VolumeLabel;
                        if (string.IsNullOrEmpty(driveLabel))
                        {
                            infoName = drive.Name;
                        }
                        else
                        {
                            infoName = string.Format("{0} ({1})", drive.Name, driveLabel);
                        }
                    }
                    catch (Exception)
                    {
                        infoName = drive.Name;
                    }

                    EntryInfo          info      = new EntryInfo(TypeEnum.DRIVE, infoName, drive.Name);
                    FileSystemTreeNode driveNode = FileSystemTreeNode.CreateDriveNode(info);
                    this.Nodes.Add(driveNode);
                    RestoreNodeState(driveNode);
                }
            }
            catch (System.SystemException e)
            {
                ShowErrorMessage(e, null);
            }
        }
Beispiel #13
0
 public FileSystemTreeNodeData(EntryInfo infoObject)
 {
     InfoObject = infoObject;
 }
Beispiel #14
0
 // May throw System.SystemException
 private void PopulateDrive(EntryInfo info)
 {
     PopuplateDirectory(info);
 }
Beispiel #15
0
 public BackupPlanTreeNodeData(Models.StorageAccount account, EntryInfo infoObject)
 {
     StorageAccount = account;
     InfoObject     = infoObject;
 }