|
14 | 14 |
|
15 | 15 | namespace BetterExplorer { |
16 | 16 | using BEHelper; |
17 | | - using BetterExplorer.UsbEject; |
| 17 | + //using BetterExplorer.UsbEject; |
18 | 18 | using BetterExplorerControls; |
19 | 19 | using BExplorer.Shell; |
20 | 20 | using BExplorer.Shell._Plugin_Interfaces; |
@@ -934,75 +934,75 @@ private void btnCloseTray_Click(object sender, RoutedEventArgs e) { |
934 | 934 | } |
935 | 935 |
|
936 | 936 | private void EjectDisk(char DriveLetter) { |
937 | | - Thread t = new Thread(() => { |
938 | | - Thread.Sleep(10); |
939 | | - var vdc = new VolumeDeviceClass(); |
940 | | - foreach (Volume item in vdc.Devices) { |
941 | | - if (this.GetDriveLetterFromDrivePath(item.LogicalDrive) == DriveLetter) { |
942 | | - var veto = item.Eject(false); |
943 | | - if (veto != Native.PNP_VETO_TYPE.TypeUnknown) { |
944 | | - if (veto == Native.PNP_VETO_TYPE.Ok) { |
945 | | - this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, |
946 | | - (Action)(() => { |
947 | | - //this.beNotifyIcon.ShowBalloonTip("Information", $"It is safe to remove {item.LogicalDrive}", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info); |
948 | | - var tabsForRemove = this.tcMain.Items.OfType<Wpf.Controls.TabItem>().Where(w => { |
949 | | - var root = String.Empty; |
950 | | - try { |
951 | | - root = Path.GetPathRoot(w.ShellObject.ParsingName.ToShellParsingName()); |
952 | | - } catch { } |
953 | | - return !String.IsNullOrEmpty(root) && (w.ShellObject.IsFileSystem && |
954 | | - root.ToLowerInvariant() == $"{DriveLetter}:\\".ToLowerInvariant()); |
955 | | - }).ToArray(); |
956 | | - |
957 | | - foreach (Wpf.Controls.TabItem tab in tabsForRemove) { |
958 | | - this.tcMain.RemoveTabItem(tab); |
959 | | - } |
960 | | - })); |
961 | | - } else { |
962 | | - var message = String.Empty; |
963 | | - var obj = new ShellItem(item.LogicalDrive); |
964 | | - switch (veto) { |
965 | | - case Native.PNP_VETO_TYPE.Ok: |
966 | | - break; |
967 | | - case Native.PNP_VETO_TYPE.TypeUnknown: |
968 | | - break; |
969 | | - case Native.PNP_VETO_TYPE.LegacyDevice: |
970 | | - break; |
971 | | - case Native.PNP_VETO_TYPE.PendingClose: |
972 | | - break; |
973 | | - case Native.PNP_VETO_TYPE.WindowsApp: |
974 | | - break; |
975 | | - case Native.PNP_VETO_TYPE.WindowsService: |
976 | | - break; |
977 | | - case Native.PNP_VETO_TYPE.OutstandingOpen: |
978 | | - message = $"The device {obj.GetDisplayName(SIGDN.NORMALDISPLAY)} can not be disconnected because is in use!"; |
979 | | - break; |
980 | | - case Native.PNP_VETO_TYPE.Device: |
981 | | - break; |
982 | | - case Native.PNP_VETO_TYPE.Driver: |
983 | | - break; |
984 | | - case Native.PNP_VETO_TYPE.IllegalDeviceRequest: |
985 | | - break; |
986 | | - case Native.PNP_VETO_TYPE.InsufficientPower: |
987 | | - break; |
988 | | - case Native.PNP_VETO_TYPE.NonDisableable: |
989 | | - message = $"The device {obj.GetDisplayName(SIGDN.NORMALDISPLAY)} does not support disconnecting!"; |
990 | | - break; |
991 | | - case Native.PNP_VETO_TYPE.LegacyDriver: |
992 | | - break; |
993 | | - default: |
994 | | - break; |
995 | | - } |
996 | | - |
997 | | - //this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => this.beNotifyIcon.ShowBalloonTip("Error", message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Error))); |
998 | | - } |
999 | | - } |
1000 | | - break; |
1001 | | - } |
1002 | | - } |
1003 | | - }); |
1004 | | - t.SetApartmentState(ApartmentState.STA); |
1005 | | - t.Start(); |
| 937 | + //Thread t = new Thread(() => { |
| 938 | + // Thread.Sleep(10); |
| 939 | + // var vdc = new VolumeDeviceClass(); |
| 940 | + // foreach (Volume item in vdc.Devices) { |
| 941 | + // if (this.GetDriveLetterFromDrivePath(item.LogicalDrive) == DriveLetter) { |
| 942 | + // var veto = item.Eject(false); |
| 943 | + // if (veto != Native.PNP_VETO_TYPE.TypeUnknown) { |
| 944 | + // if (veto == Native.PNP_VETO_TYPE.Ok) { |
| 945 | + // this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, |
| 946 | + // (Action)(() => { |
| 947 | + // //this.beNotifyIcon.ShowBalloonTip("Information", $"It is safe to remove {item.LogicalDrive}", Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info); |
| 948 | + // var tabsForRemove = this.tcMain.Items.OfType<Wpf.Controls.TabItem>().Where(w => { |
| 949 | + // var root = String.Empty; |
| 950 | + // try { |
| 951 | + // root = Path.GetPathRoot(w.ShellObject.ParsingName.ToShellParsingName()); |
| 952 | + // } catch { } |
| 953 | + // return !String.IsNullOrEmpty(root) && (w.ShellObject.IsFileSystem && |
| 954 | + // root.ToLowerInvariant() == $"{DriveLetter}:\\".ToLowerInvariant()); |
| 955 | + // }).ToArray(); |
| 956 | + |
| 957 | + // foreach (Wpf.Controls.TabItem tab in tabsForRemove) { |
| 958 | + // this.tcMain.RemoveTabItem(tab); |
| 959 | + // } |
| 960 | + // })); |
| 961 | + // } else { |
| 962 | + // var message = String.Empty; |
| 963 | + // var obj = new ShellItem(item.LogicalDrive); |
| 964 | + // switch (veto) { |
| 965 | + // case Native.PNP_VETO_TYPE.Ok: |
| 966 | + // break; |
| 967 | + // case Native.PNP_VETO_TYPE.TypeUnknown: |
| 968 | + // break; |
| 969 | + // case Native.PNP_VETO_TYPE.LegacyDevice: |
| 970 | + // break; |
| 971 | + // case Native.PNP_VETO_TYPE.PendingClose: |
| 972 | + // break; |
| 973 | + // case Native.PNP_VETO_TYPE.WindowsApp: |
| 974 | + // break; |
| 975 | + // case Native.PNP_VETO_TYPE.WindowsService: |
| 976 | + // break; |
| 977 | + // case Native.PNP_VETO_TYPE.OutstandingOpen: |
| 978 | + // message = $"The device {obj.GetDisplayName(SIGDN.NORMALDISPLAY)} can not be disconnected because is in use!"; |
| 979 | + // break; |
| 980 | + // case Native.PNP_VETO_TYPE.Device: |
| 981 | + // break; |
| 982 | + // case Native.PNP_VETO_TYPE.Driver: |
| 983 | + // break; |
| 984 | + // case Native.PNP_VETO_TYPE.IllegalDeviceRequest: |
| 985 | + // break; |
| 986 | + // case Native.PNP_VETO_TYPE.InsufficientPower: |
| 987 | + // break; |
| 988 | + // case Native.PNP_VETO_TYPE.NonDisableable: |
| 989 | + // message = $"The device {obj.GetDisplayName(SIGDN.NORMALDISPLAY)} does not support disconnecting!"; |
| 990 | + // break; |
| 991 | + // case Native.PNP_VETO_TYPE.LegacyDriver: |
| 992 | + // break; |
| 993 | + // default: |
| 994 | + // break; |
| 995 | + // } |
| 996 | + |
| 997 | + // //this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action)(() => this.beNotifyIcon.ShowBalloonTip("Error", message, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Error))); |
| 998 | + // } |
| 999 | + // } |
| 1000 | + // break; |
| 1001 | + // } |
| 1002 | + // } |
| 1003 | + //}); |
| 1004 | + //t.SetApartmentState(ApartmentState.STA); |
| 1005 | + //t.Start(); |
1006 | 1006 | } |
1007 | 1007 |
|
1008 | 1008 | private void btnEjectDevice_Click(object sender, RoutedEventArgs e) { |
|
0 commit comments