void newt_Drop(object sender, DragEventArgs e) { e.Handled = true; var tabItemTarget = e.Source as CloseableTabItem; var tabItemSource = e.Data.GetData(typeof(CloseableTabItem)) as CloseableTabItem; if (tabItemSource != null) { if (!tabItemTarget.Equals(tabItemSource)) { var tabControl = tabItemTarget.Parent as TabControl; int tabState = -1; int sourceIndex = tabControl.Items.IndexOf(tabItemSource); int targetIndex = tabControl.Items.IndexOf(tabItemTarget); if (!tabItemSource.IsSelected && tabItemTarget.IsSelected) tabState = 1; else if (!tabItemSource.IsSelected && !tabItemTarget.IsSelected) tabState = 2; else tabState = 0; tabControl.Items.Remove(tabItemSource); tabControl.Items.Insert(targetIndex, tabItemSource); tabControl.Items.Remove(tabItemTarget); tabControl.Items.Insert(sourceIndex, tabItemTarget); if (tabState == 1) tabControl.SelectedIndex = sourceIndex; else if (tabState == 0) tabControl.SelectedIndex = targetIndex; } } else { System.Windows.Point pt = e.GetPosition(sender as IInputElement); //if (e.Data.GetDataPresent(DataFormats.FileDrop)) //{ if ((sender as CloseableTabItem).Path.IsFileSystemObject) { if ((e.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey) { e.Effects = DragDropEffects.Copy; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { DropData PasteData = new DropData(); String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); StringCollection scol = new StringCollection(); scol.AddRange(collection); PasteData.DropList = scol; PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName; Thread t = null; t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); } } else { //if (Path.GetPathRoot((sender as CloseableTabItem).Path.ParsingName) == // Path.GetPathRoot(Explorer.NavigationLog.CurrentLocation.ParsingName)) //{ e.Effects = DragDropEffects.Move; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { DropData PasteData = new DropData(); String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); StringCollection scol = new StringCollection(); scol.AddRange(collection); PasteData.DropList = scol; PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName; Thread t = null; t = new Thread(new ParameterizedThreadStart(Explorer.DoMove)); t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); } //} //else //{ // e.Effects = DragDropEffects.Copy; // if (e.Data.GetDataPresent(DataFormats.FileDrop)) // { // DropData PasteData = new DropData(); // String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); // StringCollection scol = new StringCollection(); // scol.AddRange(collection); // PasteData.DropList = scol; // PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName; // Thread t = null; // t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); // t.SetApartmentState(ApartmentState.STA); // t.Start(PasteData); // } //} } } else { e.Effects = DragDropEffects.None; } DropTargetHelper.Drop(e.Data, pt, e.Effects); // attempt at making drag-and-drop tabs a possibility //} //else //{ // if (e.Data.GetDataPresent(typeof(CloseableTabItem))) // { // var tabItemTarget = e.Source as CloseableTabItem; // var tabItemSource = e.Data.GetData(typeof(CloseableTabItem)) as CloseableTabItem; // if (!tabItemTarget.Equals(tabItemSource)) // { // var tabControl = tabItemTarget.Parent as TabControl; // int sourceIndex = tabControl.Items.IndexOf(tabItemSource); // int targetIndex = tabControl.Items.IndexOf(tabItemTarget); // tabControl.Items.Remove(tabItemSource); // tabControl.Items.Insert(targetIndex, tabItemSource); // tabControl.Items.Remove(tabItemTarget); // tabControl.Items.Insert(targetIndex, tabItemTarget); // } // } // else // { // } //} } }
void bbi_Drop(object sender, DragEventArgs e) { System.Windows.Point pt = e.GetPosition(sender as IInputElement); if ((sender as BreadcrumbBarItem).ShellObject.IsFileSystemObject) { if ((e.KeyStates & DragDropKeyStates.ControlKey) == DragDropKeyStates.ControlKey) { e.Effects = DragDropEffects.Copy; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { DropData PasteData = new DropData(); String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); StringCollection scol = new StringCollection(); scol.AddRange(collection); PasteData.DropList = scol; PasteData.PathForDrop = (sender as BreadcrumbBarItem).ShellObject.ParsingName; AddToLog("Copied Files to " + PasteData.PathForDrop + " Files copied: " + scol.ToString()); Thread t = null; t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); } } else { //if (Path.GetPathRoot((sender as CloseableTabItem).Path.ParsingName) == // Path.GetPathRoot(Explorer.NavigationLog.CurrentLocation.ParsingName)) //{ e.Effects = DragDropEffects.Move; if (e.Data.GetDataPresent(DataFormats.FileDrop)) { DropData PasteData = new DropData(); String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); StringCollection scol = new StringCollection(); scol.AddRange(collection); PasteData.DropList = scol; PasteData.PathForDrop = (sender as BreadcrumbBarItem).ShellObject.ParsingName; AddToLog("Moved Files to " + PasteData.PathForDrop + " Files moved: " + scol.ToString()); Thread t = null; t = new Thread(new ParameterizedThreadStart(Explorer.DoMove)); t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); } //} //else //{ // e.Effects = DragDropEffects.Copy; // if (e.Data.GetDataPresent(DataFormats.FileDrop)) // { // DropData PasteData = new DropData(); // String[] collection = (String[])e.Data.GetData(DataFormats.FileDrop); // StringCollection scol = new StringCollection(); // scol.AddRange(collection); // PasteData.DropList = scol; // PasteData.PathForDrop = (sender as CloseableTabItem).Path.ParsingName; // Thread t = null; // t = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); // t.SetApartmentState(ApartmentState.STA); // t.Start(PasteData); // } //} } } else { e.Effects = DragDropEffects.None; } DropTargetHelper.Drop(e.Data, pt, e.Effects); }