private void treeDragStarted(UIElement uiElt) { _isMouseDown = false; Mouse.Capture(uiElt); DataObject data = new DataObject(); if (tvSearchResult.SelectedItem is FormattedGrepLine) { FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem; data.SetData(DataFormats.Text, selectedNode.GrepLine.LineText); } else if (tvSearchResult.SelectedItem is FormattedGrepResult) { FormattedGrepResult result = (FormattedGrepResult)tvSearchResult.SelectedItem; StringCollection files = new StringCollection(); files.Add(result.GrepResult.FileNameReal); data.SetFileDropList(files); } DragDropEffects supportedEffects = DragDropEffects.Move | DragDropEffects.Copy; // Perform DragDrop DragDropEffects effects = System.Windows.DragDrop.DoDragDrop(_draggedElt, data, supportedEffects); // Clean up Mouse.Capture(null); _draggedElt = null; }
private void btnCopyNameToClipboard_Click(object sender, RoutedEventArgs e) { if (tvSearchResult.SelectedItem is FormattedGrepLine) { FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem; Clipboard.SetText(System.IO.Path.GetFileName(selectedNode.Parent.GrepResult.FileNameDisplayed)); } else if (tvSearchResult.SelectedItem is FormattedGrepResult) { FormattedGrepResult result = (FormattedGrepResult)tvSearchResult.SelectedItem; Clipboard.SetText(System.IO.Path.GetFileName(result.GrepResult.FileNameDisplayed)); } }
private void copyToClipboard() { if (tvSearchResult.SelectedItem is FormattedGrepLine) { FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem; Clipboard.SetText(selectedNode.GrepLine.LineText); } else if (tvSearchResult.SelectedItem is FormattedGrepResult) { FormattedGrepResult result = (FormattedGrepResult)tvSearchResult.SelectedItem; Clipboard.SetText(result.GrepResult.FileNameDisplayed); } }
private void btnExclude_Click(object sender, RoutedEventArgs e) { if (tvSearchResult.SelectedItem is FormattedGrepLine) { FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem; inputData.SearchResults.Remove(selectedNode.Parent); } else if (tvSearchResult.SelectedItem is FormattedGrepResult) { FormattedGrepResult selectedNode = (FormattedGrepResult)tvSearchResult.SelectedItem; inputData.SearchResults.Remove(selectedNode); } }
private void btnOpenContainingFolder_Click(object sender, RoutedEventArgs e) { if (tvSearchResult.SelectedItem is FormattedGrepLine) { FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem; //ShellIntegration.OpenFolder(selectedNode.Parent.GrepResult.FileNameReal); Utils.OpenContainingFolder(selectedNode.Parent.GrepResult.FileNameReal, selectedNode.GrepLine.LineNumber); } else if (tvSearchResult.SelectedItem is FormattedGrepResult) { FormattedGrepResult selectedNode = (FormattedGrepResult)tvSearchResult.SelectedItem; //ShellIntegration.OpenFolder(selectedNode.GrepResult.FileNameReal); Utils.OpenContainingFolder(selectedNode.GrepResult.FileNameReal, -1); } }
void ObservableGrepSearchResults_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { List <IGrepResult> toRemove = new List <IGrepResult>(); foreach (var node in SelectedNodes) { FormattedGrepResult item = node as FormattedGrepResult; FormattedGrepLine line = node as FormattedGrepLine; if (item != null && !this.Contains(item)) { toRemove.Add(item); } if (line != null && !this.Contains(line.Parent)) { toRemove.Add(line); } } foreach (var item in toRemove) { SelectedNodes.Remove(item); } if (e.NewItems != null) { foreach (FormattedGrepResult newEntry in e.NewItems.Cast <FormattedGrepResult>()) { string extension = Path.GetExtension(newEntry.GrepResult.FileNameDisplayed); if (extension.Length <= 1) { extension = ".na"; } if (!icons.ContainsKey(extension)) { System.Drawing.Bitmap bitmapIcon = IconHandler.IconFromExtensionShell(extension, IconSize.Small); if (bitmapIcon == null) { bitmapIcon = dnGREP.Common.Properties.Resources.na_icon; } icons[extension] = GetBitmapSource(bitmapIcon); } newEntry.Icon = icons[extension]; } } }
private void btnShowFileProperties_Click(object sender, RoutedEventArgs e) { string fileName = ""; if (tvSearchResult.SelectedItem is FormattedGrepLine) { FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem; fileName = selectedNode.Parent.GrepResult.FileNameReal; } else if (tvSearchResult.SelectedItem is FormattedGrepResult) { FormattedGrepResult selectedNode = (FormattedGrepResult)tvSearchResult.SelectedItem; fileName = selectedNode.GrepResult.FileNameReal; } if (fileName != "" && File.Exists(fileName)) { ShellIntegration.ShowFileProperties(fileName); } }
public void PreviewFile(FormattedGrepLine line, System.Drawing.RectangleF windowSize) { PreviewFileLineRequest(this, new GrepLineEventArgs { FormattedGrepLine = line, ParentWindowSize = windowSize }); }
public void OpenFile(FormattedGrepLine line, bool useCustomEditor) { OpenFileLineRequest(this, new GrepLineEventArgs { FormattedGrepLine = line, UseCustomEditor = useCustomEditor }); }