public ArchiveCreateWizard(ShellObjectCollection list) { InitializeComponent(); //LoadStrings(); radioButton1.Checked = true; ListFilesToBeAdded(list); }
// Handle dropped programs into the add program/shortcut field private void pnlDragDropExt(object sender, DragEventArgs e) { var files = (String[])e.Data.GetData(DataFormats.FileDrop); if (files == null) { ShellObjectCollection ShellObj = ShellObjectCollection.FromDataObject((System.Runtime.InteropServices.ComTypes.IDataObject)e.Data); foreach (ShellNonFileSystemItem item in ShellObj) { addShortcut(item.ParsingName, true); } } else { // Loops through each file to make sure they exist and to add them directly to the shortcut list foreach (var file in files) { if (extensionExt.Contains(Path.GetExtension(file)) && System.IO.File.Exists(file) || Directory.Exists(file)) { addShortcut(file); } } } if (pnlShortcuts.Controls.Count != 0) { pnlShortcuts.ScrollControlIntoView(pnlShortcuts.Controls[0]); } resetSelection(); }
private static bool MoveItem(IntPtr sourceItems, IntPtr destinationFolder) { if (!IsCustomDialog) { return(false); } var destinationObject = Marshal.GetObjectForIUnknown(destinationFolder); var sourceObject = Marshal.GetObjectForIUnknown(sourceItems); var sourceItemsCollection = ShellObjectCollection.FromDataObject((System.Runtime.InteropServices.ComTypes.IDataObject)sourceObject).Select(c => c.ParsingName).ToArray(); var destinationLocation = ShellObjectFactory.Create((IShellItem)destinationObject).ParsingName; SyncContext.Post((o) => { var tempWindow = new Shell.FileOperations.FileOperation(sourceItemsCollection, destinationLocation, OperationType.Move); var currentDialog = System.Windows.Application.Current.MainWindow.OwnedWindows.OfType <FileOperationDialog>().SingleOrDefault(); if (currentDialog == null) { currentDialog = new FileOperationDialog(); tempWindow.ParentContents = currentDialog; currentDialog.Owner = System.Windows.Application.Current.MainWindow; tempWindow.Visibility = Visibility.Collapsed; currentDialog.Contents.Add(tempWindow); } else { tempWindow.ParentContents = currentDialog; tempWindow.Visibility = Visibility.Collapsed; currentDialog.Contents.Add(tempWindow); } }, null); return(true); }
public ArchiveCreateWizard(ShellObjectCollection list, string output_folder) { InitializeComponent(); radioButton1.Checked = true; ListFilesToBeAdded(list); this.txtOutput.Text = output_folder; this.openFileDialog1.InitialDirectory = output_folder; }
public ArchiveCreateWizard(ShellObjectCollection list, string output_folder) { InitializeComponent(); //LoadStrings(); radioButton1.Checked = true; ListFilesToBeAdded(list); this.txtOutput.Text = output_folder; this.openFileDialog1.InitialDirectory = output_folder; }
private int GetPhotosCount(ShellObjectCollection items) { int total = 0; IEnumerable <ShellObject> fileinfos = items.Where(f => ( f.IsFileSystemObject && !f.IsLink && EXIF.PhotoExts.Contains(Path.GetExtension(f.Name), StringComparer.CurrentCultureIgnoreCase) )); total = fileinfos.Count(); return(total); }
private static bool DeleteItem(IntPtr sourceItems) { if (!IsCustomDialog) { explorer.SetExplorerFocus(); return(false); } var isMoveToRB = Keyboard.Modifiers != ModifierKeys.Shift; var sourceObject = Marshal.GetObjectForIUnknown(sourceItems); var sourceItemsCollection = ShellObjectCollection.FromDataObject((System.Runtime.InteropServices.ComTypes.IDataObject)sourceObject).Select(c => c.ParsingName).ToArray(); var win = System.Windows.Application.Current.MainWindow; ShowDeleteDialog(sourceItemsCollection, win, isMoveToRB); explorer.SetExplorerFocus(); return(true); }
void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (!IsMouseCaptured) { dragStart = e.GetPosition(this); ShellObjectCollection collection = new ShellObjectCollection(); System.Collections.IList list = (DropDataList.SelectedItems.Count > 0) ? DropDataList.SelectedItems : DropDataList.Items; foreach (ShellObject shellObject in list) { collection.Add(shellObject); } if (collection.Count > 0) { // This builds a DataObject from a "Shell IDList Array" formatted memory stream. // This allows drag/clipboard operations with non-file based ShellObjects (i.e., // control panel, libraries, search query results) dataObject = new DataObject( "Shell IDList Array", collection.BuildShellIDList()); // Also build a file drop list System.Collections.Specialized.StringCollection paths = new System.Collections.Specialized.StringCollection(); foreach (ShellObject shellObject in collection) { if (shellObject.IsFileSystemObject) { paths.Add(shellObject.ParsingName); } } if (paths.Count > 0) { dataObject.SetFileDropList(paths); } } } }
void OnDrop(object sender, DragEventArgs e) { if (!inDragDrop) { string[] formats = e.Data.GetFormats(); foreach (string format in formats) { // Shell items are passed using the "Shell IDList Array" format. if (format == "Shell IDList Array") { // Retrieve the ShellObjects from the data object DropDataList.ItemsSource = ShellObjectCollection.FromDataObject( (System.Runtime.InteropServices.ComTypes.IDataObject)e.Data); e.Handled = true; return; } } } e.Handled = false; }
void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (!IsMouseCaptured) { dragStart = e.GetPosition(this); ShellObjectCollection collection = new ShellObjectCollection(); System.Collections.IList list = (DropDataList.SelectedItems.Count > 0) ? DropDataList.SelectedItems : DropDataList.Items; foreach (ShellObject shellObject in list) { collection.Add(shellObject); } if (collection.Count > 0) { // This builds a DataObject from a "Shell IDList Array" formatted memory stream. // This allows drag/clipboard operations with non-file based ShellObjects (i.e., // control panel, libraries, search query results) dataObject = new DataObject( "Shell IDList Array", collection.BuildShellIDList()); // Also build a file drop list System.Collections.Specialized.StringCollection paths = new System.Collections.Specialized.StringCollection(); foreach (ShellObject shellObject in collection) { if (shellObject.IsFileSystemObject) { paths.Add(shellObject.ParsingName); } } if (paths.Count > 0) dataObject.SetFileDropList(paths); } } }
public void ListFilesToBeAdded(ShellObjectCollection list) { foreach (ShellObject item in list) { if (item.IsFolder == true) { try { System.IO.DirectoryInfo dd = new System.IO.DirectoryInfo(item.ParsingName); foreach (System.IO.FileInfo file in dd.GetFiles("*.*", System.IO.SearchOption.AllDirectories)) { listBox1.Items.Add(file.FullName); } } catch { listBox1.Items.Add(item.ParsingName); } } else { System.IO.FileInfo fd = new System.IO.FileInfo(item.ParsingName); listBox1.Items.Add(item.ParsingName); } } UpdateFileListFromBox(); try { this.txtName.Text = new System.IO.FileInfo((string)this.listBox1.Items[0]).Name + "_compressed"; } catch { } }
public ShellObjectCollection FilterByAccessDate(ShellObjectCollection shells, DateTime datetocompare, ConditionalSelectParameters.DateFilterTypes filter) { ShellObjectCollection outshells = new ShellObjectCollection(); foreach (ShellObject item in shells) { FileInfo data = new FileInfo(item.ParsingName); switch (filter) { case ConditionalSelectParameters.DateFilterTypes.EarlierThan: if (DateTime.Compare(data.LastAccessTimeUtc.Date, datetocompare) < 0) outshells.Add(item); break; case ConditionalSelectParameters.DateFilterTypes.LaterThan: if (DateTime.Compare(data.LastAccessTimeUtc.Date, datetocompare) > 0) outshells.Add(item); break; case ConditionalSelectParameters.DateFilterTypes.Equals: if (DateTime.Compare(data.LastAccessTimeUtc.Date, datetocompare) == 0) outshells.Add(item); break; default: break; } } return outshells; }
private void ConditionallySelectFiles(ConditionalSelectData csd) { if (csd == null) { return; } ShellObjectCollection shells = Explorer.Items; ShellObjectCollection l1shells = new ShellObjectCollection(); ShellObjectCollection l2shells = new ShellObjectCollection(); ShellObjectCollection l3shells = new ShellObjectCollection(); ShellObjectCollection l4shells = new ShellObjectCollection(); ShellObjectCollection l5shells = new ShellObjectCollection(); Explorer.DeSelectAllItems(); if (csd.FilterByFileName == true) { foreach (ShellObject item in shells) { if (Directory.Exists(item.ParsingName) == false) { FileInfo data = new FileInfo(item.ParsingName); if (csd.FileNameData.matchCase == true) { switch (csd.FileNameData.filter) { case ConditionalSelectParameters.FileNameFilterTypes.Contains: if (data.Name.Contains(csd.FileNameData.query) == true) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.StartsWith: if (data.Name.StartsWith(csd.FileNameData.query) == true) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.EndsWith: if (data.Name.EndsWith(csd.FileNameData.query) == true) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.Equals: if (data.Name == csd.FileNameData.query) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.DoesNotContain: if (data.Name.Contains(csd.FileNameData.query) == false) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.NotEqualTo: if (data.Name != csd.FileNameData.query) l1shells.Add(item); break; default: break; } } else { switch (csd.FileNameData.filter) { case ConditionalSelectParameters.FileNameFilterTypes.Contains: if (data.Name.ToLower().Contains(csd.FileNameData.query.ToLower()) == true) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.StartsWith: if (data.Name.ToLower().StartsWith(csd.FileNameData.query.ToLower()) == true) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.EndsWith: if (data.Name.ToLower().EndsWith(csd.FileNameData.query.ToLower()) == true) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.Equals: if (data.Name.ToLower() == csd.FileNameData.query.ToLower()) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.DoesNotContain: if (data.Name.ToLower().Contains(csd.FileNameData.query.ToLower()) == false) l1shells.Add(item); break; case ConditionalSelectParameters.FileNameFilterTypes.NotEqualTo: if (data.Name.ToLower() != csd.FileNameData.query.ToLower()) l1shells.Add(item); break; default: break; } } } } } else { foreach (ShellObject item in shells) { if (Directory.Exists(item.ParsingName) == false) { l1shells.Add(item); } } } if (csd.FilterByFileSize == true) { foreach (ShellObject item in l1shells) { FileInfo data = new FileInfo(item.ParsingName); switch (csd.FileSizeData.filter) { case ConditionalSelectParameters.FileSizeFilterTypes.LargerThan: if (data.Length > csd.FileSizeData.query1) l2shells.Add(item); break; case ConditionalSelectParameters.FileSizeFilterTypes.SmallerThan: if (data.Length < csd.FileSizeData.query1) l2shells.Add(item); break; case ConditionalSelectParameters.FileSizeFilterTypes.Equals: if (data.Length == csd.FileSizeData.query1) l2shells.Add(item); break; case ConditionalSelectParameters.FileSizeFilterTypes.Between: long smallbound; long largebound; if (csd.FileSizeData.query2 > csd.FileSizeData.query1) { smallbound = csd.FileSizeData.query1; largebound = csd.FileSizeData.query2; } else { if (csd.FileSizeData.query2 < csd.FileSizeData.query1) { smallbound = csd.FileSizeData.query2; largebound = csd.FileSizeData.query1; } else { // they are the same, use Equal code //MessageBox.Show("Could not continue Conditional Select operation. When searching for files that is between a certain size, make sure the upper and lower bounds of the search parameters are not the same.", "BetterExplorer Conditional Select - Filter by File Size", MessageBoxButton.OK, MessageBoxImage.Error); //return; if (data.Length == csd.FileSizeData.query1) l2shells.Add(item); break; } } if (data.Length > smallbound) if (data.Length < largebound) l2shells.Add(item); break; case ConditionalSelectParameters.FileSizeFilterTypes.NotEqualTo: if (data.Length != csd.FileSizeData.query1) l2shells.Add(item); break; case ConditionalSelectParameters.FileSizeFilterTypes.NotBetween: long smallbound2; long largebound2; if (csd.FileSizeData.query2 > csd.FileSizeData.query1) { smallbound2 = csd.FileSizeData.query1; largebound2 = csd.FileSizeData.query2; } else { if (csd.FileSizeData.query2 < csd.FileSizeData.query1) { smallbound2 = csd.FileSizeData.query2; largebound2 = csd.FileSizeData.query1; } else { // they are the same, use Unequal code if (data.Length != csd.FileSizeData.query1) l2shells.Add(item); break; //MessageBox.Show("Could not continue Conditional Select operation. When searching for files that is not between a certain size, make sure the upper and lower bounds of the search parameters are not the same.", "BetterExplorer Conditional Select - Filter by File Size", MessageBoxButton.OK, MessageBoxImage.Error); //return; } } if (data.Length < smallbound2 || data.Length > largebound2) l2shells.Add(item); break; default: break; } } } else { foreach (ShellObject item in l1shells) { l2shells.Add(item); } } if (csd.FilterByDateCreated == true) { foreach (ShellObject item in FilterByCreateDate(l2shells, csd.DateCreatedData.queryDate, csd.DateCreatedData.filter)) { l3shells.Add(item); } } else { foreach (ShellObject item in l2shells) { l3shells.Add(item); } } if (csd.FilterByDateModified == true) { foreach (ShellObject item in FilterByWriteDate(l3shells, csd.DateModifiedData.queryDate, csd.DateModifiedData.filter)) { l4shells.Add(item); } } else { foreach (ShellObject item in l2shells) { l4shells.Add(item); } } if (csd.FilterByDateAccessed == true) { foreach (ShellObject item in FilterByAccessDate(l4shells, csd.DateAccessedData.queryDate, csd.DateAccessedData.filter)) { l5shells.Add(item); } } else { foreach (ShellObject item in l4shells) { l5shells.Add(item); } } List<ShellObject> sel = new List<ShellObject>(); foreach (ShellObject item in l5shells) { // this is where the code should be to select multiple files. // // However, the Explorer control does not support selecting multiple files. Explorer.SelectItem(item); } Explorer.Focus(); }
public ArchiveCreateWizard(ShellObjectCollection list) { InitializeComponent(); radioButton1.Checked = true; ListFilesToBeAdded(list); }