private void SelectTab(Wpf.Controls.TabItem tab) {
//tab.ShellObject = FileSystemListItem.ToFileSystemItem(this._ShellListView.LVHandle, tab.ShellObject.PIDL);
if (tab != null && !tab.ShellObject.Equals(this._ShellListView.CurrentFolder) || tab.ShellObject.IsSearchFolder) {
tcMain.isGoingBackOrForward = true;
NavigationController(tab.ShellObject);
var selectedItem = tab; //TODO: Find out if we can replace [selectedItem] with [tab]
selectedItem.Header = tab.ShellObject.DisplayName;
selectedItem.Icon = tab.ShellObject.ThumbnailSource(16, ShellThumbnailFormatOption.IconOnly, ShellThumbnailRetrievalOption.Default);
selectedItem.ShellObject = tab.ShellObject;
//if (selectedItem != null) {
var selectedPaths = selectedItem?.SelectedItems;
if (selectedPaths != null && selectedPaths.Any()) {
foreach (var path in selectedPaths) {
var sho = this._ShellListView.Items.FirstOrDefault(w => w.ParsingName == path);
if (sho != null && sho.Equals(this._ShellListView.Items[sho.ItemIndex])) {
this._ShellListView.SelectItemByIndex(sho.ItemIndex, true);
selectedPaths.Remove(path);
}
}
}
else {
//this._ShellListView.ScrollToTop();
}
//}
}
}