/// <summary> /// Add or overwrite the specified directroy to the project, using a specified scope and set the associated ExplorerTreeViewNode /// </summary> /// <param name="directory">Specifies the directory to add to project</param> /// <param name="scope">Specifies the scope of the specified directroy to add to project</param> internal void Project_AddDirectoryToProject(DirectoryInfo directory, Project.Project.DirectoryScope scope) { if (directory == null) { return; } if (!this._projectManager.ActiveProject.ToBackupDirectorys.ContainsKey(directory.FullName)) { //Add directory to ToDo list and set scope this._projectManager.ActiveProject.DirectoryAdd(directory, scope); } else { //Set new scope this._projectManager.ActiveProject.ToBackupDirectorys[directory.FullName] = scope; } this.Project_AddParentDirectoriesToProject(directory); }
private void trvExplorer_AfterSelect(object sender, TreeViewEventArgs e) { this._suppressControleEvents = true; // Clear if no node is selected if (this.trvExplorer.SelectedNode == null) { this.btnExplorerGoTop.Enabled = false; this.btnGoToFolder.Enabled = false; this.btnRefresh.Enabled = false; this.grbDirectoryScope.Enabled = false; this.lsvDirectoryContent.Enabled = false; this.prgItemProperty.Enabled = false; this.txtExplorerPath.Enabled = false; this.rabSaveNothing.Checked = true; this.prgItemProperty.SelectedObject = null; this._suppressControleEvents = false; return; } // Show directroy properties bool DirectroyAccess; if (OLKI.Toolbox.DirectoryAndFile.Path.IsDrive(this.trvExplorer.LastSelectedNode.DirectoryInfo.FullName)) { DriveInfo SelectedDrive = new DriveInfo(this.trvExplorer.LastSelectedNode.DirectoryInfo.Name); DirectroyAccess = SelectedDrive.IsReady; this.prgItemProperty.SelectedObject = SelectedDrive; } else { DirectroyAccess = this.trvExplorer.LastSelectedNode.DirectoryInfo.Exists; this.prgItemProperty.SelectedObject = this.trvExplorer.LastSelectedNode.DirectoryInfo; } this.btnExplorerGoTop.Enabled = DirectroyAccess; this.btnGoToFolder.Enabled = DirectroyAccess; this.btnRefresh.Enabled = DirectroyAccess; this.prgItemProperty.Enabled = true; this.txtExplorerPath.Enabled = DirectroyAccess; this.txtExplorerPath.Text = this.trvExplorer.LastSelectedNode.DirectoryInfo.FullName; //List directrory items this._mainFormHelper.DirectoryContentListView_ListDirectoryItems(this.trvExplorer.LastSelectedNode.DirectoryInfo, this.lsvDirectoryContent, this.imlListViewIcon); // Search in project for an defined scrope or set default to nothing selected Project.Project.DirectoryScope Scope = this._mainFormHelper.DirectoryContentListView_GetDirectoryScope(this.trvExplorer.LastSelectedNode.DirectoryInfo); switch (Scope) { case Project.Project.DirectoryScope.Nothing: this.rabSaveNothing.Checked = true; break; case Project.Project.DirectoryScope.All: this.rabSaveAll.Checked = true; break; case Project.Project.DirectoryScope.Selected: this.rabSaveSelected.Checked = true; break; default: this.rabSaveNothing.Checked = true; break; } //If Scope if from parent and all, avoid change scope by user if (Scope == Project.Project.DirectoryScope.All && !this._projectManager.ActiveProject.ToBackupDirectorys.ContainsKey(this.trvExplorer.LastSelectedNode.DirectoryInfo.FullName)) { this.btnLsvExplorerChangeSelect.Visible = false; this.grbDirectoryScope.Enabled = false; this.lblDirectoryScopeDisabled.Visible = true; this.lsvDirectoryContent.Enabled = false; this.rabSaveAll.Visible = false; this.rabSaveNothing.Visible = false; this.rabSaveSelected.Visible = false; } else { this.btnLsvExplorerChangeSelect.Visible = true; this.grbDirectoryScope.Enabled = DirectroyAccess; this.lblDirectoryScopeDisabled.Visible = false; this.lsvDirectoryContent.Enabled = DirectroyAccess; this.rabSaveAll.Visible = true; this.rabSaveNothing.Visible = true; this.rabSaveSelected.Visible = true; } this.SaveDirectoryScopSetSelectionControles(); this._suppressControleEvents = false; }
/// <summary> /// Set the controles for the tabPageSelect controles /// </summary> private void SaveDirectoryScopSetSelectionControles() { // Set Explorer this.btnLsvExplorerChangeSelect.Enabled = this.rabSaveSelected.Checked; this.lsvDirectoryContent.BackColor = System.Drawing.SystemColors.Window; if (this.rabSaveAll.Checked) { this.lsvDirectoryContent.BackColor = System.Drawing.Color.FromArgb(192, 255, 192); } if (this.rabSaveNothing.Checked) { this.lsvDirectoryContent.BackColor = System.Drawing.Color.FromArgb(255, 192, 192); } if (this.rabSaveSelected.Checked) { this.lsvDirectoryContent.BackColor = System.Drawing.Color.FromArgb(192, 255, 255); } // Set Directory and TreeView if (!this._suppressControleEvents) { if (this.trvExplorer.LastSelectedNode == null) { this.trvExplorer.SetImageVariant(); return; } Project.Project.DirectoryScope Scope = Project.Project.DirectoryScope.All; if (this.rabSaveNothing.Checked) { Scope = Project.Project.DirectoryScope.Nothing; } if (this.rabSaveAll.Checked) { Scope = Project.Project.DirectoryScope.All; } if (this.rabSaveSelected.Checked) { Scope = Project.Project.DirectoryScope.Selected; } switch (Scope) { case Project.Project.DirectoryScope.All: this._mainFormHelper.Project_AddDirectoryToProject(this.trvExplorer.LastSelectedNode.DirectoryInfo, Project.Project.DirectoryScope.All); this._mainFormHelper.Project_RemoveSubDirectorysAndFilesFromBackup(this.trvExplorer.LastSelectedNode.DirectoryInfo); break; case Project.Project.DirectoryScope.Nothing: this._mainFormHelper.Project_RemoveDirectorysFromBackup(this.trvExplorer.LastSelectedNode.DirectoryInfo); this._mainFormHelper.Project_RemoveSubDirectorysAndFilesFromBackup(this.trvExplorer.LastSelectedNode.DirectoryInfo); break; case Project.Project.DirectoryScope.Selected: this._mainFormHelper.Project_AddDirectoryToProject(this.trvExplorer.LastSelectedNode.DirectoryInfo, Project.Project.DirectoryScope.Selected); //Add selected sub directories and fiels or remove unselected foreach (ListViewItem Item in this.lsvDirectoryContent.Items) { this.lsvExplorer_ItemChecked(this, new ItemCheckedEventArgs(Item)); } break; default: throw new ArgumentException(); } //Set TreeNodes this.trvExplorer.SetImageVariant(this.trvExplorer.LastSelectedNode.DirectoryInfo.Root, true); } }