// // Copyright 2014 Perforce Software Inc. // using Perforce.Model; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Perforce.ViewModel { public class BreadcrumbBarViewModel : ViewModelBase { private ObservableCollection<BreadCrumbItem> _breadcrumbItems; public void UpdatePath(params ListingItem[] selection) { string depotPath = null; var isFolder = true; if (selection != null) { if (selection.Count() == 1) { depotPath = selection[0].DepotPath; isFolder = selection[0].Type.Equals(ListingItem.TYPE.FOLDER); } else if (selection.Count() > 1) { depotPath = selection[0].DepotPath; depotPath = depotPath.Substring(0, depotPath.LastIndexOf('/')); isFolder = true; } } if (depotPath == null) depotPath = "/"; var items = new List<BreadCrumbItem>(); var parts = depotPath.Split('/'); var last = depotPath.LastIndexOf('/'); while (last > 0) { var name = depotPath.Substring(last + 1); items.Add(new BreadCrumbItem { Label = name, Path = depotPath, IsFolder = isFolder }); depotPath = depotPath.Substring(0, last); last = depotPath.LastIndexOf('/'); isFolder = true; } items.Reverse(); ObservableCollection<BreadCrumbItem> update = new ObservableCollection<BreadCrumbItem>(); foreach (var item in items) { update.Add(item); } BreadcrumbItems = update; } public ObservableCollection<BreadCrumbItem> BreadcrumbItems { get { return _breadcrumbItems; } set { _breadcrumbItems = value; OnPropertyChanged("BreadcrumbItems"); } } } public class BreadCrumbItem { public string Label { get; set; } public string Path { get; set; } public bool IsFolder { get; set; } } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 16507 | perforce_software | Move to main branch. | ||
//guest/perforce_software/piper/windows/R1.1/Perforce/ViewModel/BreadcrumbBarViewModel.cs | |||||
#2 | 13572 | alan_petersen | updating R1.1 | ||
#1 | 11256 | alan_petersen |
Populate //guest/perforce_software/piper/windows/R1.1/... from //guest/perforce_software/piper/windows/main/.... |
||
//guest/perforce_software/piper/windows/main/Perforce/ViewModel/BreadcrumbBarViewModel.cs | |||||
#1 | 11255 | alan_petersen | Rename/move file(s) | ||
//guest/perforce_software/piper/windows/Perforce/ViewModel/BreadcrumbBarViewModel.cs | |||||
#1 | 10761 | alan_petersen |
initial drop of Piper for Windows.... this version still has _many_ bugs (er... i mean "unintended features") but I will be updating it over the next week as more stability is added. |