9 changed files
BExplorer/BetterExplorer | ||
BetterExplorer.csproj | ||
MainWindow.xaml.cs | ||
Shell/Interop | ||
Kernel32.cs | ||
UsbEject | ||
UsbEject | ||
DeviceClass.cs | ||
Native.cs | ||
Volume.cs | ||
App.config | ||
packages.config | ||
UsbEject.csproj | ||
BetterExplorer.csproj
/BExplorer/BetterExplorer/BetterExplorer.csproj-1+1/BExplorer/BetterExplorer/BetterExplorer.csproj
Add comment 1190 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Add comment 1191 <ProjectExtensions>
Add comment 1192 <VisualStudio>
Add comment 1193 Minus <UserProperties BuildVersion_BuildVersioningStyle="None.None.None.Increment" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" BuildVersion_UseGlobalSettings="True" />
Add comment 1193 Plus <UserProperties BuildVersion_UseGlobalSettings="True" BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.None.Increment" />
Add comment 1194 </VisualStudio>
Add comment 1195 </ProjectExtensions>
Add comment 1196 <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
MainWindow.xaml.cs
/BExplorer/BetterExplorer/MainWindow.xaml.cs-179+90/BExplorer/BetterExplorer/MainWindow.xaml.cs
Displayed content is truncated due to maximum viewable content limit.
Add comment 131 spCommandPrompt.Height = GridLength.Auto;
Add comment 132 if (!ctrlConsole.IsProcessRunning)
Add comment 133 ctrlConsole.ChangeFolder(_ShellListView.CurrentFolder.ParsingName, _ShellListView.CurrentFolder.IsFileSystem);
Add comment 134 Minus }
Add comment 135 Minus else {
Add comment 134 Plus } else {
Add comment 136 135 rCommandPrompt.MinHeight = 0;
Add comment 137 136 rCommandPrompt.Height = new GridLength(0);
Add comment 138 137 spCommandPrompt.Height = new GridLength(0);
Add comment 144 143 if (((Boolean)e.NewValue)) {
Add comment 145 144 this._ShellListView.IsFocusAllowed = false;
Add comment 146 145 backstage.Focus();
Add comment 147 Minus }
Add comment 148 Minus else {
Add comment 146 Plus } else {
Add comment 149 147 this._ShellListView.IsFocusAllowed = true;
Add comment 150 148 }
Add comment 151 149 autoUpdater.Visibility = Visibility.Visible;
Add comment 172 170 Convert.ToInt32(rks.GetValue("LastWindowPosLeft", "0")),
Add comment 173 171 Convert.ToInt32(rks.GetValue("LastWindowPosTop", "0"))
Add comment 174 172 );
Add comment 175 Minus }
Add comment 176 Minus catch { }
Add comment 173 Plus } catch { }
Add comment 177 174
Add comment 178 175 if (Location != null) {
Add comment 179 176 this.Left = Location.X;
Add comment 209 206 rCommandPrompt.MinHeight = 100;
Add comment 210 207 rCommandPrompt.Height = new GridLength(this.CommandPromptWinHeight);
Add comment 211 208 spCommandPrompt.Height = GridLength.Auto;
Add comment 212 Minus }
Add comment 213 Minus else {
Add comment 209 Plus } else {
Add comment 214 210 rCommandPrompt.MinHeight = 0;
Add comment 215 211 rCommandPrompt.Height = new GridLength(0);
Add comment 216 212 spCommandPrompt.Height = new GridLength(0);
Add comment 265 261 var IsCheckable2 = _ShellListView.LastGroupCollumn != null && (item.pkey.fmtid == _ShellListView.LastGroupCollumn.pkey.fmtid) && (item.pkey.pid == _ShellListView.LastGroupCollumn.pkey.pid);
Add comment 266 262 btnGroup.Items.Add(Utilities.Build_MenuItem(item.Name, item, checkable: true, isChecked: IsCheckable2, GroupName: "GR3", onClick: mig_Click));
Add comment 267 263 }
Add comment 268 Minus }
Add comment 269 Minus catch (Exception ex) {
Add comment 264 Plus } catch (Exception ex) {
Add comment 270 265 //FIXME: I disable this message because of strange null after filter
Add comment 271 266 MessageBox.Show("BetterExplorer had an issue loading the visible columns for the current view. You might not be able to sort or group items.", ex.ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
Add comment 272 267 }
Add comment 317 312 chcm.Items.Add(
Add comment 318 313 Utilities.Build_MenuItem(allAvailColls[j].Name, allAvailColls[j], checkable: true, onClick: mic_Click, isChecked: IsChecked)
Add comment 319 314 );
Add comment 315 Plus } catch (Exception) {
Add comment 320 316 }
Add comment 321 Minus catch (Exception) {
Add comment 322 317 }
Add comment 323 Minus }
Add comment 324 318
Add comment 325 319 int ItemsCount = _ShellListView.Items.Count;
Add comment 326 320 sbiItemsCount.Visibility = ItemsCount == 0 ? Visibility.Collapsed : Visibility.Visible;
Add comment 369 363 var lib = ShellLibrary.Load(Path.GetFileNameWithoutExtension(_ShellListView.CurrentFolder.ParsingName), false);
Add comment 370 364 lib.DefaultSaveFolder = SaveLoc.ParsingName;
Add comment 371 365 lib.Close();
Add comment 372 Minus }
Add comment 373 Minus else if (_ShellListView.GetFirstSelectedItem().ParsingName.Contains(KnownFolders.Libraries.ParsingName)) {
Add comment 366 Plus } else if (_ShellListView.GetFirstSelectedItem().ParsingName.Contains(KnownFolders.Libraries.ParsingName)) {
Add comment 374 367 var lib = ShellLibrary.Load(Path.GetFileNameWithoutExtension(_ShellListView.GetFirstSelectedItem().ParsingName), false);
Add comment 375 368 lib.DefaultSaveFolder = SaveLoc.ParsingName;
Add comment 376 369 lib.Close();
Add comment 447 440 if (ctgLibraries.Visibility == Visibility.Visible && _ShellListView.CurrentFolder.ParsingName.Equals(KnownFolders.Libraries.ParsingName)) {
Add comment 448 441 if (selectedItem != null && selectedItemsCount == 1)
Add comment 449 442 SetupLibrariesTab(ShellLibrary.Load(Path.GetFileNameWithoutExtension(selectedItem.ParsingName), false));
Add comment 450 Minus }
Add comment 451 Minus else if (ctgLibraries.Visibility == Visibility.Visible && _ShellListView.CurrentFolder.Parent.ParsingName.Equals(KnownFolders.Libraries.ParsingName)) {
Add comment 443 Plus } else if (ctgLibraries.Visibility == Visibility.Visible && _ShellListView.CurrentFolder.Parent.ParsingName.Equals(KnownFolders.Libraries.ParsingName)) {
Add comment 452 444 if (selectedItemsCount == 1)
Add comment 453 445 SetupLibrariesTab(ShellLibrary.Load(Path.GetFileNameWithoutExtension(_ShellListView.CurrentFolder.ParsingName), false));
Add comment 454 446 }
Add comment 483 475 if (asImage) TheRibbon.SelectedTabItem = ctgImage.Items[0];
Add comment 484 476 }
Add comment 485 477 }
Add comment 486 Minus }
Add comment 487 Minus catch (Exception) {
Add comment 478 Plus } catch (Exception) {
Add comment 488 479 MessageBox.Show("Image was invalid");
Add comment 489 480 }
Add comment 490 481 }
Add comment 563 554
Add comment 564 555 if (selectedItem == null) {
Add comment 565 556 btnOpenWith.IsEnabled = false;
Add comment 566 Minus }
Add comment 567 Minus else {
Add comment 557 Plus } else {
Add comment 568 558 var mnu = new ShellContextMenu(this._ShellListView, false);
Add comment 569 559
Add comment 570 560 try {
Add comment 571 561 var tempPoint = btnOpenWith.PointToScreen(new WIN.Point(0, 0));
Add comment 572 562 var itemMenuCount = mnu.ShowContextMenu(new System.Drawing.Point((int)tempPoint.X, (int)tempPoint.Y + (int)btnOpenWith.ActualHeight), 1, false);
Add comment 573 563 btnOpenWith.IsEnabled = itemMenuCount > 0 && selItemsCount == 1;
Add comment 574 Minus }
Add comment 575 Minus catch {
Add comment 564 Plus } catch {
Add comment 576 565 btnOpenWith.IsEnabled = false;
Add comment 577 566 }
Add comment 578 567 }
Add comment 635 624 FolderSizeWindow.Open(_ShellListView.GetFirstSelectedItem().ParsingName, this);
Add comment 636 625 return;
Add comment 637 626 }
Add comment 638 Minus }
Add comment 639 Minus else if ((_ShellListView.CurrentFolder.IsFolder || _ShellListView.CurrentFolder.IsDrive) && _ShellListView.CurrentFolder.IsFileSystem) {
Add comment 627 Plus } else if ((_ShellListView.CurrentFolder.IsFolder || _ShellListView.CurrentFolder.IsDrive) && _ShellListView.CurrentFolder.IsFileSystem) {
Add comment 640 628 FolderSizeWindow.Open(_ShellListView.CurrentFolder.ParsingName, this);
Add comment 641 629 }
Add comment 642 630 }
Add comment 947 935 tcMain.RemoveTabItem(tab);
Add comment 948 936 }
Add comment 949 937 }));
Add comment 950 Minus }
Add comment 951 Minus else {
Add comment 938 Plus } else {
Add comment 952 939 var message = String.Empty;
Add comment 953 940 var obj = new ShellItem(item.LogicalDrive);
Add comment 954 941 switch (veto) {
Add comment 991 978 }
Add comment 992 979 }
Add comment 993 980 });
Add comment 994 Minus
Add comment 981 Plus t.SetApartmentState(ApartmentState.STA);
Add comment 995 982 t.Start();
Add comment 996 983 }
Add comment 997 984
Add comment 1007 994 try {
Add comment 1008 995 ImDiskAPI.GetDeviceList();
Add comment 1009 996 return true;
Add comment 1010 Minus }
Add comment 1011 Minus catch (DllNotFoundException) {
Add comment 997 Plus } catch (DllNotFoundException) {
Add comment 1012 998 return false;
Add comment 1013 999 }
Add comment 1014 1000 }
Add comment 1081 1067 try {
Add comment 1082 1068 var freeDriveLetter = $"{ImDiskAPI.FindFreeDriveLetter()}:";
Add comment 1083 1069 ImDiskAPI.CreateDevice(0, 0, 0, 0, 0, ImDiskFlags.Auto, _ShellListView.GetFirstSelectedItem().ParsingName, false, freeDriveLetter, IntPtr.Zero);
Add comment 1084 Minus }
Add comment 1085 Minus catch (DllNotFoundException) {
Add comment 1070 Plus } catch (DllNotFoundException) {
Add comment 1086 1071 ShowInstallImDiskMessage();
Add comment 1087 Minus }
Add comment 1088 Minus catch (Exception ex) {
Add comment 1072 Plus } catch (Exception ex) {
Add comment 1089 1073 MessageBox.Show("An error occurred while trying to mount this file. \n\n" + ex.Message, ex.ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
Add comment 1090 1074 }
Add comment 1091 1075 }
Add comment 1105 1089 ImDiskAPI.ForceRemoveDevice(SelectedDriveID);
Add comment 1106 1090 else
Add comment 1107 1091 ImDiskAPI.RemoveDevice(SelectedDriveID);
Add comment 1108 Minus }
Add comment 1109 Minus catch {
Add comment 1092 Plus } catch {
Add comment 1110 1093 if (MessageBox.Show("The drive could not be removed. Would you like to try to force a removal?", "Remove Drive Failed", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes) {
Add comment 1111 1094 ImDiskAPI.ForceRemoveDevice(SelectedDriveID);
Add comment 1112 1095 }
Add comment 1177 1160 sw.WriteLine(DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " : " + value);
Add comment 1178 1161 }
Add comment 1179 1162 }
Add comment 1180 Minus }
Add comment 1181 Minus catch (Exception exe) {
Add comment 1163 Plus } catch (Exception exe) {
Add comment 1182 1164 MessageBox.Show("An error occurred while writing to the log file. This error can be avoided if you disable the action logging feature. Please report this issue at http://bugs.gainedge.org/public/betterexplorer. \r\n\r\n Here is some information about the error: \r\n\r\n" + exe.Message + "\r\n\r\n" + exe.ToString(), "Error While Writing to Log", MessageBoxButton.OK, MessageBoxImage.Error);
Add comment 1183 1165 }
Add comment 1184 1166 }
Add comment 1266 1248 }
Add comment 1267 1249 }
Add comment 1268 1250 Reader.Close();
Add comment 1251 Plus } catch (Exception) {
Add comment 1269 1252 }
Add comment 1270 Minus catch (Exception) {
Add comment 1271 Minus }
Add comment 1272 1253
Add comment 1273 1254 return result;
Add comment 1274 1255 }
Add comment 1336 1317 var SelectedColumn = this._ShellListView.Collumns[e.ColumnIndex];
Add comment 1337 1318 if (SelectedColumn.CollumnType == typeof(String)) {
Add comment 1338 1319 Things.AddRange(new[] { "0 - 9", "A - H", "I - P", "Q - Z", "Other" });
Add comment 1339 Minus }
Add comment 1340 Minus else if (SelectedColumn.CollumnType == typeof(DateTime)) {
Add comment 1320 Plus } else if (SelectedColumn.CollumnType == typeof(DateTime)) {
Add comment 1341 1321 var Container = new ItemsControl();
Add comment 1342 1322 Container.Items.Add(new MenuItem() { Icon = new ImageSourceConverter().ConvertFromString(packUri) as ImageSource, Header = "Select a date or date range:", HorizontalContentAlignment = HorizontalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch, IsCheckable = true, StaysOpenOnClick = true });
Add comment 1343 1323 Container.Items.Add(new Calendar() { SelectionMode = CalendarSelectionMode.SingleRange, Margin = new Thickness(30, 0, 0, 0) });
Add comment 1344 1324 menu.AddItem(Container);
Add comment 1345 1325
Add comment 1346 1326 Things.AddRange(new[] { "A long time ago", "Earlier this year", "Earlier this month", "Last week", "Today" });
Add comment 1347 Minus }
Add comment 1348 Minus else if (SelectedColumn.CollumnType == typeof(long)) {
Add comment 1327 Plus } else if (SelectedColumn.CollumnType == typeof(long)) {
Add comment 1349 1328 Things.AddRange(new[] { "Tiny (0 - 10 KB)", "Small (10 - 100 KB)", "Medium (100 KB - 1 MB)", "Large (1 - 16 MB)", "Huge (16 - 128 MB)", "Unspecified" });
Add comment 1350 Minus }
Add comment 1351 Minus else if (SelectedColumn.CollumnType == typeof(Type)) {
Add comment 1329 Plus } else if (SelectedColumn.CollumnType == typeof(Type)) {
Add comment 1352 1330 var distictItems = this._ShellListView.Items.Select(s => s.GetPropertyValue(SelectedColumn.pkey, SelectedColumn.CollumnType).Value).Distinct().Cast<String>().ToArray().OrderBy(o => o);
Add comment 1353 1331 Things.AddRange(distictItems);
Add comment 1354 1332 }
Add comment 1445 1423 if (IsInfoPaneEnabled) {
Add comment 1446 1424 rPreviewPane.Height = new GridLength(InfoPaneHeight);
Add comment 1447 1425 rPreviewPaneSplitter.Height = new GridLength(1);
Add comment 1448 Minus }
Add comment 1449 Minus else {
Add comment 1426 Plus } else {
Add comment 1450 1427 rPreviewPane.Height = new GridLength(0);
Add comment 1451 1428 rPreviewPaneSplitter.Height = new GridLength(0);
Add comment 1452 1429 }
Add comment 1459 1436 if (IsPreviewPaneEnabled) {
Add comment 1460 1437 clPreview.Width = new GridLength((double)PreviewPaneWidth);
Add comment 1461 1438 clPreviewSplitter.Width = new GridLength(1);
Add comment 1462 Minus }
Add comment 1463 Minus else {
Add comment 1439 Plus } else {
Add comment 1464 1440 clPreview.Width = new GridLength(0);
Add comment 1465 1441 clPreviewSplitter.Width = new GridLength(0);
Add comment 1466 1442 }
Add comment 1535 1511 chkIsDefault.IsEnabled = true;
Add comment 1536 1512 rksbe.Close();
Add comment 1537 1513 rkbe.Close();
Add comment 1538 Minus }
Add comment 1539 Minus catch (Exception) {
Add comment 1514 Plus } catch (Exception) {
Add comment 1540 1515 chkIsDefault.IsChecked = false;
Add comment 1541 1516 chkIsDefault.IsEnabled = false;
Add comment 1542 1517 }
Add comment 1563 1538 try {
Add comment 1564 1539 autoUpdater.UpdateType = IsUpdateCheck ? UpdateType.OnlyCheck : UpdateType.DoNothing;
Add comment 1565 1540 if (IsUpdateCheckStartup) this.CheckForUpdate();
Add comment 1566 Minus }
Add comment 1567 Minus catch (IOException) {
Add comment 1541 Plus } catch (IOException) {
Add comment 1568 1542 this.stiUpdate.Content = "Switch to another BetterExplorer window or restart to check for updates.";
Add comment 1569 1543 this.btnUpdateCheck.IsEnabled = false;
Add comment 1570 1544 }
Add comment 1600 1574 });
Add comment 1601 1575
Add comment 1602 1576 AppJL.Apply();
Add comment 1577 Plus } catch {
Add comment 1603 1578 }
Add comment 1604 Minus catch {
Add comment 1605 1579 }
Add comment 1606 Minus }
Add comment 1607 1580
Add comment 1608 1581 private void Window_Loaded(object sender, RoutedEventArgs e) {
Add comment 1609 1582 this._ProgressTimer.Tick += (obj, args) => {
Add comment 1610 1583 if (this.bcbc.ProgressValue + 2 == this.bcbc.ProgressMaximum) {
Add comment 1611 1584 this.bcbc.ProgressMaximum = this.bcbc.ProgressMaximum + 2;
Add comment 1612 1585 this.bcbc.SetProgressValue(this.bcbc.ProgressValue + 2, TimeSpan.FromMilliseconds(0));
Add comment 1613 Minus }
Add comment 1614 Minus else {
Add comment 1586 Plus } else {
Add comment 1615 1587 this.bcbc.SetProgressValue(this.bcbc.ProgressValue + 2, TimeSpan.FromMilliseconds(450));
Add comment 1616 1588 }
Add comment 1617 1589 };
Add comment 1696 1668 if (Application.Current.Properties["cmd"] != null && Application.Current.Properties["cmd"].ToString() != "-minimized") {
Add comment 1697 1669 //if (Application.Current.Properties["cmd"].ToString() == "/nw")
Add comment 1698 1670 //tcMain.NewTab(ShellListView.CurrentFolder, true);
Add comment 1699 Minus }
Add comment 1700 Minus else {
Add comment 1671 Plus } else {
Add comment 1701 1672 InitializeInitialTabs();
Add comment 1702 1673 }
Add comment 1703 1674
Add comment 1711 1682 }
Add comment 1712 1683
Add comment 1713 1684 focusTimer.Tick += focusTimer_Tick;
Add comment 1714 Minus }
Add comment 1715 Minus catch (Exception exe) {
Add comment 1685 Plus } catch (Exception exe) {
Add comment 1716 1686 MessageBox.Show($"An error occurred while loading the window. Please report this issue at http://bugs.gainedge.org/public/betterexplorer. \r\n\r\n Here is some information about the error: \r\n\r\n{exe.Message}\r\n\r\n{exe}", "Error While Loading", MessageBoxButton.OK, MessageBoxImage.Error);
Add comment 1717 1687 }
Add comment 1718 1688 }
Add comment 1736 1706 if (newVersion.Contains("RC") || newVersion.Contains("Nightly") || newVersion.Contains("Beta") || newVersion.Contains("Alpha")) {
Add comment 1737 1707 config.FooterText = "This is an experimental version and may contains bugs. Use at your own risk!";
Add comment 1738 1708 config.FooterIcon = VistaTaskDialogIcon.Warning;
Add comment 1739 Minus }
Add comment 1740 Minus else {
Add comment 1709 Plus } else {
Add comment 1741 1710 config.FooterText = "This is a final version and can be installed safely!";
Add comment 1742 1711 config.FooterIcon = VistaTaskDialogIcon.SecuritySuccess;
Add comment 1743 1712 }
Add comment 1759 1728 if (args.ButtonId == 500) {
Add comment 1760 1729 this.autoUpdater.ReadyToBeInstalled += AutoUpdater_ReadyToBeInstalled;
Add comment 1761 1730 this.autoUpdater.InstallNow();
Add comment 1731 Plus } else if (args.ButtonId == 501) {
Add comment 1762 1732 }
Add comment 1763 Minus else if (args.ButtonId == 501) {
Add comment 1764 Minus }
Add comment 1765 1733 break;
Add comment 1766 1734 }
Add comment 1767 1735
Add comment 1877 1845
Add comment 1878 1846 this.WindowState = WindowState.Minimized;
Add comment 1879 1847 this.Visibility = Visibility.Hidden;
Add comment 1880 Minus }
Add comment 1881 Minus else {
Add comment 1848 Plus } else {
Add comment 1882 1849 beNotifyIcon.Visibility = Visibility.Collapsed;
Add comment 1883 1850 }
Add comment 1884 1851
Add comment 1960 1927 try {
Add comment 1961 1928 Directory.CreateDirectory(OutputLoc);
Add comment 1962 1929 ExtractToLocation(SelectedArchive, OutputLoc);
Add comment 1963 Minus }
Add comment 1964 Minus catch (Exception) {
Add comment 1930 Plus } catch (Exception) {
Add comment 1965 1931 MessageBoxResult wtd = MessageBox.Show($"The directory {OutputLoc} already exists. Would you like for BetterExplorer to extract there instead?", "Folder Exists", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
Add comment 1966 1932 switch (wtd) {
Add comment 1967 1933 case MessageBoxResult.Cancel:
Add comment 1979 1945 break;
Add comment 1980 1946 }
Add comment 1981 1947 }
Add comment 1982 Minus }
Add comment 1983 Minus else {
Add comment 1948 Plus } else {
Add comment 1984 1949 ExtractToLocation(SelectedArchive, txtExtractLocation.Text);
Add comment 1985 1950 }
Add comment 1986 1951 }
Add comment 2009 1974 try {
Add comment 2010 1975 var CAI = new CreateArchive(selectedItems, false, _ShellListView.GetFirstSelectedItem().ParsingName);
Add comment 2011 1976 CAI.Show(this.GetWin32Window());
Add comment 2012 Minus }
Add comment 2013 Minus catch {
Add comment 1977 Plus } catch {
Add comment 2014 1978
Add comment 2015 1979 }
Add comment 2016 1980 }
Add comment 2130 2094 lib.IsPinnedToNavigationPane = e.RoutedEvent.Name == "Checked";
Add comment 2131 2095
Add comment 2132 2096 lib.Close();
Add comment 2097 Plus } catch (FileNotFoundException) { }
Add comment 2133 2098 }
Add comment 2134 Minus catch (FileNotFoundException) { }
Add comment 2135 Minus }
Add comment 2136 2099
Add comment 2137 2100 private void btnManageLib_Click(object sender, RoutedEventArgs e) {
Add comment 2138 2101 this._ShellListView.CurrentRefreshedItemIndex = this._ShellListView.GetFirstSelectedItemIndex();
Add comment 2139 2102 try {
Add comment 2140 2103 ShellLibrary.ShowManageLibraryUI(_ShellListView.GetFirstSelectedItem().ComInterface,
Add comment 2141 2104 this.Handle, "Choose which folders will be in this library", "A library gathers content from all of the folders listed below and puts it all in one window for you to see.", true);
Add comment 2142 Minus }
Add comment 2143 Minus catch {
Add comment 2105 Plus } catch {
Add comment 2144 2106 ShellLibrary.ShowManageLibraryUI(_ShellListView.CurrentFolder.ComInterface,
Add comment 2145 2107 this.Handle, "Choose which folders will be in this library", "A library gathers content from all of the folders listed below and puts it all in one window for you to see.", true);
Add comment 2146 2108 }
Add comment 2403 2365 btnCreateFolder.Header = FindResource("btnNewLibraryCP"); //"New Library";
Add comment 2404 2366 stNewFolder.Title = FindResource("btnNewLibraryCP").ToString(); //"New Library";
Add comment 2405 2367 stNewFolder.Text = "Creates a new library in the current folder.";
Add comment 2406 Minus }
Add comment 2407 Minus else {
Add comment 2368 Plus } else {
Add comment 2408 2369 btnCreateFolder.Header = FindResource("btnNewFolderCP"); //"New Folder";
Add comment 2409 2370 stNewFolder.Title = FindResource("btnNewFolderCP").ToString(); //"New Folder";
Add comment 2410 2371 stNewFolder.Text = "Creates a new folder in the current folder";
Add comment 2434 2395 if (sender == ConvertToJPG) {
Add comment 2435 2396 format = ImageFormat.Jpeg;
Add comment 2436 2397 extension = ".jpg";
Add comment 2437 Minus }
Add comment 2438 Minus else if (sender == ConvertToPNG) {
Add comment 2398 Plus } else if (sender == ConvertToPNG) {
Add comment 2439 2399 format = ImageFormat.Png;
Add comment 2440 2400 extension = ".png";
Add comment 2441 Minus }
Add comment 2442 Minus else if (sender == ConvertToGIF) {
Add comment 2401 Plus } else if (sender == ConvertToGIF) {
Add comment 2443 2402 format = ImageFormat.Gif;
Add comment 2444 2403 extension = ".gif";
Add comment 2445 Minus }
Add comment 2446 Minus else if (sender == ConvertToBMP) {
Add comment 2404 Plus } else if (sender == ConvertToBMP) {
Add comment 2447 2405 format = ImageFormat.Bmp;
Add comment 2448 2406 extension = ".bmp";
Add comment 2449 Minus }
Add comment 2450 Minus else if (sender == ConvertToJPG) {
Add comment 2407 Plus } else if (sender == ConvertToJPG) {
Add comment 2451 2408 format = ImageFormat.Wmf;
Add comment 2452 2409 extension = ".wmf";
Add comment 2453 Minus }
Add comment 2454 Minus else {
Add comment 2410 Plus } else {
Add comment 2455 2411 throw new Exception("Invalid Sender");
Add comment 2456 2412 }
Add comment 2457 2413
Add comment 2463 2419 var newFilePath = namen + extension;
Add comment 2464 2420 cvt.Save(newFilePath, format);
Add comment 2465 2421 this._ShellListView.UnvalidateDirectory();
Add comment 2466 Minus }
Add comment 2467 Minus catch (Exception) {
Add comment 2422 Plus } catch (Exception) {
Add comment 2468 2423 MessageBox.Show("There appears to have been an issue with converting the file. Make sure the filename \"" + Utilities.RemoveExtensionsFromFile(_ShellListView.GetFirstSelectedItem().DisplayName, new System.IO.FileInfo(item.ParsingName).Extension) + extension + "\" does already not exist.", "Conversion Error", MessageBoxButton.OK, MessageBoxImage.Error);
Add comment 2469 2424 }
Add comment 2470 2425 cvt.Dispose();
Add comment 2525 2480 cvt.RotateFlip(Rotation);
Add comment 2526 2481 if (OverwriteOnRotate) {
Add comment 2527 2482 cvt.Save(item.ParsingName);
Add comment 2528 Minus }
Add comment 2529 Minus else {
Add comment 2483 Plus } else {
Add comment 2530 2484 string ext = item.ParsingName.Substring(item.ParsingName.LastIndexOf(".", StringComparison.Ordinal));
Add comment 2531 2485 string name = item.ParsingName;
Add comment 2532 2486 string namen = Utilities.RemoveExtensionsFromFile(name, new System.IO.FileInfo(name).Extension);
Add comment 2586 2540 // isOnLoad = false;
Add comment 2587 2541 // MessageBox.Show("Can't set Better Explorer as default!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
Add comment 2588 2542 //}
Add comment 2589 Minus }
Add comment 2590 Minus else {
Add comment 2543 Plus } else {
Add comment 2591 2544 //WindowsAPI.sendWindowsStringMessage((int)WindowsAPI.getWindowId(null, "BetterExplorerOperations"), 0, "0x77655");
Add comment 2592 2545 //proc.WaitForExit();
Add comment 2593 2546 //if (proc.ExitCode == -1) {
Add comment 2608 2561 //int h = (int)WindowsAPI.getWindowId(null, "BetterExplorerOperations");
Add comment 2609 2562 //int jj = WindowsAPI.sendWindowsStringMessage((int)WindowsAPI.getWindowId(null, "BetterExplorerOperations"), 0, "0x88775");
Add comment 2610 2563 //proc.WaitForExit();
Add comment 2611 Minus }
Add comment 2612 Minus else {
Add comment 2564 Plus } else {
Add comment 2613 2565 //int h = (int)WindowsAPI.getWindowId(null, "BetterExplorerOperations");
Add comment 2614 2566 //int jj = WindowsAPI.sendWindowsStringMessage((int)WindowsAPI.getWindowId(null, "BetterExplorerOperations"), 0, "0x88776");
Add comment 2615 2567 //proc.WaitForExit();
Add comment 2649 2601 Utilities.SetRegistryValue("RibbonMinimizedGlass", chkRibbonMinimizedGlass.IsChecked.Value == true ? 1 : 0, RegistryValueKind.DWord);
Add comment 2650 2602
Add comment 2651 2603 if (!TheRibbon.IsMinimized) {
Add comment 2652 Minus }
Add comment 2653 Minus else if (chkRibbonMinimizedGlass.IsChecked.Value) {
Add comment 2604 Plus } else if (chkRibbonMinimizedGlass.IsChecked.Value) {
Add comment 2654 2605 var p = ShellViewHost.TransformToAncestor(this).Transform(new WIN.Point(0, 0));
Add comment 2655 2606 this.GlassFrameThickness = new Thickness(8, p.Y, 8, 8);
Add comment 2656 Minus }
Add comment 2657 Minus else {
Add comment 2607 Plus } else {
Add comment 2658 2608 var p = backstage.TransformToAncestor(this).Transform(new WIN.Point(0, 0));
Add comment 2659 2609 this.GlassFrameThickness = new Thickness(8, p.Y + backstage.ActualHeight, 8, 8);
Add comment 2660 2610 }
Add comment 2670 2620 if (!Directory.Exists(logdir)) Directory.CreateDirectory(logdir);
Add comment 2671 2621 tcMain.NewTab(logdir);
Add comment 2672 2622 this.backstage.IsOpen = false;
Add comment 2673 Minus }
Add comment 2674 Minus catch (Exception exe) {
Add comment 2623 Plus } catch (Exception exe) {
Add comment 2675 2624 MessageBox.Show("An error occurred while trying to open the logs folder. Please report this issue at http://bugs.gainedge.org/public/betterexplorer. \r\n\r\n Here is some information about the error: \r\n\r\n" + exe.Message + "\r\n\r\n" + exe.ToString(), "Error While Opening Log Folder", MessageBoxButton.OK, MessageBoxImage.Error);
Add comment 2676 2625 }
Add comment 2677 2626 }
Add comment 2682 2631
Add comment 2683 2632 private void btnNavigationPane_CheckChanged(object sender, RoutedEventArgs e) {
Add comment 2684 2633 if (isOnLoad) {
Add comment 2685 Minus }
Add comment 2686 Minus else if (e.RoutedEvent.Name == "Checked") {
Add comment 2634 Plus } else if (e.RoutedEvent.Name == "Checked") {
Add comment 2687 2635 TreeGrid.ColumnDefinitions[0].Width = new GridLength(200);
Add comment 2688 2636 Utilities.SetRegistryValue("NavigationPaneEnabled", 1);
Add comment 2689 Minus }
Add comment 2690 Minus else {
Add comment 2637 Plus } else {
Add comment 2691 2638 TreeGrid.ColumnDefinitions[0].Width = new GridLength(1);
Add comment 2692 2639 Utilities.SetRegistryValue("NavigationPaneEnabled", 0);
Add comment 8 using System.Runtime.InteropServices;
Add comment 9 using System.Text;
Add comment 10
Add comment 11 Minus namespace BetterExplorer.UsbEject
Add comment 12 Minus {
Add comment 11 Plus namespace BetterExplorer.UsbEject {
Add comment 13 12 /// <summary>
Add comment 14 13 /// A generic base class for physical device classes.
Add comment 15 14 /// </summary>
Add comment 16 Minus public abstract class DeviceClass : IDisposable
Add comment 17 Minus {
Add comment 15 Plus public abstract class DeviceClass : IDisposable {
Add comment 18 16 private IntPtr _deviceInfoSet;
Add comment 19 17 private Guid _classGuid;
Add comment 20 18 private List<Device> _devices;
Add comment 21 19
Add comment 22 20 protected DeviceClass(Guid classGuid)
Add comment 23 Minus :this(classGuid, IntPtr.Zero)
Add comment 24 Minus {
Add comment 21 Plus : this(classGuid, IntPtr.Zero) {
Add comment 25 22 }
Add comment 26 23
Add comment 27 Minus internal virtual Device CreateDevice(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index)
Add comment 28 Minus {
Add comment 24 Plus internal virtual Device CreateDevice(DeviceClass deviceClass, Native.SP_DEVINFO_DATA deviceInfoData, string path, int index) {
Add comment 29 25 return new Device(deviceClass, deviceInfoData, path, index);
Add comment 30 26 }
Add comment 31 27
Add comment 34 30 /// </summary>
Add comment 35 31 /// <param name="classGuid">A device class Guid.</param>
Add comment 36 32 /// <param name="hwndParent">The handle of the top-level window to be used for any user interface or IntPtr.Zero for no handle.</param>
Add comment 37 Minus protected DeviceClass(Guid classGuid, IntPtr hwndParent)
Add comment 38 Minus {
Add comment 33 Plus protected DeviceClass(Guid classGuid, IntPtr hwndParent) {
Add comment 39 34 _classGuid = classGuid;
Add comment 40 35
Add comment 41 36 _deviceInfoSet = Native.SetupDiGetClassDevs(ref _classGuid, 0, hwndParent, Native.DIGCF_DEVICEINTERFACE | Native.DIGCF_PRESENT);
Add comment 42 Minus if (_deviceInfoSet.ToInt32() == Native.INVALID_HANDLE_VALUE)
Add comment 37 Plus if (_deviceInfoSet == new IntPtr(Native.INVALID_HANDLE_VALUE))
Add comment 43 38 throw new Win32Exception(Marshal.GetLastWin32Error());
Add comment 44 39 }
Add comment 45 40
Add comment 46 41 /// <summary>
Add comment 47 42 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Add comment 48 43 /// </summary>
Add comment 49 Minus public void Dispose()
Add comment 50 Minus {
Add comment 51 Minus if (_deviceInfoSet != IntPtr.Zero)
Add comment 52 Minus {
Add comment 44 Plus public void Dispose() {
Add comment 45 Plus if (_deviceInfoSet != IntPtr.Zero) {
Add comment 53 46 Native.SetupDiDestroyDeviceInfoList(_deviceInfoSet);
Add comment 54 47 _deviceInfoSet = IntPtr.Zero;
Add comment 55 48 }
Add comment 58 51 /// <summary>
Add comment 59 52 /// Gets the device class's guid.
Add comment 60 53 /// </summary>
Add comment 61 Minus public Guid ClassGuid
Add comment 62 Minus {
Add comment 63 Minus get
Add comment 64 Minus {
Add comment 54 Plus public Guid ClassGuid {
Add comment 55 Plus get {
Add comment 65 56 return _classGuid;
Add comment 66 57 }
Add comment 67 58 }
Add comment 69 60 /// <summary>
Add comment 70 61 /// Gets the list of devices of this device class.
Add comment 71 62 /// </summary>
Add comment 72 Minus public List<Device> Devices
Add comment 73 Minus {
Add comment 74 Minus get
Add comment 75 Minus {
Add comment 76 Minus if (_devices == null)
Add comment 77 Minus {
Add comment 63 Plus public List<Device> Devices {
Add comment 64 Plus get {
Add comment 65 Plus if (_devices == null) {
Add comment 78 66 _devices = new List<Device>();
Add comment 79 67 int index = 0;
Add comment 80 Minus while (true)
Add comment 81 Minus {
Add comment 68 Plus while (true) {
Add comment 82 69 Native.SP_DEVICE_INTERFACE_DATA interfaceData = new Native.SP_DEVICE_INTERFACE_DATA();
Add comment 83 70
Add comment 84 Minus if (!Native.SetupDiEnumDeviceInterfaces(_deviceInfoSet, null, ref _classGuid, index, interfaceData))
Add comment 85 Minus {
Add comment 71 Plus if (!Native.SetupDiEnumDeviceInterfaces(_deviceInfoSet, null, ref _classGuid, index, interfaceData)) {
Add comment 86 72 int error = Marshal.GetLastWin32Error();
Add comment 87 73 if (error != Native.ERROR_NO_MORE_ITEMS)
Add comment 88 74 throw new Win32Exception(error);
Add comment 91 77
Add comment 92 78 Native.SP_DEVINFO_DATA devData = new Native.SP_DEVINFO_DATA();
Add comment 93 79 int size = 0;
Add comment 94 Minus if (!Native.SetupDiGetDeviceInterfaceDetail(_deviceInfoSet, interfaceData, IntPtr.Zero, 0, ref size, devData))
Add comment 95 Minus {
Add comment 80 Plus if (!Native.SetupDiGetDeviceInterfaceDetail(_deviceInfoSet, interfaceData, IntPtr.Zero, 0, ref size, devData)) {
Add comment 96 81 int error = Marshal.GetLastWin32Error();
Add comment 97 82 if (error != Native.ERROR_INSUFFICIENT_BUFFER)
Add comment 98 83 throw new Win32Exception(error);
Add comment 103 88 if (IntPtr.Size == 8) // for 64 bit operating systems
Add comment 104 89 {
Add comment 105 90 detailData.cbSize = 8;
Add comment 106 Minus }
Add comment 107 Minus else
Add comment 108 Minus {
Add comment 91 Plus } else {
Add comment 109 92 detailData.cbSize = 4 + Marshal.SystemDefaultCharSize; // for 32 bit systems
Add comment 110 93 }
Add comment 111 94 //detailData.cbSize = Marshal.SizeOf(typeof(Native.SP_DEVICE_INTERFACE_DETAIL_DATA));
Add comment 112 95 Marshal.StructureToPtr(detailData, buffer, false);
Add comment 113 96
Add comment 114 Minus if (!Native.SetupDiGetDeviceInterfaceDetail(_deviceInfoSet, interfaceData, buffer, size, ref size, devData))
Add comment 115 Minus {
Add comment 97 Plus if (!Native.SetupDiGetDeviceInterfaceDetail(_deviceInfoSet, interfaceData, buffer, size, ref size, devData)) {
Add comment 116 98 Marshal.FreeHGlobal(buffer);
Add comment 117 99 throw new Win32Exception(Marshal.GetLastWin32Error());
Add comment 118 100 }
Add comment 119 101
Add comment 120 Minus IntPtr pDevicePath = (IntPtr)((int)buffer + Marshal.SizeOf(typeof(int)));
Add comment 121 Minus string devicePath = Marshal.PtrToStringAuto(pDevicePath);
Add comment 102 Plus var interfaceDetailData = Marshal.PtrToStructure<Native.SP_DEVICE_INTERFACE_DETAIL_DATA2>(buffer);
Add comment 103 Plus
Add comment 104 Plus
Add comment 105 Plus string devicePath = interfaceDetailData.DevicePath;// Marshal.PtrToStringAuto(pDevicePath);
Add comment 122 106 Marshal.FreeHGlobal(buffer);
Add comment 123 107
Add comment 124 108 Device device = CreateDevice(this, devData, devicePath, index);
Add comment 132 116 }
Add comment 133 117 }
Add comment 134 118
Add comment 135 Minus internal Native.SP_DEVINFO_DATA GetInfo(int dnDevInst)
Add comment 136 Minus {
Add comment 119 Plus internal Native.SP_DEVINFO_DATA GetInfo(int dnDevInst) {
Add comment 137 120 StringBuilder sb = new StringBuilder(1024);
Add comment 138 121 int hr = Native.CM_Get_Device_ID(dnDevInst, sb, sb.Capacity, 0);
Add comment 139 122 if (hr != 0)
Add comment 147 130 return devData;
Add comment 148 131 }
Add comment 149 132
Add comment 150 Minus internal string GetProperty(Native.SP_DEVINFO_DATA devData, int property, string defaultValue)
Add comment 151 Minus {
Add comment 133 Plus internal string GetProperty(Native.SP_DEVINFO_DATA devData, int property, string defaultValue) {
Add comment 152 134 if (devData == null)
Add comment 153 135 throw new ArgumentNullException("devData");
Add comment 154 136
Add comment 163 145 out propertyRegDataType,
Add comment 164 146 propertyBuffer,
Add comment 165 147 propertyBufferSize,
Add comment 166 Minus out requiredSize))
Add comment 167 Minus {
Add comment 148 Plus out requiredSize)) {
Add comment 168 149 Marshal.FreeHGlobal(propertyBuffer);
Add comment 169 150 int error = Marshal.GetLastWin32Error();
Add comment 170 151 if (error != Native.ERROR_INVALID_DATA)
Add comment 177 158 return value;
Add comment 178 159 }
Add comment 179 160
Add comment 180 Minus internal int GetProperty(Native.SP_DEVINFO_DATA devData, int property, int defaultValue)
Add comment 181 Minus {
Add comment 161 Plus internal int GetProperty(Native.SP_DEVINFO_DATA devData, int property, int defaultValue) {
Add comment 182 162 if (devData == null)
Add comment 183 163 throw new ArgumentNullException("devData");
Add comment 184 164
Add comment 193 173 out propertyRegDataType,
Add comment 194 174 propertyBuffer,
Add comment 195 175 propertyBufferSize,
Add comment 196 Minus out requiredSize))
Add comment 197 Minus {
Add comment 176 Plus out requiredSize)) {
Add comment 198 177 Marshal.FreeHGlobal(propertyBuffer);
Add comment 199 178 int error = Marshal.GetLastWin32Error();
Add comment 200 179 if (error != Native.ERROR_INVALID_DATA)
Add comment 207 186 return value;
Add comment 208 187 }
Add comment 209 188
Add comment 210 Minus internal Guid GetProperty(Native.SP_DEVINFO_DATA devData, int property, Guid defaultValue)
Add comment 211 Minus {
Add comment 189 Plus internal Guid GetProperty(Native.SP_DEVINFO_DATA devData, int property, Guid defaultValue) {
Add comment 212 190 if (devData == null)
Add comment 213 191 throw new ArgumentNullException("devData");
Add comment 214 192
Add comment 223 201 out propertyRegDataType,
Add comment 224 202 propertyBuffer,
Add comment 225 203 propertyBufferSize,
Add comment 226 Minus out requiredSize))
Add comment 227 Minus {
Add comment 204 Plus out requiredSize)) {
Add comment 228 205 Marshal.FreeHGlobal(propertyBuffer);
Add comment 229 206 int error = Marshal.GetLastWin32Error();
Add comment 230 207 if (error != Native.ERROR_INVALID_DATA)