/// <summary> /// Fetch data from corresponding folder model and its childs folder and files. /// </summary> public override void Refresh() { base.Refresh(); IList <IViewModel> list = new List <IViewModel>(); foreach (DriveInfo drive in Model.LocalDrives) { var vm = new DriveVM(Model) { AbsolutePath = drive.Name }; vm.Refresh(); list.Add(vm); } // TODO: remove this temporary "parent simulator" from childs collection // and make it separate in UI and code, but navigatable like always. IEnumerable <IViewModel> resultList = Enumerable.Empty <IViewModel>(); var fullVM = NavigateOut(); var parent = new ParentNodeVM(fullVM) { AbsolutePath = ((IViewModel)fullVM).AbsolutePath }; resultList = Enumerable.Repeat((IViewModel)parent, 1); resultList = resultList.Concat(list); // -- TODOEND -- OnPropertyChanging("Childs"); childs.Clear(); childs = new ObservableCollection <IViewModel>(resultList); OnPropertyChanged("Childs"); if (CurrentItemIndex == -1 && childs.Count > 0) { CurrentItemIndex = 0; } Header.Text = Name; // var imageConverter = new FileToIconConverter // { // DefaultSize = 16 // }; // // Header.Icon = imageConverter.GetImage(AbsolutePath, 16); }
/// <summary> /// Fetch data from corresponding folder model and its childs folder and files. /// </summary> public override void Refresh() { base.Refresh(); IList <IViewModel> list = new List <IViewModel>(); foreach (DirectoryInfo folder in Model.Folders(Folder.FullName)) { var vm = new FolderVM(Model) { AbsolutePath = folder.FullName }; vm.Refresh(); list.Add(vm); } foreach (FileInfo file in Model.Files(Folder.FullName)) { var vm = new FileVM(Model) { AbsolutePath = file.FullName }; vm.Refresh(); list.Add(vm); } // Sorting by file extenshion and, then, by file name. // TODO: make it configurable: sorting childs IOrderedEnumerable <IViewModel> sortedList = list.OrderBy(vm => vm is FileVM) .ThenBy( vm => (vm is FileVM) ? ((FileVM)vm).Extension.ToLowerInvariant() : string.Empty) .ThenBy( vm => (vm is FileVM) ? ((FileVM)vm).Name.ToLowerInvariant() : string.Empty); // -- TODOEND -- // TODO: remove this temporary "parent simulator" from childs collection // and make it separate in UI and code, but navigatable like always. IEnumerable <IViewModel> resultList = Enumerable.Empty <IViewModel>(); var fullVM = NavigateOut(); var parent = new ParentNodeVM(fullVM) { AbsolutePath = ((IViewModel)fullVM).AbsolutePath }; resultList = Enumerable.Repeat((IViewModel)parent, 1); resultList = resultList.Concat(sortedList); // -- TODOEND -- OnPropertyChanging("Childs"); childs.Clear(); childs = new ObservableCollection <IViewModel>(resultList); OnPropertyChanged("Childs"); if (CurrentItemIndex == -1 && childs.Count > 0) { CurrentItemIndex = 0; } Header.Text = Name; var imageConverter = new FileToIconConverter { DefaultSize = 16 }; Header.Icon = imageConverter.GetImage(AbsolutePath, 16); }