6 changed files
BExplorer/BetterExplorer | ||
MainWindow.xaml.cs | ||
Shell | ||
ShellContextMenu.cs | ||
ShellTreeView.xaml | ||
ShellTreeView.xaml.cs | ||
ShellViewEx.cs | ||
.gitignore | ||
MainWindow.xaml.cs
/BExplorer/BetterExplorer/MainWindow.xaml.cs+1/BExplorer/BetterExplorer/MainWindow.xaml.cs
Add comment 1655 this.ShellViewHost.Child = this._ShellListView;
Add comment 1656
Add comment 1657 this.stvTreeView.ShellListView = this._ShellListView;
Add comment 1658 Plus this.stvTreeView.NodeClick += (o, args) => { this.tcMain.NewTab(args.Item, false); };
Add comment 1658 1659 //this.ctrlConsole.ShellListView = this._ShellListView;
Add comment 1659 1660 this.autoUpdater.UpdateAvailable += this.AutoUpdater_UpdateAvailable;
Add comment 1660 1661 this.updateCheckTimer.Interval = 10000;//3600000 * 3;
Add comment 411 Marshal.Release(this._Result);
Add comment 412 this._Result = IntPtr.Zero;
Add comment 413 }
Add comment 414 Plus public void ShowContextMenu(Point pos, CMF aditionalFlags, bool IsOnEmpty = false) {
Add comment 415 Plus using (ContextMenu mnu = new ContextMenu()) {
Add comment 416 Plus this.Populate(mnu, aditionalFlags);
Add comment 417 Plus this._Timer.Interval = 2;
Add comment 418 Plus this._Timer.Tick += TimerOnTick;
Add comment 419 Plus this._Timer.Stop();
Add comment 420 Plus
Add comment 421 Plus var view = new ContextMenu();
Add comment 422 Plus var sortMenu = new ContextMenu();
Add comment 423 Plus var groupMenu = new ContextMenu();
Add comment 424 Plus var count = User32.GetMenuItemCount(mnu.Handle);
Add comment 425 Plus
Add comment 426 Plus var itemInfo = new MENUITEMINFO();
Add comment 427 Plus
Add comment 428 Plus itemInfo.fMask = MIIM.MIIM_FTYPE | MIIM.MIIM_DATA | MIIM.MIIM_STRING | MIIM.MIIM_SUBMENU | MIIM.MIIM_ID;
Add comment 429 Plus if (User32.GetMenuItemInfo(mnu.Handle, count - 1, true, ref itemInfo)) {
Add comment 430 Plus if ((itemInfo.fType & MFT.MFT_SEPARATOR) != 0) {
Add comment 431 Plus User32.DeleteMenu(mnu.Handle, count - 1, MF.MF_BYPOSITION);
Add comment 432 Plus }
Add comment 433 Plus }
Add comment 434 Plus
Add comment 435 Plus User32.GetMenuItemInfo(mnu.Handle, User32.GetMenuItemCount(mnu.Handle) - 3, true, ref itemInfo);
Add comment 436 Plus if (itemInfo.hSubMenu == IntPtr.Zero) {
Add comment 437 Plus User32.GetMenuItemInfo(mnu.Handle, User32.GetMenuItemCount(mnu.Handle) - 1, true, ref itemInfo);
Add comment 438 Plus }
Add comment 439 Plus
Add comment 440 Plus this._NewMenuPtr = itemInfo.hSubMenu;
Add comment 441 Plus
Add comment 442 Plus if (IsOnEmpty) {
Add comment 443 Plus this.GenerateExplorerBackgroundMenuItems(view, mnu, sortMenu, groupMenu);
Add comment 444 Plus } else {
Add comment 445 Plus if (this._Items.FirstOrDefault()?.IsFolder == true) {
Add comment 446 Plus this.GenerateMenuItem(mnu, System.Windows.Application.Current?.FindResource("mnuOpenNewTab")?.ToString(), 301, false, 1);
Add comment 447 Plus }
Add comment 448 Plus }
Add comment 449 Plus
Add comment 450 Plus this.RemoveDuplicatedSeparators(mnu);
Add comment 451 Plus
Add comment 452 Plus
Add comment 453 Plus
Add comment 454 Plus var command = User32.TrackPopupMenuEx(mnu.Handle, TPM.TPM_RETURNCMD, pos.X, pos.Y, m_MessageWindow.Handle, IntPtr.Zero);
Add comment 455 Plus if (command > 0 && command < m_CmdFirst) {
Add comment 456 Plus switch (command) {
Add comment 457 Plus case 245:
Add comment 458 Plus this._ShellView.SetGroupOrder(false);
Add comment 459 Plus break;
Add comment 460 Plus case 246:
Add comment 461 Plus this._ShellView.SetGroupOrder();
Add comment 462 Plus break;
Add comment 463 Plus case 247:
Add comment 464 Plus var colasc = this._ShellView.Collumns.FirstOrDefault(w => w.ID == this._ShellView.LastSortedColumnId);
Add comment 465 Plus this._ShellView.SetSortCollumn(true, colasc, SortOrder.Ascending);
Add comment 466 Plus break;
Add comment 467 Plus case 248:
Add comment 468 Plus var coldesc = this._ShellView.Collumns.FirstOrDefault(w => w.ID == this._ShellView.LastSortedColumnId);
Add comment 469 Plus this._ShellView.SetSortCollumn(true, coldesc, SortOrder.Descending);
Add comment 470 Plus break;
Add comment 471 Plus case 249:
Add comment 472 Plus this._ShellView.PasteAvailableFiles();
Add comment 473 Plus break;
Add comment 474 Plus case 250:
Add comment 475 Plus this._ShellView.RefreshContents();
Add comment 476 Plus break;
Add comment 477 Plus case 251:
Add comment 478 Plus this._ShellView.View = ShellViewStyle.ExtraLargeIcon;
Add comment 479 Plus break;
Add comment 480 Plus case 252:
Add comment 481 Plus this._ShellView.View = ShellViewStyle.LargeIcon;
Add comment 482 Plus break;
Add comment 483 Plus case 253:
Add comment 484 Plus this._ShellView.View = ShellViewStyle.Medium;
Add comment 485 Plus break;
Add comment 486 Plus case 254:
Add comment 487 Plus this._ShellView.View = ShellViewStyle.SmallIcon;
Add comment 488 Plus break;
Add comment 489 Plus case 255:
Add comment 490 Plus this._ShellView.View = ShellViewStyle.List;
Add comment 491 Plus break;
Add comment 492 Plus case 256:
Add comment 493 Plus this._ShellView.View = ShellViewStyle.Details;
Add comment 494 Plus break;
Add comment 495 Plus case 257:
Add comment 496 Plus this._ShellView.View = ShellViewStyle.Tile;
Add comment 497 Plus break;
Add comment 498 Plus case 258:
Add comment 499 Plus this._ShellView.View = ShellViewStyle.Content;
Add comment 500 Plus break;
Add comment 501 Plus case 259:
Add comment 502 Plus this._ShellView.View = ShellViewStyle.Thumbstrip;
Add comment 503 Plus break;
Add comment 504 Plus case 260:
Add comment 505 Plus if (this._ShellView.IsGroupsEnabled) {
Add comment 506 Plus this._ShellView.DisableGroups();
Add comment 507 Plus }
Add comment 508 Plus break;
Add comment 509 Plus case 301:
Add comment 510 Plus this._ShellView.RaiseMiddleClickOnItem(this._Items.First());
Add comment 511 Plus break;
Add comment 512 Plus default:
Add comment 513 Plus break;
Add comment 514 Plus }
Add comment 515 Plus
Add comment 516 Plus if (command >= 262 && command <= 262 + this._ShellView.Collumns.Count) {
Add comment 517 Plus this._ShellView.SetSortCollumn(true, this._ShellView.Collumns[command - 262], SortOrder.Ascending);
Add comment 518 Plus } else if (command > 260 && command != 301) {
Add comment 519 Plus if (!this._ShellView.IsGroupsEnabled)
Add comment 520 Plus this._ShellView.EnableGroups();
Add comment 521 Plus this._ShellView.GenerateGroupsFromColumn(this._ShellView.Collumns[command - (262 + this._ShellView.Collumns.Count) - 1], false);
Add comment 522 Plus }
Add comment 523 Plus }
Add comment 524 Plus
Add comment 525 Plus if (command > m_CmdFirst) {
Add comment 526 Plus var info = string.Empty;
Add comment 527 Plus var bytes = new byte[256];
Add comment 528 Plus IntPtr pszName = Marshal.AllocHGlobal(256);
Add comment 529 Plus this.m_ComInterface3.GetCommandString(command - (int)m_CmdFirst, 4, 0, pszName, 260);
Add comment 530 Plus
Add comment 531 Plus //var index = 0;
Add comment 532 Plus //while (index < bytes.Length - 1 && (bytes[index] != 0 || bytes[index + 1] != 0)) { index += 2; }
Add comment 533 Plus
Add comment 534 Plus //if (index < bytes.Length - 1) { info = Encoding.Unicode.GetString(bytes, 0, index); }
Add comment 535 Plus info = Marshal.PtrToStringAuto(pszName);
Add comment 536 Plus
Add comment 537 Plus switch (info) {
Add comment 538 Plus case "open":
Add comment 539 Plus //(control as ShellView)?.OpenOrNavigateItem();
Add comment 540 Plus break;
Add comment 541 Plus case "rename":
Add comment 542 Plus //(control as ShellView)?.RenameSelectedItem();
Add comment 543 Plus break;
Add comment 544 Plus case "cut":
Add comment 545 Plus //(control as ShellView)?.CutSelectedFiles();
Add comment 546 Plus break;
Add comment 547 Plus case "copy":
Add comment 548 Plus //(control as ShellView)?.CopySelectedFiles();
Add comment 549 Plus break;
Add comment 550 Plus default:
Add comment 551 Plus CMINVOKECOMMANDINFOEX cminvokecommandinfoex = new CMINVOKECOMMANDINFOEX {
Add comment 552 Plus lpVerb = (IntPtr)(command - m_CmdFirst),
Add comment 553 Plus lpVerbW = (IntPtr)(command - m_CmdFirst)
Add comment 554 Plus };
Add comment 555 Plus cminvokecommandinfoex.cbSize = Marshal.SizeOf(cminvokecommandinfoex);
Add comment 556 Plus
Add comment 557 Plus //cminvokecommandinfoex.lpDirectory = this._ShellView.CurrentFolder.ParsingName;
Add comment 558 Plus //cminvokecommandinfoex.lpDirectoryW = this._ShellView.CurrentFolder.ParsingName;
Add comment 559 Plus
Add comment 560 Plus cminvokecommandinfoex.fMask = ((CMIC.Asyncok | CMIC.PtInvoke | CMIC.Unicode | CMIC.FlagNoUi) | (((Control.ModifierKeys & Keys.Control) > Keys.None) ? CMIC.ControlDown : ((CMIC)0))) | (((Control.ModifierKeys & Keys.Shift) > Keys.None) ? CMIC.ShiftDown : ((CMIC)0));
Add comment 561 Plus cminvokecommandinfoex.ptInvoke = pos;
Add comment 562 Plus cminvokecommandinfoex.nShow = 1;
Add comment 563 Plus //cminvokecommandinfoex.hwnd = this._ShellView.LVHandle;
Add comment 564 Plus this.m_ComInterface3.InvokeCommand(ref cminvokecommandinfoex);
Add comment 565 Plus //this.InvokeCommand((IntPtr)(command - m_CmdFirst), pos, (IntPtr)(command - m_CmdFirst));
Add comment 566 Plus break;
Add comment 567 Plus }
Add comment 568 Plus }
Add comment 569 Plus
Add comment 570 Plus User32.DestroyMenu(mnu.Handle);
Add comment 571 Plus view.Dispose();
Add comment 572 Plus User32.DestroyMenu(view.Handle);
Add comment 573 Plus sortMenu.Dispose();
Add comment 574 Plus User32.DestroyMenu(sortMenu.Handle);
Add comment 575 Plus groupMenu.Dispose();
Add comment 576 Plus User32.DestroyMenu(groupMenu.Handle);
Add comment 577 Plus }
Add comment 578 Plus
Add comment 579 Plus Marshal.ReleaseComObject(this.m_ComInterface);
Add comment 580 Plus Marshal.ReleaseComObject(this.m_ComInterface2);
Add comment 581 Plus Marshal.ReleaseComObject(this.m_ComInterface3);
Add comment 582 Plus Marshal.Release(this._Result);
Add comment 583 Plus this._Result = IntPtr.Zero;
Add comment 584 Plus }
Add comment 414 585 private void TimerOnTick(Object sender, EventArgs e) {
Add comment 415 586 this._Timer.Stop();
Add comment 416 587 User32.SendMessage(this.m_MessageWindow.Handle, 0x001F, 0, 0);
Add comment 309 <Trigger Property="Orientation" Value="Horizontal">
Add comment 310 <Setter Property="Width" Value="Auto" />
Add comment 311 <Setter Property="Template" Value="{DynamicResource HorizontalScrollBar}" />
Add comment 312 Minus <Setter Property="Height" Value="18" />
Add comment 312 Plus <Setter Property="Height" Value="16" />
Add comment 313 </Trigger>
Add comment 314 <Trigger Property="Orientation" Value="Vertical">
Add comment 315 <Setter Property="Height" Value="Auto" />
Add comment 316 <Setter Property="Template" Value="{DynamicResource VerticalScrollBar}" />
Add comment 317 Minus <Setter Property="Width" Value="18" />
Add comment 317 Plus <Setter Property="Width" Value="16" />
Add comment 318 </Trigger>
Add comment 319 </Style.Triggers>
Add comment 320 </Style>
Add comment 326 <Trigger Property="Orientation" Value="Horizontal">
Add comment 327 <Setter Property="Width" Value="Auto" />
Add comment 328 <Setter Property="Template" Value="{DynamicResource HorizontalScrollBar}" />
Add comment 329 Minus <Setter Property="Height" Value="17" />
Add comment 329 Plus <Setter Property="Height" Value="16" />
Add comment 330 </Trigger>
Add comment 331 <Trigger Property="Orientation" Value="Vertical">
Add comment 332 <Setter Property="Height" Value="Auto" />
Add comment 333 <Setter Property="Template" Value="{DynamicResource VerticalScrollBar}" />
Add comment 334 Minus <Setter Property="Width" Value="17" />
Add comment 334 Plus <Setter Property="Width" Value="16" />
Add comment 335 </Trigger>
Add comment 336 </Style.Triggers>
Add comment 337 </Style>
Add comment 3 using System;
Add comment 4 using System.Collections.Generic;
Add comment 5 using System.Collections.ObjectModel;
Add comment 6 Plus using System.Drawing;
Add comment 6 7 using System.Linq;
Add comment 7 8 using System.Threading;
Add comment 8 9 using System.Windows;
Add comment 13 14 using System.Windows.Media;
Add comment 14 15 using System.Windows.Threading;
Add comment 15 16 using MouseEventArgs = System.Windows.Input.MouseEventArgs;
Add comment 17 Plus using TabControl = System.Windows.Controls.TabControl;
Add comment 16 18 using UserControl = System.Windows.Controls.UserControl;
Add comment 17 19
Add comment 18 20 namespace BExplorer.Shell {
Add comment 52 54
Add comment 53 55 #region Event Handlers
Add comment 54 56
Add comment 55 Minus public event EventHandler<TreeNodeMouseClickEventArgs> NodeClick;
Add comment 57 Plus public event EventHandler<TreeViewMiddleClickEventArgs> NodeClick;
Add comment 56 58
Add comment 57 59 public event EventHandler<NavigatedEventArgs> AfterSelect;
Add comment 58 60
Add comment 372 374 return;
Add comment 373 375 }
Add comment 374 376 var shItem = ((e.OriginalSource as FrameworkElement)?.DataContext as FilesystemTreeViewItem)?.FsItem;
Add comment 377 Plus switch (e.ChangedButton) {
Add comment 378 Plus case MouseButton.Left:
Add comment 375 379 this.NavigateListView(shItem);
Add comment 380 Plus break;
Add comment 381 Plus case MouseButton.Middle:
Add comment 382 Plus this.NodeClick?.Invoke(this, new TreeViewMiddleClickEventArgs() { Item = shItem });
Add comment 383 Plus break;
Add comment 384 Plus case MouseButton.Right:
Add comment 385 Plus var pt = this.PointToScreen(e.GetPosition(this));
Add comment 386 Plus new ShellContextMenu(this.ShellListView, shItem).ShowContextMenu(new System.Drawing.Point((Int32)pt.X, (Int32)pt.Y), CMF.CANRENAME);
Add comment 387 Plus break;
Add comment 388 Plus default:
Add comment 389 Plus throw new ArgumentOutOfRangeException();
Add comment 390 Plus }
Add comment 376 391 }
Add comment 377 392
Add comment 378 393 private void EventSetter_OnHandler(Object sender, RoutedEventArgs e) {