/// <inheritdoc/> public DriveItemViewModel LoadChildDirectoryAndFileViewModels(DriveItemViewModel driveItemVM) { var driveItemModel = this.PresentationLogic.LoadChildDirectoriesAndFiles(driveItemVM.DriveItemModel); driveItemVM.ChildTreeItemVMs = ConvertExplorerTreeChildItemModelsInExplorerTreeChildItemVMs(driveItemVM, driveItemModel.Childs); return(driveItemVM); }
public void MultiselectDesicions_IsEnsuredOnlyDrivesAreNowSelectableByMultiselectTrue_DriveVMIsInListSelectedDrives() { SelectionConfiguration selectionConfiguration = new SelectionConfiguration(); SelectedExplorerTreeItemHandler selectedExplorerTreeItemHandler = new SelectedExplorerTreeItemHandler(selectionConfiguration); DriveSelectionHandler driveSelectionHandler = new DriveSelectionHandler(selectedExplorerTreeItemHandler, selectionConfiguration); DriveItemViewModel driveItemVM = new DriveItemViewModel(); driveSelectionHandler.MultiselectDesicions(true, driveItemVM); Assert.AreEqual(driveItemVM, selectedExplorerTreeItemHandler.SelectedDrives.First()); }
public void AddOrRemoveDriveAccordingToIsSelected_Add_DriveVMIsInListSelectedDirectories() { SelectionConfiguration selectionConfiguration = new SelectionConfiguration(); SelectedExplorerTreeItemHandler selectedExplorerTreeItemHandler = new SelectedExplorerTreeItemHandler(selectionConfiguration); DriveSelectionHandler driveSelectionHandler = new DriveSelectionHandler(selectedExplorerTreeItemHandler, selectionConfiguration); DriveItemViewModel driveItemVM = new DriveItemViewModel(); driveSelectionHandler.AddOrRemoveDriveAccordingToIsSelected(true, driveItemVM); Assert.AreEqual(driveItemVM, selectedExplorerTreeItemHandler.SelectedDrives.First()); }
public void MultiselectDesicions_IsEnsuredOnlyDrivesAreNowSelectableByMultiselectTrue_ReturnsTrue() { SelectionConfiguration selectionConfiguration = new SelectionConfiguration(); SelectedExplorerTreeItemHandler selectedExplorerTreeItemHandler = new SelectedExplorerTreeItemHandler(selectionConfiguration); DriveSelectionHandler driveSelectionHandler = new DriveSelectionHandler(selectedExplorerTreeItemHandler, selectionConfiguration); DriveItemViewModel driveItemVM = new DriveItemViewModel(); bool result = driveSelectionHandler.MultiselectDesicions(true, driveItemVM); Assert.AreEqual(true, result); }
public async Task <IActionResult> Index(string name) { var drive = await _explorer.GetDriveByName(name); ViewBag.DriveName = name; var children = await _explorer.GetDriveRoot(drive.Id); var items = children.Select(item => DriveItemViewModel.Create(item, drive.Id)); return(View("Folder", items)); }
internal void AddOrRemoveDriveAccordingToIsSelected(bool isSelected, DriveItemViewModel driveItemVM) { if (isSelected) { this.SelectedItemHandler.AddDriveToSelectedItems(driveItemVM); } else { this.SelectedItemHandler.RemoveDriveFromSelectedItems(driveItemVM); } }
public async Task <IActionResult> Folders(string name, string id) { var drive = await _explorer.GetDriveByName(name); var folderItems = await _client.Me.Drives[drive.Id].Items[id].Children .Request() .GetAsync(); var models = folderItems.Select(item => DriveItemViewModel.Create(item, drive.Id)); return(View("Folder", models)); }
public void MultiselectDesicions_IsEnsuredOnlyDrivesAreNowSelectableByMultiselectFalseBecauseFileWasSelectedFirst_ReturnsFalse() { SelectionConfiguration selectionConfiguration = new SelectionConfiguration(); SelectedExplorerTreeItemHandler selectedExplorerTreeItemHandler = new SelectedExplorerTreeItemHandler(selectionConfiguration); selectedExplorerTreeItemHandler.SelectedFiles.Add(new FileItemViewModel()); DriveSelectionHandler driveSelectionHandler = new DriveSelectionHandler(selectedExplorerTreeItemHandler, selectionConfiguration); DriveItemViewModel driveItemVM = new DriveItemViewModel(); bool result = driveSelectionHandler.MultiselectDesicions(true, driveItemVM); Assert.AreEqual(false, result); }
private bool MultiselectDrivesOnly(bool isSelected, DriveItemViewModel drive) { if (IsEnsuredOnlyDrivesAreNowSelectableByMultiselect()) { AddOrRemoveDriveAccordingToIsSelected(isSelected, drive); } else { isSelected = false; } return(isSelected); }
public void MultiselectDesicions_IsMultiselectCombinationDirectoriesAndFilesAllowedTrue_ReturnsFalse() { SelectionConfiguration selectionConfiguration = new SelectionConfiguration(); selectionConfiguration.IsMultiselectCombinationDirectoriesAndFilesAllowed = true; SelectedExplorerTreeItemHandler selectedExplorerTreeItemHandler = new SelectedExplorerTreeItemHandler(selectionConfiguration); DriveSelectionHandler driveSelectionHandler = new DriveSelectionHandler(selectedExplorerTreeItemHandler, selectionConfiguration); DriveItemViewModel driveItemVM = new DriveItemViewModel(); bool result = driveSelectionHandler.MultiselectDesicions(true, driveItemVM); Assert.AreEqual(false, result); }
public void MultiselectDesicions_IsMultiselectCombinationAllTypesAllowedTrue_DriveVMIsInListSelectedDirectories() { SelectionConfiguration selectionConfiguration = new SelectionConfiguration(); selectionConfiguration.IsMultiselectCombinationAllTypesAllowed = true; SelectedExplorerTreeItemHandler selectedExplorerTreeItemHandler = new SelectedExplorerTreeItemHandler(selectionConfiguration); DriveSelectionHandler driveSelectionHandler = new DriveSelectionHandler(selectedExplorerTreeItemHandler, selectionConfiguration); DriveItemViewModel driveItemVM = new DriveItemViewModel(); driveSelectionHandler.MultiselectDesicions(true, driveItemVM); Assert.AreEqual(driveItemVM, selectedExplorerTreeItemHandler.SelectedDrives.First()); }
/// <summary> /// /// <para> /// If the order of the if-queries is changed, /// the documentation in <see cref="ExplorerTree.API.Configuration.SelectionConfiguration.SelectionConfiguration"/> /// has to be adapted /// </para> /// </summary> /// <param name="isSelected"></param> /// <param name="drive"></param> /// <returns></returns> internal bool MultiselectDesicions(bool isSelected, DriveItemViewModel drive) { if (SelectionConfiguration.IsMultiselectCombinationAllTypesAllowed) { this.AddOrRemoveDriveAccordingToIsSelected(isSelected, drive); } else if (SelectionConfiguration.IsMultiselectCombinationDirectoriesAndFilesAllowed) { isSelected = false; } else { isSelected = MultiselectDrivesOnly(isSelected, drive); } return(isSelected); }
public void AddOrRemoveDriveAccordingToIsSelected_Remove_DriveVMIsInListSelectedExplorerTreeItems() { SelectionConfiguration selectionConfiguration = new SelectionConfiguration(); SelectedExplorerTreeItemHandler selectedExplorerTreeItemHandler = new SelectedExplorerTreeItemHandler(selectionConfiguration); DriveSelectionHandler driveSelectionHandler = new DriveSelectionHandler(selectedExplorerTreeItemHandler, selectionConfiguration); DriveItemViewModel driveItemVM = new DriveItemViewModel(); selectedExplorerTreeItemHandler.SelectedExplorerTreeItems.Add(new DriveItemViewModel()); selectedExplorerTreeItemHandler.SelectedExplorerTreeItems.Add(driveItemVM); selectedExplorerTreeItemHandler.SelectedExplorerTreeItems.Add(new DriveItemViewModel()); selectedExplorerTreeItemHandler.SelectedExplorerTreeItems.Add(new DriveItemViewModel()); driveSelectionHandler.AddOrRemoveDriveAccordingToIsSelected(false, driveItemVM); Assert.AreEqual(-1, selectedExplorerTreeItemHandler.SelectedExplorerTreeItems.IndexOf(driveItemVM)); }
public virtual void RemoveDriveFromSelectedItems(DriveItemViewModel driveItemVM) { this.SelectedExplorerTreeItems.Remove(driveItemVM); this.SelectedDrives.Remove(driveItemVM); }
public virtual void AddDriveToSelectedItems(DriveItemViewModel driveItemVM) { this.SelectedExplorerTreeItems.Add(driveItemVM); this.SelectedDrives.Add(driveItemVM); }
/// <summary> /// To generate a drive foreach drive Type from Enum: <see cref="DriveType"/> /// </summary> private static void SetDriveTypeAccordingToEnumDriveTypeAndTheLocalVariable_i(int i, DriveItemViewModel drive) { string[] driveTyps = Enum.GetNames(typeof(DriveType)); drive.DriveType = (DriveType)Enum.Parse(typeof(DriveType), driveTyps.ElementAt(i)); }