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); }
void mim_Click(object sender, RoutedEventArgs e) { MenuItem mi = sender as MenuItem; DropData dd = new DropData(); dd.Shellobjects = Explorer.SelectedItems; dd.PathForDrop = (mi.Tag as ShellObject).ParsingName; Thread CopyThread = new Thread(new ParameterizedThreadStart(Explorer.DoMove)); CopyThread.SetApartmentState(ApartmentState.STA); CopyThread.Start(dd); }
private void btnctOther_Click(object sender, RoutedEventArgs e) { CommonOpenFileDialog dlg = new CommonOpenFileDialog(); dlg.IsFolderPicker = true; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { DropData dd = new DropData(); dd.Shellobjects = Explorer.SelectedItems; dd.PathForDrop = dlg.FileName; Thread CopyThread = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); CopyThread.SetApartmentState(ApartmentState.STA); CopyThread.Start(dd); AddToLog("Files Copied to " + dd.PathForDrop + " Files copied: " + PathStringCombiner.CombinePaths(dd.Shellobjects.ToList())); } Explorer.Focus(); }
private void btnmtDounloads_Click(object sender, RoutedEventArgs e) { DropData dd = new DropData(); dd.Shellobjects = Explorer.SelectedItems; dd.PathForDrop = KnownFolders.Downloads.ParsingName; Thread CopyThread = new Thread(new ParameterizedThreadStart(Explorer.DoMove)); CopyThread.SetApartmentState(ApartmentState.STA); CopyThread.Start(dd); AddToLog("Files Moved to " + dd.PathForDrop + " Files moved: " + PathStringCombiner.CombinePaths(dd.Shellobjects.ToList())); }
private void btnPaste_Click(object sender, RoutedEventArgs e) { DropData PasteData = new DropData(); PasteData.DropList = System.Windows.Forms.Clipboard.GetFileDropList(); if (Explorer.SelectedItems.Count > 0 & Explorer.SelectedItems.Count < 2) { PasteData.PathForDrop = Explorer.SelectedItems[0].ParsingName; } else { PasteData.PathForDrop = Explorer.NavigationLog.CurrentLocation.ParsingName; } AddToLog(String.Format("Files Pasted at {0} Files pasted: {1}", PasteData.PathForDrop, PasteData.DropList)); Thread pasteThread = null; if (Explorer.IsMoveClipboardOperation) { pasteThread = new Thread(new ParameterizedThreadStart(Explorer.DoMove)); } else { pasteThread = new Thread(new ParameterizedThreadStart(Explorer.DoCopy)); } pasteThread.SetApartmentState(ApartmentState.STA); pasteThread.Start(PasteData); }
bool IMessageFilter.PreFilterMessage(ref Message m) { HResult hr = HResult.False; Message M = m; if (explorerBrowserControl != null) { // translate keyboard input if (m.Msg == (int)WindowsAPI.WndMsg.WM_ACTIVATEAPP) { MessageBox.Show("Active"); } if (m.Msg == (int)WindowsAPI.WndMsg.WM_SETFOCUS) { MessageBox.Show("Active"); } // Catch Left Mouse Click key if ((m.Msg == (int)WindowsAPI.WndMsg.WM_LBUTTONDOWN)) { if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = 778; KeyUP(this, args); } //WindowsAPI.SetFocus(SysListViewHandle); WindowsAPI.RECTW r = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(SysListViewHandle, ref r); Rectangle reclv = r.ToRectangle(); if (Cursor.Position.Y >= reclv.Top && Cursor.Position.Y <= reclv.Top + 29) { IsMouseClickOnHeader = true; } else { IsMouseClickOnHeader = false; } if (reclv.Contains(Cursor.Position)) { IsPressedLKButton = true; } else { IsPressedLKButton = false; } //MessageBox.Show(Cursor.Position.Y.ToString() + @"\" + reclv.Top.ToString()); if (Cursor.Position.Y <= reclv.Top || Cursor.Position.Y >= reclv.Bottom) { IsMouseClickOutsideLV = true; } else { IsMouseClickOutsideLV = false; } } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_LBUTTONUP)) { IsPressedLKButton = false; IsMouseClickOnHeader = false; //WindowsAPI.ReleaseCapture(); //WindowsAPI.SetFocus(SysListViewHandle); if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = 777; KeyUP(this, args); } } if (m.Msg == (int)WindowsAPI.WndMsg.WM_XBUTTONUP) { switch (HiWord((int)m.WParam)) { case 1: NavigateLogLocation(NavigationLogDirection.Backward); break; case 2: NavigateLogLocation(NavigationLogDirection.Forward); break; } } bool h = false; if ((m.Msg == (int)WindowsAPI.WndMsg.WM_SYSCOMMAND)) { } if (m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSEWHEEL) { int Wheel_delta = HiWord((int)m.WParam); if (LoWord((int)m.WParam) == 0x0008) //Ctrl is down { if (Wheel_delta < 0) { if (ContentOptions.ThumbnailSize > 34) { if (ContentOptions.ViewMode != ExplorerBrowserViewMode.Thumbnail) { ContentOptions.ViewMode = ExplorerBrowserViewMode.Thumbnail; } ContentOptions.ThumbnailSize = ContentOptions.ThumbnailSize - 10; } } else { if (ContentOptions.ThumbnailSize < 255) { if (ContentOptions.ViewMode != ExplorerBrowserViewMode.Thumbnail) { ContentOptions.ViewMode = ExplorerBrowserViewMode.Thumbnail; } ContentOptions.ThumbnailSize = ContentOptions.ThumbnailSize + 10; } } } } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSE_ENTER)) { //WindowsAPI.SetFocus(SysListViewHandle); } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSE_LEAVE)) { ExplorerBrowserMouseLeave.Invoke(this, null); } if (m.Msg == (int)WindowsAPI.WndMsg.WM_KEYDOWN) { // Catch ESC key if (((int)m.WParam == 27)) OnEscKey(); if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = (int)m.WParam; KeyUP(this, args); } if ((int)m.WParam == (int)Keys.ControlKey) { Ctrl = true; } if (!IsExFileOpEnabled) { if ((int)m.WParam == (int)Keys.X && Ctrl) { IsMoveClipboardOperation = true; } if ((int)m.WParam == (int)Keys.C && Ctrl) { IsMoveClipboardOperation = false; } if ((int)m.WParam == (int)Keys.V && Ctrl) { if (!Clipboard.ContainsText()) { if (Clipboard.ContainsFileDropList()) { ShellObject sho; try { sho = ShellObject.FromParsingName(System.Windows.Forms.Clipboard.GetFileDropList()[0]); } catch (Exception) { sho = null; } if (sho != null) { sho.Dispose(); DropData PasteData = new DropData(); PasteData.DropList = System.Windows.Forms.Clipboard.GetFileDropList(); if (SelectedItems.Count > 0 & SelectedItems.Count < 2) { PasteData.PathForDrop = SelectedItems[0].ParsingName; } else { PasteData.PathForDrop = NavigationLog.CurrentLocation.ParsingName; } Thread t = null; if (IsMoveClipboardOperation) { t = new Thread(new ParameterizedThreadStart(DoMove)); } else { t = new Thread(new ParameterizedThreadStart(DoCopy)); } t.SetApartmentState(ApartmentState.STA); t.Start(PasteData); return true; } } } } } } if (m.Msg == (int)WindowsAPI.WndMsg.WM_KEYUP) { if (KeyUP != null) { ExplorerKeyUPEventArgs args = new ExplorerKeyUPEventArgs(); args.Key = (int)m.WParam; KeyUP(this, args); } if ((int)m.WParam == (int)Keys.ControlKey) { Ctrl = false; } if (!IsExFileOpEnabled) { if ((int)m.WParam == (int)Keys.V && Ctrl) { return true; } } } if ((m.Msg == (int)WindowsAPI.WndMsg.WM_MOUSEMOVE)) { WindowsAPI.RECTW rscroll = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(VScrollHandle, ref rscroll); WindowsAPI.RECTW rr = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(SysListViewHandle, ref rr); Rectangle reclv = rr.ToRectangle(); Rectangle rec2 = new Rectangle(reclv.X + 1, rscroll.Top + 30, reclv.Width - 3, rscroll.Bottom - rscroll.Top - 5 - 30); //ExplorerBrowser.Checktmr.Start(); //A workarownd to ugly AutoScroll bug in IExplorerBrowsers if (m.WParam.ToInt32() == 0x0001 && !IsMouseClickOnHeader && !IsMouseClickOutsideLV) { ShellObject s; if (rscroll.Height > 0) if (!rec2.Contains(Cursor.Position)) { if (Cursor.Position.Y <= rec2.Y) { Cursor.Position = new Point(Cursor.Position.X, rec2.Top); return true; } if (Cursor.Position.Y >= rec2.Bottom) { Cursor.Position = new Point(Cursor.Position.X, rec2.Bottom - 1); return true; } } } else { BeginInvoke(new MethodInvoker( delegate { Guid iid = new Guid(ExplorerBrowserIIDGuid.IShellView); IntPtr view = IntPtr.Zero; HResult hrr = this.explorerBrowserControl.GetCurrentView(ref iid, out view); if (view != IntPtr.Zero) { IShellView isv = (IShellView)Marshal.GetObjectForIUnknown(view); AvailableVisibleColumns = AvailableColumns(isv, false); Marshal.ReleaseComObject(isv); } })); } if (!reclv.Contains(Cursor.Position)) { if (ExplorerBrowserMouseLeave != null) ExplorerBrowserMouseLeave.Invoke(this, null); } BeginInvoke(new MethodInvoker( delegate { WindowsAPI.RECTW r = new WindowsAPI.RECTW(); WindowsAPI.GetWindowRect(SysListViewHandle, ref r); Rectangle recb = r.ToRectangle(); Rectangle PopFR = new Rectangle(PopFX, PopFY, 22, 22); if (recb.Contains(Cursor.Position)) { if (CurX != ((int)M.LParam & 0x0000FFFF) | CurY != HiWord((int)M.LParam)) { try { if (!IsBool && !PopFR.Contains(Cursor.Position)) { // automan.DoQuery(factory => // { // QTTabBarLib.Automation.AutomationElement el; // try // { // el = factory.FromPoint(Cursor.Position); // } // catch // { // // el = null; // } // // if (el != null) // { // string name = el.GetClassName(); // string name2 = el.GetParent().GetClassName(); // if (name == "UIProperty" || name == "UIImage") // { // el = el.GetParent(); // } // // if (el.GetClassName() == "UIItem") // { // //MessageBox.Show(el.GetBoundingRect().Top.ToString() + "/" + el.GetBoundingRect().Left.ToString() + " - " + el.GetClassName()); // Rectangle ImageRecT = new Rectangle(); // Rectangle TextRecT = new Rectangle(); // // foreach (QTTabBarLib.Automation.AutomationElement elm in el.GetChildren()) // { // //MessageBox.Show(elm.GetClassName()); // if (elm.GetClassName() == "UIImage") // { // ImageRecT = elm.GetBoundingRect(); // } // if (elm.GetClassName() == "UIProperty") // { // // TextRecT = new Rectangle(ImageRecT.Left, // ImageRecT.Top, // AvailableVisibleColumns[0].Width, elm.GetBoundingRect().Height); // } // } // // vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), false, ImageRecT, TextRecT); // } // else // { // //MessageBox.Show(name); // if (el.GetClassName() == "UIItemsView" | el.GetClassName() == "UIGroupItem") // { // vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), true, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, 0, 0)); // } // else // { // vItemHot(el.GetClassName(), el.GetItemName(), el.GetBoundingRect(), el.GetItemIndex(), true, new Rectangle(0, 0, 0, 0), new Rectangle(0, 0, 0, 0)); // } // // } // el.Dispose(); // } // // return 1; // }); } else { } } catch (Exception ex) { if (automan != null) { automan.Dispose(); } //return 1; } CurX = LoWord((int)M.LParam); CurY = HiWord((int)M.LParam); } } })); } if (m.Msg == (int)WindowsAPI.WndMsg.WM_PAINT) { if (IsOldSysListView) { WindowsAPI.SendMessage(SysListViewHandle, 296, MAKELONG(1, 1), 0); } } Invoke(new MethodInvoker( delegate { hr = ((IInputObject)explorerBrowserControl).TranslateAcceleratorIO(ref M); })); } return (hr == HResult.Ok); }
private void btnmtDesktop_Click(object sender, RoutedEventArgs e) { DropData dd = new DropData(); dd.Shellobjects = Explorer.SelectedItems; dd.PathForDrop = KnownFolders.Desktop.ParsingName; Thread CopyThread = new Thread(new ParameterizedThreadStart(Explorer.DoMove)); CopyThread.SetApartmentState(ApartmentState.STA); CopyThread.Start(dd); AddToLog("The following files have been moved to " + dd.PathForDrop + ": " + PathStringCombiner.CombinePaths(dd.Shellobjects.ToList(), " ")); }