Exemple #1
0
        private void folderSettingEnable_Click(object sender, EventArgs e)
        {
            if (RecursiveNodeCheck(selectedFolder.node) == false)
            {
                DriveBackupData tmp = Program.driveDataList[selectedDrive];
                tmp.backupList.RemoveAll(str => str.StartsWith(BackupUtil.ConvertDrivePath(selectedFolder.FullName)));
                tmp.backupList.Add(BackupUtil.ConvertDrivePath(selectedFolder.FullName));
                Program.driveDataList[selectedDrive] = tmp;
                Program.SaveDriveData(tmp);

                /*selectedFolder.ImageIndex(1);
                *
                *  bool isExpanded = selectedFolder.node.IsExpanded;
                *  selectedFolder.node.Collapse();
                *  selectedFolder.node.Nodes.Clear();
                *  selectedFolder.node.Nodes.Add(new TreeNode("**Temp", 0, 0));
                *  if(isExpanded)
                *   selectedFolder.node.Expand();*/

                selectedFolder = null;
                LoadDriveList();
                PopulateBackupDriveTree();
                UpdateUIData();
            }
        }
Exemple #2
0
        private void PopulateBackupDriveTree()
        {
            backupTreeView.Nodes.Clear();
            if (!(selectedDrive == null || !selectedDrive.IsReady))
            {
                TreeNode root = new TreeNode();
                root.Text = selectedDrive.Name;

                DirectoryInfo directories = selectedDrive.RootDirectory;
                int           imageIndex  = 0;
                foreach (string inf in Program.driveDataList[selectedDrive].backupList)
                {
                    if (BackupUtil.ConvertDrivePath(directories.FullName) == inf)
                    {
                        imageIndex = 1;
                        break;
                    }

                    if (inf.Contains(BackupUtil.ConvertDrivePath(directories.FullName)))
                    {
                        imageIndex = 2;
                    }
                }

                root.ImageIndex         = imageIndex;
                root.SelectedImageIndex = imageIndex;

                root.Tag = directories;

                if (CountSubDirectories(directories) != 0)
                {
                    TreeNode node = new TreeNode();
                    node.Text = "**Temp";
                    node.Tag  = null;

                    root.Nodes.Add(node);
                }

                backupTreeView.Nodes.Add(root);

                root.Expand();
            }

            UpdateUIData();
        }
Exemple #3
0
        private void backupTreeView_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            TreeNodeCollection nodes = e.Node.Nodes;
            bool alreadyLoaded       = true;

            foreach (TreeNode node in nodes)
            {
                if (node.Text == "**Temp" || node.Tag == null)
                {
                    node.Remove();
                    alreadyLoaded = false;
                    break;
                }
            }

            if (alreadyLoaded)
            {
                return;
            }

            foreach (DirectoryInfo dir in GetSubDirectories((DirectoryInfo)e.Node.Tag))
            {
                if (dir.Name == "__filesync")
                {
                    continue;
                }

                TreeNode tmp = new TreeNode(dir.Name, 0, 0);
                tmp.Tag = dir;

                if (CountSubDirectories(dir) != 0)
                {
                    TreeNode ph = new TreeNode();
                    ph.Text = "**Temp";
                    ph.Tag  = null;

                    tmp.Nodes.Add(ph);
                }

                e.Node.Nodes.Add(tmp);

                //Recursively check (Needs to be after added to list)
                int imageIndex = 0;
                foreach (string inf in Program.driveDataList[selectedDrive].backupList)
                {
                    if (BackupUtil.ConvertDrivePath(dir.FullName) == inf || RecursiveNodeCheck(tmp))
                    {
                        imageIndex = 1;
                        break;
                    }

                    if (inf.Contains(BackupUtil.ConvertDrivePath(dir.FullName)))
                    {
                        imageIndex = 2;
                    }
                }

                tmp.ImageIndex         = imageIndex;
                tmp.SelectedImageIndex = imageIndex;
            }
        }
Exemple #4
0
        private void UpdateUIData()
        {
            if (selectedDrive != null)
            {
                driveEditorGroup.Enabled = true;
            }
            else
            {
                driveEditorGroup.Enabled = false;
                return;
            }

            try
            {
                //DriveSettings Group
                driveSettingSetup.Enabled         = !Program.driveDataList[selectedDrive].backupDataExists;
                driveSettingForceBackup.Visible   = Program.driveDataList[selectedDrive].backupDataExists;
                driveSettingDelete.Visible        = Program.driveDataList[selectedDrive].backupDataExists;
                driveSettingBackupPath.Visible    = Program.driveDataList[selectedDrive].backupDataExists;
                driveSettingEnableBackup.Visible  = Program.driveDataList[selectedDrive].backupDataExists;
                driveSettingDisableBackup.Visible = Program.driveDataList[selectedDrive].backupDataExists;

                driveSettingEnableBackup.Enabled  = !Program.driveDataList[selectedDrive].backupEnabled;
                driveSettingDisableBackup.Enabled = Program.driveDataList[selectedDrive].backupEnabled;

                //BackupDetails Group
                backupDetailsGroup.Visible = Program.driveDataList[selectedDrive].backupDataExists;
                if (Program.driveDataList[selectedDrive].backupDataExists)
                {
                    backupPath.Text            = Program.driveDataList[selectedDrive].defaultBackupLocation + (selectedFolder != null && selectedFolder.FullName != null ? selectedFolder.FullName.Substring(2) : "");
                    backupEnabledCheck.Checked = Program.driveDataList[selectedDrive].backupEnabled;
                }

                //Folder Settings Group
                if (selectedFolder != null)
                {
                    folderSettingsGroup.Visible = Program.driveDataList[selectedDrive].backupDataExists;
                    if (RecursiveNodeCheck(selectedFolder.node) == false)
                    {
                        folderSettingDisable.Enabled = Program.driveDataList[selectedDrive].backupList.Contains(BackupUtil.ConvertDrivePath(selectedFolder.FullName));
                        folderSettingEnable.Enabled  = !Program.driveDataList[selectedDrive].backupList.Contains(BackupUtil.ConvertDrivePath(selectedFolder.FullName));
                    }
                    else
                    {
                        folderSettingEnable.Enabled  = false;
                        folderSettingDisable.Enabled = false;
                    }
                    selectedFolderPath.Text = selectedFolder.FullName;
                }
                else
                {
                    selectedFolderPath.Text     = "";
                    folderSettingsGroup.Visible = false;
                }

                //Selected Folder
                selectedFolderLabel.Visible = Program.driveDataList[selectedDrive].backupDataExists;
                selectedFolderPath.Visible  = Program.driveDataList[selectedDrive].backupDataExists;
            } catch (System.Collections.Generic.KeyNotFoundException)
            {
                driveEditorGroup.Enabled = false;
            }
        }