/// <summary> /// Creates a new tab, optionally selects it then erturns it /// </summary> /// <param name="DefPath">The <see cref="IListItemEx"/> that represents the location of this tab</param> /// <param name="IsNavigate">Do you want the new tab to be selected?</param> /// <returns></returns> public TabItem NewTab(IListItemEx DefPath, bool IsNavigate) { this.IsInTabDragDrop = false; var newt = new TabItem(DefPath) { Header = DefPath.DisplayName, Icon = DefPath.ThumbnailSource(16, BExplorer.Shell.Interop.ShellThumbnailFormatOption.IconOnly, BExplorer.Shell.Interop.ShellThumbnailRetrievalOption.Default), ToolTip = DefPath.ParsingName.Replace("%20", " ").Replace("%3A", ":").Replace("%5C", @"\"), AllowDrop = true }; newt.DragEnter += new DragEventHandler(newt_DragEnter); newt.DragOver += new DragEventHandler(newt_DragOver); newt.PreviewMouseMove += new MouseEventHandler(newt_PreviewMouseMove); newt.PreviewMouseUp += newt_PreviewMouseDown; newt.Drop += new DragEventHandler(newt_Drop); newt.DragLeave += newt_Leave; newt.GiveFeedback += newt_GiveFeedback; //TODO: Try to remove this Try Catch try { Items.Add(newt); if (IsNavigate) { this.SelectedItem = newt; } } catch (Exception) { } ConstructMoveToCopyToMenu(); this.IsInTabDragDrop = true; return(newt); }
/// <summary> /// Creates initial tab /// </summary> /// <param name="win">The main window</param> /// <param name="sho">The shell object used for tab creation</param> private void CreateInitialTab(MainWindow win, IListItemEx sho) { var bmpSource = sho.ThumbnailSource(16, ShellThumbnailFormatOption.IconOnly, ShellThumbnailRetrievalOption.Default); var newt = new Wpf.Controls.TabItem(sho) { Header = sho.DisplayName, Icon = bmpSource }; newt.PreviewMouseMove += this.Newt_PreviewMouseMove; newt.ToolTip = sho.ParsingName.Replace("%20", " ").Replace("%3A", ":").Replace("%5C", @"\"); win.tcMain.CloneTabItem(newt); }
/// <summary> /// Creates a new tab, optionally selects it then erturns it /// </summary> /// <param name="DefPath">The <see cref="IListItemEx"/> that represents the location of this tab</param> /// <param name="IsNavigate">Do you want the new tab to be selected?</param> /// <returns></returns> public TabItem NewTab(IListItemEx DefPath, bool IsNavigate) { this.IsInTabDragDrop = false; SelectNewTabOnCreate = false; var newt = new TabItem(DefPath) { Header = DefPath.DisplayName, Icon = DefPath.ThumbnailSource(16, BExplorer.Shell.Interop.ShellThumbnailFormatOption.IconOnly, BExplorer.Shell.Interop.ShellThumbnailRetrievalOption.Default), ToolTip = DefPath.ParsingName.Replace("%20", " ").Replace("%3A", ":").Replace("%5C", @"\"), AllowDrop = true }; newt.DragEnter += new DragEventHandler(newt_DragEnter); newt.DragOver += new DragEventHandler(newt_DragOver); newt.PreviewMouseMove += new MouseEventHandler(newt_PreviewMouseMove); newt.PreviewMouseUp += newt_PreviewMouseDown; newt.Drop += new DragEventHandler(newt_Drop); newt.DragLeave += newt_Leave; newt.GiveFeedback += newt_GiveFeedback; //TODO: Try to remove this Try Catch try { Items.Add(newt); //IsSelectionHandled = false; if (IsNavigate) { SelectNewTabOnCreate = true; this.SelectedItem = newt; } } catch (Exception) { } ConstructMoveToCopyToMenu(); this.IsInTabDragDrop = true; return newt; }